Skip to main content

src/DataManager/utils/TableView/pipeline/TablePipeline.hpp

src/DataManager/utils/TableView/pipeline/TablePipeline.hpp

Classes

Name
struct TableConfiguration
Represents a single table configuration in a table pipeline.
struct TableConfiguration::TransformSpec
struct TableBuildResult
Represents execution result of a table build.
struct TablePipelineResult
Represents execution result of a table pipeline.
class TablePipeline
Factory and execution engine for table construction pipelines.

Types

Name
using std::function< void(int table_index, std::string const &table_name, int table_progress, int overall_progress)> TablePipelineProgressCallback
Progress callback for table pipeline execution.

Types Documentation

using TablePipelineProgressCallback

using TablePipelineProgressCallback =  std::function<void(int table_index, std::string const& table_name, int table_progress, int overall_progress)>;

Progress callback for table pipeline execution.

Parameters:

  • table_index Current table being built (0-based)
  • table_name Name of the current table
  • table_progress Progress of current table (0-100)
  • overall_progress Overall pipeline progress (0-100)

Source code

#ifndef TABLE_PIPELINE_HPP
#define TABLE_PIPELINE_HPP

#include "utils/TableView/TableInfo.hpp"
#include "utils/TableView/ComputerRegistryTypes.hpp"

#include <nlohmann/json.hpp>

#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <unordered_map>

class ComputerRegistry;
class DataManager;
class DataManagerExtension;
class IComputerBase;
class IRowSelector;
class TableManager;
class TableRegistry;
class TableViewBuilder;

using TablePipelineProgressCallback = std::function<void(int table_index, std::string const& table_name, int table_progress, int overall_progress)>;

struct TableConfiguration {
    std::string table_id;                       // Unique identifier for this table
    std::string name;                           // Human-readable table name
    std::string description;                    // Optional description
    nlohmann::json row_selector;               // Row selector configuration
    std::vector<nlohmann::json> columns;       // Column configurations
    
    // Optional metadata
    std::vector<std::string> tags;              // Tags for organization
    struct TransformSpec {
        std::string type;                       // e.g., "PCA"
        nlohmann::json parameters;              // transform-specific params
        std::string output_table_id;            // optional explicit ID
        std::string output_name;                // optional display name
        std::string output_description;         // optional description
    };
    std::vector<TransformSpec> transforms;      // Optional transforms to apply to this table
};

struct TableBuildResult {
    bool success = false;
    std::string error_message;
    std::string table_id;
    double build_time_ms = 0.0;
    int columns_built = 0;
    int total_columns = 0;
};

struct TablePipelineResult {
    bool success = false;
    std::string error_message;
    std::vector<TableBuildResult> table_results;
    double total_execution_time_ms = 0.0;
    int tables_completed = 0;
    int total_tables = 0;
};

class TablePipeline {
public:
    TablePipeline(TableRegistry* table_registry, DataManager* data_manager);

    bool loadFromJson(nlohmann::json const& json_config);

    bool loadFromJsonFile(std::string const& json_file_path);

    TablePipelineResult execute(TablePipelineProgressCallback progress_callback = nullptr);

    TableBuildResult buildTable(TableConfiguration const& config, 
                               std::function<void(int, int)> progress_callback = nullptr);

    std::vector<TableConfiguration> const& getTableConfigurations() const { return tables_; }

    void clear();

private:
    TableRegistry* table_registry_;
    DataManager* data_manager_;
    std::shared_ptr<DataManagerExtension> data_manager_extension_;
    ComputerRegistry* computer_registry_;

    std::vector<TableConfiguration> tables_;
    nlohmann::json metadata_;

    TableConfiguration parseTableConfiguration(nlohmann::json const& table_json);

    std::unique_ptr<IRowSelector> createRowSelector(nlohmann::json const& row_selector_json);

    std::unique_ptr<IComputerBase> createColumnComputer(nlohmann::json const& column_json,
                                                        RowSelectorType row_selector_type);

    DataSourceVariant resolveDataSource(nlohmann::json const& data_source_json);

    RowSelectorType parseRowSelectorType(std::string const& type_string);

    std::string validateTableConfiguration(TableConfiguration const& config);

    bool addColumnToBuilder(TableViewBuilder& builder, 
                                      nlohmann::json const& column_json,
                                      std::unique_ptr<IComputerBase> computer);

    bool applyTransforms(TableConfiguration const& config);
};

#endif // TABLE_PIPELINE_HPP

Updated on 2026-11-13 at 20:25:43 +0000