From 9e280dfab70168beb95eda5a033c06b2ad345402 Mon Sep 17 00:00:00 2001 From: luoxiaojian Date: Thu, 25 Jun 2026 19:09:56 +0800 Subject: [PATCH 1/4] refactor: introduce FileReader base class for CSV, JSON, and Parquet readers --- extension/httpfs/tests/http_test.cc | 4 +- .../parquet/include/parquet/arrow_reader.h | 60 +- .../parquet/include/parquet/arrow_sniffer.h | 3 - .../include/parquet/record_batch_supplier.h | 2 +- .../parquet/include/parquet_read_function.h | 14 +- extension/parquet/src/arrow_reader.cc | 133 +++-- extension/parquet/src/arrow_sniffer.cc | 48 +- extension/parquet/tests/parquet_test.cc | 111 ++-- .../function/import/csv_read_function.h | 24 +- .../function/import/json_read_function.h | 31 +- include/neug/storages/loader/loader_utils.h | 8 +- .../utils/io/read/common/chunk_supplier.h | 65 +++ .../neug/utils/io/read/common/file_reader.h | 42 ++ .../neug/utils/io/read/common/read_state.h | 27 +- .../neug/utils/io/read/common/reader_utils.h | 41 ++ include/neug/utils/io/read/common/sniffer.h | 27 +- include/neug/utils/io/read/csv/csv_reader.h | 26 +- include/neug/utils/io/read/json/json_reader.h | 26 +- include/neug/utils/io/reader.h | 1 + .../execute/ops/batch/batch_update_utils.cc | 28 +- src/utils/io/read/common/chunk_supplier.cc | 64 ++ src/utils/io/read/common/reader_utils.cc | 50 ++ src/utils/io/read/common/sniffer.cc | 12 +- src/utils/io/read/csv/csv_reader.cc | 33 +- src/utils/io/read/json/json_reader.cc | 154 +++-- tests/utils/CMakeLists.txt | 3 +- tests/utils/json_test.cc | 10 +- tests/utils/test_json_io.cc | 549 ++++++++++++++++++ tests/utils/test_reader.cc | 194 ++++--- tests/utils/test_reader.h | 37 +- tests/utils/test_sniffer.cc | 24 +- 31 files changed, 1291 insertions(+), 560 deletions(-) create mode 100644 include/neug/utils/io/read/common/chunk_supplier.h create mode 100644 include/neug/utils/io/read/common/file_reader.h create mode 100644 include/neug/utils/io/read/common/reader_utils.h create mode 100644 src/utils/io/read/common/chunk_supplier.cc create mode 100644 src/utils/io/read/common/reader_utils.cc create mode 100644 tests/utils/test_json_io.cc diff --git a/extension/httpfs/tests/http_test.cc b/extension/httpfs/tests/http_test.cc index ffefd9533..24c559f48 100644 --- a/extension/httpfs/tests/http_test.cc +++ b/extension/httpfs/tests/http_test.cc @@ -21,8 +21,8 @@ #include #include #include -#include "../include/http_filesystem.h" -#include "../include/http_options.h" +#include "http_filesystem.h" +#include "http_options.h" #include "neug/compiler/common/case_insensitive_map.h" #include "neug/utils/exception/exception.h" diff --git a/extension/parquet/include/parquet/arrow_reader.h b/extension/parquet/include/parquet/arrow_reader.h index 45666e471..adbfbd447 100644 --- a/extension/parquet/include/parquet/arrow_reader.h +++ b/extension/parquet/include/parquet/arrow_reader.h @@ -21,10 +21,13 @@ #include #include -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/common/file_reader.h" #include "parquet/arrow_options.h" namespace neug { + +class IDataChunkSupplier; + namespace reader { class DatasetBuilder { @@ -38,55 +41,44 @@ class DatasetBuilder { std::shared_ptr fileFormat); }; -template -class Reader { - public: - Reader(std::shared_ptr sharedState, - std::shared_ptr fileSystem) - : sharedState(std::move(sharedState)), - fileSystem(std::move(fileSystem)) {} - virtual ~Reader() = default; - - virtual void read(std::shared_ptr localState, - execution::Context& ctx) = 0; - - protected: - std::shared_ptr sharedState; - std::shared_ptr fileSystem; -}; - -class ArrowReader : public Reader { +class ArrowReader : public FileReader { public: ArrowReader(std::shared_ptr sharedState, std::unique_ptr optionsBuilder, std::shared_ptr fileSystem) - : Reader(std::move(sharedState), std::move(fileSystem)), - optionsBuilder(std::move(optionsBuilder)), - datasetBuilder(std::make_shared()) {} + : sharedState_(std::move(sharedState)), + fileSystem_(std::move(fileSystem)), + optionsBuilder_(std::move(optionsBuilder)), + datasetBuilder_(std::make_shared()) {} ArrowReader(std::shared_ptr sharedState, std::unique_ptr optionsBuilder, std::shared_ptr fileSystem, std::shared_ptr datasetBuilder) - : Reader(std::move(sharedState), std::move(fileSystem)), - optionsBuilder(std::move(optionsBuilder)), - datasetBuilder(std::move(datasetBuilder)) {} + : sharedState_(std::move(sharedState)), + fileSystem_(std::move(fileSystem)), + optionsBuilder_(std::move(optionsBuilder)), + datasetBuilder_(std::move(datasetBuilder)) {} ~ArrowReader() override = default; - void read(std::shared_ptr localState, - execution::Context& ctx) override; + std::shared_ptr read() override; - arrow::Result> inferSchema(); + result> inferSchema() override; protected: std::shared_ptr createScanner( std::shared_ptr fs); - void full_read(std::shared_ptr scanner, - execution::Context& output); - void batch_read(std::shared_ptr scanner, - execution::Context& output); + std::shared_ptr full_read( + std::shared_ptr scanner); + std::shared_ptr batch_read( + std::shared_ptr scanner); + + result> convertArrowSchemaToEntrySchema( + const std::shared_ptr& arrowSchema); - std::unique_ptr optionsBuilder; - std::shared_ptr datasetBuilder; + std::shared_ptr sharedState_; + std::shared_ptr fileSystem_; + std::unique_ptr optionsBuilder_; + std::shared_ptr datasetBuilder_; }; } // namespace reader diff --git a/extension/parquet/include/parquet/arrow_sniffer.h b/extension/parquet/include/parquet/arrow_sniffer.h index 973fdfe9c..4ff9ac2d1 100644 --- a/extension/parquet/include/parquet/arrow_sniffer.h +++ b/extension/parquet/include/parquet/arrow_sniffer.h @@ -30,9 +30,6 @@ class ArrowSniffer : public Sniffer { result> sniff() override; private: - result> convertArrowSchemaToEntrySchema( - const std::shared_ptr& arrowSchema); - std::shared_ptr reader_; }; diff --git a/extension/parquet/include/parquet/record_batch_supplier.h b/extension/parquet/include/parquet/record_batch_supplier.h index a8a94d2fc..db7b99b13 100644 --- a/extension/parquet/include/parquet/record_batch_supplier.h +++ b/extension/parquet/include/parquet/record_batch_supplier.h @@ -18,7 +18,7 @@ #include #include -#include "neug/storages/loader/loader_utils.h" +#include "neug/utils/io/read/common/chunk_supplier.h" namespace neug { diff --git a/extension/parquet/include/parquet_read_function.h b/extension/parquet/include/parquet_read_function.h index 43177547b..aa072089d 100644 --- a/extension/parquet/include/parquet_read_function.h +++ b/extension/parquet/include/parquet_read_function.h @@ -21,6 +21,7 @@ #include "neug/compiler/function/read_function.h" #include "neug/compiler/main/metadata_registry.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/common/sniffer.h" #include "parquet/arrow_fs_resolver.h" @@ -59,15 +60,14 @@ struct ParquetReadFunction { auto optionsBuilder = std::make_unique(state); + const size_t fallback_column_count = state->columnNum(); auto arrowFs = parquet::resolveArrowFileSystem(*fs); - auto reader = std::make_unique( - state, std::move(optionsBuilder), std::move(arrowFs)); - - execution::Context ctx; - auto localState = std::make_shared(); - reader->read(localState, ctx); - return ctx; + std::unique_ptr reader = + std::make_unique(state, std::move(optionsBuilder), + std::move(arrowFs)); + return reader::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr sniffFunc( diff --git a/extension/parquet/src/arrow_reader.cc b/extension/parquet/src/arrow_reader.cc index b82ea6c7b..5b032943a 100644 --- a/extension/parquet/src/arrow_reader.cc +++ b/extension/parquet/src/arrow_reader.cc @@ -21,37 +21,38 @@ #include "parquet/arrow_context_column.h" #include "parquet/arrow_reader.h" +#include "parquet/arrow_type_converter.h" #include "parquet/record_batch_supplier.h" #include "neug/compiler/common/assert.h" #include "neug/execution/common/context.h" -#include "neug/storages/loader/loader_utils.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/result.h" namespace neug { namespace reader { -void ArrowReader::read(std::shared_ptr localState, - execution::Context& ctx) { - if (!sharedState) { +std::shared_ptr ArrowReader::read() { + if (!sharedState_) { THROW_INVALID_ARGUMENT_EXCEPTION("SharedState is null"); } - if (!fileSystem) { + if (!fileSystem_) { THROW_INVALID_ARGUMENT_EXCEPTION("FileSystem is null"); } - auto scanner = createScanner(fileSystem); + auto scanner = createScanner(fileSystem_); NEUG_ASSERT(scanner != nullptr); // Choose read mode: batch_read streams data, full_read loads entire dataset - const auto& fileSchema = sharedState->schema.file; + const auto& fileSchema = sharedState_->schema.file; ReadOptions options; if (options.batch_read.get(fileSchema.options)) { - batch_read(scanner, ctx); + return batch_read(scanner); } else { - full_read(scanner, ctx); + return full_read(scanner); } } @@ -61,31 +62,31 @@ std::shared_ptr ArrowReader::createScanner( THROW_INVALID_ARGUMENT_EXCEPTION("FileSystem is null"); } - if (!sharedState) { + if (!sharedState_) { THROW_INVALID_ARGUMENT_EXCEPTION("SharedState is null"); } - const auto& fileSchema = sharedState->schema.file; + const auto& fileSchema = sharedState_->schema.file; const std::vector& file_paths = fileSchema.paths; if (file_paths.empty()) { THROW_INVALID_ARGUMENT_EXCEPTION("No file paths provided"); } - if (!optionsBuilder) { + if (!optionsBuilder_) { THROW_INVALID_ARGUMENT_EXCEPTION("Options builder is null"); } - auto arrowOptions = optionsBuilder->build(); + auto arrowOptions = optionsBuilder_->build(); if (!arrowOptions.scanOptions) { THROW_INVALID_ARGUMENT_EXCEPTION("Failed to build arrow options"); } - if (!optionsBuilder->projectColumns(arrowOptions)) { + if (!optionsBuilder_->projectColumns(arrowOptions)) { LOG(WARNING) << "Failed to set column projection, using all columns"; } - if (!optionsBuilder->skipRows(arrowOptions)) { + if (!optionsBuilder_->skipRows(arrowOptions)) { LOG(WARNING) << "Failed to set row filter, using no filter"; } @@ -96,7 +97,7 @@ std::shared_ptr ArrowReader::createScanner( THROW_INVALID_ARGUMENT_EXCEPTION("File format is null in arrow options"); } - auto factory = datasetBuilder->buildFactory(sharedState, fs, fileFormat); + auto factory = datasetBuilder_->buildFactory(sharedState_, fs, fileFormat); arrow::Result> dataset_result; if (scan_opts->dataset_schema) { @@ -136,9 +137,9 @@ std::shared_ptr ArrowReader::createScanner( return scanner_result.ValueOrDie(); } -void ArrowReader::full_read(std::shared_ptr scanner, - execution::Context& output) { - if (!sharedState) { +std::shared_ptr ArrowReader::full_read( + std::shared_ptr scanner) { + if (!sharedState_) { THROW_INVALID_ARGUMENT_EXCEPTION("SharedState is null"); } if (!scanner) { @@ -154,7 +155,7 @@ void ArrowReader::full_read(std::shared_ptr scanner, } auto table = table_result.ValueOrDie(); - int num_cols = sharedState->columnNum(); + int num_cols = sharedState_->columnNum(); if (num_cols != table->num_columns()) { THROW_IO_EXCEPTION( "Column number mismatch between schema and table, schema: " + @@ -162,19 +163,19 @@ void ArrowReader::full_read(std::shared_ptr scanner, ", table: " + std::to_string(table->num_columns())); } - output.clear(); - execution::DataChunk chunk; + auto chunk = std::make_shared(); for (int i = 0; i < num_cols; ++i) { auto table_column = table->column(i); - chunk.set(i, - execution::arrow_arrays_to_value_column(table_column->chunks())); + chunk->set(i, + execution::arrow_arrays_to_value_column(table_column->chunks())); } - output.append_chunk(std::move(chunk)); + return std::make_shared( + std::vector>{chunk}); } -void ArrowReader::batch_read(std::shared_ptr scanner, - execution::Context& output) { - if (!sharedState) { +std::shared_ptr ArrowReader::batch_read( + std::shared_ptr scanner) { + if (!sharedState_) { THROW_INVALID_ARGUMENT_EXCEPTION("SharedState is null"); } if (!scanner) { @@ -201,47 +202,63 @@ void ArrowReader::batch_read(std::shared_ptr scanner, } auto batch_reader = batch_reader_result.ValueOrDie(); - auto batch_supplier = - std::make_shared(batch_reader, row_num); + return std::make_shared(batch_reader, row_num); +} - output.clear(); - while (auto chunk = batch_supplier->GetNextChunk()) { - output.append_chunk(std::move(*chunk)); - } +result> ArrowReader::inferSchema() { + return convertArrowSchemaToEntrySchema(nullptr); } -arrow::Result> ArrowReader::inferSchema() { - if (!sharedState) { - return arrow::Status::Invalid(neug::StatusCode::ERR_INVALID_ARGUMENT, - "SharedState is null"); +result> +ArrowReader::convertArrowSchemaToEntrySchema( + const std::shared_ptr& providedSchema) { + if (!sharedState_) { + RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, + "SharedState is null"); } - if (!fileSystem) { - return arrow::Status::Invalid(neug::StatusCode::ERR_INVALID_ARGUMENT, - "FileSystem is null"); + if (!fileSystem_) { + RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, + "FileSystem is null"); } - if (!optionsBuilder) { - return arrow::Status::Invalid(neug::StatusCode::ERR_INVALID_ARGUMENT, - "Options builder is null"); + if (!optionsBuilder_) { + RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, + "Options builder is null"); } - // Reuse optionsBuilder->build() to get fileFormat - // For schema inference, we need fileFormat but don't need entry schema. - // build() will create an empty dataset_schema if entry schema is empty, - // but fileFormat will still be correctly built. - auto arrowOptions = optionsBuilder->build(); - if (!arrowOptions.fileFormat) { - return arrow::Status::IOError( - "Failed to build file format from options builder"); + std::shared_ptr arrowSchema = providedSchema; + if (!arrowSchema) { + auto arrowOptions = optionsBuilder_->build(); + if (!arrowOptions.fileFormat) { + RETURN_STATUS_ERROR(neug::StatusCode::ERR_IO_ERROR, + "Failed to build file format from options builder"); + } + auto fileFormat = arrowOptions.fileFormat; + auto factory = + datasetBuilder_->buildFactory(sharedState_, fileSystem_, fileFormat); + auto inspectResult = factory->Inspect(); + if (!inspectResult.ok()) { + RETURN_STATUS_ERROR( + neug::StatusCode::ERR_IO_ERROR, + "Failed to inspect schema: " + inspectResult.status().message()); + } + arrowSchema = inspectResult.ValueOrDie(); } - auto fileFormat = arrowOptions.fileFormat; - - auto factory = - datasetBuilder->buildFactory(sharedState, fileSystem, fileFormat); - // Infer schema using Inspect() - return factory->Inspect(); + ArrowTypeConverter converter; + auto entrySchema = std::make_shared(); + for (const auto& field : arrowSchema->fields()) { + auto dataType = converter.convert(*field->type()); + if (!dataType) { + RETURN_STATUS_ERROR( + neug::StatusCode::ERR_IO_ERROR, + "Unsupported arrow type: " + field->type()->ToString()); + } + entrySchema->columnNames.push_back(field->name()); + entrySchema->columnTypes.push_back(dataType); + } + return entrySchema; } } // namespace reader diff --git a/extension/parquet/src/arrow_sniffer.cc b/extension/parquet/src/arrow_sniffer.cc index 779d79bc9..4b080954b 100644 --- a/extension/parquet/src/arrow_sniffer.cc +++ b/extension/parquet/src/arrow_sniffer.cc @@ -15,12 +15,7 @@ #include "parquet/arrow_sniffer.h" -#include - -#include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/schema.h" #include "neug/utils/result.h" -#include "parquet/arrow_type_converter.h" namespace neug { namespace reader { @@ -30,48 +25,7 @@ result> ArrowSniffer::sniff() { RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, "ArrowReader is null"); } - - auto arrowSchema = reader_->inferSchema(); - if (!arrowSchema.ok()) { - RETURN_STATUS_ERROR(neug::StatusCode::ERR_IO_ERROR, - "Failed to infer schema from ArrowReader: " + - arrowSchema.status().ToString()); - } - - return convertArrowSchemaToEntrySchema(arrowSchema.ValueOrDie()); -} - -result> -ArrowSniffer::convertArrowSchemaToEntrySchema( - const std::shared_ptr& arrowSchema) { - if (!arrowSchema) { - RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, - "Arrow schema is null"); - } - - auto entrySchema = std::make_shared(); - ArrowTypeConverter converter; - int numFields = arrowSchema->num_fields(); - - entrySchema->columnNames.reserve(numFields); - entrySchema->columnTypes.reserve(numFields); - - for (int i = 0; i < numFields; ++i) { - const auto& field = arrowSchema->field(i); - const std::string& columnName = field->name(); - - entrySchema->columnNames.push_back(columnName); - - auto commonType = converter.convert(*field->type()); - if (!commonType) { - RETURN_STATUS_ERROR( - neug::StatusCode::ERR_TYPE_CONVERSION, - "Failed to convert Arrow type for column: " + columnName); - } - entrySchema->columnTypes.push_back(std::move(commonType)); - } - - return entrySchema; + return reader_->inferSchema(); } } // namespace reader diff --git a/extension/parquet/tests/parquet_test.cc b/extension/parquet/tests/parquet_test.cc index 0592316cd..9a25c3630 100644 --- a/extension/parquet/tests/parquet_test.cc +++ b/extension/parquet/tests/parquet_test.cc @@ -26,16 +26,18 @@ #include #include "neug/compiler/common/case_insensitive_map.h" +#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" -#include "parquet/arrow_context_column.h" -#include "parquet/arrow_reader.h" +#include "neug/utils/io/reader.h" -#include "../../extension/parquet/include/parquet_export_function.h" -#include "../../extension/parquet/include/parquet_options.h" +#include "parquet/arrow_reader.h" +#include "parquet_export_function.h" +#include "parquet_options.h" #include "neug/generated/proto/response/response.pb.h" namespace neug { @@ -188,6 +190,12 @@ class ParquetTest : public ::testing::Test { return sharedState; } + execution::Context readToContext( + const std::shared_ptr& reader, + const std::shared_ptr& sharedState) { + return reader::toContext(reader->read(), *sharedState); + } + std::shared_ptr createParquetReader( const std::shared_ptr& sharedState) { auto fileSystem = std::make_shared(); @@ -452,11 +460,9 @@ TEST_F(ParquetTest, TestTypeMapping_StringToLargeUtf8) { {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); - // Verify string column type + // Verify string column is converted to large_utf8 auto col1 = ctx.chunk(0).columns()[1]; ASSERT_EQ(col1->column_type(), execution::ContextColumnType::kValue); EXPECT_EQ(col1->elem_type().id(), neug::DataTypeId::kVarchar); @@ -504,14 +510,11 @@ TEST_F(ParquetTest, TestTypeMapping_PreserveNumericTypes) { {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 4); EXPECT_EQ(ctx.row_num(), 1); - // Verify types are preserved correctly EXPECT_EQ(ctx.chunk(0).columns()[0]->elem_type().id(), neug::DataTypeId::kInt32); EXPECT_EQ(ctx.chunk(0).columns()[1]->elem_type().id(), @@ -580,9 +583,7 @@ TEST_F(ParquetTest, TestIntegration_ColumnPruning) { sharedState->projectColumns = {"id", "score", "grade"}; auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Verify extension translates projectColumns to Arrow projection // Should have 3 columns (id, score, grade - "name" is excluded) @@ -651,9 +652,7 @@ TEST_F(ParquetTest, TestIntegration_FilterPushdown) { sharedState->skipRows = filterExpr; // Neug's filter expression auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Verify extension translates Neug filter to Arrow filter EXPECT_EQ(ctx.col_num(), 2); @@ -677,32 +676,30 @@ TEST_F(ParquetTest, TestIntegration_FilterPushdown) { TEST_F(ParquetTest, TestIntegration_BatchReadMode) { createSimpleParquetFile("test_batch_mode.parquet"); - // Test with batch_read=true (streaming mode) auto sharedState = createSharedState( "test_batch_mode.parquet", {"id", "name", "value"}, {createInt64Type(), createStringType(), createDoubleType()}, {{"batch_read", "true"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); - - EXPECT_GT(ctx.chunk_num(), 0); // batch mode: data materialized into chunks - EXPECT_GT(ctx.col_num(), 0) << "Extension should materialize data into " - "Context chunks when batch_read=true"; + auto supplier = reader->read(); + ASSERT_NE(supplier, nullptr); + int total_rows = 0; + while (auto chunk = supplier->GetNextChunk()) { + EXPECT_EQ(chunk->col_num(), 3u); + total_rows += static_cast(chunk->row_num()); + } + EXPECT_GT(total_rows, 0); - // Test with batch_read=false (full read mode) auto sharedState2 = createSharedState( "test_batch_mode.parquet", {"id", "name", "value"}, {createInt64Type(), createStringType(), createDoubleType()}, {{"batch_read", "false"}}); auto reader2 = createParquetReader(sharedState2); - auto localState2 = std::make_shared(); - execution::Context ctx2; - reader2->read(localState2, ctx2); + execution::Context ctx2 = readToContext(reader2, sharedState2); + EXPECT_EQ(ctx2.col_num(), 3); auto col0_2 = ctx2.chunk(0).columns()[0]; EXPECT_EQ(col0_2->column_type(), execution::ContextColumnType::kValue) << "Extension should use Value column type when batch_read=false"; @@ -764,9 +761,7 @@ TEST_F(ParquetTest, TestIntegration_BatchReadWithFilter) { sharedState->skipRows = filterExpr; auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Arrow scanner applies filter in both batch and full modes EXPECT_EQ(ctx.col_num(), 2); @@ -848,9 +843,7 @@ TEST_F(ParquetTest, TestIntegration_BatchReadWithFilterAndProjection) { sharedState->skipRows = filterExpr; auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Arrow scanner applies both filter and projection in batch mode EXPECT_EQ(ctx.col_num(), 2) @@ -934,9 +927,7 @@ TEST_F(ParquetTest, TestIntegration_CombinedFilterAndProjection) { sharedState->skipRows = filterExpr; // Filter score > 90.0 auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Verify extension correctly combines filter and projection EXPECT_EQ(ctx.col_num(), 3) @@ -994,9 +985,7 @@ TEST_F(ParquetTest, TestMultiFile_ExplicitPaths) { sharedState->schema = std::move(externalSchema); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 1); EXPECT_EQ(ctx.row_num(), 30) << "Extension should correctly read and " @@ -1072,9 +1061,7 @@ TEST_F(ParquetTest, TestParquetExportWriter) { {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 3); @@ -1132,9 +1119,7 @@ TEST_F(ParquetTest, TestParquetExportWithNulls) { {createInt64Type(), createStringType()}, {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 2); EXPECT_EQ(ctx.row_num(), 3); @@ -1337,9 +1322,7 @@ TEST_F(ParquetTest, TestParquetExportWithCompressionOptions) { {createInt64Type(), createStringType()}, {{"batch_read", "false"}}); auto reader_zstd = createParquetReader(sharedState_zstd); - auto localState_zstd = std::make_shared(); - execution::Context ctx_zstd; - reader_zstd->read(localState_zstd, ctx_zstd); + execution::Context ctx_zstd = readToContext(reader_zstd, sharedState_zstd); EXPECT_EQ(ctx_zstd.row_num(), 100); auto sharedState_none = createSharedState( @@ -1347,9 +1330,7 @@ TEST_F(ParquetTest, TestParquetExportWithCompressionOptions) { {createInt64Type(), createStringType()}, {{"batch_read", "false"}}); auto reader_none = createParquetReader(sharedState_none); - auto localState_none = std::make_shared(); - execution::Context ctx_none; - reader_none->read(localState_none, ctx_none); + execution::Context ctx_none = readToContext(reader_none, sharedState_none); EXPECT_EQ(ctx_none.row_num(), 100); } @@ -1430,9 +1411,7 @@ TEST_F(ParquetTest, TestParquetExportWithRowGroupSize) { {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.row_num(), 100); } @@ -1528,9 +1507,7 @@ TEST_F(ParquetTest, TestParquetExportWithDictionaryEncoding) { {createInt64Type(), createStringType()}, {{"batch_read", "false"}}); auto reader_dict = createParquetReader(sharedState_dict); - auto localState_dict = std::make_shared(); - execution::Context ctx_dict; - reader_dict->read(localState_dict, ctx_dict); + execution::Context ctx_dict = readToContext(reader_dict, sharedState_dict); EXPECT_EQ(ctx_dict.row_num(), num_rows); auto sharedState_nodict = createSharedState( @@ -1538,9 +1515,8 @@ TEST_F(ParquetTest, TestParquetExportWithDictionaryEncoding) { {createInt64Type(), createStringType()}, {{"batch_read", "false"}}); auto reader_nodict = createParquetReader(sharedState_nodict); - auto localState_nodict = std::make_shared(); - execution::Context ctx_nodict; - reader_nodict->read(localState_nodict, ctx_nodict); + execution::Context ctx_nodict = + readToContext(reader_nodict, sharedState_nodict); EXPECT_EQ(ctx_nodict.row_num(), num_rows); } @@ -1610,9 +1586,7 @@ TEST_F(ParquetTest, TestParquetExportWithDateAndTimestamp) { {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.row_num(), num_rows); } @@ -2006,10 +1980,7 @@ TEST_F(ParquetTest, TestParquetNonExistentColumnThrows) { columnTypes, {{"batch_read", "false"}}); auto reader = createParquetReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - EXPECT_THROW(reader->read(localState, ctx), + EXPECT_THROW(readToContext(reader, sharedState), exception::SchemaMismatchException); } diff --git a/include/neug/compiler/function/import/csv_read_function.h b/include/neug/compiler/function/import/csv_read_function.h index 9a55756f2..56f8c0675 100644 --- a/include/neug/compiler/function/import/csv_read_function.h +++ b/include/neug/compiler/function/import/csv_read_function.h @@ -23,9 +23,10 @@ #include "neug/execution/execute/ops/batch/batch_update_utils.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/common/sniffer.h" -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/csv/csv_reader.h" namespace neug { namespace function { struct CSVReadFunction { @@ -124,12 +125,12 @@ struct CSVReadFunction { } state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state); - auto reader = + const size_t fallback_column_count = + optionsBuilder->build().include_columns.size(); + std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - execution::Context ctx; - auto localState = std::make_shared(); - reader->read(localState, ctx); - return ctx; + return reader::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr sniffFunc( @@ -153,9 +154,9 @@ struct CSVReadFunction { } state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state); - auto reader = + std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); + auto sniffer = std::make_shared(reader); auto sniffResult = sniffer->sniff(); if (sniffResult) { return sniffResult.value(); @@ -171,9 +172,10 @@ struct CSVReadFunction { options.insert({"SKIP_ROWS", "1"}); options.insert({"AUTOGENERATE_COLUMN_NAMES", "TRUE"}); auto optionsBuilder2 = std::make_unique(state); - auto reader2 = std::make_shared( - state, std::move(optionsBuilder2)); - auto sniffer2 = std::make_shared(reader2); + std::shared_ptr reader2 = + std::make_shared(state, + std::move(optionsBuilder2)); + auto sniffer2 = std::make_shared(reader2); sniffResult = sniffer2->sniff(); if (sniffResult) { return sniffResult.value(); diff --git a/include/neug/compiler/function/import/json_read_function.h b/include/neug/compiler/function/import/json_read_function.h index 5b2e8793c..d0e3751f8 100644 --- a/include/neug/compiler/function/import/json_read_function.h +++ b/include/neug/compiler/function/import/json_read_function.h @@ -22,9 +22,10 @@ #include "neug/compiler/main/metadata_registry.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/common/sniffer.h" -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/json/json_reader.h" namespace neug { namespace function { @@ -57,12 +58,12 @@ struct JsonReadFunction { state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state, true); - auto reader = + const size_t fallback_column_count = + optionsBuilder->build().include_columns.size(); + std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - execution::Context ctx; - auto localState = std::make_shared(); - reader->read(localState, ctx); - return ctx; + return reader::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr jsonSniffFunc( @@ -84,9 +85,9 @@ struct JsonReadFunction { state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state, true); - auto reader = + std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); + auto sniffer = std::make_shared(reader); auto sniffResult = sniffer->sniff(); if (!sniffResult) { THROW_IO_EXCEPTION("Failed to sniff schema: " + @@ -123,12 +124,12 @@ struct JsonLReadFunction { state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state, false); - auto reader = + const size_t fallback_column_count = + optionsBuilder->build().include_columns.size(); + std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - execution::Context ctx; - auto localState = std::make_shared(); - reader->read(localState, ctx); - return ctx; + return reader::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr jsonLSniffFunc( @@ -150,9 +151,9 @@ struct JsonLReadFunction { state->schema.file.paths = std::move(resolvedPaths); auto optionsBuilder = std::make_unique(state, false); - auto reader = + std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); + auto sniffer = std::make_shared(reader); auto sniffResult = sniffer->sniff(); if (!sniffResult) { THROW_IO_EXCEPTION("Failed to sniff schema: " + diff --git a/include/neug/storages/loader/loader_utils.h b/include/neug/storages/loader/loader_utils.h index 177554b68..6817c4984 100644 --- a/include/neug/storages/loader/loader_utils.h +++ b/include/neug/storages/loader/loader_utils.h @@ -27,6 +27,7 @@ #include "neug/execution/common/data_chunk.h" #include "neug/storages/loader/loading_config.h" #include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/csv/csv_read_config.h" #include "neug/utils/string_utils.h" @@ -65,13 +66,6 @@ CsvReadConfig build_csv_read_config( const std::unordered_map& csv_options, const std::vector& column_types); -class IDataChunkSupplier { - public: - virtual ~IDataChunkSupplier() = default; - virtual std::shared_ptr GetNextChunk() = 0; - virtual int64_t RowNum() const = 0; -}; - /// csv-parser based supplier. Reads CSV in chunks and yields ValueColumns. class CSVChunkSupplier : public IDataChunkSupplier { public: diff --git a/include/neug/utils/io/read/common/chunk_supplier.h b/include/neug/utils/io/read/common/chunk_supplier.h new file mode 100644 index 000000000..fb78f54e9 --- /dev/null +++ b/include/neug/utils/io/read/common/chunk_supplier.h @@ -0,0 +1,65 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +namespace neug { +namespace execution { +class DataChunk; +} + +/// Iterator-like source of execution::DataChunk batches for file readers and loaders. +class IDataChunkSupplier { + public: + virtual ~IDataChunkSupplier() = default; + virtual std::shared_ptr GetNextChunk() = 0; + virtual int64_t RowNum() const = 0; +}; + +/// Yields pre-materialized DataChunks one by one. +class MultiDataChunkSupplier : public IDataChunkSupplier { + public: + explicit MultiDataChunkSupplier( + std::vector> chunks); + + std::shared_ptr GetNextChunk() override; + + int64_t RowNum() const override; + + private: + std::vector> chunks_; + size_t index_ = 0; +}; + +/// Wraps multiple IDataChunkSupplier instances into a single sequential stream. +class ChunkSupplierWrapper : public IDataChunkSupplier { + public: + explicit ChunkSupplierWrapper( + std::vector> suppliers); + + std::shared_ptr GetNextChunk() override; + + int64_t RowNum() const override; + + private: + std::vector> suppliers_; + size_t current_supplier_index_ = 0; +}; + +} // namespace neug diff --git a/include/neug/utils/io/read/common/file_reader.h b/include/neug/utils/io/read/common/file_reader.h new file mode 100644 index 000000000..b62284f80 --- /dev/null +++ b/include/neug/utils/io/read/common/file_reader.h @@ -0,0 +1,42 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/utils/io/read/common/read_state.h" +#include "neug/utils/io/read/common/schema.h" +#include "neug/utils/result.h" + +namespace neug { +namespace reader { + +/// Reads external files and yields row batches via IDataChunkSupplier. +class FileReader { + public: + virtual ~FileReader() = default; + + /// Returns an iterator-like supplier that yields DataChunk batches. + /// A nullptr DataChunk from the supplier marks end of stream (EOF). + /// Calling read() again after EOF has been signalled is undefined behavior. + virtual std::shared_ptr read() = 0; + + virtual result> inferSchema() = 0; +}; + +} // namespace reader +} // namespace neug diff --git a/include/neug/utils/io/read/common/read_state.h b/include/neug/utils/io/read/common/read_state.h index 79eed2da6..b46dfefb5 100644 --- a/include/neug/utils/io/read/common/read_state.h +++ b/include/neug/utils/io/read/common/read_state.h @@ -19,7 +19,6 @@ #include #include -#include "neug/compiler/common/cast.h" #include "neug/utils/io/read/common/schema.h" namespace common { @@ -29,36 +28,12 @@ class Expression; namespace neug { namespace reader { -struct ReadLocalState { - virtual ~ReadLocalState() = default; - - template - TARGET& cast() { - return common::neug_dynamic_cast(*this); - } - - template - TARGET* ptrCast() { - return common::neug_dynamic_cast(this); - } - - template - const TARGET& constCast() const { - return common::neug_dynamic_cast(*this); - } - - template - const TARGET* constPtrCast() const { - return common::neug_dynamic_cast(this); - } -}; - struct ReadSharedState { ExternalSchema schema; std::vector projectColumns; std::shared_ptr<::common::Expression> skipRows; - int columnNum() { + int columnNum() const { if (!schema.entry) { return 0; } diff --git a/include/neug/utils/io/read/common/reader_utils.h b/include/neug/utils/io/read/common/reader_utils.h new file mode 100644 index 000000000..f297dc5fd --- /dev/null +++ b/include/neug/utils/io/read/common/reader_utils.h @@ -0,0 +1,41 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "neug/execution/common/context.h" +#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/utils/io/read/common/file_reader.h" +#include "neug/utils/io/read/common/read_state.h" + +namespace neug { +namespace reader { + +execution::Context toContext(std::shared_ptr supplier, + const ReadSharedState& state, + size_t fallback_column_count = 0); + +inline execution::Context runFileReader(std::unique_ptr reader, + const ReadSharedState& state, + size_t fallback_column_count = 0) { + return toContext(reader->read(), state, fallback_column_count); +} + + +} // namespace reader +} // namespace neug diff --git a/include/neug/utils/io/read/common/sniffer.h b/include/neug/utils/io/read/common/sniffer.h index 43ef37e73..30a51b981 100644 --- a/include/neug/utils/io/read/common/sniffer.h +++ b/include/neug/utils/io/read/common/sniffer.h @@ -16,10 +16,10 @@ #pragma once #include + #include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/file_reader.h" #include "neug/utils/io/read/common/schema.h" -#include "neug/utils/io/read/csv/csv_reader.h" -#include "neug/utils/io/read/json/json_reader.h" #include "neug/utils/result.h" namespace neug { @@ -31,34 +31,19 @@ class Sniffer { virtual result> sniff() = 0; }; -class CsvSniffer : public Sniffer { - public: - explicit CsvSniffer(std::shared_ptr reader) - : reader_(std::move(reader)) { - if (!reader_) { - THROW_RUNTIME_ERROR("CsvReader cannot be null"); - } - } - - result> sniff() override; - - private: - std::shared_ptr reader_; -}; - -class JsonSniffer : public Sniffer { +class ReaderSniffer : public Sniffer { public: - explicit JsonSniffer(std::shared_ptr reader) + explicit ReaderSniffer(std::shared_ptr reader) : reader_(std::move(reader)) { if (!reader_) { - THROW_RUNTIME_ERROR("JsonReader cannot be null"); + THROW_RUNTIME_ERROR("FileReader cannot be null"); } } result> sniff() override; private: - std::shared_ptr reader_; + std::shared_ptr reader_; }; } // namespace reader diff --git a/include/neug/utils/io/read/csv/csv_reader.h b/include/neug/utils/io/read/csv/csv_reader.h index bf4f66d74..ef3c315ee 100644 --- a/include/neug/utils/io/read/csv/csv_reader.h +++ b/include/neug/utils/io/read/csv/csv_reader.h @@ -18,40 +18,32 @@ #include #include -#include "neug/execution/common/context.h" +#include "neug/utils/io/read/common/file_reader.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/read_state.h" #include "neug/utils/io/read/csv/csv_read_config.h" -#include "neug/utils/result.h" namespace neug { class IDataChunkSupplier; -namespace execution { -class Context; -} - namespace reader { -class CsvReader { +class CsvReader : public FileReader { public: explicit CsvReader(std::shared_ptr sharedState, std::unique_ptr optionsBuilder); - ~CsvReader(); + ~CsvReader() override; - void read(std::shared_ptr localState, - execution::Context& ctx); + std::shared_ptr read() override; - result> inferSchema(); + result> inferSchema() override; private: - void full_read( - const std::vector>& suppliers, - execution::Context& output, const CsvReadConfig& output_config); - void batch_read( + std::shared_ptr full_read( const std::vector>& suppliers, - execution::Context& output); + const CsvReadConfig& output_config); + std::shared_ptr batch_read( + const std::vector>& suppliers); std::shared_ptr sharedState_; std::unique_ptr optionsBuilder_; diff --git a/include/neug/utils/io/read/json/json_reader.h b/include/neug/utils/io/read/json/json_reader.h index b88011352..f000cac2d 100644 --- a/include/neug/utils/io/read/json/json_reader.h +++ b/include/neug/utils/io/read/json/json_reader.h @@ -18,40 +18,32 @@ #include #include -#include "neug/execution/common/context.h" +#include "neug/utils/io/read/common/file_reader.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/read_state.h" #include "neug/utils/io/read/json/json_read_config.h" -#include "neug/utils/result.h" namespace neug { class IDataChunkSupplier; -namespace execution { -class Context; -} - namespace reader { -class JsonReader { +class JsonReader : public FileReader { public: explicit JsonReader(std::shared_ptr sharedState, std::unique_ptr optionsBuilder); - ~JsonReader(); + ~JsonReader() override; - void read(std::shared_ptr localState, - execution::Context& ctx); + std::shared_ptr read() override; - result> inferSchema(); + result> inferSchema() override; private: - void full_read( - const std::vector>& suppliers, - execution::Context& output, const JsonReadConfig& output_config); - void batch_read( + std::shared_ptr full_read( const std::vector>& suppliers, - execution::Context& output); + const JsonReadConfig& output_config); + std::shared_ptr batch_read( + const std::vector>& suppliers); std::shared_ptr sharedState_; std::unique_ptr optionsBuilder_; diff --git a/include/neug/utils/io/reader.h b/include/neug/utils/io/reader.h index c89a45ffd..f7d4aba48 100644 --- a/include/neug/utils/io/reader.h +++ b/include/neug/utils/io/reader.h @@ -15,6 +15,7 @@ #pragma once +#include "neug/utils/io/read/common/file_reader.h" #include "neug/utils/io/read/common/read_state.h" #include "neug/utils/io/read/csv/csv_reader.h" #include "neug/utils/io/read/json/json_reader.h" diff --git a/src/execution/execute/ops/batch/batch_update_utils.cc b/src/execution/execute/ops/batch/batch_update_utils.cc index c35d59d7e..eb6c0308f 100644 --- a/src/execution/execute/ops/batch/batch_update_utils.cc +++ b/src/execution/execute/ops/batch/batch_update_utils.cc @@ -33,6 +33,7 @@ #include "neug/execution/common/types/value.h" #include "neug/storages/graph/graph_interface.h" #include "neug/storages/loader/loader_utils.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/string_utils.h" namespace neug { @@ -298,31 +299,6 @@ std::string path_to_json_string(Path& path, const StorageReadInterface& graph) { return buffer.GetString(); } -/// A supplier that yields pre-projected DataChunks one by one. -class MultiChunkSupplier : public IDataChunkSupplier { - public: - explicit MultiChunkSupplier(std::vector> chunks) - : chunks_(std::move(chunks)), index_(0) {} - - std::shared_ptr GetNextChunk() override { - if (index_ >= chunks_.size()) - return nullptr; - return chunks_[index_++]; - } - - int64_t RowNum() const override { - int64_t total = 0; - for (const auto& chunk : chunks_) { - total += static_cast(chunk->row_num()); - } - return total; - } - - private: - std::vector> chunks_; - size_t index_; -}; - std::shared_ptr create_data_chunk_supplier( const Context& ctx, const std::vector>& prop_mappings) { @@ -342,7 +318,7 @@ std::shared_ptr create_data_chunk_supplier( } projected_chunks.push_back(std::move(out_chunk)); } - return std::make_shared(std::move(projected_chunks)); + return std::make_shared(std::move(projected_chunks)); } std::vector match_files_with_pattern( diff --git a/src/utils/io/read/common/chunk_supplier.cc b/src/utils/io/read/common/chunk_supplier.cc new file mode 100644 index 000000000..6998e6504 --- /dev/null +++ b/src/utils/io/read/common/chunk_supplier.cc @@ -0,0 +1,64 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "neug/utils/io/read/common/chunk_supplier.h" + +#include "neug/execution/common/data_chunk.h" + +namespace neug { + +MultiDataChunkSupplier::MultiDataChunkSupplier( + std::vector> chunks) + : chunks_(std::move(chunks)), index_(0) {} + +std::shared_ptr MultiDataChunkSupplier::GetNextChunk() { + if (index_ >= chunks_.size()) { + return nullptr; + } + return chunks_[index_++]; +} + +int64_t MultiDataChunkSupplier::RowNum() const { + int64_t total = 0; + for (const auto& chunk : chunks_) { + total += static_cast(chunk->row_num()); + } + return total; +} + +ChunkSupplierWrapper::ChunkSupplierWrapper( + std::vector> suppliers) + : suppliers_(std::move(suppliers)) {} + +std::shared_ptr ChunkSupplierWrapper::GetNextChunk() { + while (current_supplier_index_ < suppliers_.size()) { + auto chunk = suppliers_[current_supplier_index_]->GetNextChunk(); + if (chunk) { + return chunk; + } + current_supplier_index_++; + } + return nullptr; +} + +int64_t ChunkSupplierWrapper::RowNum() const { + int64_t total_rows = 0; + for (const auto& supplier : suppliers_) { + total_rows += supplier->RowNum(); + } + return total_rows; +} + +} // namespace neug diff --git a/src/utils/io/read/common/reader_utils.cc b/src/utils/io/read/common/reader_utils.cc new file mode 100644 index 000000000..d1d0b15bd --- /dev/null +++ b/src/utils/io/read/common/reader_utils.cc @@ -0,0 +1,50 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "neug/utils/io/read/common/reader_utils.h" + +#include "neug/utils/exception/exception.h" + +namespace neug { +namespace reader { + +execution::Context toContext(std::shared_ptr supplier, + const ReadSharedState& state, + size_t fallback_column_count) { + int expected_cols = state.columnNum(); + if (expected_cols <= 0 && fallback_column_count > 0) { + expected_cols = static_cast(fallback_column_count); + } + + execution::Context ctx; + while (supplier) { + auto chunk = supplier->GetNextChunk(); + if (!chunk) { + break; + } + if (expected_cols > 0 && + static_cast(chunk->col_num()) != expected_cols) { + THROW_IO_EXCEPTION( + "Column number mismatch between schema and file data, schema: " + + std::to_string(expected_cols) + ", data: " + + std::to_string(chunk->col_num())); + } + ctx.append_chunk(std::move(*chunk)); + } + return ctx; +} + +} // namespace reader +} // namespace neug diff --git a/src/utils/io/read/common/sniffer.cc b/src/utils/io/read/common/sniffer.cc index cf277a8e5..32ac5aa34 100644 --- a/src/utils/io/read/common/sniffer.cc +++ b/src/utils/io/read/common/sniffer.cc @@ -20,18 +20,10 @@ namespace neug { namespace reader { -result> CsvSniffer::sniff() { +result> ReaderSniffer::sniff() { if (!reader_) { RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, - "CsvReader is null"); - } - return reader_->inferSchema(); -} - -result> JsonSniffer::sniff() { - if (!reader_) { - RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, - "JsonReader is null"); + "FileReader is null"); } return reader_->inferSchema(); } diff --git a/src/utils/io/read/csv/csv_reader.cc b/src/utils/io/read/csv/csv_reader.cc index 269d094f6..f66b7e4ce 100644 --- a/src/utils/io/read/csv/csv_reader.cc +++ b/src/utils/io/read/csv/csv_reader.cc @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/csv/csv_reader.h" #include "neug/execution/common/columns/container_types.h" @@ -38,6 +38,7 @@ #include "neug/execution/common/context.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/storages/loader/loader_utils.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/operator_precedence.h" #include "neug/utils/io/read/common/options.h" @@ -494,8 +495,7 @@ CsvReader::CsvReader(std::shared_ptr sharedState, CsvReader::~CsvReader() = default; -void CsvReader::read(std::shared_ptr /*localState*/, - execution::Context& ctx) { +std::shared_ptr CsvReader::read() { if (!sharedState_) { THROW_INVALID_ARGUMENT_EXCEPTION("SharedState is null"); } @@ -540,15 +540,14 @@ void CsvReader::read(std::shared_ptr /*localState*/, } if (use_batch_read && !sharedState_->skipRows) { - batch_read(suppliers, ctx); - } else { - full_read(suppliers, ctx, config); + return batch_read(suppliers); } + return full_read(suppliers, config); } -void CsvReader::full_read( +std::shared_ptr CsvReader::full_read( const std::vector>& suppliers, - execution::Context& output, const CsvReadConfig& output_config) { + const CsvReadConfig& output_config) { auto merged = read_all_chunks(suppliers); int expected_cols = sharedState_->columnNum(); @@ -568,19 +567,17 @@ void CsvReader::full_read( ? output_config.include_columns : sharedState_->projectColumns); - output.clear(); - output.append_chunk(std::move(projected)); + return std::make_shared( + std::vector>{ + std::make_shared(std::move(projected))}); } -void CsvReader::batch_read( - const std::vector>& suppliers, - execution::Context& output) { - output.clear(); - for (const auto& supplier : suppliers) { - while (auto chunk = supplier->GetNextChunk()) { - output.append_chunk(std::move(*chunk)); - } +std::shared_ptr CsvReader::batch_read( + const std::vector>& suppliers) { + if (suppliers.size() == 1) { + return suppliers.front(); } + return std::make_shared(suppliers); } result> CsvReader::inferSchema() { diff --git a/src/utils/io/read/json/json_reader.cc b/src/utils/io/read/json/json_reader.cc index 0a2014977..48b920938 100644 --- a/src/utils/io/read/json/json_reader.cc +++ b/src/utils/io/read/json/json_reader.cc @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/json/json_reader.h" #include #include @@ -31,7 +31,7 @@ #include "neug/execution/common/columns/columns_utils.h" #include "neug/execution/common/context.h" #include "neug/execution/common/types/value.h" -#include "neug/storages/loader/loader_utils.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/row_expression_filter.h" @@ -65,7 +65,7 @@ std::string read_file_to_string(const std::string& path) { return ss.str(); } -rapidjson::Document parse_json_array_file(const std::string& path) { +std::vector convert_json_array_to_lines(const std::string& path) { const auto content = read_file_to_string(path); rapidjson::Document document; document.Parse(content.c_str(), content.size()); @@ -77,19 +77,12 @@ rapidjson::Document parse_json_array_file(const std::string& path) { if (!document.IsArray() || document.Empty()) { THROW_IO_EXCEPTION("Expected non-empty JSON array in file: " + path); } + std::vector lines; + lines.reserve(document.Size()); for (const auto& obj : document.GetArray()) { if (!obj.IsObject()) { THROW_IO_EXCEPTION("Expected JSON object in array in file: " + path); } - } - return document; -} - -std::vector convert_json_array_to_lines(const std::string& path) { - auto document = parse_json_array_file(path); - std::vector lines; - lines.reserve(document.Size()); - for (const auto& obj : document.GetArray()) { lines.push_back(rapidjson_stringify(obj)); } return lines; @@ -126,31 +119,28 @@ execution::Value parse_json_value(const rapidjson::Value& value, return execution::Value::FLOAT(static_cast(value.GetDouble())); case DataTypeId::kDouble: return execution::Value::DOUBLE(value.GetDouble()); - case DataTypeId::kDate: { - std::string str = - value.IsString() ? value.GetString() : rapidjson_stringify(value); - return execution::Value::CreateValue( - execution::ValueConverter::typed_from_string(str)); - } - case DataTypeId::kTimestampMs: { - std::string str = - value.IsString() ? value.GetString() : rapidjson_stringify(value); - return execution::Value::CreateValue( - execution::ValueConverter::typed_from_string( - str)); - } - case DataTypeId::kInterval: { - std::string str = - value.IsString() ? value.GetString() : rapidjson_stringify(value); - return execution::Value::CreateValue( - execution::ValueConverter::typed_from_string( - str)); - } case DataTypeId::kVarchar: if (value.IsString()) { return execution::Value::STRING(value.GetString()); } return execution::Value::STRING(rapidjson_stringify(value)); + case DataTypeId::kDate: + if (value.IsString()) { + return execution::Value::DATE(Date(std::string(value.GetString()))); + } + return execution::Value::STRING(rapidjson_stringify(value)); + case DataTypeId::kTimestampMs: + if (value.IsString()) { + return execution::Value::TIMESTAMPMS( + DateTime(std::string(value.GetString()))); + } + return execution::Value::STRING(rapidjson_stringify(value)); + case DataTypeId::kInterval: + if (value.IsString()) { + return execution::Value::INTERVAL( + Interval(std::string(value.GetString()))); + } + return execution::Value::STRING(rapidjson_stringify(value)); default: if (value.IsString()) { return execution::Value::STRING(value.GetString()); @@ -164,9 +154,9 @@ class JsonChunkSupplier : public IDataChunkSupplier { JsonChunkSupplier(const std::string& file_path, JsonReadConfig config) : file_path_(file_path), config_(std::move(config)) { if (config_.json_array_input) { - document_ = parse_json_array_file(file_path_); - doc_index_ = 0; - row_num_ = static_cast(document_.Size()); + lines_ = convert_json_array_to_lines(file_path_); + line_index_ = 0; + row_num_ = static_cast(lines_.size()); } else { input_ = std::make_unique(file_path_); if (!input_->is_open()) { @@ -206,37 +196,40 @@ class JsonChunkSupplier : public IDataChunkSupplier { size_t rows_in_chunk = 0; while (rows_in_chunk < chunk_size_) { - const rapidjson::Value* obj_ptr = nullptr; + std::string line; if (config_.json_array_input) { - if (doc_index_ >= document_.Size()) { + if (line_index_ >= lines_.size()) { break; } - obj_ptr = &document_.GetArray()[doc_index_++]; + line = lines_[line_index_++]; } else { - std::string line; if (!input_ || !std::getline(*input_, line)) { break; } if (line.empty()) { continue; } - line_doc_.Parse(line.c_str(), line.size()); - if (line_doc_.HasParseError() || !line_doc_.IsObject()) { - THROW_IO_EXCEPTION("Invalid JSON object in file: " + file_path_); - } - obj_ptr = &line_doc_; } - const auto& obj = *obj_ptr; + rapidjson::Document doc; + doc.Parse(line.c_str(), line.size()); + if (doc.HasParseError() || !doc.IsObject()) { + THROW_IO_EXCEPTION("Invalid JSON object in file: " + file_path_); + } + for (size_t col = 0; col < selected_names.size(); ++col) { const auto& name = selected_names[col]; - if (!obj.HasMember(name.c_str())) { + if (!doc.HasMember(name.c_str())) { THROW_SCHEMA_MISMATCH( "Column '" + name + "' not found in JSON object in file: " + file_path_); } - builders[col]->push_back_elem( - parse_json_value(obj[name.c_str()], selected_types[col])); + auto val = parse_json_value(doc[name.c_str()], selected_types[col]); + if (val.IsNull()) { + builders[col]->push_back_null(); + } else { + builders[col]->push_back_elem(val); + } } ++rows_in_chunk; } @@ -259,9 +252,8 @@ class JsonChunkSupplier : public IDataChunkSupplier { JsonReadConfig config_; int64_t row_num_ = 0; size_t chunk_size_ = kDefaultJsonChunkRows; - rapidjson::Document document_; - rapidjson::SizeType doc_index_ = 0; - rapidjson::Document line_doc_; // reusable parse buffer for JSONL mode + std::vector lines_; + size_t line_index_ = 0; std::unique_ptr input_; }; @@ -280,8 +272,7 @@ JsonReader::JsonReader(std::shared_ptr sharedState, JsonReader::~JsonReader() = default; -void JsonReader::read(std::shared_ptr /*localState*/, - execution::Context& ctx) { +std::shared_ptr JsonReader::read() { if (!sharedState_ || !optionsBuilder_) { THROW_INVALID_ARGUMENT_EXCEPTION("JsonReader state or builder is null"); } @@ -323,15 +314,14 @@ void JsonReader::read(std::shared_ptr /*localState*/, } if (use_batch_read && !sharedState_->skipRows) { - batch_read(suppliers, ctx); - } else { - full_read(suppliers, ctx, config); + return batch_read(suppliers); } + return full_read(suppliers, config); } -void JsonReader::full_read( +std::shared_ptr JsonReader::full_read( const std::vector>& suppliers, - execution::Context& output, const JsonReadConfig& output_config) { + const JsonReadConfig& output_config) { auto merged = read_all_chunks(suppliers); int expected_cols = sharedState_->columnNum(); @@ -350,19 +340,17 @@ void JsonReader::full_read( sharedState_->projectColumns.empty() ? output_config.include_columns : sharedState_->projectColumns); - output.clear(); - output.append_chunk(std::move(projected)); + return std::make_shared( + std::vector>{ + std::make_shared(std::move(projected))}); } -void JsonReader::batch_read( - const std::vector>& suppliers, - execution::Context& output) { - output.clear(); - for (const auto& supplier : suppliers) { - while (auto chunk = supplier->GetNextChunk()) { - output.append_chunk(std::move(*chunk)); - } +std::shared_ptr JsonReader::batch_read( + const std::vector>& suppliers) { + if (suppliers.size() == 1) { + return suppliers.front(); } + return std::make_shared(suppliers); } result> JsonReader::inferSchema() { @@ -408,26 +396,21 @@ result> JsonReader::inferSchema() { } } - sniff_config.include_columns = sniff_config.column_names; - for (const auto& name : sniff_config.column_names) { - sniff_config.column_types[name] = DataType(DataTypeId::kVarchar); - } - - // Read sample rows directly via rapidjson to infer types without forcing - // them through VARCHAR-typed parsing. + // Directly inspect JSON native types for schema inference instead of + // reading through the supplier (which coerces all values to varchar). std::vector sample_lines; - const size_t max_sample_rows = 64; + const size_t kMaxSampleRows = 100; if (config.json_array_input) { - auto all_lines = convert_json_array_to_lines(paths[0]); - for (size_t i = 0; i < std::min(all_lines.size(), max_sample_rows); ++i) { - sample_lines.push_back(std::move(all_lines[i])); + auto lines = convert_json_array_to_lines(paths[0]); + for (size_t i = 0; i < std::min(lines.size(), kMaxSampleRows); ++i) { + sample_lines.push_back(lines[i]); } } else { std::ifstream input(paths[0]); std::string line; - while (std::getline(input, line) && sample_lines.size() < max_sample_rows) { + while (std::getline(input, line) && sample_lines.size() < kMaxSampleRows) { if (!line.empty()) { - sample_lines.push_back(std::move(line)); + sample_lines.push_back(line); } } } @@ -444,6 +427,10 @@ result> JsonReader::inferSchema() { return entrySchema; } + auto entrySchema = std::make_shared(); + entrySchema->columnNames = sniff_config.column_names; + entrySchema->columnTypes.reserve(sniff_config.column_names.size()); + const auto& col_names = sniff_config.column_names; // Track per-column type flags. std::vector all_int(col_names.size(), true); @@ -453,7 +440,6 @@ result> JsonReader::inferSchema() { std::vector all_date(col_names.size(), true); std::vector all_date_or_datetime(col_names.size(), true); std::vector any_datetime(col_names.size(), false); - std::vector has_value(col_names.size(), false); // Helper lambdas for temporal detection on strings. @@ -532,10 +518,6 @@ result> JsonReader::inferSchema() { } } - auto entrySchema = std::make_shared(); - entrySchema->columnNames = col_names; - entrySchema->columnTypes.reserve(col_names.size()); - NeuGTypeConverter converter; for (size_t col = 0; col < col_names.size(); ++col) { DataType inferred_type(DataTypeId::kVarchar); diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index 976a54c64..509170093 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -7,4 +7,5 @@ add_neug_test( test_exception.cc test_sniffer.cc test_file_utils.cc - json_test.cc) + json_test.cc + test_json_io.cc) diff --git a/tests/utils/json_test.cc b/tests/utils/json_test.cc index 624130fef..6d34df3e4 100644 --- a/tests/utils/json_test.cc +++ b/tests/utils/json_test.cc @@ -25,8 +25,9 @@ #include "neug/execution/common/context.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" -#include "neug/utils/io/reader.h" +#include "neug/utils/io/read/json/json_reader.h" namespace neug { namespace test { @@ -103,7 +104,7 @@ class JsonTest : public ::testing::Test { return sharedState; } - std::shared_ptr createJsonReader( + std::shared_ptr createJsonReader( const std::shared_ptr& sharedState) { auto optionsBuilder = std::make_unique(sharedState, true); @@ -121,10 +122,7 @@ TEST_F(JsonTest, TestJsonArray) { {createUInt32Type(), createStringType(), createDoubleType()}, {{"batch_read", "false"}}); auto reader = createJsonReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = reader::toContext(reader->read(), *sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); diff --git a/tests/utils/test_json_io.cc b/tests/utils/test_json_io.cc new file mode 100644 index 000000000..dc1ed9056 --- /dev/null +++ b/tests/utils/test_json_io.cc @@ -0,0 +1,549 @@ +/** + * Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include + +#include "neug/compiler/common/case_insensitive_map.h" +#include "neug/execution/common/columns/value_columns.h" +#include "neug/execution/common/context.h" +#include "neug/generated/proto/plan/basic_type.pb.h" +#include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" +#include "neug/utils/io/read/common/schema.h" +#include "neug/utils/io/read/json/json_reader.h" + +namespace neug { +namespace test { + +static constexpr const char* JSON_IO_TEST_DIR = "/tmp/json_io_test"; + +class JsonIOTest : public ::testing::Test { + public: + void SetUp() override { + if (std::filesystem::exists(JSON_IO_TEST_DIR)) { + std::filesystem::remove_all(JSON_IO_TEST_DIR); + } + std::filesystem::create_directories(JSON_IO_TEST_DIR); + } + + void TearDown() override { + if (std::filesystem::exists(JSON_IO_TEST_DIR)) { + std::filesystem::remove_all(JSON_IO_TEST_DIR); + } + } + + void createFile(const std::string& filename, const std::string& content) { + std::ofstream file(std::string(JSON_IO_TEST_DIR) + "/" + filename); + file << content; + file.close(); + } + + std::string filePath(const std::string& filename) { + return std::string(JSON_IO_TEST_DIR) + "/" + filename; + } + + std::shared_ptr<::common::DataType> createInt32Type() { + auto type = std::make_shared<::common::DataType>(); + type->set_primitive_type(::common::PrimitiveType::DT_SIGNED_INT32); + return type; + } + + std::shared_ptr<::common::DataType> createInt64Type() { + auto type = std::make_shared<::common::DataType>(); + type->set_primitive_type(::common::PrimitiveType::DT_SIGNED_INT64); + return type; + } + + std::shared_ptr<::common::DataType> createUInt32Type() { + auto type = std::make_shared<::common::DataType>(); + type->set_primitive_type(::common::PrimitiveType::DT_UNSIGNED_INT32); + return type; + } + + std::shared_ptr<::common::DataType> createDoubleType() { + auto type = std::make_shared<::common::DataType>(); + type->set_primitive_type(::common::PrimitiveType::DT_DOUBLE); + return type; + } + + std::shared_ptr<::common::DataType> createStringType() { + auto type = std::make_shared<::common::DataType>(); + auto strType = std::make_unique<::common::String>(); + auto varChar = std::make_unique<::common::String::VarChar>(); + strType->set_allocated_var_char(varChar.release()); + type->set_allocated_string(strType.release()); + return type; + } + + std::shared_ptr<::common::DataType> createBoolType() { + auto type = std::make_shared<::common::DataType>(); + type->set_primitive_type(::common::PrimitiveType::DT_BOOL); + return type; + } + + std::shared_ptr createSharedState( + const std::string& jsonFile, const std::vector& columnNames, + const std::vector>& columnTypes, + const common::case_insensitive_map_t& options = {}, + const std::vector& projectColumns = {}) { + auto sharedState = std::make_shared(); + auto entrySchema = std::make_shared(); + entrySchema->columnNames = columnNames; + entrySchema->columnTypes = columnTypes; + + reader::FileSchema fileSchema; + fileSchema.paths = {filePath(jsonFile)}; + fileSchema.format = "json"; + fileSchema.options = options; + + reader::ExternalSchema externalSchema; + externalSchema.entry = entrySchema; + externalSchema.file = fileSchema; + + sharedState->schema = std::move(externalSchema); + sharedState->projectColumns = projectColumns; + return sharedState; + } + + std::shared_ptr createJsonReader( + const std::shared_ptr& sharedState, + bool json_array_input = false) { + auto optionsBuilder = std::make_unique( + sharedState, json_array_input); + return std::make_shared(sharedState, + std::move(optionsBuilder)); + } + + execution::Context readToContext( + const std::shared_ptr& reader, + const std::shared_ptr& sharedState) { + return reader::toContext(reader->read(), *sharedState); + } +}; + +// ============================================================================= +// JSON Lines Format - Basic Reading +// ============================================================================= + +TEST_F(JsonIOTest, JsonLines_BasicRead) { + createFile("basic.jsonl", + "{\"id\":1,\"name\":\"Alice\",\"score\":95.5}\n" + "{\"id\":2,\"name\":\"Bob\",\"score\":87.0}\n" + "{\"id\":3,\"name\":\"Charlie\",\"score\":92.5}\n"); + auto state = createSharedState( + "basic.jsonl", {"id", "name", "score"}, + {createInt64Type(), createStringType(), createDoubleType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.col_num(), 3); + EXPECT_EQ(ctx.row_num(), 3); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), 1); + EXPECT_EQ(ctx.chunk(0).columns()[1]->get_elem(0).GetValue(), + "Alice"); + EXPECT_DOUBLE_EQ(ctx.chunk(0).columns()[2]->get_elem(0).GetValue(), + 95.5); +} + +TEST_F(JsonIOTest, JsonLines_SingleRow) { + createFile("single.jsonl", "{\"x\":42,\"y\":\"hello\"}\n"); + auto state = createSharedState("single.jsonl", {"x", "y"}, + {createInt32Type(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 1); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), 42); +} + +TEST_F(JsonIOTest, JsonLines_EmptyLines) { + // Empty lines between valid JSON lines should be skipped + createFile("emptylines.jsonl", + "{\"id\":1}\n" + "\n" + "{\"id\":2}\n" + "\n"); + auto state = + createSharedState("emptylines.jsonl", {"id"}, {createInt64Type()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); +} + +// ============================================================================= +// JSON Array Format +// ============================================================================= + +TEST_F(JsonIOTest, JsonArray_BasicRead) { + createFile("array.json", + "[{\"id\":1,\"name\":\"Alice\"},{\"id\":2,\"name\":\"Bob\"}]"); + auto state = createSharedState("array.json", {"id", "name"}, + {createUInt32Type(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state, true); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.col_num(), 2); + EXPECT_EQ(ctx.row_num(), 2); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), 1u); + EXPECT_EQ(ctx.chunk(0).columns()[1]->get_elem(1).GetValue(), + "Bob"); +} + +TEST_F(JsonIOTest, JsonArray_LargeArray) { + std::string content = "["; + for (int i = 0; i < 500; ++i) { + if (i > 0) + content += ","; + content += "{\"id\":" + std::to_string(i) + + ",\"val\":" + std::to_string(i * 1.5) + "}"; + } + content += "]"; + createFile("large_array.json", content); + auto state = createSharedState("large_array.json", {"id", "val"}, + {createInt64Type(), createDoubleType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state, true); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 500); +} + +// ============================================================================= +// JSON Type Handling +// ============================================================================= + +TEST_F(JsonIOTest, Types_IntegerValues) { + createFile("int.jsonl", "{\"i32\":42,\"i64\":9876543210}\n"); + auto state = createSharedState("int.jsonl", {"i32", "i64"}, + {createInt32Type(), createInt64Type()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), 42); + EXPECT_EQ(ctx.chunk(0).columns()[1]->get_elem(0).GetValue(), + 9876543210LL); +} + +TEST_F(JsonIOTest, Types_DoubleValues) { + createFile("dbl.jsonl", "{\"pi\":3.14159265,\"e\":2.71828183}\n"); + auto state = createSharedState("dbl.jsonl", {"pi", "e"}, + {createDoubleType(), createDoubleType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_NEAR(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), + 3.14159265, 1e-8); + EXPECT_NEAR(ctx.chunk(0).columns()[1]->get_elem(0).GetValue(), + 2.71828183, 1e-8); +} + +TEST_F(JsonIOTest, Types_BoolValues) { + createFile("bool.jsonl", + "{\"a\":true,\"b\":false}\n" + "{\"a\":false,\"b\":true}\n"); + auto state = createSharedState("bool.jsonl", {"a", "b"}, + {createBoolType(), createBoolType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), true); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(1).GetValue(), false); +} + +TEST_F(JsonIOTest, Types_StringValues) { + createFile("str.jsonl", + "{\"name\":\"Alice\"}\n" + "{\"name\":\"Bob with \\\"quotes\\\"\"}\n"); + auto state = createSharedState("str.jsonl", {"name"}, {createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), + "Alice"); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(1).GetValue(), + "Bob with \"quotes\""); +} + +TEST_F(JsonIOTest, Types_UnicodeStrings) { + createFile("unicode.jsonl", + "{\"msg\":\"你好世界\"}\n" + "{\"msg\":\"café\"}\n"); + auto state = createSharedState("unicode.jsonl", {"msg"}, {createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(0).GetValue(), + "你好世界"); + EXPECT_EQ(ctx.chunk(0).columns()[0]->get_elem(1).GetValue(), + "café"); +} + +TEST_F(JsonIOTest, Types_NestedObjectAsString) { + // Nested objects should be stringified + createFile("nested.jsonl", "{\"id\":1,\"data\":{\"x\":10,\"y\":20}}\n"); + auto state = createSharedState("nested.jsonl", {"id", "data"}, + {createInt64Type(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 1); + // Nested object should be stored as JSON string + auto data_str = + ctx.chunk(0).columns()[1]->get_elem(0).GetValue(); + EXPECT_NE(data_str.find("\"x\""), std::string::npos); + EXPECT_NE(data_str.find("10"), std::string::npos); +} + +TEST_F(JsonIOTest, Types_NullHandling) { + createFile("null.jsonl", + "{\"id\":1,\"name\":null}\n" + "{\"id\":2,\"name\":\"Bob\"}\n"); + auto state = createSharedState("null.jsonl", {"id", "name"}, + {createInt64Type(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); + // First row: name is null + auto name_col = ctx.chunk(0).columns()[1]; + EXPECT_TRUE(name_col->get_elem(0).IsNull()); + EXPECT_EQ(name_col->get_elem(1).GetValue(), "Bob"); +} + +// ============================================================================= +// JSON Error Handling +// ============================================================================= + +TEST_F(JsonIOTest, Error_InvalidJson) { + createFile("invalid.jsonl", "not valid json\n"); + auto state = createSharedState("invalid.jsonl", {"id"}, {createInt64Type()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + EXPECT_THROW(readToContext(reader, state), exception::IOException); +} + +TEST_F(JsonIOTest, Error_MissingColumn) { + createFile("missing.jsonl", "{\"id\":1,\"name\":\"Alice\"}\n"); + auto state = createSharedState( + "missing.jsonl", {"id", "name", "nonexistent"}, + {createInt64Type(), createStringType(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + EXPECT_THROW(readToContext(reader, state), + exception::SchemaMismatchException); +} + +TEST_F(JsonIOTest, Error_InvalidJsonArray) { + createFile("bad_array.json", "[1, 2, 3]"); // Array of non-objects + auto state = createSharedState("bad_array.json", {"val"}, {createInt64Type()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state, true); + EXPECT_THROW(readToContext(reader, state), exception::IOException); +} + +// ============================================================================= +// JSON Batch Mode +// ============================================================================= + +TEST_F(JsonIOTest, BatchMode_MultiChunk) { + std::string content; + for (int i = 0; i < 200; ++i) { + content += "{\"id\":" + std::to_string(i) + + ",\"val\":" + std::to_string(i * 2.0) + "}\n"; + } + createFile("batch.jsonl", content); + auto state = createSharedState("batch.jsonl", {"id", "val"}, + {createInt64Type(), createDoubleType()}, + {{"batch_read", "true"}}); + auto reader = createJsonReader(state); + auto supplier = reader->read(); + ASSERT_NE(supplier, nullptr); + int total_rows = 0; + int chunk_count = 0; + while (auto chunk = supplier->GetNextChunk()) { + total_rows += static_cast(chunk->row_num()); + chunk_count++; + } + EXPECT_EQ(total_rows, 200); + // With default chunk_size=4096, all 200 rows fit in one chunk + EXPECT_GE(chunk_count, 1); +} + +// ============================================================================= +// JSON Schema Inference +// ============================================================================= + +TEST_F(JsonIOTest, InferSchema_IntegerColumn) { + createFile("infer_int.jsonl", + "{\"id\":1,\"name\":\"a\"}\n" + "{\"id\":2,\"name\":\"b\"}\n"); + auto state = createSharedState("infer_int.jsonl", {"id", "name"}, + {createStringType(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto result = reader->inferSchema(); + ASSERT_TRUE(result.has_value()); + auto schema = result.value(); + ASSERT_EQ(schema->columnNames.size(), 2u); + EXPECT_EQ(schema->columnNames[0], "id"); + EXPECT_EQ(schema->columnNames[1], "name"); + // id should be inferred as integer + EXPECT_EQ(schema->columnTypes[0]->primitive_type(), + ::common::PrimitiveType::DT_SIGNED_INT64); +} + +TEST_F(JsonIOTest, InferSchema_MixedTypes) { + createFile("infer_mixed.jsonl", + "{\"a\":1,\"b\":1.5,\"c\":\"hello\"}\n" + "{\"a\":2,\"b\":2.5,\"c\":\"world\"}\n"); + auto state = createSharedState( + "infer_mixed.jsonl", {"a", "b", "c"}, + {createStringType(), createStringType(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto result = reader->inferSchema(); + ASSERT_TRUE(result.has_value()); + auto schema = result.value(); + // a: integer, b: double, c: string + EXPECT_EQ(schema->columnTypes[0]->primitive_type(), + ::common::PrimitiveType::DT_SIGNED_INT64); + EXPECT_EQ(schema->columnTypes[1]->primitive_type(), + ::common::PrimitiveType::DT_DOUBLE); + EXPECT_TRUE(schema->columnTypes[2]->has_string()); +} + +TEST_F(JsonIOTest, InferSchema_AutoDetectColumnNames) { + createFile("infer_auto.jsonl", "{\"x\":1,\"y\":2,\"z\":3}\n"); + // Create state without explicit column_names to trigger auto-detection + auto sharedState = std::make_shared(); + auto entrySchema = std::make_shared(); + // Empty column names - should be auto-detected + reader::FileSchema fileSchema; + fileSchema.paths = {filePath("infer_auto.jsonl")}; + fileSchema.format = "json"; + fileSchema.options = {{"batch_read", "false"}}; + reader::ExternalSchema externalSchema; + externalSchema.entry = entrySchema; + externalSchema.file = fileSchema; + sharedState->schema = std::move(externalSchema); + + auto optionsBuilder = + std::make_unique(sharedState, false); + auto reader = std::make_shared(sharedState, + std::move(optionsBuilder)); + auto result = reader->inferSchema(); + ASSERT_TRUE(result.has_value()); + auto schema = result.value(); + EXPECT_EQ(schema->columnNames.size(), 3u); + // Check column names were auto-detected (order from rapidjson iteration) + EXPECT_NE( + std::find(schema->columnNames.begin(), schema->columnNames.end(), "x"), + schema->columnNames.end()); +} + +TEST_F(JsonIOTest, InferSchema_NoDataRowsDefaultsToVarchar) { + createFile("infer_empty.jsonl", ""); + auto state = createSharedState("infer_empty.jsonl", {"a", "b", "c"}, + {createStringType(), createStringType(), + createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto result = reader->inferSchema(); + ASSERT_TRUE(result.has_value()); + auto schema = result.value(); + EXPECT_EQ(schema->columnNames.size(), 3u); + ASSERT_EQ(schema->columnTypes.size(), 3u); + for (const auto& type : schema->columnTypes) { + EXPECT_TRUE(type->has_string()); + } +} + +TEST_F(JsonIOTest, ReadBoolFromString) { + createFile("bool_str.jsonl", "{\"flag\":\"true\"}\n{\"flag\":\"false\"}\n"); + auto state = createSharedState("bool_str.jsonl", {"flag"}, {createBoolType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 2); + auto col = ctx.chunk(0).columns()[0]; + EXPECT_EQ(col->get_elem(0).GetValue(), true); + EXPECT_EQ(col->get_elem(1).GetValue(), false); +} + +// ============================================================================= +// JSON Column Projection +// ============================================================================= + +TEST_F(JsonIOTest, ColumnProjection_SubsetColumns) { + createFile("project.jsonl", + "{\"a\":1,\"b\":\"x\",\"c\":3.14}\n" + "{\"a\":2,\"b\":\"y\",\"c\":2.71}\n"); + auto state = createSharedState( + "project.jsonl", {"a", "b", "c"}, + {createInt64Type(), createStringType(), createDoubleType()}, + {{"batch_read", "false"}}, {"a", "c"}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.col_num(), 2); + EXPECT_EQ(ctx.row_num(), 2); +} + +// ============================================================================= +// JSON Multi-file +// ============================================================================= + +TEST_F(JsonIOTest, MultiFile_Read) { + createFile("part1.jsonl", "{\"id\":1}\n{\"id\":2}\n"); + createFile("part2.jsonl", "{\"id\":3}\n{\"id\":4}\n"); + auto state = createSharedState("part1.jsonl", {"id"}, {createInt64Type()}, + {{"batch_read", "false"}}); + state->schema.file.paths.push_back(filePath("part2.jsonl")); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 4); +} + +// ============================================================================= +// JSON Large Data / Stress +// ============================================================================= + +TEST_F(JsonIOTest, LargeData_10000Rows) { + std::string content; + for (int i = 0; i < 10000; ++i) { + content += "{\"id\":" + std::to_string(i) + ",\"name\":\"user_" + + std::to_string(i) + "\"}\n"; + } + createFile("large.jsonl", content); + auto state = createSharedState("large.jsonl", {"id", "name"}, + {createInt64Type(), createStringType()}, + {{"batch_read", "false"}}); + auto reader = createJsonReader(state); + auto ctx = readToContext(reader, state); + EXPECT_EQ(ctx.row_num(), 10000); +} + +} // namespace test +} // namespace neug diff --git a/tests/utils/test_reader.cc b/tests/utils/test_reader.cc index 2d3e2c072..e76e97c02 100644 --- a/tests/utils/test_reader.cc +++ b/tests/utils/test_reader.cc @@ -34,10 +34,7 @@ TEST_F(ReaderTest, TestBasicCsvRead) { {{"skip_rows", "1"}, {"batch_read", "false"}}); auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Verify data: should have 3 columns EXPECT_EQ(ctx.col_num(), 3); @@ -59,10 +56,7 @@ TEST_F(ReaderTest, TestCsvWithTabDelimiter) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); @@ -84,10 +78,7 @@ TEST_F(ReaderTest, TestCsvWithCustomQuoting) { {"batch_read", "false"}}); auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); @@ -105,10 +96,7 @@ TEST_F(ReaderTest, TestCsvWithNoHeader) { {{"batch_read", "false"}}); auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); @@ -133,18 +121,21 @@ TEST_F(ReaderTest, TestBatchRead) { {{"batch_read", "true"}, {"batch_size", "1024"}, {"skip_rows", "1"}}); auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + // In the new streaming architecture, batch_read returns a supplier + // that streams chunks on-demand rather than materializing all at once. + auto supplier = reader->read(); + ASSERT_NE(supplier, nullptr); - // Batch mode: data is materialized into Context chunks - EXPECT_GT(ctx.chunk_num(), 0); - EXPECT_EQ(ctx.col_num(), 3); + // Verify total row count via supplier + EXPECT_EQ(supplier->RowNum(), 100); // All 100 rows should be readable - // Count rows using helper function - int64_t totalRows = count_batch_row_num(ctx); - EXPECT_EQ(totalRows, 100); // All 100 rows should be read + // Verify actual data iteration + int64_t totalRows = 0; + while (auto chunk = supplier->GetNextChunk()) { + EXPECT_EQ(chunk->col_num(), 3); + totalRows += static_cast(chunk->row_num()); + } + EXPECT_EQ(totalRows, 100); } // Test 6: Column pruning (skip columns) @@ -164,10 +155,7 @@ TEST_F(ReaderTest, TestColumnPruning) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should only have 2 columns (id and score) EXPECT_EQ(ctx.col_num(), 2); @@ -175,6 +163,28 @@ TEST_F(ReaderTest, TestColumnPruning) { EXPECT_EQ(ctx.row_num(), 3); } +// Test 6b: batch_read=true with column projection only (no filter) +TEST_F(ReaderTest, TestBatchReadWithProjectionOnly) { + createCsvFile("test6b.csv", + "id|name|score\n1|Alice|95.5\n2|Bob|87.0\n3|Charlie|92.5\n"); + + std::vector columnNames = {"id", "name", "score"}; + std::vector> columnTypes = { + createInt32Type(), createStringType(), createDoubleType()}; + + std::vector projectColumns = {"id", "score"}; + auto sharedState = createSharedState( + "test6b.csv", columnNames, columnTypes, + {{"skip_rows", "1"}, {"batch_read", "true"}}, projectColumns); + + auto reader = createCsvReader(sharedState); + execution::Context ctx = readToContext(reader, sharedState); + + EXPECT_EQ(ctx.col_num(), 2); + EXPECT_EQ(sharedState->columnNum(), 2); + EXPECT_EQ(ctx.row_num(), 3); +} + // Test 7: Filter pushdown (row filtering) TEST_F(ReaderTest, TestFilterPushdown) { createCsvFile("test7.csv", @@ -194,10 +204,7 @@ TEST_F(ReaderTest, TestFilterPushdown) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should filter out rows with score <= 90.0 // Expected: Alice (95.5) and Charlie (92.5) - 2 rows @@ -205,6 +212,52 @@ TEST_F(ReaderTest, TestFilterPushdown) { EXPECT_EQ(ctx.row_num(), 2); } +// Test 7b: Filter with numeric type coercion (int column vs double constant) +TEST_F(ReaderTest, TestFilterNumericTypeCoercion) { + createCsvFile("test7b.csv", + "id|name|score\n1|Alice|95.5\n2|Bob|87.0\n3|Charlie|92.5\n4|" + "David|88.0\n"); + + std::vector columnNames = {"id", "name", "score"}; + std::vector> columnTypes = { + createInt32Type(), createStringType(), createDoubleType()}; + + auto filterExpr = + createFilterExpression("id", ValueConverter::fromDouble(2.5)); + auto sharedState = createSharedState( + "test7b.csv", columnNames, columnTypes, + {{"skip_rows", "1"}, {"batch_read", "false"}}, {}, filterExpr); + + auto reader = createCsvReader(sharedState); + execution::Context ctx = readToContext(reader, sharedState); + + // id > 2.5 keeps rows with id 3 and 4 + EXPECT_EQ(ctx.row_num(), 2); +} + +// Test 7c: Filter with arithmetic expression (score - id > 90) +TEST_F(ReaderTest, TestFilterArithmeticExpression) { + createCsvFile("test7c.csv", + "id|name|score\n1|Alice|95.5\n2|Bob|87.0\n3|Charlie|92.5\n4|" + "David|88.0\n5|Eve|96.0\n"); + + std::vector columnNames = {"id", "name", "score"}; + std::vector> columnTypes = { + createInt32Type(), createStringType(), createDoubleType()}; + + auto filterExpr = createSubtractGtFilterExpression( + "score", "id", ValueConverter::fromDouble(90.0)); + auto sharedState = createSharedState( + "test7c.csv", columnNames, columnTypes, + {{"skip_rows", "1"}, {"batch_read", "false"}}, {}, filterExpr); + + auto reader = createCsvReader(sharedState); + execution::Context ctx = readToContext(reader, sharedState); + + // Alice (94.5) and Eve (91.0) + EXPECT_EQ(ctx.row_num(), 2); +} + // Test 8: Combined column pruning and filter pushdown TEST_F(ReaderTest, TestColumnPruningAndFilterPushdown) { createCsvFile("test8.csv", @@ -227,10 +280,7 @@ TEST_F(ReaderTest, TestColumnPruningAndFilterPushdown) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should have 2 columns (id, score) and filtered rows (score > 90.0) EXPECT_EQ(ctx.col_num(), 2); @@ -256,10 +306,7 @@ TEST_F(ReaderTest, TestMultipleFiles) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should read all rows from both files (4 rows total) EXPECT_EQ(ctx.col_num(), 3); @@ -282,10 +329,7 @@ TEST_F(ReaderTest, TestForceColumnTypeConversion) { {{"skip_rows", "1"}, {"batch_read", "false"}}); auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 3); @@ -326,10 +370,7 @@ TEST_F(ReaderTest, TestMultiColumnAndFilterPushdown) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should have 3 columns EXPECT_EQ(ctx.col_num(), 3); @@ -357,10 +398,7 @@ TEST_F(ReaderTest, TestBatchReadWithFilter) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should filter out rows with score <= 90.0 // Expected: Alice (95.5) and Charlie (92.5) - 2 rows @@ -389,10 +427,7 @@ TEST_F(ReaderTest, TestBatchReadWithFilterAndProjection) { auto reader = createCsvReader(sharedState); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should have 2 columns (id, score) and filtered rows (score > 90.0) EXPECT_EQ(ctx.col_num(), 2); @@ -416,10 +451,7 @@ TEST_F(ReaderTest, TestBasicJsonRead) { {{"batch_read", "false"}}); auto reader = createJsonReader(sharedState, false); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); @@ -438,13 +470,33 @@ TEST_F(ReaderTest, TestJsonNonExistentColumnThrows) { {{"batch_read", "false"}}); auto reader = createJsonReader(sharedState, false); - auto localState = std::make_shared(); - execution::Context ctx; - - EXPECT_THROW(reader->read(localState, ctx), + EXPECT_THROW(readToContext(reader, sharedState), exception::SchemaMismatchException); } +// Test: JSON batch_read=true with column projection only (no filter) +TEST_F(ReaderTest, TestJsonBatchReadWithProjectionOnly) { + createJsonFile("test_json_batch_proj.jsonl", + "{\"id\":1,\"name\":\"Alice\",\"score\":95.5}\n" + "{\"id\":2,\"name\":\"Bob\",\"score\":87.0}\n"); + + std::vector columnNames = {"id", "name", "score"}; + std::vector> columnTypes = { + createInt64Type(), createStringType(), createDoubleType()}; + + auto sharedState = createJsonSharedState( + "test_json_batch_proj.jsonl", columnNames, columnTypes, + {{"batch_read", "true"}}); + sharedState->projectColumns = {"id", "score"}; + + auto reader = createJsonReader(sharedState, false); + execution::Context ctx = readToContext(reader, sharedState); + + EXPECT_EQ(ctx.col_num(), 2); + EXPECT_EQ(sharedState->columnNum(), 2); + EXPECT_EQ(ctx.row_num(), 2); +} + // Test: JSON batch_read=true with filter should fallback to full_read TEST_F(ReaderTest, TestJsonBatchReadWithFilter) { createJsonFile("test_json_filter.json", @@ -467,10 +519,7 @@ TEST_F(ReaderTest, TestJsonBatchReadWithFilter) { auto reader = createJsonReader(sharedState, false); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should filter out rows with score <= 90.0 // Expected: Alice (95.5) and Charlie (92.5) - 2 rows @@ -501,10 +550,7 @@ TEST_F(ReaderTest, TestJsonBatchReadWithFilterAndProjection) { auto reader = createJsonReader(sharedState, false); - auto localState = std::make_shared(); - execution::Context ctx; - - reader->read(localState, ctx); + execution::Context ctx = readToContext(reader, sharedState); // Should have 2 columns (id, score) and filtered rows (score > 90.0) EXPECT_EQ(ctx.col_num(), 2); diff --git a/tests/utils/test_reader.h b/tests/utils/test_reader.h index 7f0142337..c232aabbd 100644 --- a/tests/utils/test_reader.h +++ b/tests/utils/test_reader.h @@ -32,6 +32,7 @@ #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/utils/io/read/common/options.h" +#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/common/type_converter.h" #include "neug/utils/io/reader.h" @@ -214,6 +215,25 @@ class ReaderTest : public ::testing::Test { return expr; } + // Helper: leftColumn - rightColumn > threshold (postfix RPN) + std::shared_ptr<::common::Expression> createSubtractGtFilterExpression( + const std::string& leftColumn, const std::string& rightColumn, + const ::common::Value& threshold) { + auto expr = std::make_shared<::common::Expression>(); + + auto left_var = expr->add_operators()->mutable_var(); + left_var->mutable_tag()->set_name(leftColumn); + + auto right_var = expr->add_operators()->mutable_var(); + right_var->mutable_tag()->set_name(rightColumn); + + expr->add_operators()->set_arith(::common::Arithmetic::SUB); + expr->add_operators()->set_logical(::common::Logical::GT); + *expr->add_operators()->mutable_const_() = threshold; + + return expr; + } + // Helper function to create ReadSharedState std::shared_ptr createSharedState( const std::string& csvFile, const std::vector& columnNames, @@ -245,7 +265,15 @@ class ReaderTest : public ::testing::Test { return sharedState; } - std::shared_ptr createCsvReader( + execution::Context readToContext( + const std::shared_ptr& reader, + const std::shared_ptr& sharedState, + size_t fallback_column_count = 0) { + return reader::toContext(reader->read(), *sharedState, + fallback_column_count); + } + + std::shared_ptr createCsvReader( const std::shared_ptr& sharedState) { auto optionsBuilder = std::make_unique(sharedState); @@ -253,6 +281,11 @@ class ReaderTest : public ::testing::Test { std::move(optionsBuilder)); } + std::shared_ptr createArrowReader( + const std::shared_ptr& sharedState) { + return createCsvReader(sharedState); + } + void createJsonFile(const std::string& filename, const std::string& content) { std::ofstream file(std::string(ARROW_READER_TEST_DIR) + "/" + filename); file << content; @@ -282,7 +315,7 @@ class ReaderTest : public ::testing::Test { return sharedState; } - std::shared_ptr createJsonReader( + std::shared_ptr createJsonReader( const std::shared_ptr& sharedState, bool json_array_input = true) { auto optionsBuilder = std::make_unique( diff --git a/tests/utils/test_sniffer.cc b/tests/utils/test_sniffer.cc index 3a1a0effc..99d96042a 100644 --- a/tests/utils/test_sniffer.cc +++ b/tests/utils/test_sniffer.cc @@ -32,7 +32,7 @@ TEST_F(SnifferTest, TestSniffBasic) { auto sharedState = createSharedState("test_sniff.csv", {}, {}); auto reader = createCsvReader(sharedState); - auto sniffer = reader::CsvSniffer(reader); + auto sniffer = reader::ReaderSniffer(reader); auto schema = sniffer.sniff().value(); EXPECT_EQ(schema->type(), reader::EntrySchemaType::TABLE); @@ -56,5 +56,27 @@ TEST_F(SnifferTest, TestSniffBasic) { ::common::PrimitiveType::DT_DOUBLE); } +TEST_F(SnifferTest, TestSniffHeaderOnlyDefaultsToVarchar) { + createCsvFile("test_sniff_header_only.csv", "id|name|score\n"); + + auto sharedState = createSharedState("test_sniff_header_only.csv", {}, {}, + {{"skip_rows", "1"}}); + + auto reader = createCsvReader(sharedState); + auto sniffer = reader::ReaderSniffer(reader); + auto result = sniffer.sniff(); + ASSERT_TRUE(result.has_value()); + auto schema = result.value(); + + EXPECT_EQ(schema->columnNames.size(), 3u); + EXPECT_EQ(schema->columnNames[0], "id"); + EXPECT_EQ(schema->columnNames[1], "name"); + EXPECT_EQ(schema->columnNames[2], "score"); + ASSERT_EQ(schema->columnTypes.size(), 3u); + for (const auto& type : schema->columnTypes) { + EXPECT_TRUE(type->has_string()); + } +} + } // namespace test } // namespace neug From f18287e8418b999a2c16655d5d8158e5336b0ae2 Mon Sep 17 00:00:00 2001 From: luoxiaojian Date: Mon, 29 Jun 2026 21:41:29 +0800 Subject: [PATCH 2/4] remove sniffer --- .../parquet/include/parquet/arrow_sniffer.h | 37 -------------- .../parquet/include/parquet_read_function.h | 5 +- extension/parquet/src/arrow_sniffer.cc | 32 ------------ .../function/import/csv_read_function.h | 7 +-- .../function/import/json_read_function.h | 7 +-- include/neug/utils/io/read/common/sniffer.h | 50 ------------------- src/utils/io/read/common/sniffer.cc | 32 ------------ tests/utils/test_sniffer.cc | 7 +-- 8 files changed, 7 insertions(+), 170 deletions(-) delete mode 100644 extension/parquet/include/parquet/arrow_sniffer.h delete mode 100644 extension/parquet/src/arrow_sniffer.cc delete mode 100644 include/neug/utils/io/read/common/sniffer.h delete mode 100644 src/utils/io/read/common/sniffer.cc diff --git a/extension/parquet/include/parquet/arrow_sniffer.h b/extension/parquet/include/parquet/arrow_sniffer.h deleted file mode 100644 index 4ff9ac2d1..000000000 --- a/extension/parquet/include/parquet/arrow_sniffer.h +++ /dev/null @@ -1,37 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -#include "neug/utils/io/read/common/sniffer.h" -#include "parquet/arrow_reader.h" - -namespace neug { -namespace reader { - -class ArrowSniffer : public Sniffer { - public: - explicit ArrowSniffer(std::shared_ptr reader) - : reader_(std::move(reader)) {} - - result> sniff() override; - - private: - std::shared_ptr reader_; -}; - -} // namespace reader -} // namespace neug diff --git a/extension/parquet/include/parquet_read_function.h b/extension/parquet/include/parquet_read_function.h index aa072089d..eeae5d9e2 100644 --- a/extension/parquet/include/parquet_read_function.h +++ b/extension/parquet/include/parquet_read_function.h @@ -23,10 +23,8 @@ #include "neug/execution/execute/ops/batch/batch_update_utils.h" #include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" -#include "neug/utils/io/read/common/sniffer.h" #include "parquet/arrow_fs_resolver.h" #include "parquet/arrow_reader.h" -#include "parquet/arrow_sniffer.h" #include "parquet_options.h" namespace neug { @@ -97,8 +95,7 @@ struct ParquetReadFunction { auto reader = std::make_shared( state, std::move(optionsBuilder), std::move(arrowFs)); - auto sniffer = std::make_shared(reader); - auto sniffResult = sniffer->sniff(); + auto sniffResult = reader->inferSchema(); if (!sniffResult) { LOG(ERROR) << "Failed to sniff Parquet schema: " diff --git a/extension/parquet/src/arrow_sniffer.cc b/extension/parquet/src/arrow_sniffer.cc deleted file mode 100644 index 4b080954b..000000000 --- a/extension/parquet/src/arrow_sniffer.cc +++ /dev/null @@ -1,32 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "parquet/arrow_sniffer.h" - -#include "neug/utils/result.h" - -namespace neug { -namespace reader { - -result> ArrowSniffer::sniff() { - if (!reader_) { - RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, - "ArrowReader is null"); - } - return reader_->inferSchema(); -} - -} // namespace reader -} // namespace neug diff --git a/include/neug/compiler/function/import/csv_read_function.h b/include/neug/compiler/function/import/csv_read_function.h index 56f8c0675..c55cfc7fc 100644 --- a/include/neug/compiler/function/import/csv_read_function.h +++ b/include/neug/compiler/function/import/csv_read_function.h @@ -25,7 +25,6 @@ #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" -#include "neug/utils/io/read/common/sniffer.h" #include "neug/utils/io/read/csv/csv_reader.h" namespace neug { namespace function { @@ -156,8 +155,7 @@ struct CSVReadFunction { auto optionsBuilder = std::make_unique(state); std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); - auto sniffResult = sniffer->sniff(); + auto sniffResult = reader->inferSchema(); if (sniffResult) { return sniffResult.value(); } @@ -175,8 +173,7 @@ struct CSVReadFunction { std::shared_ptr reader2 = std::make_shared(state, std::move(optionsBuilder2)); - auto sniffer2 = std::make_shared(reader2); - sniffResult = sniffer2->sniff(); + sniffResult = reader2->inferSchema(); if (sniffResult) { return sniffResult.value(); } diff --git a/include/neug/compiler/function/import/json_read_function.h b/include/neug/compiler/function/import/json_read_function.h index d0e3751f8..c9fc1d47c 100644 --- a/include/neug/compiler/function/import/json_read_function.h +++ b/include/neug/compiler/function/import/json_read_function.h @@ -24,7 +24,6 @@ #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" -#include "neug/utils/io/read/common/sniffer.h" #include "neug/utils/io/read/json/json_reader.h" namespace neug { namespace function { @@ -87,8 +86,7 @@ struct JsonReadFunction { std::make_unique(state, true); std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); - auto sniffResult = sniffer->sniff(); + auto sniffResult = reader->inferSchema(); if (!sniffResult) { THROW_IO_EXCEPTION("Failed to sniff schema: " + sniffResult.error().ToString()); @@ -153,8 +151,7 @@ struct JsonLReadFunction { std::make_unique(state, false); std::shared_ptr reader = std::make_shared(state, std::move(optionsBuilder)); - auto sniffer = std::make_shared(reader); - auto sniffResult = sniffer->sniff(); + auto sniffResult = reader->inferSchema(); if (!sniffResult) { THROW_IO_EXCEPTION("Failed to sniff schema: " + sniffResult.error().ToString()); diff --git a/include/neug/utils/io/read/common/sniffer.h b/include/neug/utils/io/read/common/sniffer.h deleted file mode 100644 index 30a51b981..000000000 --- a/include/neug/utils/io/read/common/sniffer.h +++ /dev/null @@ -1,50 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/file_reader.h" -#include "neug/utils/io/read/common/schema.h" -#include "neug/utils/result.h" - -namespace neug { -namespace reader { - -class Sniffer { - public: - virtual ~Sniffer() = default; - virtual result> sniff() = 0; -}; - -class ReaderSniffer : public Sniffer { - public: - explicit ReaderSniffer(std::shared_ptr reader) - : reader_(std::move(reader)) { - if (!reader_) { - THROW_RUNTIME_ERROR("FileReader cannot be null"); - } - } - - result> sniff() override; - - private: - std::shared_ptr reader_; -}; - -} // namespace reader -} // namespace neug diff --git a/src/utils/io/read/common/sniffer.cc b/src/utils/io/read/common/sniffer.cc deleted file mode 100644 index 32ac5aa34..000000000 --- a/src/utils/io/read/common/sniffer.cc +++ /dev/null @@ -1,32 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "neug/utils/io/read/common/sniffer.h" - -#include "neug/utils/result.h" - -namespace neug { -namespace reader { - -result> ReaderSniffer::sniff() { - if (!reader_) { - RETURN_STATUS_ERROR(neug::StatusCode::ERR_INVALID_ARGUMENT, - "FileReader is null"); - } - return reader_->inferSchema(); -} - -} // namespace reader -} // namespace neug diff --git a/tests/utils/test_sniffer.cc b/tests/utils/test_sniffer.cc index 99d96042a..e475fd00c 100644 --- a/tests/utils/test_sniffer.cc +++ b/tests/utils/test_sniffer.cc @@ -15,7 +15,6 @@ #include -#include "neug/utils/io/read/common/sniffer.h" #include "test_reader.h" namespace neug { namespace test { @@ -32,8 +31,7 @@ TEST_F(SnifferTest, TestSniffBasic) { auto sharedState = createSharedState("test_sniff.csv", {}, {}); auto reader = createCsvReader(sharedState); - auto sniffer = reader::ReaderSniffer(reader); - auto schema = sniffer.sniff().value(); + auto schema = reader->inferSchema().value(); EXPECT_EQ(schema->type(), reader::EntrySchemaType::TABLE); @@ -63,8 +61,7 @@ TEST_F(SnifferTest, TestSniffHeaderOnlyDefaultsToVarchar) { {{"skip_rows", "1"}}); auto reader = createCsvReader(sharedState); - auto sniffer = reader::ReaderSniffer(reader); - auto result = sniffer.sniff(); + auto result = reader->inferSchema(); ASSERT_TRUE(result.has_value()); auto schema = result.value(); From 1f200ecead55f13b73cb8e78a5ccf0851f7ef38d Mon Sep 17 00:00:00 2001 From: luoxiaojian Date: Mon, 29 Jun 2026 21:53:30 +0800 Subject: [PATCH 3/4] fmt --- extension/parquet/src/arrow_reader.cc | 2 +- extension/parquet/tests/parquet_test.cc | 2 +- include/neug/utils/io/read/common/chunk_supplier.h | 3 ++- include/neug/utils/io/read/common/reader_utils.h | 1 - src/utils/io/read/common/reader_utils.cc | 4 ++-- src/utils/io/read/csv/csv_reader.cc | 2 +- src/utils/io/read/json/json_reader.cc | 2 +- tests/utils/test_json_io.cc | 8 ++++---- tests/utils/test_reader.cc | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/extension/parquet/src/arrow_reader.cc b/extension/parquet/src/arrow_reader.cc index 5b032943a..6b09899b4 100644 --- a/extension/parquet/src/arrow_reader.cc +++ b/extension/parquet/src/arrow_reader.cc @@ -26,8 +26,8 @@ #include "neug/compiler/common/assert.h" #include "neug/execution/common/context.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/result.h" diff --git a/extension/parquet/tests/parquet_test.cc b/extension/parquet/tests/parquet_test.cc index 9a25c3630..0aaba0062 100644 --- a/extension/parquet/tests/parquet_test.cc +++ b/extension/parquet/tests/parquet_test.cc @@ -35,10 +35,10 @@ #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/reader.h" +#include "neug/generated/proto/response/response.pb.h" #include "parquet/arrow_reader.h" #include "parquet_export_function.h" #include "parquet_options.h" -#include "neug/generated/proto/response/response.pb.h" namespace neug { namespace test { diff --git a/include/neug/utils/io/read/common/chunk_supplier.h b/include/neug/utils/io/read/common/chunk_supplier.h index fb78f54e9..821b1a40c 100644 --- a/include/neug/utils/io/read/common/chunk_supplier.h +++ b/include/neug/utils/io/read/common/chunk_supplier.h @@ -24,7 +24,8 @@ namespace execution { class DataChunk; } -/// Iterator-like source of execution::DataChunk batches for file readers and loaders. +/// Iterator-like source of execution::DataChunk batches for file readers and +/// loaders. class IDataChunkSupplier { public: virtual ~IDataChunkSupplier() = default; diff --git a/include/neug/utils/io/read/common/reader_utils.h b/include/neug/utils/io/read/common/reader_utils.h index f297dc5fd..889f1f535 100644 --- a/include/neug/utils/io/read/common/reader_utils.h +++ b/include/neug/utils/io/read/common/reader_utils.h @@ -36,6 +36,5 @@ inline execution::Context runFileReader(std::unique_ptr reader, return toContext(reader->read(), state, fallback_column_count); } - } // namespace reader } // namespace neug diff --git a/src/utils/io/read/common/reader_utils.cc b/src/utils/io/read/common/reader_utils.cc index d1d0b15bd..79526ce2b 100644 --- a/src/utils/io/read/common/reader_utils.cc +++ b/src/utils/io/read/common/reader_utils.cc @@ -38,8 +38,8 @@ execution::Context toContext(std::shared_ptr supplier, static_cast(chunk->col_num()) != expected_cols) { THROW_IO_EXCEPTION( "Column number mismatch between schema and file data, schema: " + - std::to_string(expected_cols) + ", data: " + - std::to_string(chunk->col_num())); + std::to_string(expected_cols) + + ", data: " + std::to_string(chunk->col_num())); } ctx.append_chunk(std::move(*chunk)); } diff --git a/src/utils/io/read/csv/csv_reader.cc b/src/utils/io/read/csv/csv_reader.cc index f66b7e4ce..63957c910 100644 --- a/src/utils/io/read/csv/csv_reader.cc +++ b/src/utils/io/read/csv/csv_reader.cc @@ -38,8 +38,8 @@ #include "neug/execution/common/context.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/storages/loader/loader_utils.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/operator_precedence.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/schema.h" diff --git a/src/utils/io/read/json/json_reader.cc b/src/utils/io/read/json/json_reader.cc index 48b920938..e4aff6573 100644 --- a/src/utils/io/read/json/json_reader.cc +++ b/src/utils/io/read/json/json_reader.cc @@ -31,8 +31,8 @@ #include "neug/execution/common/columns/columns_utils.h" #include "neug/execution/common/context.h" #include "neug/execution/common/types/value.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/exception/exception.h" +#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/row_expression_filter.h" #include "neug/utils/io/read/common/schema.h" diff --git a/tests/utils/test_json_io.cc b/tests/utils/test_json_io.cc index dc1ed9056..4bc195fb2 100644 --- a/tests/utils/test_json_io.cc +++ b/tests/utils/test_json_io.cc @@ -466,10 +466,10 @@ TEST_F(JsonIOTest, InferSchema_AutoDetectColumnNames) { TEST_F(JsonIOTest, InferSchema_NoDataRowsDefaultsToVarchar) { createFile("infer_empty.jsonl", ""); - auto state = createSharedState("infer_empty.jsonl", {"a", "b", "c"}, - {createStringType(), createStringType(), - createStringType()}, - {{"batch_read", "false"}}); + auto state = createSharedState( + "infer_empty.jsonl", {"a", "b", "c"}, + {createStringType(), createStringType(), createStringType()}, + {{"batch_read", "false"}}); auto reader = createJsonReader(state); auto result = reader->inferSchema(); ASSERT_TRUE(result.has_value()); diff --git a/tests/utils/test_reader.cc b/tests/utils/test_reader.cc index e76e97c02..6cac92d36 100644 --- a/tests/utils/test_reader.cc +++ b/tests/utils/test_reader.cc @@ -484,9 +484,9 @@ TEST_F(ReaderTest, TestJsonBatchReadWithProjectionOnly) { std::vector> columnTypes = { createInt64Type(), createStringType(), createDoubleType()}; - auto sharedState = createJsonSharedState( - "test_json_batch_proj.jsonl", columnNames, columnTypes, - {{"batch_read", "true"}}); + auto sharedState = + createJsonSharedState("test_json_batch_proj.jsonl", columnNames, + columnTypes, {{"batch_read", "true"}}); sharedState->projectColumns = {"id", "score"}; auto reader = createJsonReader(sharedState, false); From 65396bd198977303d029ad3b3f706c0eb2356e62 Mon Sep 17 00:00:00 2001 From: luoxiaojian Date: Thu, 2 Jul 2026 14:30:17 +0800 Subject: [PATCH 4/4] refactor: extract neug/columnar module and relocate IO pipeline boundary --- bin/benchmark.cc | 18 +- doc/source/_scripts/generate_cpp_docs.py | 4 +- doc/source/reference/cpp_api/connection.md | 2 +- extension/gds/include/impl/bfs_impl.h | 2 +- extension/gds/include/impl/bfs_pred_impl.h | 2 +- extension/gds/include/impl/cdlp_impl.h | 2 +- extension/gds/include/impl/cdlp_pred_impl.h | 2 +- extension/gds/include/impl/kcore_impl.h | 2 +- extension/gds/include/impl/kcore_pred_impl.h | 2 +- .../gds/include/impl/lcc_directed_impl.h | 2 +- extension/gds/include/impl/lcc_pred_impl.h | 2 +- .../gds/include/impl/lcc_undirected_impl.h | 2 +- .../include/impl/page_rank_directed_impl.h | 2 +- .../gds/include/impl/page_rank_pred_impl.h | 2 +- .../include/impl/page_rank_undirected_impl.h | 2 +- extension/gds/include/impl/sssp_impl.h | 2 +- extension/gds/include/impl/sssp_pred_impl.h | 2 +- extension/gds/include/impl/wcc_impl.h | 2 +- extension/gds/include/impl/wcc_pred_impl.h | 2 +- extension/gds/include/utils/path_utils.h | 31 +- extension/gds/src/impl/bfs_impl.cc | 12 +- extension/gds/src/impl/bfs_pred_impl.cc | 12 +- extension/gds/src/impl/cdlp_impl.cc | 8 +- extension/gds/src/impl/cdlp_pred_impl.cc | 8 +- extension/gds/src/impl/kcore_impl.cc | 8 +- extension/gds/src/impl/kcore_pred_impl.cc | 8 +- extension/gds/src/impl/lcc_directed_impl.cc | 8 +- extension/gds/src/impl/lcc_pred_impl.cc | 8 +- extension/gds/src/impl/lcc_undirected_impl.cc | 8 +- extension/gds/src/impl/leiden_impl.cc | 8 +- extension/gds/src/impl/louvain_impl.cc | 8 +- .../gds/src/impl/page_rank_directed_impl.cc | 8 +- extension/gds/src/impl/page_rank_pred_impl.cc | 8 +- .../gds/src/impl/page_rank_undirected_impl.cc | 8 +- extension/gds/src/impl/sssp_impl.cc | 8 +- extension/gds/src/impl/sssp_pred_impl.cc | 12 +- extension/gds/src/impl/wcc_impl.cc | 8 +- extension/gds/src/impl/wcc_pred_impl.cc | 8 +- extension/gds/src/utils/subgraph_utils.cc | 12 +- ...{arrow_context_column.h => arrow_column.h} | 12 +- .../include/parquet/record_batch_supplier.h | 4 +- .../parquet/include/parquet_read_function.h | 6 +- ...rrow_context_column.cc => arrow_column.cc} | 22 +- extension/parquet/src/arrow_reader.cc | 10 +- .../parquet/src/record_batch_supplier.cc | 8 +- extension/parquet/tests/parquet_test.cc | 10 +- .../columns/columns_utils.h | 9 +- .../columns/edge_columns.h | 61 +-- .../columns/i_column.h} | 41 +- .../columns/list_columns.h | 31 +- .../columns/path_columns.h | 23 +- .../columns/struct_columns.h | 27 +- .../columns/value_columns.h | 33 +- .../columns/vertex_columns.h | 42 +- .../columns => columnar}/container_types.h | 0 .../common => columnar}/data_chunk.h | 12 +- .../common/types => columnar}/graph_types.h | 16 +- .../utils => columnar}/numeric_cast.h | 4 +- .../common/types => columnar}/value.h | 40 +- .../function/import/csv_read_function.h | 6 +- .../function/import/json_read_function.h | 10 +- .../function/string/vector_string_functions.h | 12 +- include/neug/execution/columnar_aliases.h | 101 ++++ include/neug/execution/common/context.h | 10 +- include/neug/execution/common/context_chunk.h | 21 +- .../common/operators/insert/create_edge.h | 2 +- .../common/operators/retrieve/edge_expand.h | 2 +- .../operators/retrieve/edge_expand_impl.h | 26 +- .../common/operators/retrieve/get_v.h | 11 +- .../common/operators/retrieve/group_by.h | 2 +- .../common/operators/retrieve/intersect.h | 1 + .../common/operators/retrieve/join.h | 2 +- .../common/operators/retrieve/path_expand.h | 1 + .../operators/retrieve/path_expand_impl.h | 26 +- .../common/operators/retrieve/project.h | 7 +- .../common/operators/retrieve/scan.h | 5 +- .../common/operators/retrieve/sink.h | 1 + include/neug/execution/common/params_map.h | 5 +- .../execute/ops/batch/batch_update_utils.h | 4 +- .../execute/ops/retrieve/order_by_utils.h | 7 +- .../execute/ops/retrieve/project_utils.h | 4 +- .../execute/ops/retrieve/scan_utils.h | 2 +- include/neug/execution/expression/expr.h | 2 +- .../execution/expression/special_predicates.h | 2 +- .../io/chunk_stream_adapter.h} | 23 +- .../common => execution/io}/chunk_supplier.h | 17 +- include/neug/execution/utils/params.h | 2 +- include/neug/execution/utils/pb_parse_utils.h | 2 +- include/neug/main/connection.h | 4 +- include/neug/main/query_processor.h | 2 +- include/neug/main/query_request.h | 2 +- include/neug/storages/csr/csr_base.h | 6 +- include/neug/storages/csr/csr_view.h | 24 +- include/neug/storages/csr/csr_view_utils.h | 5 +- include/neug/storages/graph/edge_table.h | 18 +- include/neug/storages/graph/graph_interface.h | 48 +- include/neug/storages/graph/graph_view.h | 25 +- .../neug/storages/graph/operation_params.h | 34 +- include/neug/storages/graph/property_graph.h | 26 +- include/neug/storages/graph/schema.h | 34 +- include/neug/storages/graph/vertex_table.h | 24 +- include/neug/storages/loader/loader_utils.h | 9 +- include/neug/transaction/insert_transaction.h | 20 +- include/neug/transaction/update_transaction.h | 19 +- include/neug/transaction/wal/wal.h | 54 +- include/neug/transaction/wal/wal_builder.h | 28 +- include/neug/utils/encoder.h | 2 +- include/neug/utils/function_type.h | 5 +- include/neug/utils/id_indexer.h | 38 +- .../neug/utils/io/read/common/file_reader.h | 2 +- .../io/read/common/row_expression_filter.h | 16 +- include/neug/utils/pb_utils.h | 6 +- include/neug/utils/property/column.h | 46 +- include/neug/utils/property/default_value.h | 8 +- include/neug/utils/property/table.h | 10 +- include/neug/utils/top_n_generator.h | 2 +- src/CMakeLists.txt | 1 + src/columnar/CMakeLists.txt | 6 + .../columns/columns_utils.cc | 20 +- .../columns/edge_columns.cc | 29 +- .../columns/list_columns.cc | 18 +- .../columns/path_columns.cc | 11 +- .../columns/struct_columns.cc | 19 +- .../columns/vertex_columns.cc | 30 +- .../common => columnar}/data_chunk.cc | 14 +- .../common/types => columnar}/graph_types.cc | 6 +- .../common/types => columnar}/value.cc | 80 +-- .../function/gds/project_graph_function.cpp | 12 +- .../function/list/list_extract_function.cpp | 10 +- .../show_loaded_extensions_function.cpp | 8 +- .../function/vector_cast_functions.cpp | 8 +- .../function/vector_string_functions.cpp | 24 +- src/execution/CMakeLists.txt | 1 + src/execution/common/context.cc | 3 +- src/execution/common/context_chunk.cc | 27 +- .../common/operators/insert/create_edge.cc | 8 +- .../common/operators/insert/create_vertex.cc | 6 +- .../common/operators/retrieve/dedup.cc | 2 +- .../common/operators/retrieve/edge_expand.cc | 4 +- .../common/operators/retrieve/intersect.cc | 6 +- .../common/operators/retrieve/join.cc | 20 +- .../common/operators/retrieve/path_expand.cc | 5 +- .../operators/retrieve/path_expand_impl.cc | 6 +- .../common/operators/retrieve/sink.cc | 18 +- .../common/operators/retrieve/unfold.cc | 2 +- .../execute/ops/batch/batch_delete_edge.cc | 2 +- .../execute/ops/batch/batch_delete_vertex.cc | 4 +- .../execute/ops/batch/batch_update_edge.cc | 2 +- .../execute/ops/batch/batch_update_utils.cc | 41 +- .../execute/ops/batch/batch_update_vertex.cc | 2 +- .../execute/ops/ddl/add_edge_property.cc | 2 +- .../execute/ops/ddl/add_vertex_property.cc | 2 +- .../execute/ops/ddl/create_edge_type.cc | 2 +- .../execute/ops/ddl/create_vertex_type.cc | 2 +- .../execute/ops/insert/merge_edge.cc | 10 +- .../execute/ops/insert/merge_vertex.cc | 6 +- .../execute/ops/retrieve/group_by_utils.cc | 73 ++- src/execution/execute/ops/retrieve/join.cc | 2 +- .../execute/ops/retrieve/order_by_utils.cc | 2 +- src/execution/execute/ops/retrieve/path.cc | 14 +- .../execute/ops/retrieve/project_utils.cc | 20 +- src/execution/execute/ops/retrieve/scan.cc | 4 +- .../execute/ops/retrieve/scan_utils.cc | 2 +- src/execution/execute/ops/retrieve/select.cc | 66 ++- src/execution/execute/ops/retrieve/tc_fuse.cc | 2 +- src/execution/execute/ops/retrieve/vertex.cc | 2 +- .../expression/accessors/record_accessor.cc | 2 +- src/execution/expression/exprs/path_expr.cc | 2 +- .../io/chunk_stream_adapter.cc} | 16 +- .../common => execution/io}/chunk_supplier.cc | 10 +- src/main/query_processor.cc | 4 +- src/main/query_request.cc | 6 +- src/storages/csr/csr_view_utils.cc | 8 +- src/storages/graph/edge_table.cc | 46 +- src/storages/graph/graph_interface.cc | 10 +- src/storages/graph/graph_view.cc | 23 +- src/storages/graph/operation_params.cc | 10 +- src/storages/graph/property_graph.cc | 26 +- src/storages/graph/schema.cc | 2 +- src/storages/graph/vertex_table.cc | 19 +- src/storages/loader/loader_utils.cc | 41 +- src/transaction/insert_transaction.cc | 17 +- src/transaction/update_transaction.cc | 22 +- src/transaction/wal/wal.cc | 30 +- src/transaction/wal/wal_builder.cc | 28 +- .../io/read/common/row_expression_filter.cc | 85 ++- src/utils/io/read/csv/csv_reader.cc | 83 ++- src/utils/io/read/json/json_reader.cc | 67 ++- src/utils/pb_utils.cc | 34 +- src/utils/property/default_value.cc | 28 +- src/utils/property/table.cc | 10 +- tests/execution/test_runtime_column.cc | 26 +- tests/execution/test_value.cc | 2 +- tests/execution/test_value_column.cc | 58 +- tests/main/test_query_request.cc | 12 +- tests/storage/alter_property_test.cc | 18 +- tests/storage/test_csr_batch_ops.cc | 4 +- tests/storage/test_csr_stream_ops.cc | 2 +- tests/storage/test_edge_table.cc | 127 +++-- .../test_graph_snapshot_store_concurrency.cc | 10 +- tests/storage/test_graph_view.cc | 46 +- tests/storage/test_property_graph.cc | 67 ++- tests/storage/test_temporary_graph.cc | 4 +- tests/storage/test_vertex_table.cc | 90 ++-- tests/transaction/test_acid.cc | 273 +++++----- tests/transaction/test_insert_transaction.cc | 18 +- tests/transaction/test_update_transaction.cc | 494 +++++++++--------- tests/unittest/logical_delete_test.cc | 140 ++--- tests/unittest/schema_test.cc | 6 +- tests/unittest/test_connection.cc | 4 +- tests/unittest/test_indexer.cc | 64 +-- tests/unittest/utils.h | 33 +- tests/utils/json_test.cc | 11 +- tests/utils/test_json_io.cc | 6 +- tests/utils/test_reader.cc | 4 +- tests/utils/test_reader.h | 8 +- tests/utils/test_table.cc | 56 +- tests/utils/test_types.cc | 54 +- tests/utils/test_utils.cc | 2 +- tools/nodejs_bind/src/node_connection.h | 2 +- tools/nodejs_bind/src/node_query_request.cc | 2 +- tools/python_bind/src/py_connection.h | 2 +- tools/python_bind/src/py_query_request.cc | 2 +- tools/python_bind/src/py_query_request.h | 2 +- 224 files changed, 2231 insertions(+), 2212 deletions(-) rename extension/parquet/include/parquet/{arrow_context_column.h => arrow_column.h} (81%) rename extension/parquet/src/{arrow_context_column.cc => arrow_column.cc} (90%) rename include/neug/{execution/common => columnar}/columns/columns_utils.h (89%) rename include/neug/{execution/common => columnar}/columns/edge_columns.h (94%) rename include/neug/{execution/common/columns/i_context_column.h => columnar/columns/i_column.h} (72%) rename include/neug/{execution/common => columnar}/columns/list_columns.h (81%) rename include/neug/{execution/common => columnar}/columns/path_columns.h (82%) rename include/neug/{execution/common => columnar}/columns/struct_columns.h (73%) rename include/neug/{execution/common => columnar}/columns/value_columns.h (88%) rename include/neug/{execution/common => columnar}/columns/vertex_columns.h (91%) rename include/neug/{execution/common/columns => columnar}/container_types.h (100%) rename include/neug/{execution/common => columnar}/data_chunk.h (88%) rename include/neug/{execution/common/types => columnar}/graph_types.h (93%) rename include/neug/{execution/utils => columnar}/numeric_cast.h (99%) rename include/neug/{execution/common/types => columnar}/value.h (94%) create mode 100644 include/neug/execution/columnar_aliases.h rename include/neug/{utils/io/read/common/reader_utils.h => execution/io/chunk_stream_adapter.h} (55%) rename include/neug/{utils/io/read/common => execution/io}/chunk_supplier.h (76%) create mode 100644 src/columnar/CMakeLists.txt rename src/{execution/common => columnar}/columns/columns_utils.cc (77%) rename src/{execution/common => columnar}/columns/edge_columns.cc (92%) rename src/{execution/common => columnar}/columns/list_columns.cc (87%) rename src/{execution/common => columnar}/columns/path_columns.cc (85%) rename src/{execution/common => columnar}/columns/struct_columns.cc (86%) rename src/{execution/common => columnar}/columns/vertex_columns.cc (90%) rename src/{execution/common => columnar}/data_chunk.cc (90%) rename src/{execution/common/types => columnar}/graph_types.cc (98%) rename src/{execution/common/types => columnar}/value.cc (92%) rename src/{utils/io/read/common/reader_utils.cc => execution/io/chunk_stream_adapter.cc} (79%) rename src/{utils/io/read/common => execution/io}/chunk_supplier.cc (83%) diff --git a/bin/benchmark.cc b/bin/benchmark.cc index aa9f06e03..d223c183b 100644 --- a/bin/benchmark.cc +++ b/bin/benchmark.cc @@ -22,7 +22,7 @@ #include "neug/execution/common/context.h" #include "neug/execution/common/operators/retrieve/sink.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/execution/execute/plan_parser.h" #include "neug/main/neug_db.h" #include "neug/main/query_request.h" @@ -54,40 +54,40 @@ neug::execution::ParamsMap deserialize_string_kv_map( switch (type.id()) { case neug::DataTypeId::kInt32: { map.emplace(iter.first, - neug::execution::Value::INT32(std::stoi(iter.second))); + neug::columnar::Value::INT32(std::stoi(iter.second))); break; } case neug::DataTypeId::kInt64: { map.emplace(iter.first, - neug::execution::Value::INT64(std::stoll(iter.second))); + neug::columnar::Value::INT64(std::stoll(iter.second))); break; } case neug::DataTypeId::kUInt32: { map.emplace(iter.first, - neug::execution::Value::UINT32(std::stoul(iter.second))); + neug::columnar::Value::UINT32(std::stoul(iter.second))); break; } case neug::DataTypeId::kUInt64: { map.emplace(iter.first, - neug::execution::Value::UINT64(std::stoull(iter.second))); + neug::columnar::Value::UINT64(std::stoull(iter.second))); break; } case neug::DataTypeId::kBoolean: { map.emplace(iter.first, - neug::execution::Value::BOOLEAN(iter.second == "true")); + neug::columnar::Value::BOOLEAN(iter.second == "true")); break; } case neug::DataTypeId::kVarchar: { - map.emplace(iter.first, neug::execution::Value::STRING(iter.second)); + map.emplace(iter.first, neug::columnar::Value::STRING(iter.second)); break; } case neug::DataTypeId::kTimestampMs: { - map.emplace(iter.first, neug::execution::Value::TIMESTAMPMS( + map.emplace(iter.first, neug::columnar::Value::TIMESTAMPMS( neug::DateTime(std::stoll(iter.second)))); break; } case neug::DataTypeId::kDate: { - map.emplace(iter.first, neug::execution::Value::DATE(neug::Date( + map.emplace(iter.first, neug::columnar::Value::DATE(neug::Date( int64_t(std::stoll(iter.second))))); break; default: diff --git a/doc/source/_scripts/generate_cpp_docs.py b/doc/source/_scripts/generate_cpp_docs.py index 7f5fdb140..4b9e1b18d 100644 --- a/doc/source/_scripts/generate_cpp_docs.py +++ b/doc/source/_scripts/generate_cpp_docs.py @@ -1507,8 +1507,8 @@ def _generate_category_index_md(self, categories: Dict[str, Any]): ```cpp // Safe parameter passing prevents injection neug::execution::ParamsMap params; -params["min_age"] = neug::execution::Value(25); -params["city"] = neug::execution::Value("Beijing"); +params["min_age"] = neug::columnar::Value(25); +params["city"] = neug::columnar::Value("Beijing"); auto result = conn->Query( "MATCH (p:Person) WHERE p.age > $min_age AND p.city = $city RETURN p", diff --git a/doc/source/reference/cpp_api/connection.md b/doc/source/reference/cpp_api/connection.md index dcf1699da..db396f704 100644 --- a/doc/source/reference/cpp_api/connection.md +++ b/doc/source/reference/cpp_api/connection.md @@ -58,7 +58,7 @@ Compiles and executes a Cypher query string against the database. The query is p auto result = conn->Query("MATCH (n:Person) RETURN n.name", "read"); // Query with parameters neug::execution::ParamsMap params; -params["min_age"] = neug::execution::Value(18); +params["min_age"] = neug::columnar::Value(18); result = conn->Query("MATCH (p:Person) WHERE p.age > $min_age RETURN p", "read", params); // Process results diff --git a/extension/gds/include/impl/bfs_impl.h b/extension/gds/include/impl/bfs_impl.h index a8c343c41..3299ef7ff 100644 --- a/extension/gds/include/impl/bfs_impl.h +++ b/extension/gds/include/impl/bfs_impl.h @@ -18,7 +18,7 @@ #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" namespace neug { diff --git a/extension/gds/include/impl/bfs_pred_impl.h b/extension/gds/include/impl/bfs_pred_impl.h index 4d26b7e25..70b2cf03d 100644 --- a/extension/gds/include/impl/bfs_pred_impl.h +++ b/extension/gds/include/impl/bfs_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/cdlp_impl.h b/extension/gds/include/impl/cdlp_impl.h index b015e892e..2ad095674 100644 --- a/extension/gds/include/impl/cdlp_impl.h +++ b/extension/gds/include/impl/cdlp_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/execution/expression/predicates.h" diff --git a/extension/gds/include/impl/cdlp_pred_impl.h b/extension/gds/include/impl/cdlp_pred_impl.h index 65022b7f9..cae8fcc64 100644 --- a/extension/gds/include/impl/cdlp_pred_impl.h +++ b/extension/gds/include/impl/cdlp_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/kcore_impl.h b/extension/gds/include/impl/kcore_impl.h index 5b28fc1d7..476680c62 100644 --- a/extension/gds/include/impl/kcore_impl.h +++ b/extension/gds/include/impl/kcore_impl.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/kcore_pred_impl.h b/extension/gds/include/impl/kcore_pred_impl.h index c47c3d5c5..825ff45ca 100644 --- a/extension/gds/include/impl/kcore_pred_impl.h +++ b/extension/gds/include/impl/kcore_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/lcc_directed_impl.h b/extension/gds/include/impl/lcc_directed_impl.h index 82bf95444..a8ab642b5 100644 --- a/extension/gds/include/impl/lcc_directed_impl.h +++ b/extension/gds/include/impl/lcc_directed_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/lcc_pred_impl.h b/extension/gds/include/impl/lcc_pred_impl.h index 9753deb3f..edf403fd3 100644 --- a/extension/gds/include/impl/lcc_pred_impl.h +++ b/extension/gds/include/impl/lcc_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/lcc_undirected_impl.h b/extension/gds/include/impl/lcc_undirected_impl.h index e515a33ec..c5ec5b9ae 100644 --- a/extension/gds/include/impl/lcc_undirected_impl.h +++ b/extension/gds/include/impl/lcc_undirected_impl.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/page_rank_directed_impl.h b/extension/gds/include/impl/page_rank_directed_impl.h index 6f54efb14..e36af67aa 100644 --- a/extension/gds/include/impl/page_rank_directed_impl.h +++ b/extension/gds/include/impl/page_rank_directed_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/expression/expr.h" namespace neug { diff --git a/extension/gds/include/impl/page_rank_pred_impl.h b/extension/gds/include/impl/page_rank_pred_impl.h index 359dd6c29..5019b7161 100644 --- a/extension/gds/include/impl/page_rank_pred_impl.h +++ b/extension/gds/include/impl/page_rank_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/page_rank_undirected_impl.h b/extension/gds/include/impl/page_rank_undirected_impl.h index e4fb716c8..61bba9df2 100644 --- a/extension/gds/include/impl/page_rank_undirected_impl.h +++ b/extension/gds/include/impl/page_rank_undirected_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/expression/expr.h" namespace neug { diff --git a/extension/gds/include/impl/sssp_impl.h b/extension/gds/include/impl/sssp_impl.h index 648cba502..02acbb0f6 100644 --- a/extension/gds/include/impl/sssp_impl.h +++ b/extension/gds/include/impl/sssp_impl.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/sssp_pred_impl.h b/extension/gds/include/impl/sssp_pred_impl.h index 84919555d..dea6ccb48 100644 --- a/extension/gds/include/impl/sssp_pred_impl.h +++ b/extension/gds/include/impl/sssp_pred_impl.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/wcc_impl.h b/extension/gds/include/impl/wcc_impl.h index 74b114426..0afdaf108 100644 --- a/extension/gds/include/impl/wcc_impl.h +++ b/extension/gds/include/impl/wcc_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/impl/wcc_pred_impl.h b/extension/gds/include/impl/wcc_pred_impl.h index 038397686..fd55264d4 100644 --- a/extension/gds/include/impl/wcc_pred_impl.h +++ b/extension/gds/include/impl/wcc_pred_impl.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" diff --git a/extension/gds/include/utils/path_utils.h b/extension/gds/include/utils/path_utils.h index aa9b73c69..10dd55493 100644 --- a/extension/gds/include/utils/path_utils.h +++ b/extension/gds/include/utils/path_utils.h @@ -21,15 +21,15 @@ #include #include +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/graph_types.h" #include "neug/common/extra_type_info.h" #include "neug/common/types.h" #include "neug/compiler/binder/expression/expression.h" #include "neug/compiler/common/constants.h" #include "neug/compiler/function/gds/gds_algo_function.h" #include "neug/compiler/function/table/table_function.h" -#include "neug/execution/common/columns/path_columns.h" #include "neug/execution/common/operators/retrieve/sink.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/storages/graph/graph_interface.h" namespace neug { @@ -38,11 +38,12 @@ namespace gds { // Build a Path object from a predecessor chain, looking up real edge data // pointers from the CSR graph view. The caller provides the vertex chain in // source-to-target order. -inline execution::Path build_path_from_chain( - const std::vector& chain, label_t vertex_label, label_t edge_label, - bool directed, const StorageReadInterface& graph) { +inline columnar::Path build_path_from_chain(const std::vector& chain, + label_t vertex_label, + label_t edge_label, bool directed, + const StorageReadInterface& graph) { if (chain.size() <= 1) { - return execution::Path(vertex_label, chain[0]); + return columnar::Path(vertex_label, chain[0]); } auto oe_view = @@ -50,14 +51,14 @@ inline execution::Path build_path_from_chain( auto ie_view = graph.GetGenericIncomingGraphView(vertex_label, vertex_label, edge_label); - std::vector> edge_datas; + std::vector> edge_datas; edge_datas.reserve(chain.size() - 1); for (size_t i = 0; i + 1 < chain.size(); ++i) { vid_t from = chain[i]; vid_t to = chain[i + 1]; const void* prop = nullptr; - execution::Direction dir = execution::Direction::kOut; + columnar::Direction dir = columnar::Direction::kOut; // Try outgoing edges first auto oe_edges = oe_view.get_edges(from); @@ -74,7 +75,7 @@ inline execution::Path build_path_from_chain( for (auto it = ie_edges.begin(); it != ie_edges.end(); ++it) { if (*it == to) { prop = it.get_data_ptr(); - dir = execution::Direction::kIn; + dir = columnar::Direction::kIn; break; } } @@ -83,7 +84,7 @@ inline execution::Path build_path_from_chain( edge_datas.push_back({dir, prop}); } - return execution::Path(vertex_label, edge_label, chain, edge_datas); + return columnar::Path(vertex_label, edge_label, chain, edge_datas); } // Reconstruct a path by walking backward from `target` to `source` using @@ -92,11 +93,11 @@ inline execution::Path build_path_from_chain( // vertex ID. This enables post-hoc path reconstruction from the distance // array without storing predecessors during computation. template -inline execution::Path reconstruct_path(vid_t target, vid_t source, - const PredFinder& find_pred, - label_t vertex_label, - label_t edge_label, bool directed, - const StorageReadInterface& graph) { +inline columnar::Path reconstruct_path(vid_t target, vid_t source, + const PredFinder& find_pred, + label_t vertex_label, label_t edge_label, + bool directed, + const StorageReadInterface& graph) { std::vector chain; vid_t cur = target; while (cur != source) { diff --git a/extension/gds/src/impl/bfs_impl.cc b/extension/gds/src/impl/bfs_impl.cc index e64fb0366..b9e080a13 100644 --- a/extension/gds/src/impl/bfs_impl.cc +++ b/extension/gds/src/impl/bfs_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/context.h" #include "utils/parallel_utils.h" #include "utils/path_utils.h" @@ -160,11 +160,11 @@ void BFS::compute() { void BFS::sink(execution::Context& ctx, int node_alias, int distance_alias, int path_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder distance_builder; + columnar::ValueColumnBuilder distance_builder; distance_builder.reserve(vertices_.size()); - std::shared_ptr path_column; + std::shared_ptr path_column; if (return_path_) { auto oe_view = graph_.GetGenericOutgoingGraphView( vertex_label_, vertex_label_, edge_label_); @@ -189,7 +189,7 @@ void BFS::sink(execution::Context& ctx, int node_alias, int distance_alias, return source_; }; - execution::PathColumnBuilder path_builder; + columnar::PathColumnBuilder path_builder; for (vid_t v : vertices_) { if (distances_[v] == std::numeric_limits::max()) { path_builder.push_back_null(); @@ -210,7 +210,7 @@ void BFS::sink(execution::Context& ctx, int node_alias, int distance_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(distance_alias, distance_builder.finish()); diff --git a/extension/gds/src/impl/bfs_pred_impl.cc b/extension/gds/src/impl/bfs_pred_impl.cc index 5dbec3201..5e5caf87b 100644 --- a/extension/gds/src/impl/bfs_pred_impl.cc +++ b/extension/gds/src/impl/bfs_pred_impl.cc @@ -21,8 +21,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" #include "utils/path_utils.h" @@ -123,10 +123,10 @@ void BFSPred::compute() { void BFSPred::sink(execution::Context& ctx, int node_alias, int distance_alias, int path_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder distance_builder; + columnar::ValueColumnBuilder distance_builder; distance_builder.reserve(vertices_.size()); - std::shared_ptr path_column; + std::shared_ptr path_column; if (return_path_) { auto oe_view = graph_.GetGenericOutgoingGraphView( vertex_label_, vertex_label_, edge_label_); @@ -164,7 +164,7 @@ void BFSPred::sink(execution::Context& ctx, int node_alias, int distance_alias, return source_; }; - execution::PathColumnBuilder path_builder; + columnar::PathColumnBuilder path_builder; for (vid_t v : vertices_) { if (distances_[v] == std::numeric_limits::max()) { path_builder.push_back_null(); @@ -185,7 +185,7 @@ void BFSPred::sink(execution::Context& ctx, int node_alias, int distance_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(distance_alias, distance_builder.finish()); diff --git a/extension/gds/src/impl/cdlp_impl.cc b/extension/gds/src/impl/cdlp_impl.cc index ef0df9c47..8bb855a42 100644 --- a/extension/gds/src/impl/cdlp_impl.cc +++ b/extension/gds/src/impl/cdlp_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -223,7 +223,7 @@ void CDLP::compute() { void CDLP::sink(execution::Context& ctx, int32_t node_alias, int32_t label_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder label_builder; + columnar::ValueColumnBuilder label_builder; label_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -231,7 +231,7 @@ void CDLP::sink(execution::Context& ctx, int32_t node_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(label_alias, label_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/cdlp_pred_impl.cc b/extension/gds/src/impl/cdlp_pred_impl.cc index 1f834e3c8..0cd4d4644 100644 --- a/extension/gds/src/impl/cdlp_pred_impl.cc +++ b/extension/gds/src/impl/cdlp_pred_impl.cc @@ -21,8 +21,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -149,7 +149,7 @@ void CDLPPred::compute() { void CDLPPred::sink(execution::Context& ctx, int32_t node_alias, int32_t label_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder label_builder; + columnar::ValueColumnBuilder label_builder; label_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -157,7 +157,7 @@ void CDLPPred::sink(execution::Context& ctx, int32_t node_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(label_alias, label_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/kcore_impl.cc b/extension/gds/src/impl/kcore_impl.cc index 6269f4a28..d1c8d3031 100644 --- a/extension/gds/src/impl/kcore_impl.cc +++ b/extension/gds/src/impl/kcore_impl.cc @@ -20,8 +20,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -148,7 +148,7 @@ void KCore::compute() { void KCore::sink(execution::Context& ctx, int node_alias, int core_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder core_builder; + columnar::ValueColumnBuilder core_builder; node_builder.reserve(vertices_.size()); core_builder.reserve(vertices_.size()); @@ -163,7 +163,7 @@ void KCore::sink(execution::Context& ctx, int node_alias, int core_alias) { } } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(core_alias, core_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/kcore_pred_impl.cc b/extension/gds/src/impl/kcore_pred_impl.cc index 27deb1ea2..45bdce0f5 100644 --- a/extension/gds/src/impl/kcore_pred_impl.cc +++ b/extension/gds/src/impl/kcore_pred_impl.cc @@ -19,8 +19,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -143,7 +143,7 @@ void KCorePred::compute() { void KCorePred::sink(execution::Context& ctx, int node_alias, int core_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder core_builder; + columnar::ValueColumnBuilder core_builder; core_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -152,7 +152,7 @@ void KCorePred::sink(execution::Context& ctx, int node_alias, int core_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(core_alias, core_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/lcc_directed_impl.cc b/extension/gds/src/impl/lcc_directed_impl.cc index 66f99e151..d548b06e3 100644 --- a/extension/gds/src/impl/lcc_directed_impl.cc +++ b/extension/gds/src/impl/lcc_directed_impl.cc @@ -20,8 +20,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -159,7 +159,7 @@ void LCCDirected::compute() { void LCCDirected::sink(execution::Context& ctx, int node_alias, int lcc_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder lcc_builder; + columnar::ValueColumnBuilder lcc_builder; lcc_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -167,7 +167,7 @@ void LCCDirected::sink(execution::Context& ctx, int node_alias, int lcc_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(lcc_alias, lcc_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/lcc_pred_impl.cc b/extension/gds/src/impl/lcc_pred_impl.cc index 09e8c6a46..ead387d03 100644 --- a/extension/gds/src/impl/lcc_pred_impl.cc +++ b/extension/gds/src/impl/lcc_pred_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -168,7 +168,7 @@ void LCCPred::compute() { void LCCPred::sink(execution::Context& ctx, int node_alias, int lcc_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder lcc_builder; + columnar::ValueColumnBuilder lcc_builder; lcc_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -176,7 +176,7 @@ void LCCPred::sink(execution::Context& ctx, int node_alias, int lcc_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(lcc_alias, lcc_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/lcc_undirected_impl.cc b/extension/gds/src/impl/lcc_undirected_impl.cc index 1a847eaf7..73eb135e5 100644 --- a/extension/gds/src/impl/lcc_undirected_impl.cc +++ b/extension/gds/src/impl/lcc_undirected_impl.cc @@ -20,8 +20,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -237,7 +237,7 @@ void LCCUndirected::compute() { void LCCUndirected::sink(execution::Context& ctx, int node_alias, int lcc_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder lcc_builder; + columnar::ValueColumnBuilder lcc_builder; lcc_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -245,7 +245,7 @@ void LCCUndirected::sink(execution::Context& ctx, int node_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(lcc_alias, lcc_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/leiden_impl.cc b/extension/gds/src/impl/leiden_impl.cc index c8b585086..ce70d0698 100644 --- a/extension/gds/src/impl/leiden_impl.cc +++ b/extension/gds/src/impl/leiden_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -465,7 +465,7 @@ void Leiden::sink(execution::Context& ctx, int node_alias, int community_alias) { execution::MSVertexColumnBuilder builder(vertex_label_); builder.reserve(valid_vertices_.size()); - execution::ValueColumnBuilder community_builder; + columnar::ValueColumnBuilder community_builder; community_builder.reserve(valid_vertices_.size()); std::unordered_map com_remap; @@ -479,7 +479,7 @@ void Leiden::sink(execution::Context& ctx, int node_alias, community_builder.push_back_opt(static_cast(com_remap[c])); } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, builder.finish()); chunk.set(community_alias, community_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/louvain_impl.cc b/extension/gds/src/impl/louvain_impl.cc index a3098852c..fac0ef76b 100644 --- a/extension/gds/src/impl/louvain_impl.cc +++ b/extension/gds/src/impl/louvain_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" namespace neug { @@ -324,7 +324,7 @@ void Louvain::sink(execution::Context& ctx, int node_alias, int community_alias) { execution::MSVertexColumnBuilder builder(vertex_label_); builder.reserve(valid_vertices_.size()); - execution::ValueColumnBuilder community_builder; + columnar::ValueColumnBuilder community_builder; community_builder.reserve(valid_vertices_.size()); // Remap communities to contiguous [0, num_coms) @@ -339,7 +339,7 @@ void Louvain::sink(execution::Context& ctx, int node_alias, community_builder.push_back_opt(static_cast(com_remap[c])); } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, builder.finish()); chunk.set(community_alias, community_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/page_rank_directed_impl.cc b/extension/gds/src/impl/page_rank_directed_impl.cc index 0ed4e214c..a70b06dc8 100644 --- a/extension/gds/src/impl/page_rank_directed_impl.cc +++ b/extension/gds/src/impl/page_rank_directed_impl.cc @@ -16,8 +16,8 @@ #include "impl/page_rank_directed_impl.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/context.h" #include "utils/parallel_utils.h" @@ -116,13 +116,13 @@ void DirectedPageRank::sink(execution::Context& ctx, int node_alias, int pr_alias) { execution::MSVertexColumnBuilder builder(vertex_label_); builder.reserve(valid_vertices_.size()); - execution::ValueColumnBuilder pr_builder; + columnar::ValueColumnBuilder pr_builder; pr_builder.reserve(valid_vertices_.size()); for (vid_t v : valid_vertices_) { builder.push_back_opt(v); pr_builder.push_back_opt(pr_[v]); } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, builder.finish()); chunk.set(pr_alias, pr_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/page_rank_pred_impl.cc b/extension/gds/src/impl/page_rank_pred_impl.cc index 7a22bffcf..1c016f5ba 100644 --- a/extension/gds/src/impl/page_rank_pred_impl.cc +++ b/extension/gds/src/impl/page_rank_pred_impl.cc @@ -19,8 +19,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -185,7 +185,7 @@ void PageRankPred::compute() { void PageRankPred::sink(execution::Context& ctx, int node_alias, int pr_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder pr_builder; + columnar::ValueColumnBuilder pr_builder; pr_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -193,7 +193,7 @@ void PageRankPred::sink(execution::Context& ctx, int node_alias, int pr_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(pr_alias, pr_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/page_rank_undirected_impl.cc b/extension/gds/src/impl/page_rank_undirected_impl.cc index 486a57aac..3d220f040 100644 --- a/extension/gds/src/impl/page_rank_undirected_impl.cc +++ b/extension/gds/src/impl/page_rank_undirected_impl.cc @@ -16,8 +16,8 @@ #include "impl/page_rank_undirected_impl.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/context.h" #include "utils/parallel_utils.h" @@ -123,14 +123,14 @@ void UndirectedPageRank::sink(execution::Context& ctx, int node_alias, int pr_alias) { execution::MSVertexColumnBuilder builder(vertex_label_); - execution::ValueColumnBuilder pr_builder; + columnar::ValueColumnBuilder pr_builder; pr_builder.reserve(valid_vertices_.size()); for (vid_t v : valid_vertices_) { pr_builder.push_back_opt(pr_[v]); } builder.append(vertex_label_, std::move(valid_vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, builder.finish()); chunk.set(pr_alias, pr_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/sssp_impl.cc b/extension/gds/src/impl/sssp_impl.cc index 95191458a..56c898da9 100644 --- a/extension/gds/src/impl/sssp_impl.cc +++ b/extension/gds/src/impl/sssp_impl.cc @@ -23,8 +23,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "utils/parallel_utils.h" #include "utils/subgraph_utils.h" @@ -180,7 +180,7 @@ void SSSP::compute() { void SSSP::sink(execution::Context& ctx, int node_alias, int distance_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder distance_builder; + columnar::ValueColumnBuilder distance_builder; distance_builder.reserve(vertices_.size()); @@ -190,7 +190,7 @@ void SSSP::sink(execution::Context& ctx, int node_alias, int distance_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(distance_alias, distance_builder.finish()); diff --git a/extension/gds/src/impl/sssp_pred_impl.cc b/extension/gds/src/impl/sssp_pred_impl.cc index 11e1ace1b..c9ddf940b 100644 --- a/extension/gds/src/impl/sssp_pred_impl.cc +++ b/extension/gds/src/impl/sssp_pred_impl.cc @@ -23,8 +23,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" #include "utils/path_utils.h" @@ -139,10 +139,10 @@ void SSSPPred::compute() { void SSSPPred::sink(execution::Context& ctx, int node_alias, int distance_alias, int path_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder distance_builder; + columnar::ValueColumnBuilder distance_builder; distance_builder.reserve(vertices_.size()); - std::shared_ptr path_column; + std::shared_ptr path_column; if (return_path_) { auto oe_view = graph_.GetGenericOutgoingGraphView( vertex_label_, vertex_label_, edge_label_); @@ -199,7 +199,7 @@ void SSSPPred::sink(execution::Context& ctx, int node_alias, int distance_alias, return source_; }; - execution::PathColumnBuilder path_builder; + columnar::PathColumnBuilder path_builder; for (vid_t v : vertices_) { if (distances_[v] < 0) { path_builder.push_back_null(); @@ -217,7 +217,7 @@ void SSSPPred::sink(execution::Context& ctx, int node_alias, int distance_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(distance_alias, distance_builder.finish()); diff --git a/extension/gds/src/impl/wcc_impl.cc b/extension/gds/src/impl/wcc_impl.cc index c91522eeb..672a14115 100644 --- a/extension/gds/src/impl/wcc_impl.cc +++ b/extension/gds/src/impl/wcc_impl.cc @@ -22,8 +22,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/context.h" #include "neug/storages/csr/csr_view.h" #include "utils/parallel_utils.h" @@ -262,7 +262,7 @@ void WCC::compute() { void WCC::sink(execution::Context& ctx, int node_alias, int component_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder component_builder; + columnar::ValueColumnBuilder component_builder; size_t vertex_count = vertices_.size(); component_builder.reserve(vertex_count); @@ -271,7 +271,7 @@ void WCC::sink(execution::Context& ctx, int node_alias, int component_alias) { } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(component_alias, component_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/impl/wcc_pred_impl.cc b/extension/gds/src/impl/wcc_pred_impl.cc index b6e15e9bc..6c0f1866a 100644 --- a/extension/gds/src/impl/wcc_pred_impl.cc +++ b/extension/gds/src/impl/wcc_pred_impl.cc @@ -21,8 +21,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -135,7 +135,7 @@ void WCCPred::compute() { void WCCPred::sink(execution::Context& ctx, int node_alias, int component_alias) { execution::MSVertexColumnBuilder node_builder(vertex_label_); - execution::ValueColumnBuilder component_builder; + columnar::ValueColumnBuilder component_builder; component_builder.reserve(vertices_.size()); for (vid_t v : vertices_) { @@ -143,7 +143,7 @@ void WCCPred::sink(execution::Context& ctx, int node_alias, } node_builder.append(vertex_label_, std::move(vertices_)); - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(node_alias, node_builder.finish()); chunk.set(component_alias, component_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/extension/gds/src/utils/subgraph_utils.cc b/extension/gds/src/utils/subgraph_utils.cc index 83f202135..1558b2564 100644 --- a/extension/gds/src/utils/subgraph_utils.cc +++ b/extension/gds/src/utils/subgraph_utils.cc @@ -99,23 +99,23 @@ bool try_parse_source_vertex(const StorageReadInterface& graph, auto pk_type = std::get<0>(graph.schema().get_vertex_primary_key(vertex_label)[0]); - execution::Value oid; + columnar::Value oid; try { switch (pk_type.id()) { case DataTypeId::kInt32: - oid = execution::Value::INT32(std::stoi(source_str)); + oid = columnar::Value::INT32(std::stoi(source_str)); break; case DataTypeId::kInt64: - oid = execution::Value::INT64(std::atoll(source_str.c_str())); + oid = columnar::Value::INT64(std::atoll(source_str.c_str())); break; case DataTypeId::kUInt32: - oid = execution::Value::UINT32(std::stoul(source_str)); + oid = columnar::Value::UINT32(std::stoul(source_str)); break; case DataTypeId::kUInt64: - oid = execution::Value::UINT64(std::stoull(source_str)); + oid = columnar::Value::UINT64(std::stoull(source_str)); break; case DataTypeId::kVarchar: - oid = execution::Value::CreateValue(source_str); + oid = columnar::Value::CreateValue(source_str); break; default: LOG(ERROR) << "Unsupported primary key type for source vertex lookup."; diff --git a/extension/parquet/include/parquet/arrow_context_column.h b/extension/parquet/include/parquet/arrow_column.h similarity index 81% rename from extension/parquet/include/parquet/arrow_context_column.h rename to extension/parquet/include/parquet/arrow_column.h index 2c0872c57..4478d5b15 100644 --- a/extension/parquet/include/parquet/arrow_context_column.h +++ b/extension/parquet/include/parquet/arrow_column.h @@ -21,23 +21,23 @@ #include #include -#include "neug/execution/common/columns/i_context_column.h" -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/columns/i_column.h" +#include "neug/columnar/data_chunk.h" namespace neug { -namespace execution { +namespace columnar { /// Convert a single Arrow array to a ValueColumn. -std::shared_ptr arrow_array_to_value_column( +std::shared_ptr arrow_array_to_value_column( const std::shared_ptr& array); /// Convert multiple Arrow array chunks (from a ChunkedArray) to a ValueColumn. -std::shared_ptr arrow_arrays_to_value_column( +std::shared_ptr arrow_arrays_to_value_column( const std::vector>& arrays); /// Convert an Arrow RecordBatch to a DataChunk with ValueColumns. std::shared_ptr recordbatch_to_value_datachunk( const std::shared_ptr& batch); -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/extension/parquet/include/parquet/record_batch_supplier.h b/extension/parquet/include/parquet/record_batch_supplier.h index db7b99b13..cb1db1264 100644 --- a/extension/parquet/include/parquet/record_batch_supplier.h +++ b/extension/parquet/include/parquet/record_batch_supplier.h @@ -18,7 +18,7 @@ #include #include -#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/execution/io/chunk_supplier.h" namespace neug { @@ -28,7 +28,7 @@ class RecordBatchChunkSupplier : public IDataChunkSupplier { const std::shared_ptr& reader, int64_t row_num) : row_num_(row_num), reader_(reader) {} - std::shared_ptr GetNextChunk() override; + std::shared_ptr GetNextChunk() override; int64_t RowNum() const override { return row_num_; } diff --git a/extension/parquet/include/parquet_read_function.h b/extension/parquet/include/parquet_read_function.h index eeae5d9e2..be22ab357 100644 --- a/extension/parquet/include/parquet_read_function.h +++ b/extension/parquet/include/parquet_read_function.h @@ -21,7 +21,7 @@ #include "neug/compiler/function/read_function.h" #include "neug/compiler/main/metadata_registry.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" -#include "neug/utils/io/read/common/reader_utils.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/utils/io/read/common/schema.h" #include "parquet/arrow_fs_resolver.h" #include "parquet/arrow_reader.h" @@ -64,8 +64,8 @@ struct ParquetReadFunction { std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder), std::move(arrowFs)); - return reader::runFileReader(std::move(reader), *state, - fallback_column_count); + return execution::io::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr sniffFunc( diff --git a/extension/parquet/src/arrow_context_column.cc b/extension/parquet/src/arrow_column.cc similarity index 90% rename from extension/parquet/src/arrow_context_column.cc rename to extension/parquet/src/arrow_column.cc index 618a4763d..d4114802b 100644 --- a/extension/parquet/src/arrow_context_column.cc +++ b/extension/parquet/src/arrow_column.cc @@ -13,20 +13,20 @@ * limitations under the License. */ -#include "parquet/arrow_context_column.h" +#include "parquet/arrow_column.h" #include #include -#include "neug/execution/common/columns/value_columns.h" +#include "neug/columnar/columns/value_columns.h" #include "neug/utils/exception/exception.h" namespace neug { -namespace execution { +namespace columnar { /// Convert numeric arrow arrays directly to ValueColumn. template -static std::shared_ptr convert_numeric_arrays( +static std::shared_ptr convert_numeric_arrays( const std::vector>& arrays) { ValueColumnBuilder builder; for (const auto& arr : arrays) { @@ -44,7 +44,7 @@ static std::shared_ptr convert_numeric_arrays( /// Convert string-typed arrow arrays to ValueColumn. template -static std::shared_ptr convert_string_arrays( +static std::shared_ptr convert_string_arrays( const std::vector>& arrays) { ValueColumnBuilder builder; for (const auto& arr : arrays) { @@ -62,7 +62,7 @@ static std::shared_ptr convert_string_arrays( } /// Convert date32 arrow arrays (days since epoch) to ValueColumn. -static std::shared_ptr convert_date32_arrays( +static std::shared_ptr convert_date32_arrays( const std::vector>& arrays) { ValueColumnBuilder builder; for (const auto& arr : arrays) { @@ -81,7 +81,7 @@ static std::shared_ptr convert_date32_arrays( } /// Convert date64 arrow arrays (ms since epoch) to ValueColumn. -static std::shared_ptr convert_date64_arrays( +static std::shared_ptr convert_date64_arrays( const std::vector>& arrays) { ValueColumnBuilder builder; for (const auto& arr : arrays) { @@ -98,7 +98,7 @@ static std::shared_ptr convert_date64_arrays( } /// Convert timestamp arrow arrays to ValueColumn. -static std::shared_ptr convert_timestamp_arrays( +static std::shared_ptr convert_timestamp_arrays( const std::vector>& arrays) { ValueColumnBuilder builder; for (const auto& arr : arrays) { @@ -114,7 +114,7 @@ static std::shared_ptr convert_timestamp_arrays( return builder.finish(); } -std::shared_ptr arrow_arrays_to_value_column( +std::shared_ptr arrow_arrays_to_value_column( const std::vector>& arrays) { if (arrays.empty()) { return ValueColumnBuilder().finish(); @@ -151,7 +151,7 @@ std::shared_ptr arrow_arrays_to_value_column( } } -std::shared_ptr arrow_array_to_value_column( +std::shared_ptr arrow_array_to_value_column( const std::shared_ptr& array) { return arrow_arrays_to_value_column({array}); } @@ -168,5 +168,5 @@ std::shared_ptr recordbatch_to_value_datachunk( return chunk; } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/extension/parquet/src/arrow_reader.cc b/extension/parquet/src/arrow_reader.cc index 6b09899b4..af9864705 100644 --- a/extension/parquet/src/arrow_reader.cc +++ b/extension/parquet/src/arrow_reader.cc @@ -19,15 +19,15 @@ #include #include -#include "parquet/arrow_context_column.h" +#include "parquet/arrow_column.h" #include "parquet/arrow_reader.h" #include "parquet/arrow_type_converter.h" #include "parquet/record_batch_supplier.h" #include "neug/compiler/common/assert.h" #include "neug/execution/common/context.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/result.h" @@ -163,14 +163,14 @@ std::shared_ptr ArrowReader::full_read( ", table: " + std::to_string(table->num_columns())); } - auto chunk = std::make_shared(); + auto chunk = std::make_shared(); for (int i = 0; i < num_cols; ++i) { auto table_column = table->column(i); chunk->set(i, - execution::arrow_arrays_to_value_column(table_column->chunks())); + columnar::arrow_arrays_to_value_column(table_column->chunks())); } return std::make_shared( - std::vector>{chunk}); + std::vector>{chunk}); } std::shared_ptr ArrowReader::batch_read( diff --git a/extension/parquet/src/record_batch_supplier.cc b/extension/parquet/src/record_batch_supplier.cc index ea14d0af7..48a9f7756 100644 --- a/extension/parquet/src/record_batch_supplier.cc +++ b/extension/parquet/src/record_batch_supplier.cc @@ -19,19 +19,19 @@ #include #include -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" #include "neug/utils/exception/exception.h" -#include "parquet/arrow_context_column.h" +#include "parquet/arrow_column.h" namespace neug { -std::shared_ptr RecordBatchChunkSupplier::GetNextChunk() { +std::shared_ptr RecordBatchChunkSupplier::GetNextChunk() { if (!reader_) { THROW_IO_EXCEPTION("Reader is null"); } auto result = reader_->Next(); if (result.ok()) { - return execution::recordbatch_to_value_datachunk(result.ValueOrDie()); + return columnar::recordbatch_to_value_datachunk(result.ValueOrDie()); } LOG(ERROR) << "Failed to get next batch: " << result.status().message(); THROW_IO_EXCEPTION("Failed to get next batch: " + result.status().message()); diff --git a/extension/parquet/tests/parquet_test.cc b/extension/parquet/tests/parquet_test.cc index 0aaba0062..73295daf9 100644 --- a/extension/parquet/tests/parquet_test.cc +++ b/extension/parquet/tests/parquet_test.cc @@ -25,13 +25,13 @@ #include #include +#include "neug/columnar/columns/value_columns.h" #include "neug/compiler/common/case_insensitive_map.h" -#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/reader.h" @@ -193,7 +193,7 @@ class ParquetTest : public ::testing::Test { execution::Context readToContext( const std::shared_ptr& reader, const std::shared_ptr& sharedState) { - return reader::toContext(reader->read(), *sharedState); + return execution::io::fromChunkSupplier(reader->read(), *sharedState); } std::shared_ptr createParquetReader( @@ -464,7 +464,7 @@ TEST_F(ParquetTest, TestTypeMapping_StringToLargeUtf8) { // Verify string column is converted to large_utf8 auto col1 = ctx.chunk(0).columns()[1]; - ASSERT_EQ(col1->column_type(), execution::ContextColumnType::kValue); + ASSERT_EQ(col1->column_type(), columnar::ColumnKind::kValue); EXPECT_EQ(col1->elem_type().id(), neug::DataTypeId::kVarchar); } @@ -701,7 +701,7 @@ TEST_F(ParquetTest, TestIntegration_BatchReadMode) { EXPECT_EQ(ctx2.col_num(), 3); auto col0_2 = ctx2.chunk(0).columns()[0]; - EXPECT_EQ(col0_2->column_type(), execution::ContextColumnType::kValue) + EXPECT_EQ(col0_2->column_type(), columnar::ColumnKind::kValue) << "Extension should use Value column type when batch_read=false"; } diff --git a/include/neug/execution/common/columns/columns_utils.h b/include/neug/columnar/columns/columns_utils.h similarity index 89% rename from include/neug/execution/common/columns/columns_utils.h rename to include/neug/columnar/columns/columns_utils.h index 719e353f9..1668b578f 100644 --- a/include/neug/execution/common/columns/columns_utils.h +++ b/include/neug/columnar/columns/columns_utils.h @@ -18,10 +18,10 @@ #include #include #include -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" namespace neug { -namespace execution { +namespace columnar { class ColumnsUtils { public: template @@ -52,8 +52,7 @@ class ColumnsUtils { } } - static std::shared_ptr create_builder( - const DataType& type); + static std::shared_ptr create_builder(const DataType& type); }; -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/edge_columns.h b/include/neug/columnar/columns/edge_columns.h similarity index 94% rename from include/neug/execution/common/columns/edge_columns.h rename to include/neug/columnar/columns/edge_columns.h index 542434e6a..d7a30ca16 100644 --- a/include/neug/execution/common/columns/edge_columns.h +++ b/include/neug/columnar/columns/edge_columns.h @@ -14,26 +14,24 @@ */ #pragma once -#include "neug/execution/common/columns/columns_utils.h" -#include "neug/execution/common/columns/i_context_column.h" -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/columns/i_column.h" +#include "neug/columnar/graph_types.h" #include "neug/utils/property/column.h" #include "neug/utils/property/types.h" namespace neug { -namespace execution { +namespace columnar { enum class EdgeColumnType { kSDSL, kSDML, kBDSL, kBDML, kMS, kUnKnown }; -class IEdgeColumn : public IContextColumn { +class IEdgeColumn : public IColumn { public: IEdgeColumn() : type_(DataType(DataTypeId::kEdge)) {} virtual ~IEdgeColumn() = default; - ContextColumnType column_type() const override { - return ContextColumnType::kEdge; - } + ColumnKind column_type() const override { return ColumnKind::kEdge; } virtual EdgeRecord get_edge(size_t idx) const = 0; @@ -90,10 +88,9 @@ class SDSLEdgeColumn : public IEdgeColumn { ", size = " + std::to_string(edges_.size()); } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; template @@ -128,7 +125,7 @@ class SDSLEdgeColumn : public IEdgeColumn { vector_t> edges_; }; -class SDSLEdgeColumnBuilder : public IContextColumnBuilder { +class SDSLEdgeColumnBuilder : public IColumnBuilder { public: SDSLEdgeColumnBuilder(Direction dir, const LabelTriplet& label) : dir_(dir), label_(label), is_optional_(false) {} @@ -151,7 +148,7 @@ class SDSLEdgeColumnBuilder : public IContextColumnBuilder { std::numeric_limits::max(), nullptr); } - std::shared_ptr finish() override; + std::shared_ptr finish() override; private: Direction dir_; @@ -197,10 +194,9 @@ class MSEdgeColumn : public IEdgeColumn { ", size = " + std::to_string(total_size_); } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline EdgeColumnType edge_column_type() const override { @@ -250,7 +246,7 @@ class MSEdgeColumn : public IEdgeColumn { size_t total_size_; }; -class MSEdgeColumnBuilder : public IContextColumnBuilder { +class MSEdgeColumnBuilder : public IColumnBuilder { public: MSEdgeColumnBuilder() : is_optional_(false) {} ~MSEdgeColumnBuilder() = default; @@ -292,7 +288,7 @@ class MSEdgeColumnBuilder : public IContextColumnBuilder { std::numeric_limits::max(), nullptr); } - inline std::shared_ptr finish() override { + inline std::shared_ptr finish() override { if (!cur_edges_.empty()) { edges_.emplace_back(cur_label_idx_, cur_dir_, std::move(cur_edges_)); } @@ -364,10 +360,9 @@ class BDSLEdgeColumn : public IEdgeColumn { ", size = " + std::to_string(edges_.size()); } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline EdgeColumnType edge_column_type() const override { @@ -401,7 +396,7 @@ class BDSLEdgeColumn : public IEdgeColumn { bool is_optional_; }; -class BDSLEdgeColumnBuilder : public IContextColumnBuilder { +class BDSLEdgeColumnBuilder : public IColumnBuilder { public: explicit BDSLEdgeColumnBuilder(const LabelTriplet& label) : label_(label), edges_(), is_optional_(false) {} @@ -428,7 +423,7 @@ class BDSLEdgeColumnBuilder : public IContextColumnBuilder { Direction::kOut); } - inline std::shared_ptr finish() override { + inline std::shared_ptr finish() override { auto col = std::make_shared(label_); col->edges_ = std::move(edges_); col->is_optional_ = is_optional_; @@ -475,10 +470,9 @@ class SDMLEdgeColumn : public IEdgeColumn { ", size = " + std::to_string(edges_.size()); } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline EdgeColumnType edge_column_type() const override { @@ -514,7 +508,7 @@ class SDMLEdgeColumn : public IEdgeColumn { bool is_optional_; }; -class SDMLEdgeColumnBuilder : public IContextColumnBuilder { +class SDMLEdgeColumnBuilder : public IColumnBuilder { public: SDMLEdgeColumnBuilder(Direction dir, const std::vector& labels) : dir_(dir), labels_(labels), is_optional_(false) { @@ -550,7 +544,7 @@ class SDMLEdgeColumnBuilder : public IContextColumnBuilder { std::numeric_limits::max(), nullptr); } - inline std::shared_ptr finish() override { + inline std::shared_ptr finish() override { auto col = std::make_shared(dir_); col->edges_ = std::move(edges_); col->index_ = std::move(index_); @@ -601,10 +595,9 @@ class BDMLEdgeColumn : public IEdgeColumn { ", size = " + std::to_string(edges_.size()); } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline EdgeColumnType edge_column_type() const override { @@ -637,7 +630,7 @@ class BDMLEdgeColumn : public IEdgeColumn { bool is_optional_; }; -class BDMLEdgeColumnBuilder : public IContextColumnBuilder { +class BDMLEdgeColumnBuilder : public IColumnBuilder { public: explicit BDMLEdgeColumnBuilder(const std::vector& labels) : labels_(labels), edges_(), is_optional_(false) { @@ -676,7 +669,7 @@ class BDMLEdgeColumnBuilder : public IContextColumnBuilder { Direction::kOut); } - inline std::shared_ptr finish() override { + inline std::shared_ptr finish() override { auto col = std::make_shared(); col->edges_ = std::move(edges_); col->index_ = std::move(index_); @@ -885,6 +878,6 @@ void foreach_edge( } } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/i_context_column.h b/include/neug/columnar/columns/i_column.h similarity index 72% rename from include/neug/execution/common/columns/i_context_column.h rename to include/neug/columnar/columns/i_column.h index 6a1c33c33..39b7b713d 100644 --- a/include/neug/execution/common/columns/i_context_column.h +++ b/include/neug/columnar/columns/i_column.h @@ -19,17 +19,17 @@ #include #include -#include "neug/execution/common/columns/container_types.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/container_types.h" +#include "neug/columnar/value.h" #include "glog/logging.h" #include "neug/utils/property/types.h" namespace neug { -namespace execution { +namespace columnar { -enum class ContextColumnType { +enum class ColumnKind { kVertex, kEdge, kValue, @@ -37,35 +37,34 @@ enum class ContextColumnType { kNone, }; -class IContextColumnBuilder; +class IColumnBuilder; -class IContextColumn { +class IColumn { public: - IContextColumn() = default; - virtual ~IContextColumn() = default; + IColumn() = default; + virtual ~IColumn() = default; virtual size_t size() const = 0; virtual std::string column_info() const = 0; - virtual ContextColumnType column_type() const = 0; + virtual ColumnKind column_type() const = 0; virtual const DataType& elem_type() const = 0; - virtual std::shared_ptr shuffle( - const sel_vec_t& offsets) const { + virtual std::shared_ptr shuffle(const sel_vec_t& offsets) const { LOG(FATAL) << "shuffle not implemented for " << this->column_info(); return nullptr; } - virtual std::shared_ptr optional_shuffle( + virtual std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const { LOG(FATAL) << "optional_shuffle not implemented for " << this->column_info(); return nullptr; } - virtual std::shared_ptr union_col( - std::shared_ptr other) const { + virtual std::shared_ptr union_col( + std::shared_ptr other) const { LOG(FATAL) << "union_col not implemented for " << this->column_info(); return nullptr; } @@ -81,11 +80,11 @@ class IContextColumn { return false; } - virtual std::pair, vector_t> + virtual std::pair, vector_t> generate_aggregate_offset() const { LOG(INFO) << "generate_aggregate_offset not implemented for " << this->column_info() << ", return empty by default"; - std::shared_ptr col(nullptr); + std::shared_ptr col(nullptr); return std::make_pair(col, vector_t()); } @@ -97,10 +96,10 @@ class IContextColumn { } }; -class IContextColumnBuilder { +class IColumnBuilder { public: - IContextColumnBuilder() = default; - virtual ~IContextColumnBuilder() = default; + IColumnBuilder() = default; + virtual ~IColumnBuilder() = default; virtual void reserve(size_t size) = 0; virtual void push_back_elem(const Value& val) = 0; @@ -108,9 +107,9 @@ class IContextColumnBuilder { LOG(FATAL) << "push_back_null not implemented"; } - virtual std::shared_ptr finish() = 0; + virtual std::shared_ptr finish() = 0; }; -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/list_columns.h b/include/neug/columnar/columns/list_columns.h similarity index 81% rename from include/neug/execution/common/columns/list_columns.h rename to include/neug/columnar/columns/list_columns.h index ada82a568..379dec7ec 100644 --- a/include/neug/execution/common/columns/list_columns.h +++ b/include/neug/columnar/columns/list_columns.h @@ -14,10 +14,10 @@ */ #pragma once -#include "neug/execution/common/columns/value_columns.h" +#include "neug/columnar/columns/value_columns.h" namespace neug { -namespace execution { +namespace columnar { struct list_item { uint64_t offset; @@ -26,7 +26,7 @@ struct list_item { class ListColumnBuilder; -class ListColumn : public IContextColumn { +class ListColumn : public IColumn { public: explicit ListColumn(DataType type) : elem_type_(type) { std::shared_ptr elem_type_info = @@ -41,12 +41,9 @@ class ListColumn : public IContextColumn { return "ListColumn[" + std::to_string(size()) + "]"; } - ContextColumnType column_type() const override { - return ContextColumnType::kValue; - } + ColumnKind column_type() const override { return ColumnKind::kValue; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; const DataType& elem_type() const override { return type_; } Value get_elem(size_t idx) const override { @@ -58,13 +55,13 @@ class ListColumn : public IContextColumn { return Value::LIST(elem_type_, std::move(list_values)); } - std::pair, sel_vec_t> unfold() const; + std::pair, sel_vec_t> unfold() const; - std::shared_ptr data_column() const { return datas_; } + std::shared_ptr data_column() const { return datas_; } const vector_t& items() const { return items_; } - std::shared_ptr reorder() const { + std::shared_ptr reorder() const { auto ptr = std::make_shared(elem_type_); vector_t new_items(items_.size()); size_t cur_offset = 0; @@ -89,7 +86,7 @@ class ListColumn : public IContextColumn { private: template - std::pair, sel_vec_t> unfold_impl() const { + std::pair, sel_vec_t> unfold_impl() const { sel_vec_t offsets; auto builder = std::make_shared>(); size_t i = 0; @@ -107,10 +104,10 @@ class ListColumn : public IContextColumn { DataType elem_type_; DataType type_; vector_t items_; - std::shared_ptr datas_; + std::shared_ptr datas_; }; -class ListColumnBuilder : public IContextColumnBuilder { +class ListColumnBuilder : public IColumnBuilder { public: explicit ListColumnBuilder(DataType type) : type_(type), cur_offset_(0) { child_builder_ = ColumnsUtils::create_builder(type_); @@ -130,7 +127,7 @@ class ListColumnBuilder : public IContextColumnBuilder { cur_offset_ += values.size(); } - std::shared_ptr finish() override { + std::shared_ptr finish() override { auto ret = std::make_shared(type_); ret->datas_ = child_builder_->finish(); ret->items_.swap(items_); @@ -142,8 +139,8 @@ class ListColumnBuilder : public IContextColumnBuilder { size_t cur_offset_; vector_t items_; - std::shared_ptr child_builder_; + std::shared_ptr child_builder_; }; -} // namespace execution +} // namespace columnar } // namespace neug \ No newline at end of file diff --git a/include/neug/execution/common/columns/path_columns.h b/include/neug/columnar/columns/path_columns.h similarity index 82% rename from include/neug/execution/common/columns/path_columns.h rename to include/neug/columnar/columns/path_columns.h index 199e92504..9877b4727 100644 --- a/include/neug/execution/common/columns/path_columns.h +++ b/include/neug/columnar/columns/path_columns.h @@ -14,15 +14,15 @@ */ #pragma once -#include "neug/execution/common/columns/columns_utils.h" -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/columns/i_column.h" namespace neug { -namespace execution { +namespace columnar { class PathColumnBuilder; -class PathColumn : public IContextColumn { +class PathColumn : public IColumn { public: PathColumn() : type_(DataType(DataTypeId::kPath)) {} ~PathColumn() {} @@ -30,13 +30,10 @@ class PathColumn : public IContextColumn { std::string column_info() const override { return "PathColumn[" + std::to_string(size()) + "]"; } - inline ContextColumnType column_type() const override { - return ContextColumnType::kPath; - } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + inline ColumnKind column_type() const override { return ColumnKind::kPath; } + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline const DataType& elem_type() const override { return type_; } inline Value get_elem(size_t idx) const override { @@ -76,7 +73,7 @@ class PathColumn : public IContextColumn { bool is_optional_ = false; }; -class PathColumnBuilder : public IContextColumnBuilder { +class PathColumnBuilder : public IColumnBuilder { public: PathColumnBuilder(bool is_optional = false) : is_optional_(is_optional) {} ~PathColumnBuilder() = default; @@ -92,7 +89,7 @@ class PathColumnBuilder : public IContextColumnBuilder { } void reserve(size_t size) override { data_.reserve(size); } - std::shared_ptr finish() override { + std::shared_ptr finish() override { auto col = std::make_shared(); col->data_.swap(data_); col->is_optional_ = is_optional_; @@ -104,5 +101,5 @@ class PathColumnBuilder : public IContextColumnBuilder { vector_t data_; }; -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/struct_columns.h b/include/neug/columnar/columns/struct_columns.h similarity index 73% rename from include/neug/execution/common/columns/struct_columns.h rename to include/neug/columnar/columns/struct_columns.h index 3047ab637..d9fd0e564 100644 --- a/include/neug/execution/common/columns/struct_columns.h +++ b/include/neug/columnar/columns/struct_columns.h @@ -14,13 +14,13 @@ */ #pragma once -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" namespace neug { -namespace execution { +namespace columnar { class StructColumnBuilder; -class StructColumn : public IContextColumn { +class StructColumn : public IColumn { public: StructColumn() = default; ~StructColumn() = default; @@ -36,14 +36,11 @@ class StructColumn : public IContextColumn { return "StructColumn[" + std::to_string(size()) + "]"; } - ContextColumnType column_type() const override { - return ContextColumnType::kValue; - } + ColumnKind column_type() const override { return ColumnKind::kValue; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; const DataType& elem_type() const override { return type_; } @@ -58,7 +55,7 @@ class StructColumn : public IContextColumn { return valids_[idx]; } - const std::vector>& children() const { + const std::vector>& children() const { return children_; } @@ -69,10 +66,10 @@ class StructColumn : public IContextColumn { DataType type_; bool is_optional_; vector_t valids_; - std::vector> children_; + std::vector> children_; }; -class StructColumnBuilder : public IContextColumnBuilder { +class StructColumnBuilder : public IColumnBuilder { public: StructColumnBuilder(DataType type); ~StructColumnBuilder() = default; @@ -86,15 +83,15 @@ class StructColumnBuilder : public IContextColumnBuilder { void push_back_elem(const Value& val) override; void push_back_null() override; - std::shared_ptr finish() override; + std::shared_ptr finish() override; private: size_t current_size_ = 0; DataType type_; bool is_optional_; vector_t valids_; - std::vector> child_builders_; + std::vector> child_builders_; }; -} // namespace execution +} // namespace columnar } // namespace neug \ No newline at end of file diff --git a/include/neug/execution/common/columns/value_columns.h b/include/neug/columnar/columns/value_columns.h similarity index 88% rename from include/neug/execution/common/columns/value_columns.h rename to include/neug/columnar/columns/value_columns.h index ba94728bb..ecc622e73 100644 --- a/include/neug/execution/common/columns/value_columns.h +++ b/include/neug/columnar/columns/value_columns.h @@ -14,19 +14,19 @@ */ #pragma once -#include "neug/execution/common/columns/columns_utils.h" +#include "neug/columnar/columns/columns_utils.h" #include "neug/utils/property/types.h" #include "neug/utils/top_n_generator.h" namespace neug { -namespace execution { +namespace columnar { template class ValueColumnBuilder; template -class ValueColumn : public IContextColumn { +class ValueColumn : public IColumn { public: ValueColumn() : is_optional_(false), type_(ValueConverter::type()) {} ~ValueColumn() = default; @@ -37,14 +37,11 @@ class ValueColumn : public IContextColumn { return "ValueColumn<" + ValueConverter::name() + ">[" + std::to_string(size()) + "]"; } - inline ContextColumnType column_type() const override { - return ContextColumnType::kValue; - } + inline ColumnKind column_type() const override { return ColumnKind::kValue; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; inline const DataType& elem_type() const override { return type_; } @@ -83,8 +80,8 @@ class ValueColumn : public IContextColumn { return true; } - std::shared_ptr union_col( - std::shared_ptr other) const override; + std::shared_ptr union_col( + std::shared_ptr other) const override; bool order_by_limit(bool asc, size_t limit, sel_vec_t& offsets) const override; @@ -108,7 +105,7 @@ class ValueColumn : public IContextColumn { }; template -class ValueColumnBuilder : public IContextColumnBuilder { +class ValueColumnBuilder : public IColumnBuilder { public: ValueColumnBuilder(bool is_optional = false) : is_optional_(is_optional) {} ~ValueColumnBuilder() = default; @@ -134,7 +131,7 @@ class ValueColumnBuilder : public IContextColumnBuilder { data_.emplace_back(T()); } - std::shared_ptr finish() override { + std::shared_ptr finish() override { if (is_optional_) { auto ret = std::make_shared>(); valid_.resize(data_.size(), true); @@ -158,7 +155,7 @@ class ValueColumnBuilder : public IContextColumnBuilder { }; template -std::shared_ptr ValueColumn::shuffle( +std::shared_ptr ValueColumn::shuffle( const sel_vec_t& offsets) const { ValueColumnBuilder builder; builder.reserve(offsets.size()); @@ -179,7 +176,7 @@ std::shared_ptr ValueColumn::shuffle( } template -std::shared_ptr ValueColumn::optional_shuffle( +std::shared_ptr ValueColumn::optional_shuffle( const sel_vec_t& offsets) const { ValueColumnBuilder builder(true); builder.reserve(offsets.size()); @@ -204,8 +201,8 @@ std::shared_ptr ValueColumn::optional_shuffle( } template -std::shared_ptr ValueColumn::union_col( - std::shared_ptr other) const { +std::shared_ptr ValueColumn::union_col( + std::shared_ptr other) const { ValueColumnBuilder builder; if (is_optional_) { for (size_t i = 0; i < data_.size(); ++i) { @@ -263,6 +260,6 @@ bool ValueColumn::order_by_limit(bool asc, size_t limit, return true; } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/vertex_columns.h b/include/neug/columnar/columns/vertex_columns.h similarity index 91% rename from include/neug/execution/common/columns/vertex_columns.h rename to include/neug/columnar/columns/vertex_columns.h index ad734e613..a2a5847ea 100644 --- a/include/neug/execution/common/columns/vertex_columns.h +++ b/include/neug/columnar/columns/vertex_columns.h @@ -14,11 +14,11 @@ */ #pragma once -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" namespace neug { -namespace execution { +namespace columnar { enum class VertexColumnType { kSingle, @@ -26,14 +26,12 @@ enum class VertexColumnType { kMultiple, }; -class IVertexColumn : public IContextColumn { +class IVertexColumn : public IColumn { public: IVertexColumn() : type_(DataType(DataTypeId::kVertex)) {} virtual ~IVertexColumn() = default; - ContextColumnType column_type() const override { - return ContextColumnType::kVertex; - } + ColumnKind column_type() const override { return ColumnKind::kVertex; } virtual VertexColumnType vertex_column_type() const = 0; virtual VertexRecord get_vertex(size_t idx) const = 0; @@ -55,7 +53,7 @@ class IVertexColumn : public IContextColumn { DataType type_; }; -class IVertexColumnBuilder : public IContextColumnBuilder { +class IVertexColumnBuilder : public IColumnBuilder { public: IVertexColumnBuilder() = default; virtual ~IVertexColumnBuilder() = default; @@ -92,10 +90,9 @@ class SLVertexColumn : public IVertexColumn { return VertexColumnType::kSingle; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offset) const override; __attribute__((always_inline)) VertexRecord get_vertex( @@ -111,12 +108,12 @@ class SLVertexColumn : public IVertexColumn { return vertices_[idx] != std::numeric_limits::max(); } - std::shared_ptr union_col( - std::shared_ptr other) const override; + std::shared_ptr union_col( + std::shared_ptr other) const override; bool generate_dedup_offset(sel_vec_t& offsets) const override; - std::pair, vector_t> + std::pair, vector_t> generate_aggregate_offset() const override; template @@ -177,10 +174,9 @@ class MSVertexColumn : public IVertexColumn { return VertexColumnType::kMultiSegment; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; __attribute__((always_inline)) VertexRecord get_vertex( @@ -287,7 +283,7 @@ class MSVertexColumnBuilder : public IVertexColumnBuilder { cur_list_.emplace_back(std::numeric_limits::max()); } - std::shared_ptr finish() override; + std::shared_ptr finish() override; __attribute__((always_inline)) size_t cur_size() const { return cur_list_.size(); @@ -332,9 +328,8 @@ class MLVertexColumn : public IVertexColumn { return VertexColumnType::kMultiple; } - std::shared_ptr shuffle( - const sel_vec_t& offsets) const override; - std::shared_ptr optional_shuffle( + std::shared_ptr shuffle(const sel_vec_t& offsets) const override; + std::shared_ptr optional_shuffle( const sel_vec_t& offsets) const override; __attribute__((always_inline)) VertexRecord get_vertex( @@ -394,7 +389,7 @@ class MLVertexColumnBuilder : public IVertexColumnBuilder { std::numeric_limits::max()}); } - std::shared_ptr finish() override; + std::shared_ptr finish() override; private: vector_t vertices_; @@ -431,8 +426,7 @@ class MLVertexColumnBuilderOpt : public IVertexColumnBuilder { std::numeric_limits::max()); } - __attribute__((always_inline)) std::shared_ptr finish() - override { + __attribute__((always_inline)) std::shared_ptr finish() override { auto ret = std::make_shared(); for (size_t i = 0; i < labels_bitmap_.size(); ++i) { if (labels_bitmap_[i]) { @@ -468,6 +462,6 @@ void foreach_vertex(const IVertexColumn& col, const FUNC_T& func) { } } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/columns/container_types.h b/include/neug/columnar/container_types.h similarity index 100% rename from include/neug/execution/common/columns/container_types.h rename to include/neug/columnar/container_types.h diff --git a/include/neug/execution/common/data_chunk.h b/include/neug/columnar/data_chunk.h similarity index 88% rename from include/neug/execution/common/data_chunk.h rename to include/neug/columnar/data_chunk.h index b53f1938d..fa428f780 100644 --- a/include/neug/execution/common/data_chunk.h +++ b/include/neug/columnar/data_chunk.h @@ -20,13 +20,13 @@ #include #include -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" #include "neug/utils/exception/exception.h" namespace neug { class StorageReadInterface; -namespace execution { +namespace columnar { /** * @brief A DataChunk holds a set of columns that share the same row count. @@ -53,10 +53,10 @@ class DataChunk { void clear(); /// Stores the given column under the given alias (alias must be >= 0). - void set(int alias, std::shared_ptr col); + void set(int alias, std::shared_ptr col); /// Returns the column at the given alias (alias must be >= 0). - std::shared_ptr get(int alias) const; + std::shared_ptr get(int alias) const; void remove(int alias); @@ -72,8 +72,8 @@ class DataChunk { DataChunk union_chunk(const DataChunk& other) const; - std::vector> columns; + std::vector> columns; }; -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/types/graph_types.h b/include/neug/columnar/graph_types.h similarity index 93% rename from include/neug/execution/common/types/graph_types.h rename to include/neug/columnar/graph_types.h index c873417b1..eb2604fa2 100644 --- a/include/neug/execution/common/types/graph_types.h +++ b/include/neug/columnar/graph_types.h @@ -27,7 +27,7 @@ namespace neug { -namespace execution { +namespace columnar { int64_t encode_unique_vertex_id(label_t label_id, vid_t vid); std::pair decode_unique_vertex_id(uint64_t unique_id); @@ -195,7 +195,7 @@ struct Path { std::shared_ptr impl_; }; -} // namespace execution +} // namespace columnar } // namespace neug @@ -207,14 +207,14 @@ static inline void hash_combine(std::size_t& seed, const T& val) { seed ^= hasher(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template <> -struct hash { +struct hash { // Hash combine functions copied from Boost.ContainerHash // https://github.com/boostorg/container_hash/blob/171c012d4723c5e93cc7cffe42919afdf8b27dfa/include/boost/container_hash/hash.hpp#L311 // that is based on Peter Dimov's proposal // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf // issue 6.18. - size_t operator()(const neug::execution::VertexRecord& record) const { + size_t operator()(const neug::columnar::VertexRecord& record) const { std::size_t seed = 0; hash_combine(seed, record.vid_); hash_combine(seed, record.label_); @@ -222,8 +222,8 @@ struct hash { } std::size_t operator()( - const std::pair& p) const { + const std::pair& p) const { std::size_t seed = 0; hash_combine(seed, p.first.vid_); hash_combine(seed, p.first.label_); @@ -241,8 +241,8 @@ struct hash { }; template <> -struct hash { - size_t operator()(const neug::execution::LabelTriplet& lt) const { +struct hash { + size_t operator()(const neug::columnar::LabelTriplet& lt) const { size_t seed = 0; hash_combine(seed, lt.src_label); hash_combine(seed, lt.dst_label); diff --git a/include/neug/execution/utils/numeric_cast.h b/include/neug/columnar/numeric_cast.h similarity index 99% rename from include/neug/execution/utils/numeric_cast.h rename to include/neug/columnar/numeric_cast.h index 91626184f..edec01758 100644 --- a/include/neug/execution/utils/numeric_cast.h +++ b/include/neug/columnar/numeric_cast.h @@ -29,7 +29,7 @@ #include "fast_float.h" namespace neug { -namespace execution { +namespace columnar { inline std::pair removeWhiteSpaces(std::string_view sw) { // skip leading/trailing spaces @@ -491,6 +491,6 @@ struct NumericCast { return result; } }; -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/include/neug/execution/common/types/value.h b/include/neug/columnar/value.h similarity index 94% rename from include/neug/execution/common/types/value.h rename to include/neug/columnar/value.h index f368cf7a2..cff444cc3 100644 --- a/include/neug/execution/common/types/value.h +++ b/include/neug/columnar/value.h @@ -24,9 +24,9 @@ #include #include #include +#include "neug/columnar/graph_types.h" +#include "neug/columnar/numeric_cast.h" #include "neug/common/types.h" -#include "neug/execution/common/types/graph_types.h" -#include "neug/execution/utils/numeric_cast.h" namespace neug { class Encoder; @@ -34,12 +34,12 @@ class InArchive; class OutArchive; struct EmptyType; -namespace execution { +namespace columnar { using timestamp_ms_t = neug::DateTime; using interval_t = neug::Interval; using date_t = neug::Date; -using vertex_t = neug::execution::VertexRecord; -using edge_t = neug::execution::EdgeRecord; +using vertex_t = neug::columnar::VertexRecord; +using edge_t = neug::columnar::EdgeRecord; struct ExtraValueInfo; class Value { friend struct StringValue; @@ -271,11 +271,11 @@ struct ValueConverter { template static bool cast(const T& input, int32_t& output) { if constexpr (std::is_same_v) { - auto [data, len] = neug::execution::removeWhiteSpaces(input); + auto [data, len] = neug::columnar::removeWhiteSpaces(input); auto [ptr, ec] = std::from_chars(data, data + len, output); return ec == std::errc() && ptr == data + len; } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -300,11 +300,11 @@ struct ValueConverter { output = input.to_mill_seconds(); return true; } else if constexpr (std::is_same_v) { - auto [data, len] = neug::execution::removeWhiteSpaces(input); + auto [data, len] = neug::columnar::removeWhiteSpaces(input); auto [ptr, ec] = std::from_chars(data, data + len, output); return ec == std::errc() && ptr == data + len; } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -319,11 +319,11 @@ struct ValueConverter { template static bool cast(const T& input, uint32_t& output) { if constexpr (std::is_same_v) { - auto [data, len] = neug::execution::removeWhiteSpaces(input); + auto [data, len] = neug::columnar::removeWhiteSpaces(input); auto [ptr, ec] = std::from_chars(data, data + len, output); return ec == std::errc() && ptr == data + len; } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -338,11 +338,11 @@ struct ValueConverter { template static bool cast(const T& input, uint64_t& output) { if constexpr (std::is_same_v) { - auto [data, len] = neug::execution::removeWhiteSpaces(input); + auto [data, len] = neug::columnar::removeWhiteSpaces(input); auto [ptr, ec] = std::from_chars(data, data + len, output); return ec == std::errc() && ptr == data + len; } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -365,9 +365,9 @@ struct ValueConverter { template static bool cast(const T& input, double& output) { if constexpr (std::is_same_v) { - return neug::execution::tryDoubleCast(input, output); + return neug::columnar::tryDoubleCast(input, output); } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -382,9 +382,9 @@ struct ValueConverter { template static bool cast(const T& input, float& output) { if constexpr (std::is_same_v) { - return neug::execution::tryDoubleCast(input, output); + return neug::columnar::tryDoubleCast(input, output); } else { - return neug::execution::TryCastWithOverflowCheck(input, output); + return neug::columnar::TryCastWithOverflowCheck(input, output); } } }; @@ -728,9 +728,9 @@ Value performCastToString(const Value& input); void encode_value(const Value& val, Encoder& encoder); -} // namespace execution +} // namespace columnar -InArchive& operator<<(InArchive& in_archive, const execution::Value& value); -OutArchive& operator>>(OutArchive& out_archive, execution::Value& value); +InArchive& operator<<(InArchive& in_archive, const columnar::Value& value); +OutArchive& operator>>(OutArchive& out_archive, columnar::Value& value); } // namespace neug \ No newline at end of file diff --git a/include/neug/compiler/function/import/csv_read_function.h b/include/neug/compiler/function/import/csv_read_function.h index c55cfc7fc..bfb51f91d 100644 --- a/include/neug/compiler/function/import/csv_read_function.h +++ b/include/neug/compiler/function/import/csv_read_function.h @@ -21,9 +21,9 @@ #include "neug/compiler/function/read_function.h" #include "neug/compiler/main/metadata_registry.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/csv/csv_reader.h" namespace neug { @@ -128,8 +128,8 @@ struct CSVReadFunction { optionsBuilder->build().include_columns.size(); std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - return reader::runFileReader(std::move(reader), *state, - fallback_column_count); + return execution::io::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr sniffFunc( diff --git a/include/neug/compiler/function/import/json_read_function.h b/include/neug/compiler/function/import/json_read_function.h index c9fc1d47c..b66719d7d 100644 --- a/include/neug/compiler/function/import/json_read_function.h +++ b/include/neug/compiler/function/import/json_read_function.h @@ -21,8 +21,8 @@ #include "neug/compiler/function/read_function.h" #include "neug/compiler/main/metadata_registry.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/json/json_reader.h" namespace neug { @@ -61,8 +61,8 @@ struct JsonReadFunction { optionsBuilder->build().include_columns.size(); std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - return reader::runFileReader(std::move(reader), *state, - fallback_column_count); + return execution::io::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr jsonSniffFunc( @@ -126,8 +126,8 @@ struct JsonLReadFunction { optionsBuilder->build().include_columns.size(); std::unique_ptr reader = std::make_unique(state, std::move(optionsBuilder)); - return reader::runFileReader(std::move(reader), *state, - fallback_column_count); + return execution::io::runFileReader(std::move(reader), *state, + fallback_column_count); } static std::shared_ptr jsonLSniffFunc( diff --git a/include/neug/compiler/function/string/vector_string_functions.h b/include/neug/compiler/function/string/vector_string_functions.h index b4d295308..ee8f9775e 100644 --- a/include/neug/compiler/function/string/vector_string_functions.h +++ b/include/neug/compiler/function/string/vector_string_functions.h @@ -22,8 +22,8 @@ #pragma once +#include "neug/columnar/value.h" #include "neug/compiler/function/scalar_function.h" -#include "neug/execution/common/types/value.h" namespace neug { namespace function { @@ -64,7 +64,7 @@ struct LowerFunction : public VectorStringFunction { static function_set getFunctionSet(); - static execution::Value Exec(const std::vector& args); + static columnar::Value Exec(const std::vector& args); }; struct ToLowerFunction : public VectorStringFunction { @@ -84,8 +84,8 @@ struct ReverseFunction : public VectorStringFunction { static function_set getFunctionSet(); - static neug::execution::Value Exec( - const std::vector& args); + static neug::columnar::Value Exec( + const std::vector& args); }; struct StartsWithFunction : public VectorStringFunction { @@ -99,8 +99,8 @@ struct UpperFunction : public VectorStringFunction { static function_set getFunctionSet(); - static neug::execution::Value Exec( - const std::vector& args); + static neug::columnar::Value Exec( + const std::vector& args); }; struct ToUpperFunction : public VectorStringFunction { diff --git a/include/neug/execution/columnar_aliases.h b/include/neug/execution/columnar_aliases.h new file mode 100644 index 000000000..28a335c3c --- /dev/null +++ b/include/neug/execution/columnar_aliases.h @@ -0,0 +1,101 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/i_column.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" +#include "neug/columnar/graph_types.h" +#include "neug/columnar/value.h" + +namespace neug { +namespace execution { + +#include "neug/columnar/graph_types.h" +using columnar::decode_edge_label_id; +using columnar::decode_unique_vertex_id; +using columnar::encode_unique_edge_id; +using columnar::encode_unique_vertex_id; +using columnar::foreach_vertex; +using columnar::generate_edge_label_id; + +using columnar::AggrKind; +using columnar::BDMLEdgeColumn; +using columnar::BDMLEdgeColumnBuilder; +using columnar::BDSLEdgeColumn; +using columnar::BDSLEdgeColumnBuilder; +using columnar::ColumnKind; +using columnar::ColumnsUtils; +using columnar::DataChunk; +using columnar::date_t; +using columnar::Direction; +using columnar::edge_t; +using columnar::EdgeColumnType; +using columnar::EdgeRecord; +using columnar::IColumn; +using columnar::IColumnBuilder; +using columnar::IEdgeColumn; +using columnar::interval_t; +using columnar::IVertexColumn; +using columnar::IVertexColumnBuilder; +using columnar::JoinKind; +using columnar::LabelTriplet; +using columnar::ListColumn; +using columnar::ListColumnBuilder; +using columnar::ListValue; +using columnar::MLVertexColumn; +using columnar::MLVertexColumnBuilder; +using columnar::MLVertexColumnBuilderOpt; +using columnar::MSEdgeColumn; +using columnar::MSEdgeColumnBuilder; +using columnar::MSVertexColumn; +using columnar::MSVertexColumnBuilder; +using columnar::Path; +using columnar::PathColumn; +using columnar::PathColumnBuilder; +using columnar::PathOpt; +using columnar::PathValue; +using columnar::SDMLEdgeColumn; +using columnar::SDMLEdgeColumnBuilder; +using columnar::SDSLEdgeColumn; +using columnar::SDSLEdgeColumnBuilder; +using columnar::SLVertexColumn; +using columnar::StringValue; +using columnar::StructColumn; +using columnar::StructColumnBuilder; +using columnar::StructValue; +using columnar::timestamp_ms_t; +using columnar::Value; +using columnar::ValueConverter; +using columnar::vertex_t; +using columnar::VertexColumnType; +using columnar::VertexRecord; +using columnar::VOpt; + +template +using ValueColumn = columnar::ValueColumn; + +template +using ValueColumnBuilder = columnar::ValueColumnBuilder; + +} // namespace execution +} // namespace neug diff --git a/include/neug/execution/common/context.h b/include/neug/execution/common/context.h index 78458d473..51acd1d86 100644 --- a/include/neug/execution/common/context.h +++ b/include/neug/execution/common/context.h @@ -18,17 +18,19 @@ #include #include +#include "neug/columnar/container_types.h" #include "neug/common/types.h" -#include "neug/execution/common/columns/container_types.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" -#include "neug/execution/common/data_chunk.h" #include "neug/utils/result.h" namespace neug { class StorageReadInterface; namespace execution { -class IContextColumn; + +using columnar::DataChunk; +using columnar::IColumn; /** * @brief Context is a multi-chunk container passed between operators. @@ -69,7 +71,7 @@ class Context { void append_chunk(DataChunk&& chunk); /// Appends a chunk with the given head column. - void append_chunk(DataChunk&& chunk, std::shared_ptr head); + void append_chunk(DataChunk&& chunk, std::shared_ptr head); /// Appends a fully-formed ContextChunk to this Context. void append_chunk(ContextChunk&& chunk); diff --git a/include/neug/execution/common/context_chunk.h b/include/neug/execution/common/context_chunk.h index 847029706..f0de42eb1 100644 --- a/include/neug/execution/common/context_chunk.h +++ b/include/neug/execution/common/context_chunk.h @@ -19,7 +19,8 @@ #include #include -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" +#include "neug/execution/columnar_aliases.h" namespace neug { @@ -45,7 +46,7 @@ class ContextChunk { ~ContextChunk() = default; ContextChunk(DataChunk&& chunk); // NOLINT(runtime/explicit) - ContextChunk(DataChunk&& chunk, std::shared_ptr head); + ContextChunk(DataChunk&& chunk, std::shared_ptr head); ContextChunk(const ContextChunk& other) = default; ContextChunk& operator=(const ContextChunk& other) = default; @@ -56,11 +57,11 @@ class ContextChunk { DataChunk& chunk(); const DataChunk& chunk() const; - std::shared_ptr& head(); - const std::shared_ptr& head() const; + std::shared_ptr& head(); + const std::shared_ptr& head() const; - std::vector>& columns(); - const std::vector>& columns() const; + std::vector>& columns(); + const std::vector>& columns() const; // ---- mutation ---- @@ -68,12 +69,12 @@ class ContextChunk { /// Stores `col`. If alias >= 0 the column is also placed in the chunk /// under that alias; head is updated either way. - void set(int alias, std::shared_ptr col); + void set(int alias, std::shared_ptr col); /// Returns the column referenced by alias. alias = -1 returns head. - std::shared_ptr get(int alias) const; + std::shared_ptr get(int alias) const; - void set_with_reshuffle(int alias, std::shared_ptr col, + void set_with_reshuffle(int alias, std::shared_ptr col, const sel_vec_t& offsets); void remove(int alias); @@ -103,7 +104,7 @@ class ContextChunk { private: DataChunk chunk_; - std::shared_ptr head_; + std::shared_ptr head_; }; } // namespace execution diff --git a/include/neug/execution/common/operators/insert/create_edge.h b/include/neug/execution/common/operators/insert/create_edge.h index 7069c0b6b..444d90dd1 100644 --- a/include/neug/execution/common/operators/insert/create_edge.h +++ b/include/neug/execution/common/operators/insert/create_edge.h @@ -14,13 +14,13 @@ */ #pragma once +#include "neug/execution/columnar_aliases.h" #include "neug/utils/result.h" namespace neug { class StorageInsertInterface; namespace execution { class ContextChunk; -struct LabelTriplet; class BindedExprBase; namespace ops { class CreateEdge { diff --git a/include/neug/execution/common/operators/retrieve/edge_expand.h b/include/neug/execution/common/operators/retrieve/edge_expand.h index 989c3f267..0d8a34ce9 100644 --- a/include/neug/execution/common/operators/retrieve/edge_expand.h +++ b/include/neug/execution/common/operators/retrieve/edge_expand.h @@ -14,10 +14,10 @@ */ #pragma once +#include "neug/columnar/graph_types.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/common/operators/retrieve/edge_expand_impl.h" #include "neug/execution/common/params_map.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/execution/expression/special_predicates.h" #include "neug/execution/utils/params.h" #include "neug/utils/result.h" diff --git a/include/neug/execution/common/operators/retrieve/edge_expand_impl.h b/include/neug/execution/common/operators/retrieve/edge_expand_impl.h index 1a082bf27..1829721e3 100644 --- a/include/neug/execution/common/operators/retrieve/edge_expand_impl.h +++ b/include/neug/execution/common/operators/retrieve/edge_expand_impl.h @@ -15,8 +15,9 @@ */ #pragma once -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/execution/columnar_aliases.h" #include "neug/storages/graph/graph_interface.h" namespace neug { @@ -130,7 +131,7 @@ get_label_dirs_list(const std::set& input_labels, const Schema& schema, } template -std::pair, sel_vec_t> expand_vertex_impl( +std::pair, sel_vec_t> expand_vertex_impl( const StorageReadInterface& graph, const SLVertexColumn& input, const std::vector& labels, Direction dir, const GPRED_T& gpred) { @@ -219,7 +220,7 @@ std::pair, sel_vec_t> expand_vertex_impl( } template -std::pair, sel_vec_t> expand_vertex_impl( +std::pair, sel_vec_t> expand_vertex_impl( const StorageReadInterface& graph, const MLVertexColumn& input, const std::vector& labels, Direction dir, const GPRED_T& gpred) { @@ -632,7 +633,7 @@ std::pair, sel_vec_t> expand_vertex_impl( } template -std::pair, sel_vec_t> expand_vertex_impl( +std::pair, sel_vec_t> expand_vertex_impl( const StorageReadInterface& graph, const MSVertexColumn& input, const std::vector& labels, Direction dir, const GPRED_T& gpred) { @@ -749,11 +750,10 @@ std::pair, sel_vec_t> expand_vertex_impl( #undef expand_sv_p_ml template -std::pair, sel_vec_t> -expand_vertex_optional_impl(const StorageReadInterface& graph, - const IVertexColumn& input, - const std::vector& labels, - Direction dir, const PRED_T& pred) { +std::pair, sel_vec_t> expand_vertex_optional_impl( + const StorageReadInterface& graph, const IVertexColumn& input, + const std::vector& labels, Direction dir, + const PRED_T& pred) { auto vertex_column_type = input.vertex_column_type(); if (vertex_column_type == VertexColumnType::kSingle) { const SLVertexColumn& sl_col = dynamic_cast(input); @@ -768,7 +768,7 @@ expand_vertex_optional_impl(const StorageReadInterface& graph, } template -std::pair, sel_vec_t> expand_edge_impl( +std::pair, sel_vec_t> expand_edge_impl( const StorageReadInterface& graph, const SLVertexColumn& input, const std::vector& labels, Direction dir, const PRED_T& pred) { @@ -891,7 +891,7 @@ std::pair, sel_vec_t> expand_edge_impl( } template -std::pair, sel_vec_t> expand_edge_impl( +std::pair, sel_vec_t> expand_edge_impl( const StorageReadInterface& graph, const MSVertexColumn& input, const std::vector& labels, Direction dir, const PRED_T& pred) { @@ -1016,7 +1016,7 @@ std::pair, sel_vec_t> expand_edge_impl( } template -std::pair, sel_vec_t> expand_edge_impl( +std::pair, sel_vec_t> expand_edge_impl( const StorageReadInterface& graph, const MLVertexColumn& input, const std::vector& labels, Direction dir, const PRED_T& pred) { diff --git a/include/neug/execution/common/operators/retrieve/get_v.h b/include/neug/execution/common/operators/retrieve/get_v.h index 4d2b9dcfa..a5e2b59d8 100644 --- a/include/neug/execution/common/operators/retrieve/get_v.h +++ b/include/neug/execution/common/operators/retrieve/get_v.h @@ -14,9 +14,10 @@ */ #pragma once -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/path_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/expression/predicates.h" #include "neug/execution/utils/params.h" @@ -51,7 +52,7 @@ inline std::vector extract_labels( class GetV { public: template - static std::pair, sel_vec_t> + static std::pair, sel_vec_t> get_vertex_from_edges_impl(const IEdgeColumn& input_edge_list, const GetVParams& params, const PRED_T& pred) { auto labels = input_edge_list.get_labels(); @@ -324,7 +325,7 @@ class GetV { const GetVParams& params, const PRED_T& pred) { sel_vec_t shuffle_offset; auto col = chunk.get(params.tag); - if (col->column_type() == ContextColumnType::kPath) { + if (col->column_type() == ColumnKind::kPath) { return get_vertex_from_path(graph, std::move(chunk), params, pred); } auto column = std::dynamic_pointer_cast(chunk.get(params.tag)); diff --git a/include/neug/execution/common/operators/retrieve/group_by.h b/include/neug/execution/common/operators/retrieve/group_by.h index b38cf04ff..072356e65 100644 --- a/include/neug/execution/common/operators/retrieve/group_by.h +++ b/include/neug/execution/common/operators/retrieve/group_by.h @@ -61,7 +61,7 @@ struct Key : public KeyBase { struct ReducerBase { virtual ~ReducerBase() = default; - virtual std::shared_ptr reduce( + virtual std::shared_ptr reduce( const vector_t& groups) = 0; }; diff --git a/include/neug/execution/common/operators/retrieve/intersect.h b/include/neug/execution/common/operators/retrieve/intersect.h index c3151c8ac..b569b36ec 100644 --- a/include/neug/execution/common/operators/retrieve/intersect.h +++ b/include/neug/execution/common/operators/retrieve/intersect.h @@ -14,6 +14,7 @@ */ #pragma once +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/expression/predicates.h" diff --git a/include/neug/execution/common/operators/retrieve/join.h b/include/neug/execution/common/operators/retrieve/join.h index a074b2609..c0514e175 100644 --- a/include/neug/execution/common/operators/retrieve/join.h +++ b/include/neug/execution/common/operators/retrieve/join.h @@ -14,7 +14,7 @@ */ #pragma once -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/graph_types.h" #include "neug/utils/result.h" namespace neug { diff --git a/include/neug/execution/common/operators/retrieve/path_expand.h b/include/neug/execution/common/operators/retrieve/path_expand.h index 4f8f3d49b..065ca13ec 100644 --- a/include/neug/execution/common/operators/retrieve/path_expand.h +++ b/include/neug/execution/common/operators/retrieve/path_expand.h @@ -14,6 +14,7 @@ */ #pragma once +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/common/operators/retrieve/path_expand_impl.h" #include "neug/execution/common/params_map.h" diff --git a/include/neug/execution/common/operators/retrieve/path_expand_impl.h b/include/neug/execution/common/operators/retrieve/path_expand_impl.h index d2ef2ae7c..a1fa6e02d 100644 --- a/include/neug/execution/common/operators/retrieve/path_expand_impl.h +++ b/include/neug/execution/common/operators/retrieve/path_expand_impl.h @@ -15,27 +15,28 @@ */ #pragma once -#include "neug/execution/common/columns/path_columns.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/graph_types.h" +#include "neug/execution/columnar_aliases.h" #include "neug/storages/graph/graph_interface.h" namespace neug { namespace execution { -std::pair, sel_vec_t> +std::pair, sel_vec_t> iterative_expand_vertex_on_graph_view(const CsrView& view, const SLVertexColumn& input, int lower, int upper); -std::pair, sel_vec_t> +std::pair, sel_vec_t> iterative_expand_vertex_on_dual_graph_view(const CsrView& iview, const CsrView& oview, const SLVertexColumn& input, int lower, int upper); -std::pair, sel_vec_t> +std::pair, sel_vec_t> path_expand_vertex_without_predicate_impl( const StorageReadInterface& graph, const SLVertexColumn& input, const std::vector& labels, Direction dir, int lower, @@ -359,8 +360,7 @@ void sssp_both_dir_with_order_by_length_limit( } } template -std::tuple, std::shared_ptr, - sel_vec_t> +std::tuple, std::shared_ptr, sel_vec_t> single_source_shortest_path_with_order_by_length_limit_impl( const StorageReadInterface& graph, const IVertexColumn& input, label_t e_label, Direction dir, int lower, int upper, const PRED_T& pred, @@ -387,8 +387,7 @@ single_source_shortest_path_with_order_by_length_limit_impl( } template -std::tuple, std::shared_ptr, - sel_vec_t> +std::tuple, std::shared_ptr, sel_vec_t> single_source_shortest_path_impl(const StorageReadInterface& graph, const IVertexColumn& input, label_t e_label, Direction dir, int lower, int upper, @@ -421,8 +420,7 @@ single_source_shortest_path_impl(const StorageReadInterface& graph, } template -std::tuple, std::shared_ptr, - sel_vec_t> +std::tuple, std::shared_ptr, sel_vec_t> default_single_source_shortest_path_impl( const StorageReadInterface& graph, const IVertexColumn& input, const std::vector& labels, Direction dir, int lower, @@ -455,7 +453,7 @@ default_single_source_shortest_path_impl( PathColumnBuilder path_col_builder; sel_vec_t offsets; - std::shared_ptr dest_col(nullptr); + std::shared_ptr dest_col(nullptr); if (dest_labels.size() == 1) { MSVertexColumnBuilder dest_col_builder(*dest_labels.begin()); diff --git a/include/neug/execution/common/operators/retrieve/project.h b/include/neug/execution/common/operators/retrieve/project.h index f125c0c7d..9560df858 100644 --- a/include/neug/execution/common/operators/retrieve/project.h +++ b/include/neug/execution/common/operators/retrieve/project.h @@ -14,7 +14,7 @@ */ #pragma once -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/common/operators/retrieve/order_by.h" #include "neug/execution/common/params_map.h" @@ -26,8 +26,7 @@ namespace execution { struct ProjectExprBase { virtual ~ProjectExprBase() = default; - virtual std::shared_ptr evaluate( - const ContextChunk& chunk) = 0; + virtual std::shared_ptr evaluate(const ContextChunk& chunk) = 0; virtual bool order_by_limit(const ContextChunk& chunk, bool asc, size_t limit, sel_vec_t& offsets) const { return false; @@ -45,7 +44,7 @@ struct ProjectOp { fallback_expr_(std::move(fallback_expr)), alias_(alias) {} void evaluate(const ContextChunk& chunk, DataChunk& ret) const { - std::shared_ptr col; + std::shared_ptr col; if (expr_) { col = expr_->evaluate(chunk); } diff --git a/include/neug/execution/common/operators/retrieve/scan.h b/include/neug/execution/common/operators/retrieve/scan.h index d1421f799..df8c38c97 100644 --- a/include/neug/execution/common/operators/retrieve/scan.h +++ b/include/neug/execution/common/operators/retrieve/scan.h @@ -14,10 +14,11 @@ */ #pragma once -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/value.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context_chunk.h" #include "neug/execution/common/params_map.h" -#include "neug/execution/common/types/value.h" #include "neug/execution/expression/special_predicates.h" #include "neug/execution/utils/params.h" #include "neug/storages/graph/graph_interface.h" diff --git a/include/neug/execution/common/operators/retrieve/sink.h b/include/neug/execution/common/operators/retrieve/sink.h index eabfa59ff..cdccdf228 100644 --- a/include/neug/execution/common/operators/retrieve/sink.h +++ b/include/neug/execution/common/operators/retrieve/sink.h @@ -14,6 +14,7 @@ */ #pragma once +#include "neug/execution/columnar_aliases.h" #include "neug/generated/proto/response/response.pb.h" #include "neug/main/query_result.h" namespace neug { diff --git a/include/neug/execution/common/params_map.h b/include/neug/execution/common/params_map.h index 4ee138db3..59758afa2 100644 --- a/include/neug/execution/common/params_map.h +++ b/include/neug/execution/common/params_map.h @@ -17,12 +17,13 @@ #include #include +#include "neug/execution/columnar_aliases.h" + namespace neug { struct DataType; namespace execution { -class Value; using ParamsMap = std::map; using ParamsMetaMap = std::map; } // namespace execution -} // namespace neug \ No newline at end of file +} // namespace neug diff --git a/include/neug/execution/execute/ops/batch/batch_update_utils.h b/include/neug/execution/execute/ops/batch/batch_update_utils.h index c4b1cd8f5..6232dafe2 100644 --- a/include/neug/execution/execute/ops/batch/batch_update_utils.h +++ b/include/neug/execution/execute/ops/batch/batch_update_utils.h @@ -16,6 +16,7 @@ #include +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context.h" #include "neug/utils/property/types.h" @@ -34,9 +35,6 @@ class IDataChunkSupplier; class Schema; class StorageReadInterface; namespace execution { -class VertexRecord; -class EdgeRecord; -struct Path; namespace ops { diff --git a/include/neug/execution/execute/ops/retrieve/order_by_utils.h b/include/neug/execution/execute/ops/retrieve/order_by_utils.h index 3865fb05e..fcfcf2c41 100644 --- a/include/neug/execution/execute/ops/retrieve/order_by_utils.h +++ b/include/neug/execution/execute/ops/retrieve/order_by_utils.h @@ -16,20 +16,19 @@ #include -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/execution/columnar_aliases.h" #include "neug/utils/top_n_generator.h" namespace neug { class StorageReadInterface; namespace execution { -class IVertexColumn; namespace ops { class GeneralComparer { public: GeneralComparer() : keys_num_(0) {} ~GeneralComparer() {} - void add_keys(const std::shared_ptr& key, bool asc) { + void add_keys(const std::shared_ptr& key, bool asc) { keys_.emplace_back(key); order_.push_back(asc); ++keys_num_; @@ -52,7 +51,7 @@ class GeneralComparer { } private: - std::vector> keys_; + std::vector> keys_; std::vector order_; size_t keys_num_; }; diff --git a/include/neug/execution/execute/ops/retrieve/project_utils.h b/include/neug/execution/execute/ops/retrieve/project_utils.h index cb1639e0b..5ea9206b4 100644 --- a/include/neug/execution/execute/ops/retrieve/project_utils.h +++ b/include/neug/execution/execute/ops/retrieve/project_utils.h @@ -14,8 +14,8 @@ */ #pragma once -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/operators/retrieve/project.h" #include "neug/execution/execute/ops/retrieve/order_by_utils.h" #include "neug/execution/expression/expr.h" diff --git a/include/neug/execution/execute/ops/retrieve/scan_utils.h b/include/neug/execution/execute/ops/retrieve/scan_utils.h index c852d6dc7..5a85f2b2a 100644 --- a/include/neug/execution/execute/ops/retrieve/scan_utils.h +++ b/include/neug/execution/execute/ops/retrieve/scan_utils.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/execution/execute/operator.h" #include "neug/utils/property/types.h" diff --git a/include/neug/execution/expression/expr.h b/include/neug/execution/expression/expr.h index 0f3b00cce..337be7a9f 100644 --- a/include/neug/execution/expression/expr.h +++ b/include/neug/execution/expression/expr.h @@ -16,9 +16,9 @@ #pragma once #include #include "neug/common/types.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context.h" #include "neug/execution/common/params_map.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/graph/graph_interface.h" namespace neug { diff --git a/include/neug/execution/expression/special_predicates.h b/include/neug/execution/expression/special_predicates.h index 8c537ac6a..d743065ff 100644 --- a/include/neug/execution/expression/special_predicates.h +++ b/include/neug/execution/expression/special_predicates.h @@ -15,7 +15,7 @@ */ #pragma once -#include "neug/execution/common/types/value.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/utils/pb_parse_utils.h" #include "neug/execution/common/context.h" diff --git a/include/neug/utils/io/read/common/reader_utils.h b/include/neug/execution/io/chunk_stream_adapter.h similarity index 55% rename from include/neug/utils/io/read/common/reader_utils.h rename to include/neug/execution/io/chunk_stream_adapter.h index 889f1f535..b37af41b4 100644 --- a/include/neug/utils/io/read/common/reader_utils.h +++ b/include/neug/execution/io/chunk_stream_adapter.h @@ -19,22 +19,25 @@ #include #include "neug/execution/common/context.h" -#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/utils/io/read/common/file_reader.h" #include "neug/utils/io/read/common/read_state.h" namespace neug { -namespace reader { +namespace execution { +namespace io { -execution::Context toContext(std::shared_ptr supplier, - const ReadSharedState& state, - size_t fallback_column_count = 0); +/// Drains a chunk supplier into an execution Context (IO → pipeline boundary). +Context fromChunkSupplier(std::shared_ptr supplier, + const reader::ReadSharedState& state, + size_t fallback_column_count = 0); -inline execution::Context runFileReader(std::unique_ptr reader, - const ReadSharedState& state, - size_t fallback_column_count = 0) { - return toContext(reader->read(), state, fallback_column_count); +inline Context runFileReader(std::unique_ptr reader, + const reader::ReadSharedState& state, + size_t fallback_column_count = 0) { + return fromChunkSupplier(reader->read(), state, fallback_column_count); } -} // namespace reader +} // namespace io +} // namespace execution } // namespace neug diff --git a/include/neug/utils/io/read/common/chunk_supplier.h b/include/neug/execution/io/chunk_supplier.h similarity index 76% rename from include/neug/utils/io/read/common/chunk_supplier.h rename to include/neug/execution/io/chunk_supplier.h index 821b1a40c..90ca2d482 100644 --- a/include/neug/utils/io/read/common/chunk_supplier.h +++ b/include/neug/execution/io/chunk_supplier.h @@ -19,17 +19,16 @@ #include #include +#include "neug/columnar/data_chunk.h" + namespace neug { -namespace execution { -class DataChunk; -} -/// Iterator-like source of execution::DataChunk batches for file readers and +/// Iterator-like source of columnar::DataChunk batches for file readers and /// loaders. class IDataChunkSupplier { public: virtual ~IDataChunkSupplier() = default; - virtual std::shared_ptr GetNextChunk() = 0; + virtual std::shared_ptr GetNextChunk() = 0; virtual int64_t RowNum() const = 0; }; @@ -37,14 +36,14 @@ class IDataChunkSupplier { class MultiDataChunkSupplier : public IDataChunkSupplier { public: explicit MultiDataChunkSupplier( - std::vector> chunks); + std::vector> chunks); - std::shared_ptr GetNextChunk() override; + std::shared_ptr GetNextChunk() override; int64_t RowNum() const override; private: - std::vector> chunks_; + std::vector> chunks_; size_t index_ = 0; }; @@ -54,7 +53,7 @@ class ChunkSupplierWrapper : public IDataChunkSupplier { explicit ChunkSupplierWrapper( std::vector> suppliers); - std::shared_ptr GetNextChunk() override; + std::shared_ptr GetNextChunk() override; int64_t RowNum() const override; diff --git a/include/neug/execution/utils/params.h b/include/neug/execution/utils/params.h index 3c0869fa4..3094259cb 100644 --- a/include/neug/execution/utils/params.h +++ b/include/neug/execution/utils/params.h @@ -17,7 +17,7 @@ #include #include -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/graph_types.h" namespace neug { namespace execution { diff --git a/include/neug/execution/utils/pb_parse_utils.h b/include/neug/execution/utils/pb_parse_utils.h index 88d5a2332..872a6bb89 100644 --- a/include/neug/execution/utils/pb_parse_utils.h +++ b/include/neug/execution/utils/pb_parse_utils.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/types/graph_types.h" +#include "neug/execution/columnar_aliases.h" #include "neug/generated/proto/plan/physical.pb.h" #include "neug/utils/encoder.h" diff --git a/include/neug/main/connection.h b/include/neug/main/connection.h index 6d4a94d3c..7621d2d7e 100644 --- a/include/neug/main/connection.h +++ b/include/neug/main/connection.h @@ -21,8 +21,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/compiler/planner/graph_planner.h" -#include "neug/execution/common/types/value.h" #include "neug/generated/proto/plan/physical.pb.h" #include "neug/main/query_processor.h" #include "neug/main/query_result.h" @@ -104,7 +104,7 @@ class Connection { * * // Query with parameters * neug::execution::ParamsMap params; - * params["min_age"] = neug::execution::Value(18); + * params["min_age"] = neug::columnar::Value(18); * result = conn->Query("MATCH (p:Person) WHERE p.age > $min_age RETURN p", * "read", params); * diff --git a/include/neug/main/query_processor.h b/include/neug/main/query_processor.h index 8e96dd94a..2e9deb508 100644 --- a/include/neug/main/query_processor.h +++ b/include/neug/main/query_processor.h @@ -23,9 +23,9 @@ #include #include +#include "neug/columnar/value.h" #include "neug/compiler/planner/graph_planner.h" #include "neug/execution/common/params_map.h" -#include "neug/execution/common/types/value.h" #include "neug/execution/execute/query_cache.h" #include "neug/execution/utils/opr_timer.h" #include "neug/generated/proto/plan/physical.pb.h" diff --git a/include/neug/main/query_request.h b/include/neug/main/query_request.h index c4b058c72..578780849 100644 --- a/include/neug/main/query_request.h +++ b/include/neug/main/query_request.h @@ -18,8 +18,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/execution/common/params_map.h" -#include "neug/execution/common/types/value.h" #include "neug/utils/access_mode.h" #include "neug/utils/result.h" diff --git a/include/neug/storages/csr/csr_base.h b/include/neug/storages/csr/csr_base.h index 95999cb1f..5b353441c 100644 --- a/include/neug/storages/csr/csr_base.h +++ b/include/neug/storages/csr/csr_base.h @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/allocators.h" #include "neug/storages/csr/csr_view.h" #include "neug/storages/csr/nbr.h" @@ -83,7 +83,7 @@ class CsrBase : public Module { timestamp_t ts) = 0; virtual std::pair put_generic_edge( - vid_t src, vid_t dst, const execution::Value& data, timestamp_t ts, + vid_t src, vid_t dst, const columnar::Value& data, timestamp_t ts, Allocator& alloc) = 0; virtual std::tuple, std::vector> batch_export( @@ -114,7 +114,7 @@ class TypedCsrBase : public CsrBase { } std::pair put_generic_edge(vid_t src, vid_t dst, - const execution::Value& data, + const columnar::Value& data, timestamp_t ts, Allocator& alloc) override { return this->put_edge(src, dst, data.GetValue(), ts, alloc); diff --git a/include/neug/storages/csr/csr_view.h b/include/neug/storages/csr/csr_view.h index a87207320..157608261 100644 --- a/include/neug/storages/csr/csr_view.h +++ b/include/neug/storages/csr/csr_view.h @@ -16,7 +16,7 @@ #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/csr/nbr.h" #include "neug/storages/csr/prefetch_utils.h" #include "neug/utils/property/column.h" @@ -253,8 +253,8 @@ static_assert(std::is_pod::value, "NbrList should be POD"); * NbrList edges = view.get_edges(v); * * for (auto it = edges.begin(); it != edges.end(); ++it) { - * // Get property as generic execution::Value - * execution::Value val = accessor.get_value(it); + * // Get property as generic columnar::Value + * columnar::Value val = accessor.get_value(it); * * // Or get as typed value (faster if type is known) * double weight = accessor.get_typed_data(it); @@ -308,25 +308,25 @@ struct EdgeDataAccessor { } /** - * @brief Get property value for current edge as execution::Value. + * @brief Get property value for current edge as columnar::Value. * @param it Iterator pointing to the edge - * @return execution::Value containing the edge data + * @return columnar::Value containing the edge data */ - inline execution::Value get_data(const NbrIterator& it) const { + inline columnar::Value get_data(const NbrIterator& it) const { return data_column_ == nullptr ? get_generic_bundled_data_from_ptr(it.get_data_ptr()) : data_column_->get_any( *reinterpret_cast(it.get_data_ptr())); } - inline execution::Value get_data_from_ptr(const void* data_ptr) const { + inline columnar::Value get_data_from_ptr(const void* data_ptr) const { return data_column_ == nullptr ? get_generic_bundled_data_from_ptr(data_ptr) : data_column_->get_any( *reinterpret_cast(data_ptr)); } - inline void set_data(const NbrIterator& it, const execution::Value& value, + inline void set_data(const NbrIterator& it, const columnar::Value& value, timestamp_t ts) { if (it.cfg.ts_offset != 0) { *const_cast(it.get_timestamp_ptr()) = ts; @@ -366,15 +366,15 @@ struct EdgeDataAccessor { return reinterpret_cast*>(data_column_)->get_view(idx); } - inline execution::Value get_generic_bundled_data_from_ptr( + inline columnar::Value get_generic_bundled_data_from_ptr( const void* data_ptr) const { if (data_type_ == DataTypeId::kEmpty) { - return execution::Value(DataType::EMPTY); + return columnar::Value(DataType::EMPTY); } switch (data_type_) { #define TYPE_DISPATCHER(enum_val, type) \ case DataTypeId::enum_val: { \ - return execution::Value::CreateValue( \ + return columnar::Value::CreateValue( \ get_bundled_data_from_ptr(data_ptr)); \ } FOR_EACH_DATA_TYPE_NO_STRING(TYPE_DISPATCHER) @@ -382,7 +382,7 @@ struct EdgeDataAccessor { default: THROW_RUNTIME_ERROR("Could not get bundled data for type " + std::to_string(data_type_)); - return execution::Value(DataType::SQLNULL); + return columnar::Value(DataType::SQLNULL); } } diff --git a/include/neug/storages/csr/csr_view_utils.h b/include/neug/storages/csr/csr_view_utils.h index e99c881ad..b85db1bf5 100644 --- a/include/neug/storages/csr/csr_view_utils.h +++ b/include/neug/storages/csr/csr_view_utils.h @@ -18,9 +18,6 @@ namespace neug { -namespace execution { -class EdgeRecord; -} // namespace execution enum class DataTypeId : uint8_t; class Property; @@ -31,7 +28,7 @@ int32_t fuzzy_search_offset_from_nbr_list(const NbrList& nbr_list, std::pair record_to_csr_offset_pair( const CsrView& oe, const CsrView& ie, - const neug::execution::EdgeRecord& record, + const neug::columnar::EdgeRecord& record, const std::vector& props); int32_t search_other_offset_with_cur_offset(const CsrView& cur_view, diff --git a/include/neug/storages/graph/edge_table.h b/include/neug/storages/graph/edge_table.h index c6a2833a5..5c3690d28 100644 --- a/include/neug/storages/graph/edge_table.h +++ b/include/neug/storages/graph/edge_table.h @@ -23,7 +23,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/allocators.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/csr/csr_base.h" @@ -139,13 +139,13 @@ class EdgeTable { void BatchAddEdges( const std::vector& src_lid_list, const std::vector& dst_lid_list, - const std::vector>& edge_data_list); + const std::vector>& edge_data_list); // Add a single edge to the edge table. Note this method requires an Allocator // to allocate memory for the edge data. Should be called in tp mode. std::pair AddEdge( vid_t src_lid, vid_t dst_lid, - const std::vector& properties, timestamp_t ts, + const std::vector& properties, timestamp_t ts, Allocator& alloc, bool insert_safe); void RenameProperties(const std::vector& old_names, @@ -153,7 +153,7 @@ class EdgeTable { void AddProperties(Checkpoint& ckp, const std::vector& names, const std::vector& types, - const std::vector& default_values = {}); + const std::vector& default_values = {}); void DeleteProperties(Checkpoint& ckp, const std::vector& col_names); @@ -171,7 +171,7 @@ class EdgeTable { void UpdateEdgeProperty(vid_t src_lid, vid_t dst_lid, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& new_prop, timestamp_t ts); + const columnar::Value& new_prop, timestamp_t ts); void Compact(bool compact_csr, const std::optional& sort_key_for_nbr, @@ -214,7 +214,7 @@ template std::pair insert_edge_into_csr_internal( CsrBase& out_csr, CsrBase& in_csr, TABLE& table, std::atomic& table_idx, const EdgeSchema& meta, vid_t src_lid, - vid_t dst_lid, const std::vector& properties, + vid_t dst_lid, const std::vector& properties, timestamp_t ts, Allocator& alloc, bool insert_safe) { int32_t oe_offset; const void* data_ptr = nullptr; @@ -223,8 +223,8 @@ std::pair insert_edge_into_csr_internal( properties.size() == 1 || (properties.size() == 0 && (meta.properties.empty() || meta.properties[0] == DataTypeId::kEmpty))); - execution::Value bundled_data = - properties.empty() ? execution::Value(DataType::EMPTY) : properties[0]; + columnar::Value bundled_data = + properties.empty() ? columnar::Value(DataType::EMPTY) : properties[0]; in_csr.put_generic_edge(dst_lid, src_lid, bundled_data, ts, alloc); auto out_ret = out_csr.put_generic_edge(src_lid, dst_lid, bundled_data, ts, alloc); @@ -236,7 +236,7 @@ std::pair insert_edge_into_csr_internal( "edge data size not match edge table property size"); } size_t row_id = table_idx.fetch_add(1); - execution::Value prop = execution::Value::UINT64(row_id); + columnar::Value prop = columnar::Value::UINT64(row_id); in_csr.put_generic_edge(dst_lid, src_lid, prop, ts, alloc); auto out_ret = out_csr.put_generic_edge(src_lid, dst_lid, prop, ts, alloc); oe_offset = out_ret.first; diff --git a/include/neug/storages/graph/graph_interface.h b/include/neug/storages/graph/graph_interface.h index 58438a996..f4d1bbc96 100644 --- a/include/neug/storages/graph/graph_interface.h +++ b/include/neug/storages/graph/graph_interface.h @@ -16,8 +16,8 @@ #include -#include "neug/execution/common/columns/container_types.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/container_types.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/graph_view.h" #include "neug/storages/graph/property_graph.h" #include "neug/storages/graph/schema.h" @@ -89,7 +89,7 @@ class IStorageInterface { * @param index Output parameter for internal vertex index * @return true if vertex found, false otherwise */ - virtual bool GetVertexIndex(label_t label, const execution::Value& id, + virtual bool GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const = 0; }; @@ -200,7 +200,7 @@ class StorageReadInterface : virtual public IStorageInterface { return view_.GetVertexSet(label, read_ts_); } - bool GetVertexIndex(label_t label, const execution::Value& id, + bool GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const override { return view_.get_lid(label, id, index, read_ts_); } @@ -223,11 +223,11 @@ class StorageReadInterface : virtual public IStorageInterface { * * @param label Vertex label * @param index Internal vertex ID - * @return execution::Value containing the primary key value + * @return columnar::Value containing the primary key value * * @since v0.1.0 */ - inline execution::Value GetVertexId(label_t label, vid_t index) const { + inline columnar::Value GetVertexId(label_t label, vid_t index) const { return view_.GetOid(label, index, read_ts_); } @@ -236,21 +236,21 @@ class StorageReadInterface : virtual public IStorageInterface { * * **Usage Example:** * @code{.cpp} - * execution::Value age = reader.GetVertexProperty(person_label, vid, + * columnar::Value age = reader.GetVertexProperty(person_label, vid, * age_prop_id); int64_t age_val = age.GetValue(); * @endcode * * @param label Vertex label * @param index Internal vertex ID * @param prop_id Property column index - * @return execution::Value containing the value + * @return columnar::Value containing the value * * @since v0.1.0 */ - inline execution::Value GetVertexProperty(label_t label, vid_t index, - int prop_id) const { + inline columnar::Value GetVertexProperty(label_t label, vid_t index, + int prop_id) const { auto col = view_.GetVertexPropertyColumn(label, prop_id); - return col ? col->get_any(index) : execution::Value(); + return col ? col->get_any(index) : columnar::Value(); } /** @@ -398,8 +398,8 @@ class StorageInsertInterface : virtual public IStorageInterface { * @return Status::OK() on success, or an error Status if validation fails * (e.g. property count/type mismatch, capacity failure). */ - virtual Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, + virtual Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) = 0; /** @@ -419,7 +419,7 @@ class StorageInsertInterface : virtual public IStorageInterface { */ virtual Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop) = 0; /** @@ -510,7 +510,7 @@ class StorageUpdateInterface : public StorageReadInterface, * @param value New property value */ virtual Status UpdateVertexProperty(label_t label, vid_t lid, int col_id, - const execution::Value& value) = 0; + const columnar::Value& value) = 0; /** * @brief Update an edge property value. @@ -529,14 +529,14 @@ class StorageUpdateInterface : public StorageReadInterface, label_t dst_label, vid_t dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& value) = 0; + const columnar::Value& value) = 0; - virtual Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, + virtual Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) override = 0; virtual Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop) override = 0; /** @@ -629,17 +629,17 @@ class StorageAPUpdateInterface : public StorageUpdateInterface { ~StorageAPUpdateInterface() {} Status UpdateVertexProperty(label_t label, vid_t lid, int col_id, - const execution::Value& value) override; + const columnar::Value& value) override; Status UpdateEdgeProperty(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& value) override; - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, + const columnar::Value& value) override; + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) override; Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop) override; Status DeleteVertex(label_t label, vid_t lid) override; Status DeleteEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, diff --git a/include/neug/storages/graph/graph_view.h b/include/neug/storages/graph/graph_view.h index 14f942c63..d564d57e9 100644 --- a/include/neug/storages/graph/graph_view.h +++ b/include/neug/storages/graph/graph_view.h @@ -42,7 +42,7 @@ class TableView { // Note: insert_safe is kept for compatibility with the old interface. // It must be false for TableView. - void insert(size_t index, const std::vector& values, + void insert(size_t index, const std::vector& values, bool insert_safe); private: @@ -55,17 +55,17 @@ class VertexTableView { VertexTableView() = default; explicit VertexTableView(VertexTable& table); - bool get_lid(const execution::Value& oid, vid_t& lid, timestamp_t ts) const; + bool get_lid(const columnar::Value& oid, vid_t& lid, timestamp_t ts) const; vid_t LidNum() const; bool IsValidLid(vid_t lid, timestamp_t ts) const; - execution::Value GetOid(vid_t lid, timestamp_t ts) const; + columnar::Value GetOid(vid_t lid, timestamp_t ts) const; VertexSet GetVertexSet(timestamp_t ts) const; std::shared_ptr GetPropertyColumn(int col_id) const; std::shared_ptr GetPropertyColumn( const std::string& prop) const; - bool AddVertex(const execution::Value& id, - const std::vector& props, vid_t& ret, + bool AddVertex(const columnar::Value& id, + const std::vector& props, vid_t& ret, timestamp_t ts, bool insert_safe); private: @@ -88,7 +88,7 @@ class EdgeTableView { std::pair AddEdge( vid_t src_lid, vid_t dst_lid, - const std::vector& properties, timestamp_t ts, + const std::vector& properties, timestamp_t ts, Allocator& alloc, bool insert_safe); private: @@ -114,7 +114,7 @@ class GraphView { const Schema& schema() const { return *schema_; } - inline bool get_lid(label_t label, const execution::Value& oid, vid_t& lid, + inline bool get_lid(label_t label, const columnar::Value& oid, vid_t& lid, timestamp_t ts) const { return vertex_views_[label].get_lid(oid, lid, ts); } @@ -134,7 +134,7 @@ class GraphView { } VertexSet GetVertexSet(label_t label, timestamp_t ts) const; - execution::Value GetOid(label_t label, vid_t lid, timestamp_t ts) const; + columnar::Value GetOid(label_t label, vid_t lid, timestamp_t ts) const; CsrView GetGenericOutgoingView(label_t src_label, label_t dst_label, label_t edge_label, timestamp_t ts) const; @@ -146,15 +146,14 @@ class GraphView { label_t edge_label, const std::string& prop_name) const; - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, vid_t& vid, + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid, timestamp_t ts); Status AddEdge(label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, label_t edge_label, - const std::vector& properties, - timestamp_t ts, Allocator& alloc, int32_t& oe_offset, - const void*& prop); + const std::vector& properties, timestamp_t ts, + Allocator& alloc, int32_t& oe_offset, const void*& prop); void Rebuild(PropertyGraph& pg); diff --git a/include/neug/storages/graph/operation_params.h b/include/neug/storages/graph/operation_params.h index 3fd5c3664..dc6183859 100644 --- a/include/neug/storages/graph/operation_params.h +++ b/include/neug/storages/graph/operation_params.h @@ -18,7 +18,7 @@ #include #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/property/types.h" namespace neug { @@ -28,7 +28,7 @@ class OutArchive; class CreateVertexTypeParam { private: std::string vertex_label_name; - std::vector> properties; + std::vector> properties; std::vector primary_key_names; bool temporary = false; CreateVertexTypeParam() = default; @@ -36,7 +36,7 @@ class CreateVertexTypeParam { public: const std::string& GetVertexLabel() const { return vertex_label_name; } - const std::vector>& GetProperties() + const std::vector>& GetProperties() const { return properties; } @@ -60,13 +60,13 @@ class CreateVertexTypeParamBuilder { } CreateVertexTypeParamBuilder& Properties( - const std::vector>& properties) { + const std::vector>& properties) { config.properties = properties; return *this; } CreateVertexTypeParamBuilder& AddProperty(const std::string& name, - const execution::Value& value) { + const columnar::Value& value) { config.properties.emplace_back(name, value); return *this; } @@ -106,7 +106,7 @@ class CreateEdgeTypeParam { std::string src_label_name; std::string dst_label_name; std::string edge_label_name; - std::vector> properties; + std::vector> properties; EdgeStrategy oe_edge_strategy; EdgeStrategy ie_edge_strategy; std::optional sort_key_for_nbr; @@ -118,7 +118,7 @@ class CreateEdgeTypeParam { const std::string& GetSrcLabel() const { return src_label_name; } const std::string& GetDstLabel() const { return dst_label_name; } const std::string& GetEdgeLabel() const { return edge_label_name; } - const std::vector>& GetProperties() + const std::vector>& GetProperties() const { return properties; } @@ -157,13 +157,13 @@ class CreateEdgeTypeParamBuilder { } CreateEdgeTypeParamBuilder& Properties( - const std::vector>& properties) { + const std::vector>& properties) { config.properties = properties; return *this; } CreateEdgeTypeParamBuilder& AddProperty(const std::string& name, - const execution::Value& value) { + const columnar::Value& value) { config.properties.emplace_back(name, value); return *this; } @@ -209,13 +209,13 @@ class CreateEdgeTypeParamBuilder { class AddVertexPropertiesParam { private: std::string vertex_label_name; - std::vector> properties; + std::vector> properties; AddVertexPropertiesParam() = default; friend class AddVertexPropertiesParamBuilder; public: const std::string& GetVertexLabel() const { return vertex_label_name; } - const std::vector>& GetProperties() + const std::vector>& GetProperties() const { return properties; } @@ -235,13 +235,13 @@ class AddVertexPropertiesParamBuilder { } AddVertexPropertiesParamBuilder& Properties( - const std::vector>& properties) { + const std::vector>& properties) { config.properties = properties; return *this; } AddVertexPropertiesParamBuilder& AddProperty(const std::string& name, - const execution::Value& value) { + const columnar::Value& value) { config.properties.emplace_back(name, value); return *this; } @@ -260,7 +260,7 @@ class AddEdgePropertiesParam { std::string src_label_name; std::string dst_label_name; std::string edge_label_name; - std::vector> properties; + std::vector> properties; AddEdgePropertiesParam() = default; friend class AddEdgePropertiesParamBuilder; @@ -268,7 +268,7 @@ class AddEdgePropertiesParam { const std::string& GetSrcLabel() const { return src_label_name; } const std::string& GetDstLabel() const { return dst_label_name; } const std::string& GetEdgeLabel() const { return edge_label_name; } - const std::vector>& GetProperties() + const std::vector>& GetProperties() const { return properties; } @@ -298,13 +298,13 @@ class AddEdgePropertiesParamBuilder { } AddEdgePropertiesParamBuilder& Properties( - const std::vector>& properties) { + const std::vector>& properties) { config.properties = properties; return *this; } AddEdgePropertiesParamBuilder& AddProperty(const std::string& name, - const execution::Value& value) { + const columnar::Value& value) { config.properties.emplace_back(name, value); return *this; } diff --git a/include/neug/storages/graph/property_graph.h b/include/neug/storages/graph/property_graph.h index e8860dbd3..b5dd7ee0e 100644 --- a/include/neug/storages/graph/property_graph.h +++ b/include/neug/storages/graph/property_graph.h @@ -27,7 +27,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/allocators.h" #include "neug/storages/checkpoint.h" #include "neug/storages/checkpoint_manager.h" @@ -42,10 +42,6 @@ namespace neug { -namespace execution { -class EdgeRecord; -} - /** * @brief Core property graph storage engine for vertices, edges, and schema. * @@ -321,7 +317,7 @@ class PropertyGraph { * @return true if deletion is successful, false otherwise. * @note We always delete vertex in detach mode. */ - Status DeleteVertex(label_t v_label, const execution::Value& oid, + Status DeleteVertex(label_t v_label, const columnar::Value& oid, timestamp_t ts); Status DeleteVertex(label_t v_label, vid_t lid, timestamp_t ts); @@ -387,28 +383,28 @@ class PropertyGraph { size_t EdgeNum(label_t src_label, label_t edge_label, label_t dst_label) const; - bool get_lid(label_t label, const execution::Value& oid, vid_t& lid, + bool get_lid(label_t label, const columnar::Value& oid, vid_t& lid, timestamp_t ts) const; - execution::Value GetOid(label_t label, vid_t lid, timestamp_t ts) const; + columnar::Value GetOid(label_t label, vid_t lid, timestamp_t ts) const; - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, vid_t& vid, + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid, timestamp_t ts, bool insert_safe = false); Status AddEdge(label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, label_t edge_label, - const std::vector& properties, - timestamp_t ts, Allocator& alloc, int32_t& oe_offset, - const void*& prop, bool insert_safe = false); + const std::vector& properties, timestamp_t ts, + Allocator& alloc, int32_t& oe_offset, const void*& prop, + bool insert_safe = false); Status UpdateVertexProperty(label_t v_label, vid_t vid, int32_t prop_id, - const execution::Value& value, timestamp_t ts); + const columnar::Value& value, timestamp_t ts); Status UpdateEdgeProperty(label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, label_t e_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& new_prop, timestamp_t ts); + const columnar::Value& new_prop, timestamp_t ts); /** * @brief Get a view for traversing outgoing edges. diff --git a/include/neug/storages/graph/schema.h b/include/neug/storages/graph/schema.h index 83202f0eb..815e99bdb 100644 --- a/include/neug/storages/graph/schema.h +++ b/include/neug/storages/graph/schema.h @@ -25,7 +25,7 @@ #include #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/bitset.h" #include "neug/utils/id_indexer.h" #include "neug/utils/property/default_value.h" @@ -114,7 +114,7 @@ struct VertexSchema { const std::vector& property_names_, const std::vector>& primary_keys_, - const std::vector& default_property_values_ = {}, + const std::vector& default_property_values_ = {}, const std::string& description_ = "", size_t max_num_ = static_cast(1) << 32) : label_name(label_name_), @@ -141,10 +141,10 @@ struct VertexSchema { void add_properties(const std::vector& names, const std::vector& types, - const std::vector& default_values = {}); + const std::vector& default_values = {}); void set_properties(const std::vector& types, - const std::vector& default_values = {}); + const std::vector& default_values = {}); void rename_properties(const std::vector& names, const std::vector& renames); @@ -168,7 +168,7 @@ struct VertexSchema { bool has_property(const std::string& prop) const; - const std::vector& get_default_property_values() const { + const std::vector& get_default_property_values() const { return default_property_values; } @@ -179,7 +179,7 @@ struct VertexSchema { std::vector property_names; // std::vector> primary_keys; - std::vector default_property_values; + std::vector default_property_values; std::string description; size_t max_num; @@ -258,7 +258,7 @@ struct EdgeSchema { EdgeStrategy ie_strategy_, const std::vector& properties_, const std::vector& property_names_, - const std::vector& default_property_values_ = {}) + const std::vector& default_property_values_ = {}) : src_label_name(src_label_name_), dst_label_name(dst_label_name_), edge_label_name(edge_label_name_), @@ -290,7 +290,7 @@ struct EdgeSchema { void add_properties(const std::vector& names, const std::vector& types, - const std::vector& default_values = {}); + const std::vector& default_values = {}); void rename_properties(const std::vector& names, const std::vector& renames); @@ -304,7 +304,7 @@ struct EdgeSchema { int32_t get_property_index(const std::string& prop) const; - const std::vector& get_default_property_values() const { + const std::vector& get_default_property_values() const { return default_property_values; } @@ -317,7 +317,7 @@ struct EdgeSchema { EdgeStrategy ie_strategy; std::vector properties; std::vector property_names; - std::vector default_property_values; + std::vector default_property_values; // Mark whether the edge property is soft deleted std::vector eprop_soft_deleted; @@ -465,7 +465,7 @@ class Schema { const std::vector>& primary_key, size_t max_vnum = static_cast(1) << 32, const std::string& description = "", - const std::vector& default_property_values = {}, + const std::vector& default_property_values = {}, bool temporary = false); void AddEdgeLabel( @@ -477,7 +477,7 @@ class Schema { bool ie_mutable = true, std::optional sort_key_for_nbr = std::nullopt, const std::string& description = "", - const std::vector& default_property_values = {}, + const std::vector& default_property_values = {}, bool temporary = false); bool is_vertex_label_temporary(label_t label) const; @@ -501,14 +501,14 @@ class Schema { const std::string& label, const std::vector& properties_names, const std::vector& properties_types, - const std::vector& properties_default_values); + const std::vector& properties_default_values); void AddEdgeProperties( const std::string& src_label, const std::string& dst_label, const std::string& edge_label, const std::vector& properties_names, const std::vector& properties_types, - const std::vector& properties_default_values); + const std::vector& properties_default_values); void RenameVertexProperties( const std::string& label, @@ -561,7 +561,7 @@ class Schema { void set_vertex_properties( label_t label_id, const std::vector& types, - const std::vector& default_property_values = {}); + const std::vector& default_property_values = {}); std::vector get_vertex_properties(const std::string& label) const; std::vector get_vertex_properties_id( @@ -570,7 +570,7 @@ class Schema { std::vector get_vertex_properties(label_t label) const; std::vector get_vertex_properties_id(label_t label) const; - const std::vector& get_vertex_default_property_values( + const std::vector& get_vertex_default_property_values( label_t label) const; std::vector get_vertex_property_names( @@ -591,7 +591,7 @@ class Schema { bool is_edge_triplet_valid(label_type src_label, label_type dst_label, label_type edge_label) const; - const std::vector& get_edge_default_property_values( + const std::vector& get_edge_default_property_values( label_t src_label_id, label_t dst_label_id, label_t edge_label_id) const; std::vector get_edge_properties(const std::string& src_label, diff --git a/include/neug/storages/graph/vertex_table.h b/include/neug/storages/graph/vertex_table.h index bbfe98b21..272554862 100644 --- a/include/neug/storages/graph/vertex_table.h +++ b/include/neug/storages/graph/vertex_table.h @@ -14,7 +14,7 @@ */ #pragma once -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/schema.h" #include "neug/storages/graph/vertex_timestamp.h" #include "neug/storages/loader/loader_utils.h" @@ -182,17 +182,17 @@ class VertexTable { size_t EnsureCapacity(size_t capacity); - bool get_index(const execution::Value& oid, vid_t& lid, + bool get_index(const columnar::Value& oid, vid_t& lid, timestamp_t ts = MAX_TIMESTAMP) const; - execution::Value GetOid(vid_t lid, timestamp_t ts = MAX_TIMESTAMP) const; + columnar::Value GetOid(vid_t lid, timestamp_t ts = MAX_TIMESTAMP) const; // Return false if the reserved space is not enough. - bool AddVertex(const execution::Value& id, - const std::vector& props, vid_t& vid, + bool AddVertex(const columnar::Value& id, + const std::vector& props, vid_t& vid, timestamp_t ts, bool insert_safe); - bool UpdateProperty(vid_t vid, int32_t prop_id, const execution::Value& value, + bool UpdateProperty(vid_t vid, int32_t prop_id, const columnar::Value& value, timestamp_t ts); size_t VertexNum(timestamp_t ts = MAX_TIMESTAMP) const; @@ -238,7 +238,7 @@ class VertexTable { void BatchDeleteVertices(const std::vector& vids); - void DeleteVertex(const execution::Value& id, timestamp_t ts); + void DeleteVertex(const columnar::Value& id, timestamp_t ts); void DeleteVertex(vid_t lid, timestamp_t ts); @@ -247,7 +247,7 @@ class VertexTable { void AddProperties( Checkpoint& ckp, const std::vector& property_names, const std::vector& property_types, - const std::vector& default_property_values); + const std::vector& default_property_values); void DeleteProperties(const std::vector& properties); @@ -264,11 +264,11 @@ class VertexTable { Table& get_table() { return *table_; } private: - vid_t insert_vertex_pk(const execution::Value& id, timestamp_t ts, + vid_t insert_vertex_pk(const columnar::Value& id, timestamp_t ts, bool insert_safe); template std::vector insert_primary_keys( - const std::shared_ptr& pk_col) { + const std::shared_ptr& pk_col) { size_t row_num = pk_col->size(); std::vector vids; vids.resize(row_num); @@ -320,7 +320,7 @@ class VertexTable { auto pk_col = columns[ind]; // Build a list of property columns excluding the PK column. - std::vector> prop_cols; + std::vector> prop_cols; prop_cols.reserve(columns.size() - 1); for (size_t i = 0; i < columns.size(); ++i) { if (static_cast(i) != ind) { @@ -364,7 +364,7 @@ class VertexTable { namespace internal { vid_t insert_vertex_pk_internal(IndexerType& indexer, VertexTimestamp& v_ts, - const execution::Value& id, timestamp_t ts, + const columnar::Value& id, timestamp_t ts, bool insert_safe); } // namespace internal diff --git a/include/neug/storages/loader/loader_utils.h b/include/neug/storages/loader/loader_utils.h index 6817c4984..8a92f77a6 100644 --- a/include/neug/storages/loader/loader_utils.h +++ b/include/neug/storages/loader/loader_utils.h @@ -24,10 +24,10 @@ #include #include -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/storages/loader/loading_config.h" #include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/csv/csv_read_config.h" #include "neug/utils/string_utils.h" @@ -73,7 +73,7 @@ class CSVChunkSupplier : public IDataChunkSupplier { ~CSVChunkSupplier() override; - std::shared_ptr GetNextChunk() override; + std::shared_ptr GetNextChunk() override; int64_t RowNum() const override { return row_num_; } @@ -104,8 +104,7 @@ void fillEdgeReaderMeta(label_t src_label_id, label_t dst_label_id, CsvReadConfig& config); void set_properties_from_context_column( - neug::ColumnBase* col, - const std::shared_ptr& ctx_col, + neug::ColumnBase* col, const std::shared_ptr& ctx_col, const std::vector& vids, std::shared_mutex& mutex); } // namespace neug diff --git a/include/neug/transaction/insert_transaction.h b/include/neug/transaction/insert_transaction.h index cb7ac7092..c8914b679 100644 --- a/include/neug/transaction/insert_transaction.h +++ b/include/neug/transaction/insert_transaction.h @@ -23,7 +23,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/allocators.h" #include "neug/storages/graph/graph_interface.h" #include "neug/storages/graph/graph_view.h" @@ -120,8 +120,8 @@ class InsertTransaction { * * @since v0.1.0 */ - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, vid_t& vid); + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid); /** * @brief Add a new edge to the transaction. @@ -149,7 +149,7 @@ class InsertTransaction { */ Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop); /** @@ -198,11 +198,11 @@ class InsertTransaction { const Schema& schema() const; - bool GetVertexIndex(label_t label, const execution::Value& oid, + bool GetVertexIndex(label_t label, const columnar::Value& oid, vid_t& lid) const; private: - execution::Value get_vertex_id(label_t label, vid_t lid) const; + columnar::Value get_vertex_id(label_t label, vid_t lid) const; void create_id_indexer_if_not_exists(label_t label); @@ -228,15 +228,15 @@ class StorageTPInsertInterface : public StorageInsertInterface { explicit StorageTPInsertInterface(InsertTransaction& txn) : txn_(txn) {} ~StorageTPInsertInterface() {} - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) override { return txn_.AddVertex(label, id, props, vid); } Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop) override { return txn_.AddEdge(src_label, src, dst_label, dst, edge_label, properties, prop); @@ -244,7 +244,7 @@ class StorageTPInsertInterface : public StorageInsertInterface { inline const Schema& schema() const override { return txn_.schema(); } - bool GetVertexIndex(label_t label, const execution::Value& id, + bool GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const override { return txn_.GetVertexIndex(label, id, index); } diff --git a/include/neug/transaction/update_transaction.h b/include/neug/transaction/update_transaction.h index 7399e6638..85b176dd0 100644 --- a/include/neug/transaction/update_transaction.h +++ b/include/neug/transaction/update_transaction.h @@ -24,7 +24,7 @@ #include #include "flat_hash_map/flat_hash_map.hpp" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/execution/execute/query_cache.h" #include "neug/storages/allocators.h" #include "neug/storages/csr/mutable_csr.h" @@ -117,13 +117,12 @@ class UpdateTransaction { // --- Read-only accessors (not graph modifications) --- const Schema& schema() const { return cow_graph_->schema(); } - execution::Value GetVertexId(label_t label, vid_t lid) const; + columnar::Value GetVertexId(label_t label, vid_t lid) const; - bool GetVertexIndex(label_t label, const execution::Value& id, + bool GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const; - execution::Value GetVertexProperty(label_t label, vid_t lid, - int col_id) const; + columnar::Value GetVertexProperty(label_t label, vid_t lid, int col_id) const; std::shared_ptr get_vertex_property_column( uint8_t label, const std::string& col_name) const { @@ -183,17 +182,17 @@ class StorageTPUpdateInterface : public StorageUpdateInterface { // --- DML methods --- Status UpdateVertexProperty(label_t label, vid_t lid, int col_id, - const execution::Value& value) override; + const columnar::Value& value) override; Status UpdateEdgeProperty(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& value) override; - Status AddVertex(label_t label, const execution::Value& id, - const std::vector& props, + const columnar::Value& value) override; + Status AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) override; Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, - const std::vector& properties, + const std::vector& properties, const void*& prop) override; Status DeleteVertex(label_t label, vid_t lid) override; Status DeleteEdges(label_t src_label, vid_t src, label_t dst_label, vid_t dst, diff --git a/include/neug/transaction/wal/wal.h b/include/neug/transaction/wal/wal.h index 99b2dc7db..54e3f88d7 100644 --- a/include/neug/transaction/wal/wal.h +++ b/include/neug/transaction/wal/wal.h @@ -21,7 +21,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/operation_params.h" #include "neug/transaction/transaction_utils.h" #include "neug/utils/property/types.h" @@ -208,80 +208,80 @@ struct DeleteEdgeTypeRedo { struct InsertVertexRedo { label_t label; - execution::Value oid; - std::vector props; + columnar::Value oid; + std::vector props; static void Serialize(InArchive& arc, label_t label, - const execution::Value& oid, - const std::vector& props); + const columnar::Value& oid, + const std::vector& props); static void Deserialize(OutArchive& arc, InsertVertexRedo& redo); }; struct InsertEdgeRedo { label_t src_label; - execution::Value src; + columnar::Value src; label_t dst_label; - execution::Value dst; + columnar::Value dst; label_t edge_label; - std::vector properties; + std::vector properties; static void Serialize(InArchive& arc, label_t src_label, - const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, - const std::vector& properties); + const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, + const std::vector& properties); static void Deserialize(OutArchive& arc, InsertEdgeRedo& redo); }; struct UpdateVertexPropRedo { label_t label; - execution::Value oid; + columnar::Value oid; int prop_id; - execution::Value value; + columnar::Value value; static void Serialize(InArchive& arc, label_t label, - const execution::Value& oid, int prop_id, - const execution::Value& value); + const columnar::Value& oid, int prop_id, + const columnar::Value& value); static void Deserialize(OutArchive& arc, UpdateVertexPropRedo& redo); }; struct UpdateEdgePropRedo { label_t src_label; - execution::Value src; + columnar::Value src; label_t dst_label; - execution::Value dst; + columnar::Value dst; label_t edge_label; int32_t oe_offset, ie_offset; int prop_id; - execution::Value value; + columnar::Value value; static void Serialize(InArchive& arc, label_t src_label, - const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, + const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int prop_id, - const execution::Value& value); + const columnar::Value& value); static void Deserialize(OutArchive& arc, UpdateEdgePropRedo& redo); }; struct RemoveVertexRedo { label_t label; - execution::Value oid; + columnar::Value oid; static void Serialize(InArchive& arc, label_t label, - const execution::Value& oid); + const columnar::Value& oid); static void Deserialize(OutArchive& arc, RemoveVertexRedo& redo); }; struct RemoveEdgeRedo { label_t src_label; - execution::Value src; + columnar::Value src; label_t dst_label; - execution::Value dst; + columnar::Value dst; label_t edge_label; int32_t oe_offset, ie_offset; static void Serialize(InArchive& arc, label_t src_label, - const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, + const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset); static void Deserialize(OutArchive& arc, RemoveEdgeRedo& redo); }; diff --git a/include/neug/transaction/wal/wal_builder.h b/include/neug/transaction/wal/wal_builder.h index 89c16e7d0..05d600545 100644 --- a/include/neug/transaction/wal/wal_builder.h +++ b/include/neug/transaction/wal/wal_builder.h @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/operation_params.h" #include "neug/transaction/transaction_utils.h" #include "neug/transaction/wal/wal.h" @@ -61,22 +61,22 @@ class WalBuilder { const std::string& edge_type); // --- DML logging --- - void LogInsertVertex(label_t label, const execution::Value& oid, - const std::vector& props); - void LogInsertEdge(label_t src_label, const execution::Value& src, - label_t dst_label, const execution::Value& dst, + void LogInsertVertex(label_t label, const columnar::Value& oid, + const std::vector& props); + void LogInsertEdge(label_t src_label, const columnar::Value& src, + label_t dst_label, const columnar::Value& dst, label_t edge_label, - const std::vector& properties); - void LogUpdateVertexProp(label_t label, const execution::Value& oid, - int prop_id, const execution::Value& value); - void LogUpdateEdgeProp(label_t src_label, const execution::Value& src, - label_t dst_label, const execution::Value& dst, + const std::vector& properties); + void LogUpdateVertexProp(label_t label, const columnar::Value& oid, + int prop_id, const columnar::Value& value); + void LogUpdateEdgeProp(label_t src_label, const columnar::Value& src, + label_t dst_label, const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int prop_id, - const execution::Value& value); - void LogRemoveVertex(label_t label, const execution::Value& oid); - void LogRemoveEdge(label_t src_label, const execution::Value& src, - label_t dst_label, const execution::Value& dst, + const columnar::Value& value); + void LogRemoveVertex(label_t label, const columnar::Value& oid); + void LogRemoveEdge(label_t src_label, const columnar::Value& src, + label_t dst_label, const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset); /// Checkpoint: only increments op_num, no WAL content serialized. diff --git a/include/neug/utils/encoder.h b/include/neug/utils/encoder.h index 179f45619..990ad7bd1 100644 --- a/include/neug/utils/encoder.h +++ b/include/neug/utils/encoder.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" namespace neug { diff --git a/include/neug/utils/function_type.h b/include/neug/utils/function_type.h index b5bff46a4..4b24c2a11 100644 --- a/include/neug/utils/function_type.h +++ b/include/neug/utils/function_type.h @@ -20,9 +20,12 @@ #include #include +#include "neug/columnar/value.h" + namespace neug { namespace execution { -class Value; + +using columnar::Value; using neug_func_exec_t = Value (*)(const std::vector&); diff --git a/include/neug/utils/id_indexer.h b/include/neug/utils/id_indexer.h index 20fda3590..9050d5af1 100644 --- a/include/neug/utils/id_indexer.h +++ b/include/neug/utils/id_indexer.h @@ -32,7 +32,7 @@ limitations under the License. #include "flat_hash_map/flat_hash_map.hpp" #include "glog/logging.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/container/container_utils.h" #include "neug/storages/container/i_container.h" #include "neug/storages/module/module.h" @@ -168,8 +168,8 @@ struct GHash { }; template <> -struct GHash { - size_t operator()(const execution::Value& val) const { +struct GHash { + size_t operator()(const columnar::Value& val) const { if (val.IsNull()) { return 0; } @@ -346,7 +346,7 @@ class LFIndexer { size_t size() const { return num_elements_.load(); } DataTypeId get_type() const { return keys_->type(); } - INDEX_T insert(const execution::Value& oid, bool insert_safe) { + INDEX_T insert(const columnar::Value& oid, bool insert_safe) { assert(oid.type().id() == get_type()); if (insert_safe) { @@ -378,7 +378,7 @@ class LFIndexer { return ind; } - INDEX_T get_index(const execution::Value& oid) const { + INDEX_T get_index(const columnar::Value& oid) const { assert(oid.type().id() == get_type()); auto* indices_ptr = indices_->data(); size_t index = @@ -396,7 +396,7 @@ class LFIndexer { } } - bool get_index(const execution::Value& oid, INDEX_T& ret) const { + bool get_index(const columnar::Value& oid, INDEX_T& ret) const { if (indices_->size() == 0) { return false; } @@ -420,7 +420,7 @@ class LFIndexer { return false; } - bool contains(const execution::Value& oid) const { + bool contains(const columnar::Value& oid) const { assert(oid.type().id() == get_type()); auto* indices_ptr = indices_->data(); size_t index = @@ -437,7 +437,7 @@ class LFIndexer { } } - execution::Value get_key(const INDEX_T& index) const { + columnar::Value get_key(const INDEX_T& index) const { return keys_->get_any(index); } @@ -459,7 +459,7 @@ class LFIndexer { DataType pk_type_; ska::ska::prime_number_hash_policy hash_policy_; - GHash hasher_; + GHash hasher_; }; template @@ -468,10 +468,10 @@ class IdIndexerBase { IdIndexerBase() = default; virtual ~IdIndexerBase() = default; virtual DataTypeId get_type() const = 0; - virtual void _add(const execution::Value& oid) = 0; - virtual bool add(const execution::Value& oid, INDEX_T& lid) = 0; - virtual bool get_key(const INDEX_T& lid, execution::Value& oid) const = 0; - virtual bool get_index(const execution::Value& oid, INDEX_T& lid) const = 0; + virtual void _add(const columnar::Value& oid) = 0; + virtual bool add(const columnar::Value& oid, INDEX_T& lid) = 0; + virtual bool get_key(const INDEX_T& lid, columnar::Value& oid) const = 0; + virtual bool get_index(const columnar::Value& oid, INDEX_T& lid) const = 0; virtual size_t size() const = 0; }; @@ -489,32 +489,32 @@ class IdIndexer : public IdIndexerBase { if constexpr (std::is_same_v) { return DataTypeId::kVarchar; } else { - return execution::ValueConverter::type().id(); + return columnar::ValueConverter::type().id(); } } - void _add(const execution::Value& oid) override { + void _add(const columnar::Value& oid) override { assert(get_type() == oid.type().id()); KEY_T oid_ = oid.GetValue(); _add(oid_); } - bool add(const execution::Value& oid, INDEX_T& lid) override { + bool add(const columnar::Value& oid, INDEX_T& lid) override { assert(get_type() == oid.type().id()); KEY_T oid_ = oid.GetValue(); return add(oid_, lid); } - bool get_key(const INDEX_T& lid, execution::Value& oid) const override { + bool get_key(const INDEX_T& lid, columnar::Value& oid) const override { KEY_T oid_; bool flag = get_key(lid, oid_); if (flag) { - oid = execution::Value::CreateValue(oid_); + oid = columnar::Value::CreateValue(oid_); } return flag; } - bool get_index(const execution::Value& oid, INDEX_T& lid) const override { + bool get_index(const columnar::Value& oid, INDEX_T& lid) const override { assert(get_type() == oid.type().id()); KEY_T oid_ = oid.GetValue(); return get_index(oid_, lid); diff --git a/include/neug/utils/io/read/common/file_reader.h b/include/neug/utils/io/read/common/file_reader.h index b62284f80..5fa86f5ed 100644 --- a/include/neug/utils/io/read/common/file_reader.h +++ b/include/neug/utils/io/read/common/file_reader.h @@ -17,7 +17,7 @@ #include -#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/utils/io/read/common/read_state.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/result.h" diff --git a/include/neug/utils/io/read/common/row_expression_filter.h b/include/neug/utils/io/read/common/row_expression_filter.h index 81acad54f..29e0bc2d6 100644 --- a/include/neug/utils/io/read/common/row_expression_filter.h +++ b/include/neug/utils/io/read/common/row_expression_filter.h @@ -20,7 +20,7 @@ #include #include -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" #include "neug/generated/proto/plan/expr.pb.h" namespace neug { @@ -33,23 +33,23 @@ class RowExpressionFilter { RowExpressionFilter(const ::common::Expression& expr, const std::unordered_map& column_index); - bool eval(const execution::DataChunk& chunk, size_t row) const; + bool eval(const columnar::DataChunk& chunk, size_t row) const; private: - std::function evaluator_; + std::function evaluator_; }; -execution::DataChunk filter_chunk( - const execution::DataChunk& input, +columnar::DataChunk filter_chunk( + const columnar::DataChunk& input, const std::shared_ptr<::common::Expression>& filter_expr, const std::vector& column_names); -execution::DataChunk project_chunk( - const execution::DataChunk& input, +columnar::DataChunk project_chunk( + const columnar::DataChunk& input, const std::vector& column_names, const std::vector& project_columns); -execution::DataChunk read_all_chunks( +columnar::DataChunk read_all_chunks( const std::vector>& suppliers); } // namespace reader diff --git a/include/neug/utils/pb_utils.h b/include/neug/utils/pb_utils.h index a834b3f45..63a652594 100644 --- a/include/neug/utils/pb_utils.h +++ b/include/neug/utils/pb_utils.h @@ -19,6 +19,7 @@ #include #include +#include "neug/columnar/value.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/generated/proto/plan/cypher_ddl.pb.h" #include "neug/generated/proto/plan/physical.pb.h" @@ -32,9 +33,6 @@ class Value; } // namespace common namespace neug { -namespace execution { -class Value; -} std::vector parse_result_schema_column_names( const std::string& result_schema); @@ -49,7 +47,7 @@ bool multiplicity_to_storage_strategy( const ::physical::CreateEdgeSchema::Multiplicity& multiplicity, EdgeStrategy& oe_strategy, EdgeStrategy& ie_strategy); -neug::result>> +neug::result>> property_defs_to_value( const google::protobuf::RepeatedPtrField<::physical::PropertyDef>& properties); diff --git a/include/neug/utils/property/column.h b/include/neug/utils/property/column.h index 535b231a4..4988fce16 100644 --- a/include/neug/utils/property/column.h +++ b/include/neug/utils/property/column.h @@ -30,8 +30,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/config.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/checkpoint.h" #include "neug/storages/container/container_utils.h" #include "neug/storages/container/file_header.h" @@ -59,7 +59,7 @@ class ColumnBase : public Module { virtual size_t size() const = 0; virtual void resize(size_t size) = 0; - virtual void resize(size_t size, const execution::Value& default_value) = 0; + virtual void resize(size_t size, const columnar::Value& default_value) = 0; virtual DataTypeId type() const = 0; @@ -67,10 +67,10 @@ class ColumnBase : public Module { // new value, which can happen when the value is not fixed length. If the // value is fixed length, we should already have enough space allocated, so // insert_safe can be false. - virtual void set_any(size_t index, const execution::Value& value, + virtual void set_any(size_t index, const columnar::Value& value, bool insert_safe) = 0; - virtual execution::Value get_any(size_t index) const = 0; + virtual columnar::Value get_any(size_t index) const = 0; virtual void ingest(uint32_t index, OutArchive& arc) = 0; }; @@ -107,7 +107,7 @@ class TypedColumn : public ColumnBase { // Assume it is safe to insert the default value even if it is reserving, // since user could always override - void resize(size_t size, const execution::Value& default_value) override { + void resize(size_t size, const columnar::Value& default_value) override { if (default_value.type().id() != type()) { THROW_RUNTIME_ERROR("Default value type does not match column type"); } @@ -121,7 +121,7 @@ class TypedColumn : public ColumnBase { } DataTypeId type() const override { - return execution::ValueConverter::type().id(); + return columnar::ValueConverter::type().id(); } void set_value(size_t index, const T& val) { @@ -132,7 +132,7 @@ class TypedColumn : public ColumnBase { } } - void set_any(size_t index, const execution::Value& value, + void set_any(size_t index, const columnar::Value& value, bool insert_safe) override { if (value.IsNull()) { set_value(index, T()); @@ -147,8 +147,8 @@ class TypedColumn : public ColumnBase { return reinterpret_cast(buffer_->GetData())[index]; } - execution::Value get_any(size_t index) const override { - return execution::Value::CreateValue(get_view(index)); + columnar::Value get_any(size_t index) const override { + return columnar::Value::CreateValue(get_view(index)); } void ingest(uint32_t index, OutArchive& arc) override { @@ -212,17 +212,17 @@ class TypedColumn : public ColumnBase { ModuleDescriptor Dump(Checkpoint& ckp) override { return ModuleDescriptor(); } size_t size() const override { return 0; } void resize(size_t size) override {} - void resize(size_t size, const execution::Value& default_value) override {} + void resize(size_t size, const columnar::Value& default_value) override {} DataTypeId type() const override { return DataTypeId::kEmpty; } - void set_any(size_t index, const execution::Value& value, + void set_any(size_t index, const columnar::Value& value, bool insert_safe) override {} void set_value(size_t index, const EmptyType& value) {} - execution::Value get_any(size_t index) const override { - return execution::Value(DataType::EMPTY); + columnar::Value get_any(size_t index) const override { + return columnar::Value(DataType::EMPTY); } EmptyType get_view(size_t index) const { return EmptyType(); } @@ -411,7 +411,7 @@ class TypedColumn : public ColumnBase { size_ = size; } - void resize(size_t size, const execution::Value& default_value) override { + void resize(size_t size, const columnar::Value& default_value) override { if (default_value.type().id() != type()) { THROW_RUNTIME_ERROR("Default value type does not match column type"); } @@ -464,7 +464,7 @@ class TypedColumn : public ColumnBase { // When insert_safe is set to true, concurrency control should be guaranteed // by caller. - void set_any(size_t idx, const execution::Value& value, + void set_any(size_t idx, const columnar::Value& value, bool insert_safe) override { if (idx >= size_) { THROW_RUNTIME_ERROR("Index out of range"); @@ -500,8 +500,8 @@ class TypedColumn : public ColumnBase { return std::string_view(raw_data + item.offset, item.length); } - execution::Value get_any(size_t index) const override { - return execution::Value::STRING(std::string(get_view(index))); + columnar::Value get_any(size_t index) const override { + return columnar::Value::STRING(std::string(get_view(index))); } void ingest(uint32_t index, OutArchive& arc) override { @@ -586,7 +586,7 @@ class RefColumnBase { kExternal, }; virtual ~RefColumnBase() {} - virtual execution::Value get_any(size_t index) const = 0; + virtual columnar::Value get_any(size_t index) const = 0; virtual DataTypeId type() const = 0; virtual ColType col_type() const = 0; }; @@ -607,12 +607,12 @@ class TypedRefColumn : public RefColumnBase { return basic_buffer[index]; } - execution::Value get_any(size_t index) const override { - return execution::Value::CreateValue(get_view(index)); + columnar::Value get_any(size_t index) const override { + return columnar::Value::CreateValue(get_view(index)); } DataTypeId type() const override { - return execution::ValueConverter::type().id(); + return columnar::ValueConverter::type().id(); } ColType col_type() const override { return ColType::kInternal; } @@ -636,8 +636,8 @@ class TypedRefColumn : public RefColumnBase { return column_.get_view(index); } - execution::Value get_any(size_t index) const override { - return execution::Value::STRING(std::string(get_view(index))); + columnar::Value get_any(size_t index) const override { + return columnar::Value::STRING(std::string(get_view(index))); } DataTypeId type() const override { return DataTypeId::kVarchar; } diff --git a/include/neug/utils/property/default_value.h b/include/neug/utils/property/default_value.h index 481469e3a..14f776a75 100644 --- a/include/neug/utils/property/default_value.h +++ b/include/neug/utils/property/default_value.h @@ -13,13 +13,11 @@ * limitations under the License. */ #pragma once +#include "neug/columnar/value.h" #include "neug/common/types.h" -namespace neug { -namespace execution { -class Value; -} // namespace execution +namespace neug { -execution::Value get_default_value(const DataType& type); +columnar::Value get_default_value(const DataType& type); } // namespace neug diff --git a/include/neug/utils/property/table.h b/include/neug/utils/property/table.h index 717a91f9f..b3e27d9b6 100644 --- a/include/neug/utils/property/table.h +++ b/include/neug/utils/property/table.h @@ -21,8 +21,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/config.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/checkpoint.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/module/module.h" @@ -62,7 +62,7 @@ class Table { void add_columns(Checkpoint& ckp, const std::vector& col_names, const std::vector& col_types, - const std::vector& default_property_values, + const std::vector& default_property_values, size_t capacity, MemoryLevel memory_level = MemoryLevel::kInMemory); @@ -78,7 +78,7 @@ class Table { const ColumnBase* get_column(const std::string& name) const; - std::vector get_row(size_t row_id) const; + std::vector get_row(size_t row_id) const; ColumnBase* get_column_by_id(size_t index); @@ -97,7 +97,7 @@ class Table { } } - void insert(size_t index, const std::vector& values, + void insert(size_t index, const std::vector& values, bool insert_safe); void resize(size_t row_num); @@ -107,7 +107,7 @@ class Table { * reserving, since user could always override. */ void resize(size_t row_num, - const std::vector& default_values); + const std::vector& default_values); void ingest(uint32_t index, OutArchive& arc); diff --git a/include/neug/utils/top_n_generator.h b/include/neug/utils/top_n_generator.h index 646e6e8f2..7e9f98e07 100644 --- a/include/neug/utils/top_n_generator.h +++ b/include/neug/utils/top_n_generator.h @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" namespace neug { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a825b860..d397abd0e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ if(ENABLE_GCOV) endif() add_subdirectory(utils) +add_subdirectory(columnar) add_subdirectory(storages) add_subdirectory(transaction) add_subdirectory(common) diff --git a/src/columnar/CMakeLists.txt b/src/columnar/CMakeLists.txt new file mode 100644 index 000000000..01d7f8791 --- /dev/null +++ b/src/columnar/CMakeLists.txt @@ -0,0 +1,6 @@ +file(GLOB_RECURSE COLUMNAR_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cc") +add_library(neug_columnar OBJECT ${COLUMNAR_SRC_FILES}) +add_dependencies(neug_columnar neug_proto) +set(ALL_OBJECT_FILES + ${ALL_OBJECT_FILES} $ + PARENT_SCOPE) diff --git a/src/execution/common/columns/columns_utils.cc b/src/columnar/columns/columns_utils.cc similarity index 77% rename from src/execution/common/columns/columns_utils.cc rename to src/columnar/columns/columns_utils.cc index 1faca69a9..e1996df7b 100644 --- a/src/execution/common/columns/columns_utils.cc +++ b/src/columnar/columns/columns_utils.cc @@ -13,18 +13,18 @@ * limitations under the License. */ -#include "neug/execution/common/columns/columns_utils.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/list_columns.h" -#include "neug/execution/common/columns/path_columns.h" -#include "neug/execution/common/columns/struct_columns.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/utils/exception/exception.h" namespace neug { -namespace execution { -std::shared_ptr ColumnsUtils::create_builder( +namespace columnar { +std::shared_ptr ColumnsUtils::create_builder( const DataType& type) { switch (type.id()) { #define TYPE_DISPATCHER(enum_val, type) \ @@ -58,5 +58,5 @@ std::shared_ptr ColumnsUtils::create_builder( return nullptr; } } -} // namespace execution +} // namespace columnar } // namespace neug \ No newline at end of file diff --git a/src/execution/common/columns/edge_columns.cc b/src/columnar/columns/edge_columns.cc similarity index 92% rename from src/execution/common/columns/edge_columns.cc rename to src/columnar/columns/edge_columns.cc index 4adc7cebb..2a746195b 100644 --- a/src/execution/common/columns/edge_columns.cc +++ b/src/columnar/columns/edge_columns.cc @@ -13,13 +13,13 @@ * limitations under the License. */ -#include "neug/execution/common/columns/edge_columns.h" +#include "neug/columnar/columns/edge_columns.h" namespace neug { -namespace execution { +namespace columnar { -std::shared_ptr SDSLEdgeColumn::shuffle( +std::shared_ptr SDSLEdgeColumn::shuffle( const sel_vec_t& offsets) const { SDSLEdgeColumnBuilder builder(dir_, label_); builder.reserve(offsets.size()); @@ -42,7 +42,7 @@ std::shared_ptr SDSLEdgeColumn::shuffle( return builder.finish(); } -std::shared_ptr SDSLEdgeColumn::optional_shuffle( +std::shared_ptr SDSLEdgeColumn::optional_shuffle( const sel_vec_t& offsets) const { SDSLEdgeColumnBuilder builder(dir_, label_); builder.reserve(offsets.size()); @@ -62,15 +62,14 @@ std::shared_ptr SDSLEdgeColumn::optional_shuffle( return builder.finish(); } -std::shared_ptr SDSLEdgeColumnBuilder::finish() { +std::shared_ptr SDSLEdgeColumnBuilder::finish() { auto col = std::make_shared(dir_, label_); col->edges_ = std::move(edges_); col->is_optional_ = is_optional_; return col; } -std::shared_ptr MSEdgeColumn::shuffle( - const sel_vec_t& offsets) const { +std::shared_ptr MSEdgeColumn::shuffle(const sel_vec_t& offsets) const { if (labels_.size() == 1) { BDSLEdgeColumnBuilder builder(labels_[0]); builder.reserve(offsets.size()); @@ -152,7 +151,7 @@ std::shared_ptr MSEdgeColumn::shuffle( } } -std::shared_ptr MSEdgeColumn::optional_shuffle( +std::shared_ptr MSEdgeColumn::optional_shuffle( const sel_vec_t& offsets) const { if (labels_.size() == 1) { BDSLEdgeColumnBuilder builder(labels_[0]); @@ -213,7 +212,7 @@ std::shared_ptr MSEdgeColumn::optional_shuffle( } } -std::shared_ptr BDSLEdgeColumn::shuffle( +std::shared_ptr BDSLEdgeColumn::shuffle( const sel_vec_t& offsets) const { BDSLEdgeColumnBuilder builder(label_); builder.reserve(offsets.size()); @@ -238,7 +237,7 @@ std::shared_ptr BDSLEdgeColumn::shuffle( return builder.finish(); } -std::shared_ptr BDSLEdgeColumn::optional_shuffle( +std::shared_ptr BDSLEdgeColumn::optional_shuffle( const sel_vec_t& offsets) const { BDSLEdgeColumnBuilder builder(label_); builder.reserve(offsets.size()); @@ -259,7 +258,7 @@ std::shared_ptr BDSLEdgeColumn::optional_shuffle( return builder.finish(); } -std::shared_ptr SDMLEdgeColumn::shuffle( +std::shared_ptr SDMLEdgeColumn::shuffle( const sel_vec_t& offsets) const { SDMLEdgeColumnBuilder builder(dir_, labels_); builder.reserve(offsets.size()); @@ -284,7 +283,7 @@ std::shared_ptr SDMLEdgeColumn::shuffle( return builder.finish(); } -std::shared_ptr SDMLEdgeColumn::optional_shuffle( +std::shared_ptr SDMLEdgeColumn::optional_shuffle( const sel_vec_t& offsets) const { SDMLEdgeColumnBuilder builder(dir_, labels_); builder.reserve(offsets.size()); @@ -305,7 +304,7 @@ std::shared_ptr SDMLEdgeColumn::optional_shuffle( return builder.finish(); } -std::shared_ptr BDMLEdgeColumn::shuffle( +std::shared_ptr BDMLEdgeColumn::shuffle( const sel_vec_t& offsets) const { BDMLEdgeColumnBuilder builder(labels_); builder.reserve(offsets.size()); @@ -330,7 +329,7 @@ std::shared_ptr BDMLEdgeColumn::shuffle( return builder.finish(); } -std::shared_ptr BDMLEdgeColumn::optional_shuffle( +std::shared_ptr BDMLEdgeColumn::optional_shuffle( const sel_vec_t& offsets) const { BDMLEdgeColumnBuilder builder(labels_); builder.reserve(offsets.size()); @@ -351,6 +350,6 @@ std::shared_ptr BDMLEdgeColumn::optional_shuffle( return builder.finish(); } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/src/execution/common/columns/list_columns.cc b/src/columnar/columns/list_columns.cc similarity index 87% rename from src/execution/common/columns/list_columns.cc rename to src/columnar/columns/list_columns.cc index d15ee278a..4b26b264a 100644 --- a/src/execution/common/columns/list_columns.cc +++ b/src/columnar/columns/list_columns.cc @@ -13,17 +13,16 @@ * limitations under the License. */ -#include "neug/execution/common/columns/list_columns.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/struct_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/utils/exception/exception.h" namespace neug { -namespace execution { +namespace columnar { -std::pair, sel_vec_t> ListColumn::unfold() - const { +std::pair, sel_vec_t> ListColumn::unfold() const { switch (elem_type_.id()) { #define TYPE_DISPATCHER(enum_val, type) \ case DataTypeId::enum_val: \ @@ -96,8 +95,7 @@ std::pair, sel_vec_t> ListColumn::unfold() return {nullptr, sel_vec_t()}; } } -std::shared_ptr ListColumn::shuffle( - const sel_vec_t& offsets) const { +std::shared_ptr ListColumn::shuffle(const sel_vec_t& offsets) const { auto ptr = std::make_shared(elem_type_); vector_t new_items(offsets.size()); for (size_t i = 0; i < offsets.size(); ++i) { @@ -108,5 +106,5 @@ std::shared_ptr ListColumn::shuffle( return ptr; } -} // namespace execution +} // namespace columnar } // namespace neug \ No newline at end of file diff --git a/src/execution/common/columns/path_columns.cc b/src/columnar/columns/path_columns.cc similarity index 85% rename from src/execution/common/columns/path_columns.cc rename to src/columnar/columns/path_columns.cc index 36a9f1198..893380169 100644 --- a/src/execution/common/columns/path_columns.cc +++ b/src/columnar/columns/path_columns.cc @@ -13,15 +13,14 @@ * limitations under the License. */ -#include "neug/execution/common/columns/path_columns.h" +#include "neug/columnar/columns/path_columns.h" #include namespace neug { -namespace execution { +namespace columnar { -std::shared_ptr PathColumn::shuffle( - const sel_vec_t& offsets) const { +std::shared_ptr PathColumn::shuffle(const sel_vec_t& offsets) const { if (is_optional_) { PathColumnBuilder builder(true); builder.reserve(offsets.size()); @@ -44,7 +43,7 @@ std::shared_ptr PathColumn::shuffle( } } -std::shared_ptr PathColumn::optional_shuffle( +std::shared_ptr PathColumn::optional_shuffle( const sel_vec_t& offsets) const { PathColumnBuilder builder(true); builder.reserve(offsets.size()); @@ -59,5 +58,5 @@ std::shared_ptr PathColumn::optional_shuffle( return builder.finish(); } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/src/execution/common/columns/struct_columns.cc b/src/columnar/columns/struct_columns.cc similarity index 86% rename from src/execution/common/columns/struct_columns.cc rename to src/columnar/columns/struct_columns.cc index 5b8d8d0ad..d065c5a72 100644 --- a/src/execution/common/columns/struct_columns.cc +++ b/src/columnar/columns/struct_columns.cc @@ -13,14 +13,13 @@ * limitations under the License. */ -#include "neug/execution/common/columns/struct_columns.h" -#include "neug/execution/common/columns/columns_utils.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/columns_utils.h" namespace neug { -namespace execution { -std::shared_ptr StructColumn::shuffle( - const sel_vec_t& offsets) const { - std::vector> shuffled_children; +namespace columnar { +std::shared_ptr StructColumn::shuffle(const sel_vec_t& offsets) const { + std::vector> shuffled_children; for (const auto& child : children_) { shuffled_children.emplace_back(child->shuffle(offsets)); } @@ -37,9 +36,9 @@ std::shared_ptr StructColumn::shuffle( return shuffled_col; } -std::shared_ptr StructColumn::optional_shuffle( +std::shared_ptr StructColumn::optional_shuffle( const sel_vec_t& offsets) const { - std::vector> shuffled_children; + std::vector> shuffled_children; for (const auto& child : children_) { shuffled_children.emplace_back(child->optional_shuffle(offsets)); } @@ -102,7 +101,7 @@ void StructColumnBuilder::push_back_null() { ++current_size_; } -std::shared_ptr StructColumnBuilder::finish() { +std::shared_ptr StructColumnBuilder::finish() { auto struct_col = std::make_shared(); struct_col->type_ = type_; for (const auto& child_builder : child_builders_) { @@ -114,5 +113,5 @@ std::shared_ptr StructColumnBuilder::finish() { return struct_col; } -} // namespace execution +} // namespace columnar } // namespace neug \ No newline at end of file diff --git a/src/execution/common/columns/vertex_columns.cc b/src/columnar/columns/vertex_columns.cc similarity index 90% rename from src/execution/common/columns/vertex_columns.cc rename to src/columnar/columns/vertex_columns.cc index f42135633..c66c16e2c 100644 --- a/src/execution/common/columns/vertex_columns.cc +++ b/src/columnar/columns/vertex_columns.cc @@ -13,12 +13,12 @@ * limitations under the License. */ -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" namespace neug { -namespace execution { +namespace columnar { -std::shared_ptr SLVertexColumn::shuffle( +std::shared_ptr SLVertexColumn::shuffle( const sel_vec_t& offsets) const { MSVertexColumnBuilder builder(label_); builder.reserve(offsets.size()); @@ -39,7 +39,7 @@ std::shared_ptr SLVertexColumn::shuffle( return builder.finish(); } -std::shared_ptr SLVertexColumn::optional_shuffle( +std::shared_ptr SLVertexColumn::optional_shuffle( const sel_vec_t& offsets) const { MSVertexColumnBuilder builder(label_); builder.reserve(offsets.size()); @@ -91,7 +91,7 @@ bool SLVertexColumn::generate_dedup_offset(sel_vec_t& offsets) const { return true; } -std::pair, vector_t> +std::pair, vector_t> SLVertexColumn::generate_aggregate_offset() const { vector_t offsets; MSVertexColumnBuilder builder(label_); @@ -114,9 +114,9 @@ SLVertexColumn::generate_aggregate_offset() const { return std::make_pair(builder.finish(), std::move(offsets)); } -std::shared_ptr SLVertexColumn::union_col( - std::shared_ptr other) const { - CHECK(other->column_type() == ContextColumnType::kVertex); +std::shared_ptr SLVertexColumn::union_col( + std::shared_ptr other) const { + CHECK(other->column_type() == ColumnKind::kVertex); const IVertexColumn& vertex_column = *std::dynamic_pointer_cast(other); if (vertex_column.vertex_column_type() == VertexColumnType::kSingle) { @@ -163,7 +163,7 @@ std::shared_ptr SLVertexColumn::union_col( return builder.finish(); } -std::shared_ptr MSVertexColumn::shuffle( +std::shared_ptr MSVertexColumn::shuffle( const sel_vec_t& offsets) const { MLVertexColumnBuilderOpt builder(this->get_labels_set()); builder.reserve(offsets.size()); @@ -178,7 +178,7 @@ std::shared_ptr MSVertexColumn::shuffle( return builder.finish(); } -std::shared_ptr MSVertexColumn::optional_shuffle( +std::shared_ptr MSVertexColumn::optional_shuffle( const sel_vec_t& offsets) const { MLVertexColumnBuilderOpt builder(this->get_labels_set()); builder.reserve(offsets.size()); @@ -197,7 +197,7 @@ std::shared_ptr MSVertexColumn::optional_shuffle( return builder.finish(); } -std::shared_ptr MSVertexColumnBuilder::finish() { +std::shared_ptr MSVertexColumnBuilder::finish() { if (!cur_list_.empty()) { vertices_.emplace_back(cur_label_, std::move(cur_list_)); cur_list_.clear(); @@ -241,7 +241,7 @@ bool MSVertexColumn::generate_dedup_offset(sel_vec_t& offsets) const { } return true; } -std::shared_ptr MLVertexColumn::shuffle( +std::shared_ptr MLVertexColumn::shuffle( const sel_vec_t& offsets) const { MLVertexColumnBuilderOpt builder(this->get_labels_set()); builder.reserve(offsets.size()); @@ -256,7 +256,7 @@ std::shared_ptr MLVertexColumn::shuffle( return builder.finish(); } -std::shared_ptr MLVertexColumn::optional_shuffle( +std::shared_ptr MLVertexColumn::optional_shuffle( const sel_vec_t& offsets) const { MLVertexColumnBuilderOpt builder(this->get_labels_set()); builder.reserve(offsets.size()); @@ -289,7 +289,7 @@ bool MLVertexColumn::generate_dedup_offset(sel_vec_t& offsets) const { return true; } -std::shared_ptr MLVertexColumnBuilder::finish() { +std::shared_ptr MLVertexColumnBuilder::finish() { auto ret = std::make_shared(); ret->vertices_.swap(vertices_); ret->labels_.swap(labels_); @@ -297,6 +297,6 @@ std::shared_ptr MLVertexColumnBuilder::finish() { return ret; } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/src/execution/common/data_chunk.cc b/src/columnar/data_chunk.cc similarity index 90% rename from src/execution/common/data_chunk.cc rename to src/columnar/data_chunk.cc index 2b3505eaf..799ac19aa 100644 --- a/src/execution/common/data_chunk.cc +++ b/src/columnar/data_chunk.cc @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" #include @@ -23,11 +23,11 @@ namespace neug { -namespace execution { +namespace columnar { void DataChunk::clear() { columns.clear(); } -void DataChunk::set(int alias, std::shared_ptr col) { +void DataChunk::set(int alias, std::shared_ptr col) { if (alias < 0) { THROW_RUNTIME_ERROR("DataChunk::set requires alias >= 0, got " + std::to_string(alias)); @@ -41,7 +41,7 @@ void DataChunk::set(int alias, std::shared_ptr col) { columns[alias] = std::move(col); } -std::shared_ptr DataChunk::get(int alias) const { +std::shared_ptr DataChunk::get(int alias) const { if (alias < 0 || alias >= static_cast(columns.size())) { THROW_INTERNAL_EXCEPTION( "alias out of range: " + std::to_string(alias) + @@ -75,7 +75,7 @@ size_t DataChunk::row_num() const { size_t DataChunk::col_num() const { return columns.size(); } void DataChunk::reshuffle(const sel_vec_t& offsets) { - std::vector> new_cols; + std::vector> new_cols; new_cols.reserve(columns.size()); for (size_t i = 0; i < columns.size(); ++i) { if (columns[i] == nullptr) { @@ -98,7 +98,7 @@ void DataChunk::reshuffle(const sel_vec_t& offsets) { } void DataChunk::optional_reshuffle(const sel_vec_t& offsets) { - std::vector> new_cols; + std::vector> new_cols; new_cols.reserve(columns.size()); for (size_t i = 0; i < columns.size(); ++i) { if (columns[i] == nullptr) { @@ -131,6 +131,6 @@ DataChunk DataChunk::union_chunk(const DataChunk& other) const { return out; } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/src/execution/common/types/graph_types.cc b/src/columnar/graph_types.cc similarity index 98% rename from src/execution/common/types/graph_types.cc rename to src/columnar/graph_types.cc index cc92a431e..a59cc1941 100644 --- a/src/execution/common/types/graph_types.cc +++ b/src/columnar/graph_types.cc @@ -14,12 +14,12 @@ * limitations under the License. */ -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/graph_types.h" #include "neug/utils/property/types.h" namespace neug { -namespace execution { +namespace columnar { int64_t encode_unique_vertex_id(label_t label_id, vid_t vid) { // encode label_id and vid to a unique vid GlobalId global_id(label_id, vid); @@ -248,5 +248,5 @@ VertexRecord Path::end_node() const { return VertexRecord{impl_->v_label_, impl_->vid_}; } -} // namespace execution +} // namespace columnar } // namespace neug diff --git a/src/execution/common/types/value.cc b/src/columnar/value.cc similarity index 92% rename from src/execution/common/types/value.cc rename to src/columnar/value.cc index b43d41f90..76bc4a495 100644 --- a/src/execution/common/types/value.cc +++ b/src/columnar/value.cc @@ -19,14 +19,14 @@ * by Liu Lexiao in 2026 to support Neug-specific features. */ -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/encoder.h" #include "neug/utils/exception/exception.h" #include "neug/utils/serialization/in_archive.h" #include "neug/utils/serialization/out_archive.h" namespace neug { -namespace execution { +namespace columnar { enum class ExtraValueInfoType : uint8_t { INVALID_TYPE_INFO = 0, STRING_VALUE_INFO = 1, @@ -638,64 +638,64 @@ Value Value::FromJson(const rapidjson::Value& json_value, case DataTypeId::kBoolean: { // If the value is 1/0, treat it as boolean if (json_value.IsInt()) { - return execution::Value::BOOLEAN(json_value.GetInt() != 0); + return columnar::Value::BOOLEAN(json_value.GetInt() != 0); } - return execution::Value::BOOLEAN(json_value.GetBool()); + return columnar::Value::BOOLEAN(json_value.GetBool()); } case DataTypeId::kDate: { if (json_value.IsInt64()) { - return execution::Value::DATE(Date(json_value.GetInt64())); + return columnar::Value::DATE(Date(json_value.GetInt64())); } else if (json_value.IsString()) { - return execution::Value::DATE(Date(json_value.GetString())); + return columnar::Value::DATE(Date(json_value.GetString())); } else { THROW_INVALID_ARGUMENT_EXCEPTION( "Expected an (u)int/string for Date type"); } } case DataTypeId::kDouble: { - return execution::Value::DOUBLE(json_value.GetDouble()); + return columnar::Value::DOUBLE(json_value.GetDouble()); } case DataTypeId::kFloat: { - return execution::Value::FLOAT(json_value.GetFloat()); + return columnar::Value::FLOAT(json_value.GetFloat()); } case DataTypeId::kInt32: { - return execution::Value::INT32(json_value.GetInt()); + return columnar::Value::INT32(json_value.GetInt()); } case DataTypeId::kInt64: { - return execution::Value::INT64(json_value.GetInt64()); + return columnar::Value::INT64(json_value.GetInt64()); } case DataTypeId::kUInt32: { - return execution::Value::UINT32(json_value.GetUint()); + return columnar::Value::UINT32(json_value.GetUint()); } case DataTypeId::kUInt64: { - return execution::Value::UINT64(json_value.GetUint64()); + return columnar::Value::UINT64(json_value.GetUint64()); } case DataTypeId::kVarchar: { - return execution::Value::STRING(json_value.GetString()); + return columnar::Value::STRING(json_value.GetString()); } case DataTypeId::kTimestampMs: { if (json_value.IsInt64()) { - return execution::Value::TIMESTAMPMS( - execution::timestamp_ms_t(json_value.GetInt64())); + return columnar::Value::TIMESTAMPMS( + columnar::timestamp_ms_t(json_value.GetInt64())); } else if (json_value.IsString()) { - return execution::Value::TIMESTAMPMS( - execution::timestamp_ms_t(json_value.GetString())); + return columnar::Value::TIMESTAMPMS( + columnar::timestamp_ms_t(json_value.GetString())); } else { THROW_INVALID_ARGUMENT_EXCEPTION( "Expected an (u)int64/string for TimestampMs type"); } } case DataTypeId::kList: { - std::vector values; + std::vector values; if (!json_value.IsArray()) { - return execution::Value::LIST(DataType::UNKNOWN, std::move(values)); + return columnar::Value::LIST(DataType::UNKNOWN, std::move(values)); } const auto list = json_value.GetArray(); auto child_type = ListType::GetChildType(type); for (auto item = list.begin(); item != list.end(); ++item) { values.emplace_back(FromJson(*item, child_type)); } - return execution::Value::LIST(child_type, std::move(values)); + return columnar::Value::LIST(child_type, std::move(values)); } default: THROW_NOT_IMPLEMENTED_EXCEPTION( @@ -733,7 +733,7 @@ rapidjson::Value Value::ToJson(const Value& value, #undef TYPE_DISPATCHER case neug::DataTypeId::kList: { rapidjson::Value list_doc(rapidjson::kArrayType); - const auto& list = execution::ListValue::GetChildren(value); + const auto& list = columnar::ListValue::GetChildren(value); for (size_t i = 0; i < list.size(); ++i) { list_doc.PushBack(ToJson(list[i], allocator), allocator); } @@ -859,9 +859,9 @@ Value performCastToString(const Value& input) { return Value::STRING(ret); } -} // namespace execution +} // namespace columnar -InArchive& operator<<(InArchive& in_archive, const execution::Value& value) { +InArchive& operator<<(InArchive& in_archive, const columnar::Value& value) { auto type_id = value.type().id(); if (value.IsNull()) { in_archive << DataTypeId::kEmpty; @@ -880,14 +880,14 @@ InArchive& operator<<(InArchive& in_archive, const execution::Value& value) { } else if (type_id == DataTypeId::kDouble) { in_archive << type_id << value.GetValue(); } else if (type_id == DataTypeId::kVarchar) { - in_archive << type_id << execution::StringValue::Get(value); + in_archive << type_id << columnar::StringValue::Get(value); } else if (type_id == DataTypeId::kDate) { - in_archive << type_id << value.GetValue().to_u32(); + in_archive << type_id << value.GetValue().to_u32(); } else if (type_id == DataTypeId::kTimestampMs) { in_archive << type_id - << value.GetValue().milli_second; + << value.GetValue().milli_second; } else if (type_id == DataTypeId::kInterval) { - auto interval = value.GetValue(); + auto interval = value.GetValue(); in_archive << type_id << interval.months << interval.days << interval.micros; } else { @@ -898,57 +898,57 @@ InArchive& operator<<(InArchive& in_archive, const execution::Value& value) { return in_archive; } -OutArchive& operator>>(OutArchive& out_archive, execution::Value& value) { +OutArchive& operator>>(OutArchive& out_archive, columnar::Value& value) { DataTypeId type_id; out_archive >> type_id; if (type_id == DataTypeId::kEmpty) { - value = execution::Value(); + value = columnar::Value(); } else if (type_id == DataTypeId::kBoolean) { bool tmp; out_archive >> tmp; - value = execution::Value::BOOLEAN(tmp); + value = columnar::Value::BOOLEAN(tmp); } else if (type_id == DataTypeId::kInt32) { int32_t tmp; out_archive >> tmp; - value = execution::Value::INT32(tmp); + value = columnar::Value::INT32(tmp); } else if (type_id == DataTypeId::kUInt32) { uint32_t tmp; out_archive >> tmp; - value = execution::Value::UINT32(tmp); + value = columnar::Value::UINT32(tmp); } else if (type_id == DataTypeId::kInt64) { int64_t tmp; out_archive >> tmp; - value = execution::Value::INT64(tmp); + value = columnar::Value::INT64(tmp); } else if (type_id == DataTypeId::kUInt64) { uint64_t tmp; out_archive >> tmp; - value = execution::Value::UINT64(tmp); + value = columnar::Value::UINT64(tmp); } else if (type_id == DataTypeId::kFloat) { float tmp; out_archive >> tmp; - value = execution::Value::FLOAT(tmp); + value = columnar::Value::FLOAT(tmp); } else if (type_id == DataTypeId::kDouble) { double tmp; out_archive >> tmp; - value = execution::Value::DOUBLE(tmp); + value = columnar::Value::DOUBLE(tmp); } else if (type_id == DataTypeId::kVarchar) { std::string_view tmp; out_archive >> tmp; - value = execution::Value::STRING(std::string(tmp)); + value = columnar::Value::STRING(std::string(tmp)); } else if (type_id == DataTypeId::kDate) { uint32_t date_val; out_archive >> date_val; Date d; d.from_u32(date_val); - value = execution::Value::DATE(d); + value = columnar::Value::DATE(d); } else if (type_id == DataTypeId::kTimestampMs) { int64_t dt_val; out_archive >> dt_val; - value = execution::Value::TIMESTAMPMS(DateTime(dt_val)); + value = columnar::Value::TIMESTAMPMS(DateTime(dt_val)); } else if (type_id == DataTypeId::kInterval) { Interval interval; out_archive >> interval.months >> interval.days >> interval.micros; - value = execution::Value::INTERVAL(interval); + value = columnar::Value::INTERVAL(interval); } else { THROW_NOT_SUPPORTED_EXCEPTION( std::string("Value deserialization not supported for type: ") + diff --git a/src/compiler/function/gds/project_graph_function.cpp b/src/compiler/function/gds/project_graph_function.cpp index 3f09a8046..ad3693abe 100644 --- a/src/compiler/function/gds/project_graph_function.cpp +++ b/src/compiler/function/gds/project_graph_function.cpp @@ -17,6 +17,7 @@ #include "neug/compiler/function/gds/project_graph_function.h" #include +#include "neug/columnar/columns/value_columns.h" #include "neug/compiler/common/string_format.h" #include "neug/compiler/common/types/types.h" #include "neug/compiler/common/types/value/nested.h" @@ -27,7 +28,6 @@ #include "neug/compiler/main/client_context.h" #include "neug/compiler/main/metadata_manager.h" #include "neug/compiler/main/metadata_registry.h" -#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" #include "neug/storages/graph/graph_interface.h" #include "neug/utils/exception/exception.h" @@ -273,7 +273,7 @@ function_set ShowProjectedGraphsFunction::getFunctionSet() { function->execFunc = [](const CallFuncInputBase& /*input*/, neug::IStorageInterface& /*graph*/) { neug::execution::Context out; - neug::execution::ValueColumnBuilder name_builder; + neug::columnar::ValueColumnBuilder name_builder; auto metadataManager = main::MetadataRegistry::getMetadata(); if (metadataManager == nullptr) { THROW_INVALID_ARGUMENT_EXCEPTION("Metadata manager is not set"); @@ -284,7 +284,7 @@ function_set ShowProjectedGraphsFunction::getFunctionSet() { for (const auto& [name, _] : nameToEntryMap) { name_builder.push_back_opt(name); } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(0, name_builder.finish()); out.append_chunk(std::move(chunk)); out.tag_ids = {0}; @@ -326,8 +326,8 @@ function_set ProjectedGraphInfoFunction::getFunctionSet() { function->execFunc = [](const CallFuncInputBase& input, neug::IStorageInterface& /*graph*/) { neug::execution::Context out; - neug::execution::ValueColumnBuilder name_builder; - neug::execution::ValueColumnBuilder predicate_builder; + neug::columnar::ValueColumnBuilder name_builder; + neug::columnar::ValueColumnBuilder predicate_builder; auto metadataManager = main::MetadataRegistry::getMetadata(); if (metadataManager == nullptr) { THROW_INVALID_ARGUMENT_EXCEPTION("Metadata manager is not set"); @@ -351,7 +351,7 @@ function_set ProjectedGraphInfoFunction::getFunctionSet() { name_builder.push_back_opt(std::move(triplets)); predicate_builder.push_back_opt(relInfo.predicate); } - execution::DataChunk chunk; + columnar::DataChunk chunk; chunk.set(0, name_builder.finish()); chunk.set(1, predicate_builder.finish()); out.append_chunk(std::move(chunk)); diff --git a/src/compiler/function/list/list_extract_function.cpp b/src/compiler/function/list/list_extract_function.cpp index daa7c95e9..cf1610149 100644 --- a/src/compiler/function/list/list_extract_function.cpp +++ b/src/compiler/function/list/list_extract_function.cpp @@ -22,17 +22,17 @@ #include "neug/compiler/function/list/functions/list_extract_function.h" +#include "neug/columnar/value.h" #include "neug/compiler/function/list/vector_list_functions.h" #include "neug/compiler/function/neug_scalar_function.h" #include "neug/compiler/function/scalar_function.h" -#include "neug/execution/common/types/value.h" using namespace neug::common; namespace neug { namespace function { -static int checkAndGetIndex(const execution::Value& value) { +static int checkAndGetIndex(const columnar::Value& value) { switch (value.type().id()) { case neug::DataTypeId::kUInt32: return value.GetValue(); @@ -50,7 +50,7 @@ static int checkAndGetIndex(const execution::Value& value) { } } -static execution::Value execFunc(const std::vector& args) { +static columnar::Value execFunc(const std::vector& args) { if (args.size() != 2) { THROW_RUNTIME_ERROR( "LIST_EXTRACT([], index): expect exactly 2 argument, got " + @@ -60,9 +60,9 @@ static execution::Value execFunc(const std::vector& args) { const auto& arg0 = args[0]; switch (arg0.type().id()) { case neug::DataTypeId::kStruct: - return execution::StructValue::GetChildren(arg0).at(index); + return columnar::StructValue::GetChildren(arg0).at(index); case neug::DataTypeId::kList: - return execution::ListValue::GetChildren(arg0).at(index); + return columnar::ListValue::GetChildren(arg0).at(index); default: THROW_RUNTIME_ERROR( "LIST_EXTRACT([], index): the first element should be a tuple or a " diff --git a/src/compiler/function/show_loaded_extensions_function.cpp b/src/compiler/function/show_loaded_extensions_function.cpp index efa2a56dc..a4eb6e000 100644 --- a/src/compiler/function/show_loaded_extensions_function.cpp +++ b/src/compiler/function/show_loaded_extensions_function.cpp @@ -16,8 +16,8 @@ #include "neug/compiler/function/show_loaded_extensions_function.h" #include +#include "neug/columnar/columns/value_columns.h" #include "neug/compiler/extension/extension_api.h" -#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" #include "neug/utils/exception/exception.h" @@ -46,8 +46,8 @@ function_set ShowLoadedExtensionsFunction::getFunctionSet() { const auto& ext_map = neug::extension::ExtensionAPI::getLoadedExtensions(); - neug::execution::ValueColumnBuilder name_builder; - neug::execution::ValueColumnBuilder desc_builder; + neug::columnar::ValueColumnBuilder name_builder; + neug::columnar::ValueColumnBuilder desc_builder; name_builder.reserve(ext_map.size()); desc_builder.reserve(ext_map.size()); @@ -59,7 +59,7 @@ function_set ShowLoadedExtensionsFunction::getFunctionSet() { desc_builder.push_back_opt(desc_view); } - neug::execution::DataChunk chunk; + neug::columnar::DataChunk chunk; chunk.set(0, name_builder.finish()); chunk.set(1, desc_builder.finish()); ctx.append_chunk(std::move(chunk)); diff --git a/src/compiler/function/vector_cast_functions.cpp b/src/compiler/function/vector_cast_functions.cpp index fa40f3608..e755ee76b 100644 --- a/src/compiler/function/vector_cast_functions.cpp +++ b/src/compiler/function/vector_cast_functions.cpp @@ -24,6 +24,7 @@ #include #include +#include "neug/columnar/value.h" #include "neug/compiler/binder/expression/expression_util.h" #include "neug/compiler/binder/expression/literal_expression.h" #include "neug/compiler/catalog/catalog.h" @@ -35,7 +36,6 @@ #include "neug/compiler/function/neug_scalar_function.h" #include "neug/compiler/function/scalar_function.h" #include "neug/compiler/main/client_context.h" -#include "neug/execution/common/types/value.h" #include "neug/utils/exception/exception.h" using namespace neug::common; @@ -725,14 +725,14 @@ static std::unique_ptr castBindFunc( return bindData; } -static execution::Value castFunc(const std::vector& args) { +static columnar::Value castFunc(const std::vector& args) { if (args.size() != 2) { THROW_RUNTIME_ERROR("CAST(VAL, TYPE): expect exactly 2 argument, got " + std::to_string(args.size())); } const auto& arg0 = args[0]; const auto& arg1 = args[1]; - auto type = execution::StringValue::Get(arg1); + auto type = columnar::StringValue::Get(arg1); if (type == "INT64") { return performCast(arg0); @@ -756,7 +756,7 @@ static execution::Value castFunc(const std::vector& args) { THROW_RUNTIME_ERROR(std::string("Unsupported target type for CAST: ") + std::string(type)); } - return execution::Value(DataType::SQLNULL); + return columnar::Value(DataType::SQLNULL); } function_set CastAnyFunction::getFunctionSet() { diff --git a/src/compiler/function/vector_string_functions.cpp b/src/compiler/function/vector_string_functions.cpp index f1eb3a2e9..a3474b12c 100644 --- a/src/compiler/function/vector_string_functions.cpp +++ b/src/compiler/function/vector_string_functions.cpp @@ -25,7 +25,7 @@ #include "neug/compiler/function/neug_scalar_function.h" #include "neug/compiler/function/string/functions/array_extract_function.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" using namespace neug::common; @@ -64,8 +64,7 @@ function_set UpperFunction::getFunctionSet() { return functionSet; } -execution::Value UpperFunction::Exec( - const std::vector& args) { +columnar::Value UpperFunction::Exec(const std::vector& args) { if (args.size() != 1) { THROW_RUNTIME_ERROR("UPPER: expect exactly 1 argument, got " + std::to_string(args.size())); @@ -74,9 +73,9 @@ execution::Value UpperFunction::Exec( if (val.type().id() != DataTypeId::kVarchar) { THROW_RUNTIME_ERROR("UPPER: input value is not a string"); } - std::string str(execution::StringValue::Get(val)); + std::string str(columnar::StringValue::Get(val)); std::transform(str.begin(), str.end(), str.begin(), ::toupper); - return execution::Value::STRING(str); + return columnar::Value::STRING(str); } function_set LowerFunction::getFunctionSet() { @@ -87,8 +86,7 @@ function_set LowerFunction::getFunctionSet() { return functionSet; } -execution::Value LowerFunction::Exec( - const std::vector& args) { +columnar::Value LowerFunction::Exec(const std::vector& args) { if (args.size() != 1) { THROW_RUNTIME_ERROR("LOWER: expect exactly 1 argument, got " + std::to_string(args.size())); @@ -97,9 +95,9 @@ execution::Value LowerFunction::Exec( if (val.type().id() != DataTypeId::kVarchar) { THROW_RUNTIME_ERROR("LOWER: input value is not a string"); } - std::string str(execution::StringValue::Get(val)); + std::string str(columnar::StringValue::Get(val)); std::transform(str.begin(), str.end(), str.begin(), ::tolower); - return execution::Value::STRING(str); + return columnar::Value::STRING(str); } function_set ReverseFunction::getFunctionSet() { @@ -110,8 +108,8 @@ function_set ReverseFunction::getFunctionSet() { return functionSet; } -execution::Value ReverseFunction::Exec( - const std::vector& args) { +columnar::Value ReverseFunction::Exec( + const std::vector& args) { if (args.size() != 1) { THROW_RUNTIME_ERROR("REVERSE: expect exactly 1 argument, got " + std::to_string(args.size())); @@ -120,9 +118,9 @@ execution::Value ReverseFunction::Exec( if (val.type().id() != DataTypeId::kVarchar) { THROW_RUNTIME_ERROR("REVERSE: input value is not a string"); } - std::string str(execution::StringValue::Get(val)); + std::string str(columnar::StringValue::Get(val)); std::reverse(str.begin(), str.end()); - return execution::Value::STRING(str); + return columnar::Value::STRING(str); } } // namespace function diff --git a/src/execution/CMakeLists.txt b/src/execution/CMakeLists.txt index d57f870e9..e1fc512c4 100644 --- a/src/execution/CMakeLists.txt +++ b/src/execution/CMakeLists.txt @@ -2,6 +2,7 @@ # So currently we just add all the source files to the graph_db library file(GLOB_RECURSE EXECUTION_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/common/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/execute/*.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/io/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/extension/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/expression/*.cc") diff --git a/src/execution/common/context.cc b/src/execution/common/context.cc index 97808a927..c568ccf16 100644 --- a/src/execution/common/context.cc +++ b/src/execution/common/context.cc @@ -45,8 +45,7 @@ void Context::append_chunk(DataChunk&& chunk) { chunks_.emplace_back(std::move(chunk)); } -void Context::append_chunk(DataChunk&& chunk, - std::shared_ptr head) { +void Context::append_chunk(DataChunk&& chunk, std::shared_ptr head) { chunks_.emplace_back(std::move(chunk), std::move(head)); } diff --git a/src/execution/common/context_chunk.cc b/src/execution/common/context_chunk.cc index 4a5836dff..59f11ae45 100644 --- a/src/execution/common/context_chunk.cc +++ b/src/execution/common/context_chunk.cc @@ -27,26 +27,22 @@ namespace execution { ContextChunk::ContextChunk(DataChunk&& chunk) : chunk_(std::move(chunk)) {} -ContextChunk::ContextChunk(DataChunk&& chunk, - std::shared_ptr head) +ContextChunk::ContextChunk(DataChunk&& chunk, std::shared_ptr head) : chunk_(std::move(chunk)), head_(std::move(head)) {} DataChunk& ContextChunk::chunk() { return chunk_; } const DataChunk& ContextChunk::chunk() const { return chunk_; } -std::shared_ptr& ContextChunk::head() { return head_; } +std::shared_ptr& ContextChunk::head() { return head_; } -const std::shared_ptr& ContextChunk::head() const { - return head_; -} +const std::shared_ptr& ContextChunk::head() const { return head_; } -std::vector>& ContextChunk::columns() { +std::vector>& ContextChunk::columns() { return chunk_.columns; } -const std::vector>& ContextChunk::columns() - const { +const std::vector>& ContextChunk::columns() const { return chunk_.columns; } @@ -55,7 +51,7 @@ void ContextChunk::clear() { head_.reset(); } -void ContextChunk::set(int alias, std::shared_ptr col) { +void ContextChunk::set(int alias, std::shared_ptr col) { head_ = col; if (alias < 0) { return; @@ -69,7 +65,7 @@ void ContextChunk::set(int alias, std::shared_ptr col) { chunk_.columns[alias] = std::move(col); } -std::shared_ptr ContextChunk::get(int alias) const { +std::shared_ptr ContextChunk::get(int alias) const { if (alias == -1) { return head_; } @@ -81,8 +77,7 @@ std::shared_ptr ContextChunk::get(int alias) const { return chunk_.columns[alias]; } -void ContextChunk::set_with_reshuffle(int alias, - std::shared_ptr col, +void ContextChunk::set_with_reshuffle(int alias, std::shared_ptr col, const sel_vec_t& offsets) { head_.reset(); if (alias >= 0 && chunk_.columns.size() > static_cast(alias) && @@ -120,7 +115,7 @@ size_t ContextChunk::col_num() const { return chunk_.col_num(); } void ContextChunk::reshuffle(const sel_vec_t& offsets) { auto& columns = chunk_.columns; - std::vector> new_cols; + std::vector> new_cols; new_cols.reserve(columns.size()); bool head_shuffled = false; for (size_t i = 0; i < columns.size(); ++i) { @@ -158,7 +153,7 @@ void ContextChunk::reshuffle(const sel_vec_t& offsets) { void ContextChunk::optional_reshuffle(const sel_vec_t& offsets) { auto& columns = chunk_.columns; - std::vector> new_cols; + std::vector> new_cols; new_cols.reserve(columns.size()); bool head_shuffled = false; for (size_t i = 0; i < columns.size(); ++i) { @@ -196,7 +191,7 @@ void ContextChunk::optional_reshuffle(const sel_vec_t& offsets) { ContextChunk ContextChunk::union_with(const ContextChunk& other) const { DataChunk merged = chunk_.union_chunk(other.chunk_); - std::shared_ptr merged_head; + std::shared_ptr merged_head; if (head_ != nullptr && other.head_ != nullptr) { bool aligned = false; for (size_t k = 0; k < chunk_.columns.size(); ++k) { diff --git a/src/execution/common/operators/insert/create_edge.cc b/src/execution/common/operators/insert/create_edge.cc index 918da9e7a..69e96a4a6 100644 --- a/src/execution/common/operators/insert/create_edge.cc +++ b/src/execution/common/operators/insert/create_edge.cc @@ -14,10 +14,10 @@ */ #include "neug/execution/common/operators/insert/create_edge.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/execution/common/context_chunk.h" -#include "neug/execution/common/data_chunk.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" @@ -70,7 +70,7 @@ neug::result CreateEdge::insert_edge( std::to_string(dst_label) + ", got " + std::to_string(v2.label_)); } - std::vector property_values(properties.size()); + std::vector property_values(properties.size()); for (size_t j = 0; j < properties.size(); ++j) { const auto& [prop_name, prop_expr] = properties[j]; Value value = diff --git a/src/execution/common/operators/insert/create_vertex.cc b/src/execution/common/operators/insert/create_vertex.cc index 52af604ab..44503172a 100644 --- a/src/execution/common/operators/insert/create_vertex.cc +++ b/src/execution/common/operators/insert/create_vertex.cc @@ -14,9 +14,9 @@ */ #include "neug/execution/common/operators/insert/create_vertex.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/execution/common/context_chunk.h" -#include "neug/execution/common/data_chunk.h" #include "neug/execution/expression/expr.h" #include "neug/storages/graph/graph_interface.h" namespace neug { @@ -59,7 +59,7 @@ neug::result CreateVertex::insert_vertex( } Value pk_value; - std::vector property_values(properties.size() - 1); + std::vector property_values(properties.size() - 1); // When the chunk has no rows (seed from DummySourceOpr), we still need to // execute exactly once to create the vertex from constant expressions. size_t num_rows = std::max(chunk.row_num(), (size_t) 1); diff --git a/src/execution/common/operators/retrieve/dedup.cc b/src/execution/common/operators/retrieve/dedup.cc index d3440f0b5..c8ba4500e 100644 --- a/src/execution/common/operators/retrieve/dedup.cc +++ b/src/execution/common/operators/retrieve/dedup.cc @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" #include "neug/utils/encoder.h" namespace neug { diff --git a/src/execution/common/operators/retrieve/edge_expand.cc b/src/execution/common/operators/retrieve/edge_expand.cc index e23925d5a..e8bfd1c61 100644 --- a/src/execution/common/operators/retrieve/edge_expand.cc +++ b/src/execution/common/operators/retrieve/edge_expand.cc @@ -15,7 +15,7 @@ #include "neug/execution/common/operators/retrieve/edge_expand.h" -#include "neug/execution/common/columns/value_columns.h" +#include "neug/columnar/columns/value_columns.h" #include "neug/execution/common/operators/retrieve/edge_expand_impl.h" #include "neug/execution/expression/predicates.h" #include "neug/execution/utils/opr_timer.h" @@ -468,7 +468,7 @@ neug::result EdgeExpand::expand_vertex_ep_cmp( nbr_label, edge_label, dir, ep_val, tp); } } - std::shared_ptr col = builder.finish(); + std::shared_ptr col = builder.finish(); chunk.set_with_reshuffle(params.alias, col, offsets); return chunk; } else { diff --git a/src/execution/common/operators/retrieve/intersect.cc b/src/execution/common/operators/retrieve/intersect.cc index f4482ff53..775693ff8 100644 --- a/src/execution/common/operators/retrieve/intersect.cc +++ b/src/execution/common/operators/retrieve/intersect.cc @@ -15,10 +15,10 @@ #include "neug/execution/common/operators/retrieve/intersect.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/execution/common/context_chunk.h" -#include "neug/execution/common/data_chunk.h" #include "neug/execution/utils/params.h" #include "neug/storages/graph/graph_interface.h" diff --git a/src/execution/common/operators/retrieve/join.cc b/src/execution/common/operators/retrieve/join.cc index c0acfde47..fb15f57fa 100644 --- a/src/execution/common/operators/retrieve/join.cc +++ b/src/execution/common/operators/retrieve/join.cc @@ -15,10 +15,10 @@ #include "neug/execution/common/operators/retrieve/join.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/common/types.h" -#include "neug/execution/common/columns/vertex_columns.h" #include "neug/execution/common/context_chunk.h" -#include "neug/execution/common/data_chunk.h" #include "neug/execution/utils/params.h" #include "neug/storages/graph/graph_interface.h" #include "neug/utils/encoder.h" @@ -620,9 +620,9 @@ neug::result Join::join(ContextChunk&& chunk, params.join_type == JoinKind::kAntiJoin) { if (params.left_columns.size() == 2 && chunk.get(params.left_columns[0])->column_type() == - ContextColumnType::kVertex && + ColumnKind::kVertex && chunk.get(params.left_columns[1])->column_type() == - ContextColumnType::kVertex) { + ColumnKind::kVertex) { return dual_vertex_column_semi_join(std::move(chunk), std::move(chunk2), params); } @@ -630,14 +630,14 @@ neug::result Join::join(ContextChunk&& chunk, } else if (params.join_type == JoinKind::kInnerJoin) { if (params.right_columns.size() == 1 && chunk2.get(params.right_columns[0])->column_type() == - ContextColumnType::kVertex) { + ColumnKind::kVertex) { return single_vertex_column_inner_join(std::move(chunk), std::move(chunk2), params); } else if (params.right_columns.size() == 2 && chunk2.get(params.right_columns[0])->column_type() == - ContextColumnType::kVertex && + ColumnKind::kVertex && chunk2.get(params.right_columns[1])->column_type() == - ContextColumnType::kVertex) { + ColumnKind::kVertex) { return dual_vertex_column_inner_join(std::move(chunk), std::move(chunk2), params); } else { @@ -646,14 +646,14 @@ neug::result Join::join(ContextChunk&& chunk, } else if (params.join_type == JoinKind::kLeftOuterJoin) { if (params.right_columns.size() == 1 && chunk2.get(params.right_columns[0])->column_type() == - ContextColumnType::kVertex) { + ColumnKind::kVertex) { return single_vertex_column_left_outer_join(std::move(chunk), std::move(chunk2), params); } else if (params.right_columns.size() == 2 && chunk2.get(params.right_columns[0])->column_type() == - ContextColumnType::kVertex && + ColumnKind::kVertex && chunk2.get(params.right_columns[1])->column_type() == - ContextColumnType::kVertex) { + ColumnKind::kVertex) { return dual_vertex_column_left_outer_join(std::move(chunk), std::move(chunk2), params); } else { diff --git a/src/execution/common/operators/retrieve/path_expand.cc b/src/execution/common/operators/retrieve/path_expand.cc index dce19dc11..6a9ef2df4 100644 --- a/src/execution/common/operators/retrieve/path_expand.cc +++ b/src/execution/common/operators/retrieve/path_expand.cc @@ -15,7 +15,7 @@ #include "neug/execution/common/operators/retrieve/path_expand.h" -#include "neug/execution/common/columns/path_columns.h" +#include "neug/columnar/columns/path_columns.h" #include "neug/execution/common/operators/retrieve/path_expand_impl.h" #include "neug/execution/expression/special_predicates.h" @@ -30,8 +30,7 @@ neug::result PathExpand::edge_expand_v( if (params.labels.size() == 1 && params.labels[0].src_label == params.labels[0].dst_label && - chunk.get(params.start_tag)->column_type() == - ContextColumnType::kVertex) { + chunk.get(params.start_tag)->column_type() == ColumnKind::kVertex) { auto vertex_col = dynamic_cast(chunk.get(params.start_tag).get()); if (vertex_col->vertex_column_type() == VertexColumnType::kSingle) { diff --git a/src/execution/common/operators/retrieve/path_expand_impl.cc b/src/execution/common/operators/retrieve/path_expand_impl.cc index 8b95a3c42..ef24b3114 100644 --- a/src/execution/common/operators/retrieve/path_expand_impl.cc +++ b/src/execution/common/operators/retrieve/path_expand_impl.cc @@ -21,7 +21,7 @@ namespace neug { namespace execution { -std::pair, sel_vec_t> +std::pair, sel_vec_t> iterative_expand_vertex_on_graph_view(const CsrView& view, const SLVertexColumn& input, int lower, int upper) { @@ -85,7 +85,7 @@ iterative_expand_vertex_on_graph_view(const CsrView& view, return std::make_pair(builder.finish(), std::move(offsets)); } -std::pair, sel_vec_t> +std::pair, sel_vec_t> iterative_expand_vertex_on_dual_graph_view(const CsrView& iview, const CsrView& oview, const SLVertexColumn& input, @@ -158,7 +158,7 @@ iterative_expand_vertex_on_dual_graph_view(const CsrView& iview, return std::make_pair(builder.finish(), std::move(offsets)); } -std::pair, sel_vec_t> +std::pair, sel_vec_t> path_expand_vertex_without_predicate_impl( const StorageReadInterface& graph, const SLVertexColumn& input, const std::vector& labels, Direction dir, int lower, diff --git a/src/execution/common/operators/retrieve/sink.cc b/src/execution/common/operators/retrieve/sink.cc index afa6ca5be..735c4b820 100644 --- a/src/execution/common/operators/retrieve/sink.cc +++ b/src/execution/common/operators/retrieve/sink.cc @@ -15,14 +15,14 @@ #include "neug/execution/common/operators/retrieve/sink.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/list_columns.h" -#include "neug/execution/common/columns/path_columns.h" -#include "neug/execution/common/columns/struct_columns.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/value.h" #include "neug/execution/common/context.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/graph/graph_interface.h" @@ -326,7 +326,7 @@ static void add_primitive_column(const ValueColumn& col, } } -static void add_column(const std::shared_ptr& col, +static void add_column(const std::shared_ptr& col, const StorageReadInterface& graph, neug::Array* column) { switch (col->elem_type().id()) { case DataTypeId::kBoolean: { @@ -525,7 +525,7 @@ void Sink::sink_results(const Context& ctx, const StorageReadInterface& graph, response->mutable_arrays()->Reserve(ctx.tag_ids.size()); for (size_t i : ctx.tag_ids) { // Merge column across all chunks via union_col. - std::shared_ptr merged; + std::shared_ptr merged; for (size_t c = 0; c < ctx.chunk_num(); ++c) { auto col = ctx.chunk(c).get(i); if (col == nullptr) diff --git a/src/execution/common/operators/retrieve/unfold.cc b/src/execution/common/operators/retrieve/unfold.cc index 203a9a2c3..88dd60ffc 100644 --- a/src/execution/common/operators/retrieve/unfold.cc +++ b/src/execution/common/operators/retrieve/unfold.cc @@ -15,7 +15,7 @@ #include "neug/execution/common/operators/retrieve/unfold.h" -#include "neug/execution/common/columns/list_columns.h" +#include "neug/columnar/columns/list_columns.h" #include "neug/execution/expression/expr.h" #include "neug/utils/result.h" diff --git a/src/execution/execute/ops/batch/batch_delete_edge.cc b/src/execution/execute/ops/batch/batch_delete_edge.cc index 87fe5118f..82b3b261b 100644 --- a/src/execution/execute/ops/batch/batch_delete_edge.cc +++ b/src/execution/execute/ops/batch/batch_delete_edge.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/batch/batch_delete_edge.h" -#include "neug/execution/common/columns/edge_columns.h" +#include "neug/columnar/columns/edge_columns.h" #include "neug/storages/csr/csr_view_utils.h" #include diff --git a/src/execution/execute/ops/batch/batch_delete_vertex.cc b/src/execution/execute/ops/batch/batch_delete_vertex.cc index cf0131580..9d22f845d 100644 --- a/src/execution/execute/ops/batch/batch_delete_vertex.cc +++ b/src/execution/execute/ops/batch/batch_delete_vertex.cc @@ -14,8 +14,8 @@ */ #include "neug/execution/execute/ops/batch/batch_delete_vertex.h" -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/vertex_columns.h" namespace neug { namespace execution { diff --git a/src/execution/execute/ops/batch/batch_update_edge.cc b/src/execution/execute/ops/batch/batch_update_edge.cc index 3d3280de6..a14189f61 100644 --- a/src/execution/execute/ops/batch/batch_update_edge.cc +++ b/src/execution/execute/ops/batch/batch_update_edge.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/batch/batch_update_edge.h" -#include "neug/execution/common/columns/edge_columns.h" +#include "neug/columnar/columns/edge_columns.h" #include "neug/execution/expression/expr.h" #include "neug/storages/csr/csr_view_utils.h" #include "neug/utils/pb_utils.h" diff --git a/src/execution/execute/ops/batch/batch_update_utils.cc b/src/execution/execute/ops/batch/batch_update_utils.cc index eb6c0308f..b7595068d 100644 --- a/src/execution/execute/ops/batch/batch_update_utils.cc +++ b/src/execution/execute/ops/batch/batch_update_utils.cc @@ -28,12 +28,13 @@ #include #include "neug/utils/exception/exception.h" -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" +#include "neug/columnar/value.h" +#include "neug/execution/columnar_aliases.h" #include "neug/execution/common/context.h" -#include "neug/execution/common/types/value.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/storages/graph/graph_interface.h" #include "neug/storages/loader/loader_utils.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/string_utils.h" namespace neug { @@ -65,7 +66,7 @@ bool check_csv_import_options( void add_member(rapidjson::Value& object, rapidjson::Document::AllocatorType& allocator, - const std::string& key, const execution::Value& value) { + const std::string& key, const columnar::Value& value) { if (value.type().id() == DataTypeId::kBoolean) { object.AddMember(rapidjson::Value(key.c_str(), allocator).Move(), value.GetValue(), allocator); @@ -117,7 +118,7 @@ void add_member(rapidjson::Value& object, void add_prop_member(rapidjson::Value& object, rapidjson::Document::AllocatorType& allocator, - const std::string& key, const execution::Value& value) { + const std::string& key, const columnar::Value& value) { if (value.type().id() == DataTypeId::kInt32) { object.AddMember(rapidjson::Value(key.c_str(), allocator).Move(), value.GetValue(), allocator); @@ -170,11 +171,11 @@ rapidjson::Value build_vertex_object( std::string internal_id_key = "_ID"; std::string encoded_id_str = std::to_string(label) + ":" + std::to_string(vid); - execution::Value encoded_id = execution::Value::STRING(encoded_id_str); + columnar::Value encoded_id = columnar::Value::STRING(encoded_id_str); add_member(vertex_object, allocator, internal_id_key, encoded_id); std::string internal_label_key = "_LABEL"; std::string label_name_str = graph.schema().get_vertex_label_name(label); - execution::Value label_name = execution::Value::STRING(label_name_str); + columnar::Value label_name = columnar::Value::STRING(label_name_str); add_member(vertex_object, allocator, internal_label_key, label_name); std::string primary_key = graph.schema().get_vertex_primary_key_name(label); add_member(vertex_object, allocator, primary_key, @@ -210,30 +211,28 @@ rapidjson::Value build_edge_object( std::string internal_src_id = "_SRC"; std::string encoded_src_id_str = std::to_string(src_label) + ":" + std::to_string(edge.src); - execution::Value encoded_src_id = - execution::Value::STRING(encoded_src_id_str); + columnar::Value encoded_src_id = columnar::Value::STRING(encoded_src_id_str); add_member(edge_object, allocator, internal_src_id, encoded_src_id); std::string internal_dst_id = "_DST"; std::string encoded_dst_id_str = std::to_string(dst_label) + ":" + std::to_string(edge.dst); - execution::Value encoded_dst_id = - execution::Value::STRING(encoded_dst_id_str); + columnar::Value encoded_dst_id = columnar::Value::STRING(encoded_dst_id_str); add_member(edge_object, allocator, internal_dst_id, encoded_dst_id); std::string internal_src_label_key = "_SRC_LABEL"; - execution::Value src_label_name = - execution::Value::STRING(graph.schema().get_vertex_label_name(src_label)); + columnar::Value src_label_name = + columnar::Value::STRING(graph.schema().get_vertex_label_name(src_label)); add_member(edge_object, allocator, internal_src_label_key, src_label_name); std::string internal_dst_label_key = "_DST_LABEL"; - execution::Value dst_label_name = - execution::Value::STRING(graph.schema().get_vertex_label_name(dst_label)); + columnar::Value dst_label_name = + columnar::Value::STRING(graph.schema().get_vertex_label_name(dst_label)); add_member(edge_object, allocator, internal_dst_label_key, dst_label_name); std::string internal_label_key = "_LABEL"; - execution::Value edge_label_name = - execution::Value::STRING(graph.schema().get_edge_label_name(edge_label)); + columnar::Value edge_label_name = + columnar::Value::STRING(graph.schema().get_edge_label_name(edge_label)); add_member(edge_object, allocator, internal_label_key, edge_label_name); auto property_names = @@ -274,18 +273,18 @@ std::string path_to_json_string(Path& path, const StorageReadInterface& graph) { if (i > 0) { rapidjson::Value edge_object(rapidjson::kObjectType); std::string internal_src_label_key = "_SRC_LABEL"; - execution::Value src_label_name = execution::Value::STRING( + columnar::Value src_label_name = columnar::Value::STRING( graph.schema().get_vertex_label_name(path_vertices[i - 1].label_)); add_member(edge_object, allocator, internal_src_label_key, src_label_name); std::string internal_dst_label_key = "_DST_LABEL"; - execution::Value dst_label_name = execution::Value::STRING( + columnar::Value dst_label_name = columnar::Value::STRING( graph.schema().get_vertex_label_name(path_vertices[i].label_)); add_member(edge_object, allocator, internal_dst_label_key, dst_label_name); std::string internal_label_key = "_LABEL"; - execution::Value edge_label_name = - execution::Value::STRING(graph.schema().get_edge_label_name( + columnar::Value edge_label_name = + columnar::Value::STRING(graph.schema().get_edge_label_name( path_edges[i - 1].label.edge_label)); add_member(edge_object, allocator, internal_label_key, edge_label_name); edge_array.PushBack(edge_object, allocator); diff --git a/src/execution/execute/ops/batch/batch_update_vertex.cc b/src/execution/execute/ops/batch/batch_update_vertex.cc index 4dad212ad..5283f2e28 100644 --- a/src/execution/execute/ops/batch/batch_update_vertex.cc +++ b/src/execution/execute/ops/batch/batch_update_vertex.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/batch/batch_update_vertex.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/expr.h" #include "neug/utils/pb_utils.h" diff --git a/src/execution/execute/ops/ddl/add_edge_property.cc b/src/execution/execute/ops/ddl/add_edge_property.cc index f124593a2..0dfbe616c 100644 --- a/src/execution/execute/ops/ddl/add_edge_property.cc +++ b/src/execution/execute/ops/ddl/add_edge_property.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/ddl/add_edge_property.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/pb_utils.h" namespace neug { diff --git a/src/execution/execute/ops/ddl/add_vertex_property.cc b/src/execution/execute/ops/ddl/add_vertex_property.cc index 2c3df33b5..19a4eb63d 100644 --- a/src/execution/execute/ops/ddl/add_vertex_property.cc +++ b/src/execution/execute/ops/ddl/add_vertex_property.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/ddl/add_vertex_property.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/pb_utils.h" namespace neug { diff --git a/src/execution/execute/ops/ddl/create_edge_type.cc b/src/execution/execute/ops/ddl/create_edge_type.cc index 571f90d20..29d76ec41 100644 --- a/src/execution/execute/ops/ddl/create_edge_type.cc +++ b/src/execution/execute/ops/ddl/create_edge_type.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/ddl/create_edge_type.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/pb_utils.h" namespace neug { diff --git a/src/execution/execute/ops/ddl/create_vertex_type.cc b/src/execution/execute/ops/ddl/create_vertex_type.cc index 2236e0d0e..8f7f7cbca 100644 --- a/src/execution/execute/ops/ddl/create_vertex_type.cc +++ b/src/execution/execute/ops/ddl/create_vertex_type.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/execute/ops/ddl/create_vertex_type.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/pb_utils.h" namespace neug { diff --git a/src/execution/execute/ops/insert/merge_edge.cc b/src/execution/execute/ops/insert/merge_edge.cc index 6806ff5a8..08cd59cfb 100644 --- a/src/execution/execute/ops/insert/merge_edge.cc +++ b/src/execution/execute/ops/insert/merge_edge.cc @@ -21,11 +21,11 @@ #include #include -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/graph_types.h" +#include "neug/columnar/value.h" #include "neug/execution/common/context.h" -#include "neug/execution/common/types/graph_types.h" -#include "neug/execution/common/types/value.h" #include "neug/execution/expression/expr.h" #include "neug/generated/proto/plan/cypher_dml.pb.h" #include "neug/storages/csr/csr_view_utils.h" @@ -152,7 +152,7 @@ EdgeRecord insert_and_return_edge_row( std::to_string(dst_label) + ", got " + std::to_string(v2.label_)); } - std::vector property_values(properties.size()); + std::vector property_values(properties.size()); for (size_t j = 0; j < properties.size(); ++j) { const auto& [prop_name, prop_expr] = properties[j]; Value value = prop_expr->Cast().eval_record(chunk, row); diff --git a/src/execution/execute/ops/insert/merge_vertex.cc b/src/execution/execute/ops/insert/merge_vertex.cc index bc577757f..cd72a957b 100644 --- a/src/execution/execute/ops/insert/merge_vertex.cc +++ b/src/execution/execute/ops/insert/merge_vertex.cc @@ -21,7 +21,7 @@ #include #include -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/context.h" #include "neug/execution/expression/expr.h" #include "neug/generated/proto/plan/cypher_dml.pb.h" @@ -131,7 +131,7 @@ neug::result insert_vertex_row( } Value pk_value; - std::vector property_values(properties.size() - 1); + std::vector property_values(properties.size() - 1); for (size_t j = 0; j < properties.size(); ++j) { const auto& [prop_name, prop_expr] = properties[j]; Value value = prop_expr->Cast().eval_record(chunk, row); @@ -226,7 +226,7 @@ class MergeVertexOpr : public IOperator { // Standalone MERGE after OPTIONAL MATCH can yield row_num() == 0 // when the inner scan finds no row. MERGE write semantics still // need exactly one logical row (CREATE/MATCH branch once). - std::shared_ptr alias_col; + std::shared_ptr alias_col; if (chunk.exist(plan.alias_id)) { auto c = chunk.get(plan.alias_id); if (c != nullptr && c->size() > 0) { diff --git a/src/execution/execute/ops/retrieve/group_by_utils.cc b/src/execution/execute/ops/retrieve/group_by_utils.cc index ddb2535bd..bbf176d74 100644 --- a/src/execution/execute/ops/retrieve/group_by_utils.cc +++ b/src/execution/execute/ops/retrieve/group_by_utils.cc @@ -14,10 +14,10 @@ */ #include "neug/execution/execute/ops/retrieve/group_by_utils.h" -#include "neug/execution/common/columns/i_context_column.h" -#include "neug/execution/common/columns/list_columns.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/execution/columnar_aliases.h" #include "neug/utils/exception/exception.h" namespace neug { @@ -29,7 +29,7 @@ struct GKey : public KeyBase { : tag_alias_(tag_alias) {} std::pair> group( const ContextChunk& chunk) override { - std::vector> exprs; + std::vector> exprs; for (size_t i = 0; i < tag_alias_.size(); ++i) { exprs.push_back(chunk.get(tag_alias_[i].first)); } @@ -91,22 +91,21 @@ struct ValueWrapper { template struct TypedVarWrapper { using V = T; - explicit TypedVarWrapper(const IContextColumn& column) : column(column) {} + explicit TypedVarWrapper(const IColumn& column) : column(column) {} V operator()(size_t idx) const { return column.get_elem(idx).template GetValue(); } bool has_value(size_t idx) const { return column.has_value(idx); } - const IContextColumn& column; + const IColumn& column; }; // General wrapper for Value type struct VarWrapper { using V = Value; Value operator()(size_t idx) const { return vars->get_elem(idx); } - explicit VarWrapper(const std::shared_ptr& vars) - : vars(vars) {} + explicit VarWrapper(const std::shared_ptr& vars) : vars(vars) {} bool has_value(size_t idx) const { return !vars->get_elem(idx).IsNull(); } const DataType& type() const { return vars->elem_type(); } - std::shared_ptr vars; + std::shared_ptr vars; }; struct VarPairWrapper { @@ -115,17 +114,17 @@ struct VarPairWrapper { return std::make_pair(fst->get_elem(idx), snd->get_elem(idx)); } bool has_value(size_t idx) const { return !fst->get_elem(idx).IsNull(); } - VarPairWrapper(const std::shared_ptr& fst, - const std::shared_ptr& snd) + VarPairWrapper(const std::shared_ptr& fst, + const std::shared_ptr& snd) : fst(fst), snd(snd) {} - std::shared_ptr fst; - std::shared_ptr snd; + std::shared_ptr fst; + std::shared_ptr snd; }; static std::unique_ptr create_sp_key( const DataChunk& chunk, const std::vector>& tag_alias) { auto col = chunk.get(tag_alias[0].first); - if (col->column_type() == ContextColumnType::kVertex) { + if (col->column_type() == ColumnKind::kVertex) { auto vertex_col = std::dynamic_pointer_cast(col); VertexWrapper wrapper(*vertex_col); return std::make_unique>(std::move(wrapper), @@ -137,7 +136,7 @@ static std::unique_ptr create_sp_key( return std::make_unique>(std::move(wrapper), tag_alias); } - } else if (col->column_type() == ContextColumnType::kValue) { + } else if (col->column_type() == ColumnKind::kValue) { if (col->elem_type().id() == DataTypeId::kInt64) { ValueWrapper wrapper( *dynamic_cast*>(col.get())); @@ -169,8 +168,7 @@ struct SumReducer reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if constexpr (!IS_OPTIONAL) { @@ -218,8 +216,7 @@ struct CountDistinctReducer : public ReducerBase { explicit CountDistinctReducer(EXPR&& expr) : expr(std::move(expr)) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if (groups.empty()) { @@ -281,8 +278,7 @@ struct CountReducer : public ReducerBase { explicit CountReducer(EXPR&& expr) : expr(std::move(expr)) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if (groups.empty()) { @@ -313,8 +309,7 @@ struct CountStarReducer : public ReducerBase { CountStarReducer() {} using V = int64_t; - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if (groups.empty()) { @@ -335,8 +330,7 @@ struct MinReducer : public ReducerBase { using V = typename EXPR::V; explicit MinReducer(EXPR&& expr) : expr(std::move(expr)) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if constexpr (!IS_OPTIONAL) { @@ -380,8 +374,7 @@ struct MaxReducer : public ReducerBase { using V = typename EXPR::V; explicit MaxReducer(EXPR&& expr) : expr(std::move(expr)) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if constexpr (!IS_OPTIONAL) { @@ -424,8 +417,7 @@ struct FirstReducer : public ReducerBase { using V = typename EXPR::V; explicit FirstReducer(EXPR&& expr) : expr(std::move(expr)) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if constexpr (!IS_OPTIONAL) { @@ -463,8 +455,7 @@ struct ToSetReducer : public ReducerBase { explicit ToSetReducer(EXPR&& expr, const DataType& type) : expr(std::move(expr)), type(type) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ListColumnBuilder builder(type); builder.reserve(groups.size()); @@ -512,8 +503,7 @@ struct ToListReducer : public ReducerBase { explicit ToListReducer(EXPR&& expr, const DataType& type) : expr(std::move(expr)), type(type) {} - std::shared_ptr reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ListColumnBuilder builder(type); builder.reserve(groups.size()); @@ -555,8 +545,7 @@ struct AvgReducer reduce( - const vector_t& groups) override { + std::shared_ptr reduce(const vector_t& groups) override { ValueColumnBuilder builder; builder.reserve(groups.size()); if constexpr (!IS_OPTIONAL) { @@ -655,7 +644,7 @@ std::unique_ptr create_typed_reducer(EXPR&& expr, AggrKind kind) { } static std::unique_ptr create_general_reducer( - const std::shared_ptr& var, AggrKind kind) { + const std::shared_ptr& var, AggrKind kind) { VarWrapper var_wrap(var); if (kind == AggrKind::kCount) { if (!var->is_optional()) { @@ -691,8 +680,8 @@ static std::unique_ptr create_general_reducer( } static std::unique_ptr create_pair_reducer( - const std::shared_ptr& fst, - const std::shared_ptr& snd, AggrKind kind) { + const std::shared_ptr& fst, const std::shared_ptr& snd, + AggrKind kind) { if (kind == AggrKind::kCount) { VarPairWrapper var_wrap(std::move(fst), std::move(snd)); if ((!fst->is_optional()) && (!snd->is_optional())) { @@ -725,7 +714,7 @@ static std::unique_ptr create_reducer( int tag = var.has_tag() ? var.tag().id() : -1; auto col = chunk.get(tag); { - if (col->column_type() == ContextColumnType::kVertex) { + if (col->column_type() == ColumnKind::kVertex) { auto vertex_col = std::dynamic_pointer_cast(col); VertexWrapper wrapper(*vertex_col); if (col->is_optional()) { @@ -769,11 +758,11 @@ static std::unique_ptr create_reducer( std::move(wrapper), kind); } } - } else if (col->column_type() == ContextColumnType::kValue) { + } else if (col->column_type() == ColumnKind::kValue) { #define TYPE_DISPATCHER(enum_val, type) \ case DataTypeId::enum_val: { \ ValueWrapper wrapper( \ - *dynamic_cast*>(col.get())); \ + *dynamic_cast*>(col.get())); \ if (!col->is_optional()) { \ return create_typed_reducer( \ std::move(wrapper), kind); \ diff --git a/src/execution/execute/ops/retrieve/join.cc b/src/execution/execute/ops/retrieve/join.cc index a21edbac8..ebad926b9 100644 --- a/src/execution/execute/ops/retrieve/join.cc +++ b/src/execution/execute/ops/retrieve/join.cc @@ -17,9 +17,9 @@ #include +#include "neug/columnar/graph_types.h" #include "neug/execution/common/context.h" #include "neug/execution/common/operators/retrieve/join.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/execution/execute/pipeline.h" #include "neug/execution/execute/plan_parser.h" #include "neug/execution/utils/params.h" diff --git a/src/execution/execute/ops/retrieve/order_by_utils.cc b/src/execution/execute/ops/retrieve/order_by_utils.cc index 564ffab61..7da1c4789 100644 --- a/src/execution/execute/ops/retrieve/order_by_utils.cc +++ b/src/execution/execute/ops/retrieve/order_by_utils.cc @@ -15,7 +15,7 @@ #include "neug/execution/execute/ops/retrieve/order_by_utils.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/storages/graph/graph_interface.h" namespace neug { namespace execution { diff --git a/src/execution/execute/ops/retrieve/path.cc b/src/execution/execute/ops/retrieve/path.cc index 1c2c6c765..ec860fc9b 100644 --- a/src/execution/execute/ops/retrieve/path.cc +++ b/src/execution/execute/ops/retrieve/path.cc @@ -15,8 +15,8 @@ #include "neug/execution/execute/ops/retrieve/path.h" +#include "neug/columnar/graph_types.h" #include "neug/execution/common/operators/retrieve/path_expand.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/execution/expression/predicates.h" #include "neug/execution/utils/pb_parse_utils.h" @@ -467,14 +467,14 @@ class ASPOpr : public IOperator { neug::execution::OprTimer* timer) override { const auto& graph = dynamic_cast(graph_interface); - execution::Value oid; + columnar::Value oid; if (expr_opr_.has_param()) { auto name = expr_opr_.param().name(); auto val = params.at(name).GetValue(); - oid = execution::Value::INT64(val); + oid = columnar::Value::INT64(val); } else { const auto& c = expr_opr_.const_(); - oid = execution::Value::INT64(c.i64()); + oid = columnar::Value::INT64(c.i64()); } vid_t vid; if (!graph.GetVertexIndex(aspp_.labels[0].dst_label, oid, vid)) { @@ -512,14 +512,14 @@ class SSSDSPOpr : public IOperator { neug::execution::OprTimer* timer) override { const auto& graph = dynamic_cast(graph_interface); - execution::Value vertex = [&]() { + columnar::Value vertex = [&]() { if (expr_opr_.has_param()) { auto name = expr_opr_.param().name(); auto val = params.at(name).GetValue(); - return execution::Value::INT64(val); + return columnar::Value::INT64(val); } else { const auto& c = expr_opr_.const_(); - return execution::Value::INT64(c.i64()); + return columnar::Value::INT64(c.i64()); } }(); vid_t vid; diff --git a/src/execution/execute/ops/retrieve/project_utils.cc b/src/execution/execute/ops/retrieve/project_utils.cc index b4ce00e96..00cca121d 100644 --- a/src/execution/execute/ops/retrieve/project_utils.cc +++ b/src/execution/execute/ops/retrieve/project_utils.cc @@ -25,7 +25,7 @@ namespace ops { */ struct DummyGetter : public ProjectExprBase { DummyGetter(int from, int to) : from_(from), to_(to) {} - std::shared_ptr evaluate(const ContextChunk& chunk) override { + std::shared_ptr evaluate(const ContextChunk& chunk) override { return chunk.get(from_); } @@ -48,10 +48,9 @@ struct VertexPropertyExpr : public ProjectExprBase { tag_(tag), property_name_(property_name) {} - std::shared_ptr evaluate(const ContextChunk& chunk) override { + std::shared_ptr evaluate(const ContextChunk& chunk) override { auto col = chunk.get(tag_); - if (col->is_optional() || - col->column_type() != ContextColumnType::kVertex) { + if (col->is_optional() || col->column_type() != ColumnKind::kVertex) { return nullptr; } const auto& vertex_col = dynamic_cast(*col); @@ -86,8 +85,7 @@ struct VertexPropertyExpr : public ProjectExprBase { bool order_by_limit(const ContextChunk& chunk, bool asc, size_t limit, sel_vec_t& indices) const override { auto col = chunk.get(tag_); - if (col->is_optional() || - col->column_type() != ContextColumnType::kVertex) { + if (col->is_optional() || col->column_type() != ColumnKind::kVertex) { return false; } const auto vertex_col = std::dynamic_pointer_cast(col); @@ -136,10 +134,9 @@ struct CaseWhenExpr : public ProjectExprBase { } return true; } - std::shared_ptr evaluate(const ContextChunk& chunk) override { + std::shared_ptr evaluate(const ContextChunk& chunk) override { auto col = chunk.get(tag_); - if (col->is_optional() || - col->column_type() != ContextColumnType::kVertex) { + if (col->is_optional() || col->column_type() != ColumnKind::kVertex) { return nullptr; } const auto& vertex_col = dynamic_cast(*col); @@ -182,8 +179,7 @@ struct CaseWhenExpr : public ProjectExprBase { private: template - std::shared_ptr eval_impl(const COL_T& vertex_col, - PRED_T&& pred) { + std::shared_ptr eval_impl(const COL_T& vertex_col, PRED_T&& pred) { ValueColumnBuilder builder; size_t num_rows = vertex_col.size(); builder.reserve(num_rows); @@ -211,7 +207,7 @@ struct GeneralExpr : public ProjectExprBase { std::unique_ptr&& expr, const DataType& type) : graph(igraph), expr(std::move(expr)), type(type) {} - std::shared_ptr evaluate(const ContextChunk& chunk) override { + std::shared_ptr evaluate(const ContextChunk& chunk) override { auto column_builder = ColumnsUtils::create_builder(type); column_builder->reserve(chunk.row_num()); const auto& e = expr->Cast(); diff --git a/src/execution/execute/ops/retrieve/scan.cc b/src/execution/execute/ops/retrieve/scan.cc index 16033f1ff..fb834c0d5 100644 --- a/src/execution/execute/ops/retrieve/scan.cc +++ b/src/execution/execute/ops/retrieve/scan.cc @@ -15,8 +15,8 @@ #include "neug/execution/execute/ops/retrieve/scan.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/common/operators/retrieve/scan.h" #include "neug/execution/execute/ops/retrieve/scan_utils.h" #include "neug/execution/expression/predicates.h" diff --git a/src/execution/execute/ops/retrieve/scan_utils.cc b/src/execution/execute/ops/retrieve/scan_utils.cc index d937ebbff..25290f789 100644 --- a/src/execution/execute/ops/retrieve/scan_utils.cc +++ b/src/execution/execute/ops/retrieve/scan_utils.cc @@ -16,7 +16,7 @@ */ #include "neug/execution/execute/ops/retrieve/scan_utils.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/execution/utils/pb_parse_utils.h" #include "neug/utils/exception/exception.h" diff --git a/src/execution/execute/ops/retrieve/select.cc b/src/execution/execute/ops/retrieve/select.cc index a8830235d..9fd26b29f 100644 --- a/src/execution/execute/ops/retrieve/select.cc +++ b/src/execution/execute/ops/retrieve/select.cc @@ -20,7 +20,7 @@ #include "neug/storages/graph/graph_interface.h" #include "neug/utils/property/types.h" -#include "neug/execution/common/columns/vertex_columns.h" +#include "neug/columnar/columns/vertex_columns.h" #include "neug/execution/expression/predicates.h" namespace neug { @@ -52,41 +52,39 @@ class SelectIdNeOpr : public IOperator { ? params.at(param_name_).GetValue() : 0; - return ctx.apply_chunks( - [&](ContextChunk&& chunk) -> neug::result { - auto col = chunk.get(tag_); - if ((!col->is_optional()) && - col->column_type() == ContextColumnType::kVertex) { - auto vertex_col = std::dynamic_pointer_cast(col); - auto labels = vertex_col->get_labels_set(); - if (labels.size() == 1 && - name == graph_interface.schema().get_vertex_primary_key_name( - *labels.begin())) { - auto label = *labels.begin(); - vid_t vid; - if (graph_interface.GetVertexIndex( - label, execution::Value::INT64(oid), vid)) { - if (vertex_col->vertex_column_type() == - VertexColumnType::kSingle) { - const SLVertexColumn& sl_vertex_col = - *(dynamic_cast(vertex_col.get())); - return Select::select( - std::move(chunk), - [&sl_vertex_col, vid](const DataChunk&, size_t i) { - return sl_vertex_col.get_vertex(i).vid_ != vid; - }); - } else { - return Select::select( - std::move(chunk), - [&vertex_col, vid](const DataChunk&, size_t i) { - return vertex_col->get_vertex(i).vid_ != vid; - }); - } - } + return ctx.apply_chunks([&](ContextChunk&& chunk) + -> neug::result { + auto col = chunk.get(tag_); + if ((!col->is_optional()) && col->column_type() == ColumnKind::kVertex) { + auto vertex_col = std::dynamic_pointer_cast(col); + auto labels = vertex_col->get_labels_set(); + if (labels.size() == 1 && + name == graph_interface.schema().get_vertex_primary_key_name( + *labels.begin())) { + auto label = *labels.begin(); + vid_t vid; + if (graph_interface.GetVertexIndex(label, columnar::Value::INT64(oid), + vid)) { + if (vertex_col->vertex_column_type() == VertexColumnType::kSingle) { + const SLVertexColumn& sl_vertex_col = + *(dynamic_cast(vertex_col.get())); + return Select::select( + std::move(chunk), + [&sl_vertex_col, vid](const DataChunk&, size_t i) { + return sl_vertex_col.get_vertex(i).vid_ != vid; + }); + } else { + return Select::select( + std::move(chunk), + [&vertex_col, vid](const DataChunk&, size_t i) { + return vertex_col->get_vertex(i).vid_ != vid; + }); } } - return Select::select(std::move(chunk), fallback_pred); - }); + } + } + return Select::select(std::move(chunk), fallback_pred); + }); } private: diff --git a/src/execution/execute/ops/retrieve/tc_fuse.cc b/src/execution/execute/ops/retrieve/tc_fuse.cc index df31cd38b..b3b09cf7e 100644 --- a/src/execution/execute/ops/retrieve/tc_fuse.cc +++ b/src/execution/execute/ops/retrieve/tc_fuse.cc @@ -13,9 +13,9 @@ * limitations under the License. */ +#include "neug/columnar/graph_types.h" #include "neug/execution/common/context.h" #include "neug/execution/common/operators/retrieve/edge_expand.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/execution/execute/operator.h" #include "neug/execution/execute/ops/retrieve/edge.h" #include "neug/execution/expression/special_predicates.h" diff --git a/src/execution/execute/ops/retrieve/vertex.cc b/src/execution/execute/ops/retrieve/vertex.cc index a0c8335ce..0e97cee15 100644 --- a/src/execution/execute/ops/retrieve/vertex.cc +++ b/src/execution/execute/ops/retrieve/vertex.cc @@ -15,9 +15,9 @@ #include "neug/execution/execute/ops/retrieve/vertex.h" +#include "neug/columnar/graph_types.h" #include "neug/execution/common/context.h" #include "neug/execution/common/operators/retrieve/get_v.h" -#include "neug/execution/common/types/graph_types.h" #include "neug/execution/expression/expr.h" #include "neug/execution/utils/params.h" #include "neug/execution/utils/pb_parse_utils.h" diff --git a/src/execution/expression/accessors/record_accessor.cc b/src/execution/expression/accessors/record_accessor.cc index 282feadf4..30888a891 100644 --- a/src/execution/expression/accessors/record_accessor.cc +++ b/src/execution/expression/accessors/record_accessor.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/expression/accessors/record_accessor.h" -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" #include "neug/utils/exception/exception.h" namespace neug { diff --git a/src/execution/expression/exprs/path_expr.cc b/src/execution/expression/exprs/path_expr.cc index 37c3cf172..c53d0e366 100644 --- a/src/execution/expression/exprs/path_expr.cc +++ b/src/execution/expression/exprs/path_expr.cc @@ -14,7 +14,7 @@ */ #include "neug/execution/expression/exprs/path_expr.h" -#include "neug/execution/common/columns/i_context_column.h" +#include "neug/columnar/columns/i_column.h" #include "neug/execution/common/context.h" namespace neug { diff --git a/src/utils/io/read/common/reader_utils.cc b/src/execution/io/chunk_stream_adapter.cc similarity index 79% rename from src/utils/io/read/common/reader_utils.cc rename to src/execution/io/chunk_stream_adapter.cc index 79526ce2b..045c37e09 100644 --- a/src/utils/io/read/common/reader_utils.cc +++ b/src/execution/io/chunk_stream_adapter.cc @@ -13,22 +13,23 @@ * limitations under the License. */ -#include "neug/utils/io/read/common/reader_utils.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/utils/exception/exception.h" namespace neug { -namespace reader { +namespace execution { +namespace io { -execution::Context toContext(std::shared_ptr supplier, - const ReadSharedState& state, - size_t fallback_column_count) { +Context fromChunkSupplier(std::shared_ptr supplier, + const reader::ReadSharedState& state, + size_t fallback_column_count) { int expected_cols = state.columnNum(); if (expected_cols <= 0 && fallback_column_count > 0) { expected_cols = static_cast(fallback_column_count); } - execution::Context ctx; + Context ctx; while (supplier) { auto chunk = supplier->GetNextChunk(); if (!chunk) { @@ -46,5 +47,6 @@ execution::Context toContext(std::shared_ptr supplier, return ctx; } -} // namespace reader +} // namespace io +} // namespace execution } // namespace neug diff --git a/src/utils/io/read/common/chunk_supplier.cc b/src/execution/io/chunk_supplier.cc similarity index 83% rename from src/utils/io/read/common/chunk_supplier.cc rename to src/execution/io/chunk_supplier.cc index 6998e6504..b5153b4eb 100644 --- a/src/utils/io/read/common/chunk_supplier.cc +++ b/src/execution/io/chunk_supplier.cc @@ -13,17 +13,17 @@ * limitations under the License. */ -#include "neug/utils/io/read/common/chunk_supplier.h" +#include "neug/execution/io/chunk_supplier.h" -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/data_chunk.h" namespace neug { MultiDataChunkSupplier::MultiDataChunkSupplier( - std::vector> chunks) + std::vector> chunks) : chunks_(std::move(chunks)), index_(0) {} -std::shared_ptr MultiDataChunkSupplier::GetNextChunk() { +std::shared_ptr MultiDataChunkSupplier::GetNextChunk() { if (index_ >= chunks_.size()) { return nullptr; } @@ -42,7 +42,7 @@ ChunkSupplierWrapper::ChunkSupplierWrapper( std::vector> suppliers) : suppliers_(std::move(suppliers)) {} -std::shared_ptr ChunkSupplierWrapper::GetNextChunk() { +std::shared_ptr ChunkSupplierWrapper::GetNextChunk() { while (current_supplier_index_ < suppliers_.size()) { auto chunk = suppliers_[current_supplier_index_]->GetNextChunk(); if (chunk) { diff --git a/src/main/query_processor.cc b/src/main/query_processor.cc index a2b26e9c0..bc0989434 100644 --- a/src/main/query_processor.cc +++ b/src/main/query_processor.cc @@ -96,8 +96,8 @@ result QueryProcessor::execute(const std::string& query_string, RETURN_ERROR(neug::Status(neug::StatusCode::ERR_INVALID_ARGUMENT, "Unexpected parameter: " + key)); } - params_map.emplace( - key, execution::Value::FromJson(member.value, iter->second)); + params_map.emplace(key, + columnar::Value::FromJson(member.value, iter->second)); } } if (need_exclusive_lock(access_mode_pipeline.first)) { diff --git a/src/main/query_request.cc b/src/main/query_request.cc index b9b83cbe0..a3e5d93f6 100644 --- a/src/main/query_request.cc +++ b/src/main/query_request.cc @@ -17,7 +17,7 @@ #include "neug/utils/serialization/in_archive.h" #include "neug/utils/serialization/out_archive.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "rapidjson/document.h" #include "rapidjson/rapidjson.h" #include "rapidjson/stringbuffer.h" @@ -39,7 +39,7 @@ execution::ParamsMap ParamsParser::ParseFromJsonObj( VLOG(1) << "Parameter key not found in meta: " << key; } else { param_map.emplace(key, - execution::Value::FromJson(itr->value, meta.at(key))); + columnar::Value::FromJson(itr->value, meta.at(key))); } } return param_map; @@ -89,7 +89,7 @@ std::string RequestSerializer::SerializeRequest( for (const auto& kv : parameters) { parameter_obj.AddMember( rapidjson::Value(kv.first.c_str(), kv.first.size(), allocator), - execution::Value::ToJson(kv.second, allocator), allocator); + columnar::Value::ToJson(kv.second, allocator), allocator); } document.AddMember("parameters", parameter_obj, allocator); rapidjson::StringBuffer buffer; diff --git a/src/storages/csr/csr_view_utils.cc b/src/storages/csr/csr_view_utils.cc index 298984b1b..6c3ec3db9 100644 --- a/src/storages/csr/csr_view_utils.cc +++ b/src/storages/csr/csr_view_utils.cc @@ -14,7 +14,7 @@ */ #include "neug/storages/csr/csr_view_utils.h" -#include "neug/execution/common/types/graph_types.h" +#include "neug/columnar/graph_types.h" #include "neug/utils/property/types.h" namespace neug { @@ -135,11 +135,11 @@ size_t get_offset_for_edge_record(const NbrList& nbr_list, vid_t expected_nbr, std::pair record_to_csr_offset_pair( const CsrView& oe, const CsrView& ie, - const neug::execution::EdgeRecord& record, + const neug::columnar::EdgeRecord& record, const std::vector& props) { NbrList cur_nbr_list, another_nbr_list; vid_t src, nbr; - if (record.dir == execution::Direction::kOut) { + if (record.dir == columnar::Direction::kOut) { cur_nbr_list = oe.get_edges(record.src); another_nbr_list = ie.get_edges(record.dst); src = record.src; @@ -160,7 +160,7 @@ std::pair record_to_csr_offset_pair( another_offset = neug::fuzzy_search_offset_from_nbr_list( another_nbr_list, src, record.prop, e_prop_type); assert(another_offset != std::numeric_limits::max()); - if (record.dir == execution::Direction::kOut) { + if (record.dir == columnar::Direction::kOut) { return std::make_pair(cur_offset, another_offset); } else { return std::make_pair(another_offset, cur_offset); diff --git a/src/storages/graph/edge_table.cc b/src/storages/graph/edge_table.cc index 6bbfdacea..94b269b71 100644 --- a/src/storages/graph/edge_table.cc +++ b/src/storages/graph/edge_table.cc @@ -75,7 +75,7 @@ void batch_put_edges_with_default_edata_impl(const std::vector& src_lid, void batch_put_edges_with_default_edata(const std::vector& src_lid, const std::vector& dst_lid, DataTypeId property_type, - const execution::Value& default_value, + const columnar::Value& default_value, CsrBase* out_csr) { assert(src_lid.size() == dst_lid.size()); switch (property_type) { @@ -98,7 +98,7 @@ void batch_put_edges_with_default_edata(const std::vector& src_lid, void batch_put_edges_to_bundled_csr( const std::vector& src_lid, const std::vector& dst_lid, - DataTypeId property_type, const std::vector& edge_data, + DataTypeId property_type, const std::vector& edge_data, CsrBase* out_csr) { switch (property_type) { #define TYPE_DISPATCHER(enum_val, type) \ @@ -180,10 +180,9 @@ static std::unique_ptr create_csr(bool is_mutable, } } -static void parse_endpoint_column( - const IndexerType& indexer, - const std::shared_ptr& col, - std::vector& lids) { +static void parse_endpoint_column(const IndexerType& indexer, + const std::shared_ptr& col, + std::vector& lids) { for (size_t i = 0; i < col->size(); ++i) { auto val = col->get_elem(i); auto vid = indexer.get_index(val); @@ -204,7 +203,7 @@ template void insert_edges_bundled_typed_impl( TypedCsrBase* out_csr, TypedCsrBase* in_csr, const std::vector& src_lid, const std::vector& dst_lid, - const std::vector>& data_cols, + const std::vector>& data_cols, const std::vector& valid_flags) { std::vector edge_data; edge_data.reserve(src_lid.size()); @@ -234,10 +233,10 @@ void insert_edges_separated_impl(TypedCsrBase* out_csr, in_csr->batch_put_edges(dst_lid, src_lid, edge_data); } -static std::vector get_row_from_data_chunks( - const std::vector>& prop_cols, +static std::vector get_row_from_data_chunks( + const std::vector>& prop_cols, size_t row_idx) { - std::vector row; + std::vector row; row.reserve(prop_cols.size()); for (auto& col : prop_cols) { row.push_back(col->get_elem(row_idx)); @@ -251,7 +250,7 @@ void batch_add_unbundled_edges_impl( TypedCsrBase* in_csr, Table* table_, std::atomic& table_idx_, std::atomic& capacity_, const std::vector& prop_types, - const std::vector>& data_chunks, + const std::vector>& data_chunks, const std::vector& valid_flags) { size_t offset = table_idx_.fetch_add(src_lid_list.size()); insert_edges_separated_impl(out_csr, in_csr, src_lid_list, dst_lid_list, @@ -260,7 +259,7 @@ void batch_add_unbundled_edges_impl( for (auto& chunk : data_chunks) { size_t num_rows = chunk->row_num(); // Build per-column accessors for this chunk. - std::vector> prop_cols; + std::vector> prop_cols; prop_cols.reserve(chunk->col_num()); for (auto& c : chunk->columns) { if (c) @@ -280,7 +279,7 @@ void batch_add_bundled_edges_impl( CsrBase* out_csr, CsrBase* in_csr, std::shared_ptr meta, const std::vector& src_lid_list, const std::vector& dst_lid_list, - const std::vector>& data_cols, + const std::vector>& data_cols, const std::vector& valid_flags) { const auto& prop_types = meta->properties; if (prop_types.empty() || prop_types[0].id() == DataTypeId::kEmpty) { @@ -533,7 +532,7 @@ void EdgeTable::DeleteVertex(bool is_src, vid_t vid, timestamp_t ts) { void EdgeTable::UpdateEdgeProperty(vid_t src_lid, vid_t dst_lid, int32_t oe_offset, int32_t ie_offset, - int32_t col_id, const execution::Value& prop, + int32_t col_id, const columnar::Value& prop, timestamp_t ts) { auto accessor = get_edge_data_accessor(col_id); auto oe_edges = out_csr_->get_generic_view(ts).get_edges(src_lid); @@ -631,7 +630,7 @@ EdgeDataAccessor EdgeTable::get_edge_data_accessor( void EdgeTable::AddProperties( Checkpoint& ckp, const std::vector& prop_names, const std::vector& prop_types, - const std::vector& default_values) { + const std::vector& default_values) { if (prop_names.empty()) { return; } @@ -695,9 +694,8 @@ void EdgeTable::DeleteProperties(Checkpoint& ckp, } std::pair EdgeTable::AddEdge( - vid_t src_lid, vid_t dst_lid, - const std::vector& edge_data, timestamp_t ts, - Allocator& alloc, bool insert_safe) { + vid_t src_lid, vid_t dst_lid, const std::vector& edge_data, + timestamp_t ts, Allocator& alloc, bool insert_safe) { return internal::insert_edge_into_csr_internal( *out_csr_, *in_csr_, *table_.get(), table_idx_, *meta_, src_lid, dst_lid, edge_data, ts, alloc, insert_safe); @@ -711,8 +709,8 @@ void EdgeTable::BatchAddEdges(const IndexerType& src_indexer, std::vector src_lid, dst_lid; // Collect per-property columns across chunks (for bundled: single column; // for unbundled: full property DataChunks). - std::vector> bundled_data_cols; - std::vector> unbundled_data_chunks; + std::vector> bundled_data_cols; + std::vector> unbundled_data_chunks; while (true) { auto chunk = supplier->GetNextChunk(); if (chunk == nullptr) { @@ -728,7 +726,7 @@ void EdgeTable::BatchAddEdges(const IndexerType& src_indexer, bundled_data_cols.push_back(chunk->get(2)); } else { // Unbundled: collect remaining columns as a DataChunk. - auto prop_chunk = std::make_shared(); + auto prop_chunk = std::make_shared(); for (size_t i = 2; i < chunk->col_num(); ++i) { auto c = chunk->get(static_cast(i)); if (c) { @@ -765,7 +763,7 @@ void EdgeTable::BatchAddEdges(const IndexerType& src_indexer, void EdgeTable::BatchAddEdges( const std::vector& src_lid_list, const std::vector& dst_lid_list, - const std::vector>& edge_data_list) { + const std::vector>& edge_data_list) { size_t new_size = table_idx_.load() + src_lid_list.size(); if (new_size >= Capacity()) { auto new_cap = new_size; @@ -775,7 +773,7 @@ void EdgeTable::BatchAddEdges( EnsureCapacity(new_cap); } if (meta_->is_bundled()) { - std::vector flat_edge_data; + std::vector flat_edge_data; assert(meta_->properties.size() == 1); if (meta_->properties[0] == DataTypeId::kEmpty) { } else { @@ -879,7 +877,7 @@ void EdgeTable::dropAndCreateNewBundledCSR(Checkpoint& ckp, auto row_id_col = dynamic_cast(row_id_col_base.get()); row_id_col->Open(ckp, ModuleDescriptor(), MemoryLevel::kInMemory); auto edges = out_csr_->batch_export(row_id_col); - std::vector remaining_data; + std::vector remaining_data; remaining_data.reserve(row_id_col->size()); for (size_t i = 0; i < row_id_col->size(); ++i) { auto row_id = row_id_col->get_view(i); diff --git a/src/storages/graph/graph_interface.cc b/src/storages/graph/graph_interface.cc index 3c609aa43..e975c8b25 100644 --- a/src/storages/graph/graph_interface.cc +++ b/src/storages/graph/graph_interface.cc @@ -18,22 +18,22 @@ namespace neug { Status StorageAPUpdateInterface::UpdateVertexProperty( - label_t label, vid_t lid, int col_id, const execution::Value& value) { + label_t label, vid_t lid, int col_id, const columnar::Value& value) { return graph_.UpdateVertexProperty(label, lid, col_id, value, timestamp_); } Status StorageAPUpdateInterface::UpdateEdgeProperty( label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& value) { + const columnar::Value& value) { return graph_.UpdateEdgeProperty(src_label, src, dst_label, dst, edge_label, oe_offset, ie_offset, col_id, value, neug::timestamp_t(0)); } Status StorageAPUpdateInterface::AddVertex( - label_t label, const execution::Value& id, - const std::vector& props, vid_t& vid) { + label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) { const auto& vertex_table = graph_.get_vertex_table(label); if (vertex_table.Size() >= vertex_table.Capacity()) { auto new_cap = vertex_table.Size() < 4096 @@ -58,7 +58,7 @@ Status StorageAPUpdateInterface::AddVertex( Status StorageAPUpdateInterface::AddEdge( label_t src_label, vid_t src, label_t dst_label, vid_t dst, - label_t edge_label, const std::vector& properties, + label_t edge_label, const std::vector& properties, const void*& prop) { const auto& edge_table = graph_.get_edge_table(src_label, dst_label, edge_label); diff --git a/src/storages/graph/graph_view.cc b/src/storages/graph/graph_view.cc index d8e6c5217..96f6cedef 100644 --- a/src/storages/graph/graph_view.cc +++ b/src/storages/graph/graph_view.cc @@ -55,8 +55,7 @@ ColumnBase* TableView::get_raw_column(int col_id) const { return columns_[col_id]; } -void TableView::insert(size_t index, - const std::vector& values, +void TableView::insert(size_t index, const std::vector& values, bool insert_safe) { assert(!insert_safe); assert(values.size() == columns_.size()); @@ -73,7 +72,7 @@ VertexTableView::VertexTableView(VertexTable& table) v_ts_(table.v_ts_.get()), view_(*table.table_) {} -bool VertexTableView::get_lid(const execution::Value& oid, vid_t& lid, +bool VertexTableView::get_lid(const columnar::Value& oid, vid_t& lid, timestamp_t ts) const { auto res = indexer_->get_index(oid, lid); if (NEUG_UNLIKELY(res && !v_ts_->IsVertexValid(lid, ts))) { @@ -88,7 +87,7 @@ bool VertexTableView::IsValidLid(vid_t lid, timestamp_t ts) const { return lid < indexer_->size() && v_ts_->IsVertexValid(lid, ts); } -execution::Value VertexTableView::GetOid(vid_t lid, timestamp_t ts) const { +columnar::Value VertexTableView::GetOid(vid_t lid, timestamp_t ts) const { if (NEUG_UNLIKELY(lid >= indexer_->size())) { THROW_INVALID_ARGUMENT_EXCEPTION("Lid " + std::to_string(lid) + " is out of range."); @@ -117,8 +116,8 @@ std::shared_ptr VertexTableView::GetPropertyColumn( return view_.get_column(prop); } -bool VertexTableView::AddVertex(const execution::Value& id, - const std::vector& props, +bool VertexTableView::AddVertex(const columnar::Value& id, + const std::vector& props, vid_t& ret, timestamp_t ts, bool insert_safe) { assert(!insert_safe); // insert_safe should be false if (indexer_->capacity() <= indexer_->size()) { @@ -181,7 +180,7 @@ EdgeDataAccessor EdgeTableView::GetDataAccessor( std::pair EdgeTableView::AddEdge( vid_t src_lid, vid_t dst_lid, - const std::vector& properties, timestamp_t ts, + const std::vector& properties, timestamp_t ts, Allocator& alloc, bool insert_safe) { return internal::insert_edge_into_csr_internal( *out_csr_, *in_csr_, view_, *table_idx_, *meta_, src_lid, dst_lid, @@ -221,8 +220,8 @@ VertexSet GraphView::GetVertexSet(label_t label, timestamp_t ts) const { return vertex_views_[label].GetVertexSet(ts); } -execution::Value GraphView::GetOid(label_t label, vid_t lid, - timestamp_t ts) const { +columnar::Value GraphView::GetOid(label_t label, vid_t lid, + timestamp_t ts) const { return vertex_views_[label].GetOid(lid, ts); } @@ -279,8 +278,8 @@ EdgeDataAccessor GraphView::GetEdgeDataAccessor( return it->second.GetDataAccessor(prop_name); } -Status GraphView::AddVertex(label_t label, const execution::Value& id, - const std::vector& props, +Status GraphView::AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid, timestamp_t ts) { if (!vertex_views_[label].AddVertex(id, props, vid, ts, false)) { return Status(StatusCode::ERR_INVALID_ARGUMENT, "Fail to add vertex."); @@ -290,7 +289,7 @@ Status GraphView::AddVertex(label_t label, const execution::Value& id, Status GraphView::AddEdge(label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, label_t edge_label, - const std::vector& properties, + const std::vector& properties, timestamp_t ts, Allocator& alloc, int32_t& oe_offset, const void*& prop) { uint32_t index = diff --git a/src/storages/graph/operation_params.cc b/src/storages/graph/operation_params.cc index 2add5a00e..c82bd3556 100644 --- a/src/storages/graph/operation_params.cc +++ b/src/storages/graph/operation_params.cc @@ -14,8 +14,8 @@ */ #include "neug/storages/graph/operation_params.h" +#include "neug/columnar/value.h" #include "neug/common/extra_type_info.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/graph/schema.h" #include "neug/utils/serialization/in_archive.h" #include "neug/utils/serialization/out_archive.h" @@ -44,7 +44,7 @@ CreateVertexTypeParam CreateVertexTypeParam::Deserialize(OutArchive& arc) { for (size_t i = 0; i < prop_size; ++i) { DataType type; std::string name; - execution::Value default_value; + columnar::Value default_value; arc >> type >> name >> default_value; builder.AddProperty(name, default_value); } @@ -84,7 +84,7 @@ CreateEdgeTypeParam CreateEdgeTypeParam::Deserialize(OutArchive& arc) { for (size_t i = 0; i < prop_size; ++i) { DataType type; std::string name; - execution::Value default_value; + columnar::Value default_value; arc >> type >> name >> default_value; builder.AddProperty(name, default_value); } @@ -120,7 +120,7 @@ AddVertexPropertiesParam AddVertexPropertiesParam::Deserialize( for (size_t i = 0; i < prop_size; ++i) { DataType type; std::string name; - execution::Value default_value; + columnar::Value default_value; arc >> type >> name >> default_value; builder.AddProperty(name, default_value); } @@ -147,7 +147,7 @@ AddEdgePropertiesParam AddEdgePropertiesParam::Deserialize(OutArchive& arc) { for (size_t i = 0; i < prop_size; ++i) { DataType type; std::string name; - execution::Value default_value; + columnar::Value default_value; arc >> type >> name >> default_value; builder.AddProperty(name, default_value); } diff --git a/src/storages/graph/property_graph.cc b/src/storages/graph/property_graph.cc index 96c73a1d5..7d9928468 100644 --- a/src/storages/graph/property_graph.cc +++ b/src/storages/graph/property_graph.cc @@ -161,7 +161,7 @@ Status PropertyGraph::CreateVertexType(const CreateVertexTypeParam& config) { } std::vector property_names; std::vector property_types; - std::vector default_property_values; + std::vector default_property_values; std::vector> primary_keys; const auto& primary_key_names = config.GetPrimaryKeyNames(); std::vector primary_key_inds(primary_key_names.size(), -1); @@ -286,7 +286,7 @@ Status PropertyGraph::CreateEdgeType(const CreateEdgeTypeParam& config) { } std::vector property_names; std::vector property_types; - std::vector default_property_values; + std::vector default_property_values; const auto& properties = config.GetProperties(); for (size_t i = 0; i < properties.size(); i++) { const auto& [name, default_value] = properties[i]; @@ -335,7 +335,7 @@ Status PropertyGraph::AddVertexProperties( RETURN_IF_NOT_OK(vertex_label_check(vertex_type_name)); std::vector add_property_names; std::vector add_property_types; - std::vector add_default_property_values; + std::vector add_default_property_values; for (size_t i = 0; i < add_properties.size(); i++) { const auto& [property_name, default_value] = add_properties[i]; if (schema_.vertex_has_property(vertex_type_name, property_name)) { @@ -368,7 +368,7 @@ Status PropertyGraph::AddEdgeProperties(const AddEdgePropertiesParam& config) { edge_triplet_check(src_type_name, dst_type_name, edge_type_name)); std::vector add_property_names; std::vector add_property_types; - std::vector add_default_props; + std::vector add_default_props; for (size_t i = 0; i < add_properties.size(); i++) { const auto& [property_name, default_value] = add_properties[i]; if (schema_.edge_has_property(src_type_name, dst_type_name, edge_type_name, @@ -660,7 +660,7 @@ Status PropertyGraph::BatchDeleteVertices(label_t v_label_id, return Status::OK(); } -Status PropertyGraph::DeleteVertex(label_t label, const execution::Value& oid, +Status PropertyGraph::DeleteVertex(label_t label, const columnar::Value& oid, timestamp_t ts) { RETURN_IF_NOT_OK(vertex_label_check(label)); vid_t lid; @@ -1015,19 +1015,19 @@ size_t PropertyGraph::EdgeNum(label_t src_label, label_t edge_label, } } -bool PropertyGraph::get_lid(label_t label, const execution::Value& oid, +bool PropertyGraph::get_lid(label_t label, const columnar::Value& oid, vid_t& lid, timestamp_t ts) const { schema_.ensure_vertex_label_valid(label); return vertex_tables_[label].get_index(oid, lid, ts); } -execution::Value PropertyGraph::GetOid(label_t label, vid_t lid, - timestamp_t ts) const { +columnar::Value PropertyGraph::GetOid(label_t label, vid_t lid, + timestamp_t ts) const { return vertex_tables_[label].GetOid(lid, ts); } -Status PropertyGraph::AddVertex(label_t label, const execution::Value& id, - const std::vector& props, +Status PropertyGraph::AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& ret, timestamp_t ts, bool insert_safe) { RETURN_IF_NOT_OK(vertex_label_check(label)); if (!vertex_tables_[label].AddVertex(id, props, ret, ts, insert_safe)) { @@ -1039,7 +1039,7 @@ Status PropertyGraph::AddVertex(label_t label, const execution::Value& id, Status PropertyGraph::AddEdge(label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, label_t edge_label, - const std::vector& properties, + const std::vector& properties, timestamp_t ts, Allocator& alloc, int32_t& oe_offset, const void*& prop, bool insert_safe) { @@ -1067,7 +1067,7 @@ Status PropertyGraph::AddEdge(label_t src_label, vid_t src_lid, Status PropertyGraph::UpdateVertexProperty(label_t v_label, vid_t vid, int32_t prop_id, - const execution::Value& value, + const columnar::Value& value, timestamp_t ts) { assert(prop_id >= 0); RETURN_IF_NOT_OK(vertex_label_check(v_label)); @@ -1082,7 +1082,7 @@ Status PropertyGraph::UpdateEdgeProperty(label_t src_v_label, vid_t src_vid, label_t dst_v_label, vid_t dst_vid, label_t e_label, int32_t oe_offset, int32_t ie_offset, int32_t prop_id, - const execution::Value& value, + const columnar::Value& value, timestamp_t ts) { assert(prop_id >= 0); RETURN_IF_NOT_OK(edge_triplet_check(src_v_label, dst_v_label, e_label)); diff --git a/src/storages/graph/schema.cc b/src/storages/graph/schema.cc index 25fcd972b..b07b33ee5 100644 --- a/src/storages/graph/schema.cc +++ b/src/storages/graph/schema.cc @@ -40,7 +40,7 @@ namespace neug { -using execution::Value; +using columnar::Value; std::shared_ptr parse_extra_type_info(YAML::Node node) { try { diff --git a/src/storages/graph/vertex_table.cc b/src/storages/graph/vertex_table.cc index fd65acebc..2f0c80fd4 100644 --- a/src/storages/graph/vertex_table.cc +++ b/src/storages/graph/vertex_table.cc @@ -89,7 +89,7 @@ void VertexTable::SetVertexSchema( vertex_schema_ = vertex_schema; } -bool VertexTable::get_index(const execution::Value& oid, vid_t& lid, +bool VertexTable::get_index(const columnar::Value& oid, vid_t& lid, timestamp_t ts) const { auto res = indexer_->get_index(oid, lid); if (NEUG_UNLIKELY(res && !v_ts_->IsVertexValid(lid, ts))) { @@ -106,7 +106,7 @@ size_t VertexTable::LidNum() const { return indexer_->size(); } vid_t internal::insert_vertex_pk_internal(IndexerType& indexer, VertexTimestamp& v_ts, - const execution::Value& id, + const columnar::Value& id, timestamp_t ts, bool insert_safe) { vid_t vid; if (NEUG_UNLIKELY(indexer.get_index(id, vid))) { @@ -122,8 +122,8 @@ vid_t internal::insert_vertex_pk_internal(IndexerType& indexer, return vid; } -bool VertexTable::AddVertex(const execution::Value& id, - const std::vector& props, +bool VertexTable::AddVertex(const columnar::Value& id, + const std::vector& props, vid_t& vid, timestamp_t ts, bool insert_safe) { if (indexer_->capacity() <= indexer_->size()) { return false; @@ -142,8 +142,7 @@ bool VertexTable::AddVertex(const execution::Value& id, } bool VertexTable::UpdateProperty(vid_t vid, int32_t prop_id, - const execution::Value& value, - timestamp_t ts) { + const columnar::Value& value, timestamp_t ts) { if (NEUG_UNLIKELY(vid >= indexer_->size())) { LOG(ERROR) << "Lid " << vid << " is out of range."; return false; @@ -161,7 +160,7 @@ bool VertexTable::UpdateProperty(vid_t vid, int32_t prop_id, return true; } -execution::Value VertexTable::GetOid(vid_t lid, timestamp_t ts) const { +columnar::Value VertexTable::GetOid(vid_t lid, timestamp_t ts) const { if (NEUG_UNLIKELY(lid >= indexer_->size())) { THROW_INVALID_ARGUMENT_EXCEPTION("Lid " + std::to_string(lid) + " is out of range."); @@ -203,7 +202,7 @@ void VertexTable::BatchDeleteVertices(const std::vector& vids) { VLOG(10) << "Deleted " << delete_cnt << " vertices in batch."; } -void VertexTable::DeleteVertex(const execution::Value& id, timestamp_t ts) { +void VertexTable::DeleteVertex(const columnar::Value& id, timestamp_t ts) { vid_t vid; if (!get_index(id, vid, ts)) { LOG(WARNING) << "Vertex with id " << id.to_string() << " not found."; @@ -242,7 +241,7 @@ void VertexTable::DeleteProperties(const std::vector& properties) { void VertexTable::AddProperties( Checkpoint& ckp, const std::vector& properties, const std::vector& types, - const std::vector& default_values) { + const std::vector& default_values) { table_->add_columns(ckp, properties, types, default_values, indexer_->capacity(), memory_level_); } @@ -260,7 +259,7 @@ void VertexTable::Compact(timestamp_t ts) { // TODO(zhanglei): Support compact unused lid in indexer_ and table } -vid_t VertexTable::insert_vertex_pk(const execution::Value& id, timestamp_t ts, +vid_t VertexTable::insert_vertex_pk(const columnar::Value& id, timestamp_t ts, bool insert_safe) { return internal::insert_vertex_pk_internal(*indexer_, *v_ts_, id, ts, insert_safe); diff --git a/src/storages/loader/loader_utils.cc b/src/storages/loader/loader_utils.cc index f8f314ae4..54cc281e2 100644 --- a/src/storages/loader/loader_utils.cc +++ b/src/storages/loader/loader_utils.cc @@ -28,8 +28,8 @@ #include #include "csv.hpp" -#include "neug/execution/common/columns/columns_utils.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/value.h" #include "neug/utils/datetime_parsers.h" #include "neug/utils/exception/exception.h" #include "neug/utils/string_utils.h" @@ -154,33 +154,33 @@ std::string canonicalize_bool_token( } template -execution::Value parse_typed_value(const std::string& token) { - return execution::Value::CreateValue( - execution::ValueConverter::typed_from_string(token)); +columnar::Value parse_typed_value(const std::string& token) { + return columnar::Value::CreateValue( + columnar::ValueConverter::typed_from_string(token)); } -execution::Value parse_date_value(const std::string& token) { +columnar::Value parse_date_value(const std::string& token) { int64_t millis = 0; if (parse_timestamp_ms(token, &millis) || parse_epoch_timestamp_ms(token, &millis)) { Date d; d.from_timestamp(millis); - return execution::Value::CreateValue(d); + return columnar::Value::CreateValue(d); } - return parse_typed_value(token); + return parse_typed_value(token); } -execution::Value parse_timestamp_value(const std::string& token) { +columnar::Value parse_timestamp_value(const std::string& token) { int64_t millis = 0; if (parse_timestamp_ms(token, &millis) || parse_epoch_timestamp_ms(token, &millis)) { - return execution::Value::CreateValue( + return columnar::Value::CreateValue( DateTime(millis)); } - return parse_typed_value(token); + return parse_typed_value(token); } -execution::Value parse_value_by_type( +columnar::Value parse_value_by_type( const std::string& token, const DataType& data_type, const std::unordered_set& true_values, const std::unordered_set& false_values) { @@ -205,7 +205,7 @@ execution::Value parse_value_by_type( case DataTypeId::kTimestampMs: return parse_timestamp_value(token); case DataTypeId::kInterval: - return parse_typed_value(token); + return parse_typed_value(token); case DataTypeId::kVarchar: return parse_typed_value(token); default: @@ -229,7 +229,7 @@ std::string unescape_token(const std::string& token, char escape_char) { } void append_csv_field_to_builder( - std::shared_ptr& builder, + std::shared_ptr& builder, const DataType& data_type, csv::CSVField field, const std::unordered_set& null_values, const std::unordered_set& true_values, @@ -289,15 +289,15 @@ struct CsvSupplierRuntime { reset_reader(); } - std::shared_ptr get_next_chunk() { + std::shared_ptr get_next_chunk() { if (!reader_) { return nullptr; } - std::vector> builders; + std::vector> builders; builders.reserve(selected_column_types_.size()); for (const auto& column_type : selected_column_types_) { - auto builder = execution::ColumnsUtils::create_builder(column_type); + auto builder = columnar::ColumnsUtils::create_builder(column_type); builder->reserve(chunk_size_); builders.emplace_back(std::move(builder)); } @@ -330,7 +330,7 @@ struct CsvSupplierRuntime { return nullptr; } - auto chunk = std::make_shared(); + auto chunk = std::make_shared(); for (size_t column_index = 0; column_index < builders.size(); ++column_index) { chunk->set(static_cast(column_index), @@ -708,7 +708,7 @@ CSVChunkSupplier::CSVChunkSupplier(const std::string& file_path, CSVChunkSupplier::~CSVChunkSupplier() = default; -std::shared_ptr CSVChunkSupplier::GetNextChunk() { +std::shared_ptr CSVChunkSupplier::GetNextChunk() { if (!runtime_) { THROW_IO_EXCEPTION("CSV runtime is null for file: " + file_path_); } @@ -954,8 +954,7 @@ void fillEdgeReaderMeta(label_t src_label_id, label_t dst_label_id, } void set_properties_from_context_column( - neug::ColumnBase* col, - const std::shared_ptr& ctx_col, + neug::ColumnBase* col, const std::shared_ptr& ctx_col, const std::vector& vids, std::shared_mutex& mutex) { // Row-by-row via get_elem() auto col_type = col->type(); diff --git a/src/transaction/insert_transaction.cc b/src/transaction/insert_transaction.cc index a8d2f2659..a23770475 100644 --- a/src/transaction/insert_transaction.cc +++ b/src/transaction/insert_transaction.cc @@ -22,7 +22,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/allocators.h" #include "neug/storages/graph/schema.h" #include "neug/transaction/transaction_utils.h" @@ -47,8 +47,7 @@ InsertTransaction::InsertTransaction(SnapshotGuard guard, Allocator& alloc, InsertTransaction::~InsertTransaction() { Abort(); } -bool InsertTransaction::GetVertexIndex(label_t label, - const execution::Value& id, +bool InsertTransaction::GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const { if (view_->get_lid(label, id, index, timestamp_)) { return true; @@ -61,14 +60,14 @@ bool InsertTransaction::GetVertexIndex(label_t label, return false; } -execution::Value InsertTransaction::get_vertex_id(label_t label, - vid_t lid) const { +columnar::Value InsertTransaction::get_vertex_id(label_t label, + vid_t lid) const { if (added_vertices_.size() <= label || added_vertices_[label] == nullptr) { return view_->GetOid(label, lid, timestamp_); } vid_t base = added_vertices_base_[label]; if (lid >= base) { - execution::Value ret{DataType{DataTypeId::kNull}}; + columnar::Value ret{DataType{DataTypeId::kNull}}; CHECK(added_vertices_[label]->get_key(lid - base, ret)); return ret; } else { @@ -76,8 +75,8 @@ execution::Value InsertTransaction::get_vertex_id(label_t label, } } -Status InsertTransaction::AddVertex(label_t label, const execution::Value& id, - const std::vector& props, +Status InsertTransaction::AddVertex(label_t label, const columnar::Value& id, + const std::vector& props, vid_t& vid) { std::vector types = view_->schema().get_vertex_properties(label); if (types.size() != props.size()) { @@ -119,7 +118,7 @@ Status InsertTransaction::AddVertex(label_t label, const execution::Value& id, Status InsertTransaction::AddEdge( label_t src_label, vid_t src_vid, label_t dst_label, vid_t dst_vid, - label_t edge_label, const std::vector& properties, + label_t edge_label, const std::vector& properties, const void*& prop) { const auto& src = get_vertex_id(src_label, src_vid); const auto& dst = get_vertex_id(dst_label, dst_vid); diff --git a/src/transaction/update_transaction.cc b/src/transaction/update_transaction.cc index 3223b9a13..87d80ca62 100644 --- a/src/transaction/update_transaction.cc +++ b/src/transaction/update_transaction.cc @@ -25,8 +25,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/common/extra_type_info.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/allocators.h" #include "neug/storages/csr/csr_base.h" #include "neug/storages/csr/csr_view_utils.h" @@ -591,8 +591,8 @@ Status StorageTPUpdateInterface::DeleteEdgeType(const std::string& src_type, } Status StorageTPUpdateInterface::AddVertex( - label_t label, const execution::Value& oid, - const std::vector& props, vid_t& vid) { + label_t label, const columnar::Value& oid, + const std::vector& props, vid_t& vid) { std::vector types = cow_graph_->schema().get_vertex_properties(label); if (types.size() != props.size()) { @@ -650,7 +650,7 @@ Status StorageTPUpdateInterface::DeleteVertex(label_t label, vid_t lid) { Status StorageTPUpdateInterface::AddEdge( label_t src_label, vid_t src_lid, label_t dst_label, vid_t dst_lid, - label_t edge_label, const std::vector& properties, + label_t edge_label, const std::vector& properties, const void*& prop) { const auto& edge_table = cow_graph_->get_edge_table(src_label, dst_label, edge_label); @@ -750,8 +750,8 @@ Status StorageTPUpdateInterface::DeleteEdge(label_t src_label, vid_t src_lid, edge_label, oe_offset, ie_offset, read_ts_); } -execution::Value UpdateTransaction::GetVertexProperty(label_t label, vid_t lid, - int col_id) const { +columnar::Value UpdateTransaction::GetVertexProperty(label_t label, vid_t lid, + int col_id) const { auto col = cow_graph_->GetVertexPropertyColumn(label, col_id); if (!cow_graph_->IsValidLid(label, lid, timestamp_)) { THROW_INVALID_ARGUMENT_EXCEPTION( @@ -763,19 +763,17 @@ execution::Value UpdateTransaction::GetVertexProperty(label_t label, vid_t lid, return col->get_any(lid); } -execution::Value UpdateTransaction::GetVertexId(label_t label, - vid_t lid) const { +columnar::Value UpdateTransaction::GetVertexId(label_t label, vid_t lid) const { return cow_graph_->GetOid(label, lid, timestamp_); } -bool UpdateTransaction::GetVertexIndex(label_t label, - const execution::Value& id, +bool UpdateTransaction::GetVertexIndex(label_t label, const columnar::Value& id, vid_t& index) const { return cow_graph_->get_lid(label, id, index, timestamp_); } Status StorageTPUpdateInterface::UpdateVertexProperty( - label_t label, vid_t lid, int col_id, const execution::Value& value) { + label_t label, vid_t lid, int col_id, const columnar::Value& value) { if (!cow_graph_->IsValidLid(label, lid, read_ts_)) { return Status(StatusCode::ERR_INVALID_ARGUMENT, "Vertex lid " + std::to_string(lid) + " of label " + @@ -801,7 +799,7 @@ Status StorageTPUpdateInterface::UpdateVertexProperty( Status StorageTPUpdateInterface::UpdateEdgeProperty( label_t src_label, vid_t src, label_t dst_label, vid_t dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int32_t col_id, - const execution::Value& value) { + const columnar::Value& value) { if (!cow_graph_->IsValidLid(src_label, src, read_ts_) || !cow_graph_->IsValidLid(dst_label, dst, read_ts_)) { return Status(StatusCode::ERR_INVALID_ARGUMENT, diff --git a/src/transaction/wal/wal.cc b/src/transaction/wal/wal.cc index a758daf3d..132416fe7 100644 --- a/src/transaction/wal/wal.cc +++ b/src/transaction/wal/wal.cc @@ -23,7 +23,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/transaction/wal/dummy_wal_writer.h" #include "neug/utils/serialization/in_archive.h" #include "neug/utils/serialization/out_archive.h" @@ -249,8 +249,8 @@ void DeleteEdgeTypeRedo::Deserialize(OutArchive& arc, } void InsertVertexRedo::Serialize(InArchive& arc, label_t label, - const execution::Value& oid, - const std::vector& props) { + const columnar::Value& oid, + const std::vector& props) { arc << static_cast(OpType::kInsertVertex); arc << label << oid; arc << static_cast(props.size()); @@ -269,10 +269,10 @@ void InsertVertexRedo::Deserialize(OutArchive& arc, InsertVertexRedo& redo) { } } -void InsertEdgeRedo::Serialize( - InArchive& arc, label_t src_label, const execution::Value& src, - label_t dst_label, const execution::Value& dst, label_t edge_label, - const std::vector& properties) { +void InsertEdgeRedo::Serialize(InArchive& arc, label_t src_label, + const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, + const std::vector& properties) { arc << static_cast(OpType::kInsertEdge); arc << src_label << src << dst_label << dst << edge_label; arc << static_cast(properties.size()); @@ -293,8 +293,8 @@ void InsertEdgeRedo::Deserialize(OutArchive& arc, InsertEdgeRedo& redo) { } void UpdateVertexPropRedo::Serialize(InArchive& arc, label_t label, - const execution::Value& oid, int prop_id, - const execution::Value& value) { + const columnar::Value& oid, int prop_id, + const columnar::Value& value) { arc << static_cast(OpType::kUpdateVertexProp); arc << label << oid << prop_id << value; } @@ -305,12 +305,12 @@ void UpdateVertexPropRedo::Deserialize(OutArchive& arc, } void UpdateEdgePropRedo::Serialize(InArchive& arc, label_t src_label, - const execution::Value& src, + const columnar::Value& src, label_t dst_label, - const execution::Value& dst, + const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset, int prop_id, - const execution::Value& value) { + const columnar::Value& value) { arc << static_cast(OpType::kUpdateEdgeProp); arc << src_label << src << dst_label << dst << edge_label; arc << oe_offset << ie_offset; @@ -326,7 +326,7 @@ void UpdateEdgePropRedo::Deserialize(OutArchive& arc, } void RemoveVertexRedo::Serialize(InArchive& arc, label_t label, - const execution::Value& oid) { + const columnar::Value& oid) { arc << static_cast(OpType::kRemoveVertex); arc << label << oid; } @@ -336,8 +336,8 @@ void RemoveVertexRedo::Deserialize(OutArchive& arc, RemoveVertexRedo& redo) { } void RemoveEdgeRedo::Serialize(InArchive& arc, label_t src_label, - const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, + const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset) { arc << static_cast(OpType::kRemoveEdge); arc << src_label << src << dst_label << dst << edge_label; diff --git a/src/transaction/wal/wal_builder.cc b/src/transaction/wal/wal_builder.cc index 827ff5237..1c4a175cc 100644 --- a/src/transaction/wal/wal_builder.cc +++ b/src/transaction/wal/wal_builder.cc @@ -109,45 +109,45 @@ void WalBuilder::LogDeleteEdgeType(const std::string& src_type, // DML logging // ============================================================================= -void WalBuilder::LogInsertVertex(label_t label, const execution::Value& oid, - const std::vector& props) { +void WalBuilder::LogInsertVertex(label_t label, const columnar::Value& oid, + const std::vector& props) { InsertVertexRedo::Serialize(arc_, label, oid, props); ++op_num_; } -void WalBuilder::LogInsertEdge( - label_t src_label, const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, - const std::vector& properties) { +void WalBuilder::LogInsertEdge(label_t src_label, const columnar::Value& src, + label_t dst_label, const columnar::Value& dst, + label_t edge_label, + const std::vector& properties) { InsertEdgeRedo::Serialize(arc_, src_label, src, dst_label, dst, edge_label, properties); ++op_num_; } -void WalBuilder::LogUpdateVertexProp(label_t label, const execution::Value& oid, +void WalBuilder::LogUpdateVertexProp(label_t label, const columnar::Value& oid, int prop_id, - const execution::Value& value) { + const columnar::Value& value) { UpdateVertexPropRedo::Serialize(arc_, label, oid, prop_id, value); ++op_num_; } void WalBuilder::LogUpdateEdgeProp( - label_t src_label, const execution::Value& src, label_t dst_label, - const execution::Value& dst, label_t edge_label, int32_t oe_offset, - int32_t ie_offset, int prop_id, const execution::Value& value) { + label_t src_label, const columnar::Value& src, label_t dst_label, + const columnar::Value& dst, label_t edge_label, int32_t oe_offset, + int32_t ie_offset, int prop_id, const columnar::Value& value) { UpdateEdgePropRedo::Serialize(arc_, src_label, src, dst_label, dst, edge_label, oe_offset, ie_offset, prop_id, value); ++op_num_; } -void WalBuilder::LogRemoveVertex(label_t label, const execution::Value& oid) { +void WalBuilder::LogRemoveVertex(label_t label, const columnar::Value& oid) { RemoveVertexRedo::Serialize(arc_, label, oid); ++op_num_; } -void WalBuilder::LogRemoveEdge(label_t src_label, const execution::Value& src, - label_t dst_label, const execution::Value& dst, +void WalBuilder::LogRemoveEdge(label_t src_label, const columnar::Value& src, + label_t dst_label, const columnar::Value& dst, label_t edge_label, int32_t oe_offset, int32_t ie_offset) { RemoveEdgeRedo::Serialize(arc_, src_label, src, dst_label, dst, edge_label, diff --git a/src/utils/io/read/common/row_expression_filter.cc b/src/utils/io/read/common/row_expression_filter.cc index 0b890c784..46a11a65b 100644 --- a/src/utils/io/read/common/row_expression_filter.cc +++ b/src/utils/io/read/common/row_expression_filter.cc @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/storages/loader/loader_utils.h" #include "neug/utils/exception/exception.h" @@ -29,32 +29,31 @@ namespace neug { namespace reader { namespace { -execution::Value proto_value_to_execution(const ::common::Value& value) { +columnar::Value proto_value_to_execution(const ::common::Value& value) { switch (value.item_case()) { case ::common::Value::kBoolean: - return execution::Value::BOOLEAN(value.boolean()); + return columnar::Value::BOOLEAN(value.boolean()); case ::common::Value::kI32: - return execution::Value::INT32(value.i32()); + return columnar::Value::INT32(value.i32()); case ::common::Value::kI64: - return execution::Value::INT64(value.i64()); + return columnar::Value::INT64(value.i64()); case ::common::Value::kU32: - return execution::Value::UINT32(value.u32()); + return columnar::Value::UINT32(value.u32()); case ::common::Value::kU64: - return execution::Value::UINT64(value.u64()); + return columnar::Value::UINT64(value.u64()); case ::common::Value::kF32: - return execution::Value::FLOAT(value.f32()); + return columnar::Value::FLOAT(value.f32()); case ::common::Value::kF64: - return execution::Value::DOUBLE(value.f64()); + return columnar::Value::DOUBLE(value.f64()); case ::common::Value::kStr: - return execution::Value::STRING(value.str()); + return columnar::Value::STRING(value.str()); default: THROW_CONVERSION_EXCEPTION("Unsupported constant type in row filter"); } } bool compare_values(const ::common::Logical& logical, - const execution::Value& left, - const execution::Value& right) { + const columnar::Value& left, const columnar::Value& right) { switch (logical) { case ::common::Logical::GT: return right < left; @@ -93,7 +92,7 @@ RowExpressionFilter::RowExpressionFilter( const ::common::Expression& expr, const std::unordered_map& column_index) { using ValueFn = - std::function; + std::function; std::stack value_stack; std::stack<::common::ExprOpr> op_stack; @@ -108,12 +107,11 @@ RowExpressionFilter::RowExpressionFilter( } auto operand = value_stack.top(); value_stack.pop(); - value_stack.push( - [operand](const execution::DataChunk& chunk, size_t row) { - return execution::Value::BOOLEAN( - compare_values(::common::Logical::NOT, operand(chunk, row), - execution::Value::BOOLEAN(false))); - }); + value_stack.push([operand](const columnar::DataChunk& chunk, size_t row) { + return columnar::Value::BOOLEAN( + compare_values(::common::Logical::NOT, operand(chunk, row), + columnar::Value::BOOLEAN(false))); + }); return; } if (value_stack.size() < 2) { @@ -126,16 +124,16 @@ RowExpressionFilter::RowExpressionFilter( value_stack.pop(); auto logical = opr.logical(); value_stack.push([left_fn, right_fn, logical]( - const execution::DataChunk& chunk, size_t row) { + const columnar::DataChunk& chunk, size_t row) { auto left_val = left_fn(chunk, row); auto right_val = right_fn(chunk, row); if (logical == ::common::Logical::AND || logical == ::common::Logical::OR) { - return execution::Value::BOOLEAN(compare_values( - logical, execution::Value::BOOLEAN(left_val.GetValue()), - execution::Value::BOOLEAN(right_val.GetValue()))); + return columnar::Value::BOOLEAN(compare_values( + logical, columnar::Value::BOOLEAN(left_val.GetValue()), + columnar::Value::BOOLEAN(right_val.GetValue()))); } - return execution::Value::BOOLEAN( + return columnar::Value::BOOLEAN( compare_values(logical, left_val, right_val)); }); }; @@ -146,7 +144,7 @@ RowExpressionFilter::RowExpressionFilter( case ::common::ExprOpr::kConst: { auto value = proto_value_to_execution(opr.const_()); value_stack.push( - [value](const execution::DataChunk&, size_t) { return value; }); + [value](const columnar::DataChunk&, size_t) { return value; }); break; } case ::common::ExprOpr::kVar: { @@ -157,15 +155,14 @@ RowExpressionFilter::RowExpressionFilter( column_name); } int col_idx = iter->second; - value_stack.push( - [col_idx](const execution::DataChunk& chunk, size_t row) { - auto col = chunk.get(col_idx); - if (!col) { - THROW_RUNTIME_ERROR("Missing filter column at index " + - std::to_string(col_idx)); - } - return col->get_elem(row); - }); + value_stack.push([col_idx](const columnar::DataChunk& chunk, size_t row) { + auto col = chunk.get(col_idx); + if (!col) { + THROW_RUNTIME_ERROR("Missing filter column at index " + + std::to_string(col_idx)); + } + return col->get_elem(row); + }); break; } case ::common::ExprOpr::kBrace: { @@ -217,12 +214,12 @@ RowExpressionFilter::RowExpressionFilter( THROW_INVALID_ARGUMENT_EXCEPTION("Invalid filter expression"); } auto value_fn = value_stack.top(); - evaluator_ = [value_fn](const execution::DataChunk& chunk, size_t row) { + evaluator_ = [value_fn](const columnar::DataChunk& chunk, size_t row) { return value_fn(chunk, row).GetValue(); }; } -bool RowExpressionFilter::eval(const execution::DataChunk& chunk, +bool RowExpressionFilter::eval(const columnar::DataChunk& chunk, size_t row) const { if (!evaluator_) { return true; @@ -230,9 +227,9 @@ bool RowExpressionFilter::eval(const execution::DataChunk& chunk, return evaluator_(chunk, row); } -execution::DataChunk read_all_chunks( +columnar::DataChunk read_all_chunks( const std::vector>& suppliers) { - execution::DataChunk merged; + columnar::DataChunk merged; for (const auto& supplier : suppliers) { while (true) { auto chunk = supplier->GetNextChunk(); @@ -249,8 +246,8 @@ execution::DataChunk read_all_chunks( return merged; } -execution::DataChunk filter_chunk( - const execution::DataChunk& input, +columnar::DataChunk filter_chunk( + const columnar::DataChunk& input, const std::shared_ptr<::common::Expression>& filter_expr, const std::vector& column_names) { if (!filter_expr || input.row_num() == 0) { @@ -269,13 +266,13 @@ execution::DataChunk filter_chunk( } } - execution::DataChunk filtered = input; + columnar::DataChunk filtered = input; filtered.reshuffle(keep_offsets); return filtered; } -execution::DataChunk project_chunk( - const execution::DataChunk& input, +columnar::DataChunk project_chunk( + const columnar::DataChunk& input, const std::vector& column_names, const std::vector& project_columns) { if (project_columns.empty()) { @@ -285,7 +282,7 @@ execution::DataChunk project_chunk( std::unordered_map name_to_index; build_name_to_index(column_names, &name_to_index); - execution::DataChunk projected; + columnar::DataChunk projected; for (size_t i = 0; i < project_columns.size(); ++i) { auto iter = name_to_index.find(project_columns[i]); if (iter == name_to_index.end()) { diff --git a/src/utils/io/read/csv/csv_reader.cc b/src/utils/io/read/csv/csv_reader.cc index 63957c910..038e6ecfc 100644 --- a/src/utils/io/read/csv/csv_reader.cc +++ b/src/utils/io/read/csv/csv_reader.cc @@ -15,7 +15,7 @@ #include "neug/utils/io/read/csv/csv_reader.h" -#include "neug/execution/common/columns/container_types.h" +#include "neug/columnar/container_types.h" #include @@ -36,10 +36,10 @@ #include #include "neug/execution/common/context.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/storages/loader/loader_utils.h" #include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/operator_precedence.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/schema.h" @@ -50,24 +50,24 @@ namespace neug { namespace reader { namespace { -execution::Value proto_value_to_execution(const ::common::Value& value) { +columnar::Value proto_value_to_execution(const ::common::Value& value) { switch (value.item_case()) { case ::common::Value::kBoolean: - return execution::Value::BOOLEAN(value.boolean()); + return columnar::Value::BOOLEAN(value.boolean()); case ::common::Value::kI32: - return execution::Value::INT32(value.i32()); + return columnar::Value::INT32(value.i32()); case ::common::Value::kI64: - return execution::Value::INT64(value.i64()); + return columnar::Value::INT64(value.i64()); case ::common::Value::kU32: - return execution::Value::UINT32(value.u32()); + return columnar::Value::UINT32(value.u32()); case ::common::Value::kU64: - return execution::Value::UINT64(value.u64()); + return columnar::Value::UINT64(value.u64()); case ::common::Value::kF32: - return execution::Value::FLOAT(value.f32()); + return columnar::Value::FLOAT(value.f32()); case ::common::Value::kF64: - return execution::Value::DOUBLE(value.f64()); + return columnar::Value::DOUBLE(value.f64()); case ::common::Value::kStr: - return execution::Value::STRING(value.str()); + return columnar::Value::STRING(value.str()); default: THROW_CONVERSION_EXCEPTION("Unsupported constant type in CSV row filter"); } @@ -91,7 +91,7 @@ bool is_numeric_type(DataTypeId id) { } } -double value_to_double(const execution::Value& v) { +double value_to_double(const columnar::Value& v) { switch (v.type().id()) { case DataTypeId::kInt8: return static_cast(v.GetValue()); @@ -117,8 +117,7 @@ double value_to_double(const execution::Value& v) { } bool compare_values(const ::common::Logical& logical, - const execution::Value& left, - const execution::Value& right) { + const columnar::Value& left, const columnar::Value& right) { // Numeric type coercion: promote both operands to double when types differ. if (left.type() != right.type() && is_numeric_type(left.type().id()) && is_numeric_type(right.type().id())) { @@ -174,7 +173,7 @@ class CsvRowFilter { compile(expr); } - bool eval(const execution::DataChunk& chunk, size_t row) const { + bool eval(const columnar::DataChunk& chunk, size_t row) const { if (!evaluator_) { return true; } @@ -183,8 +182,8 @@ class CsvRowFilter { private: using ValueFn = - std::function; - using EvalFn = std::function; + std::function; + using EvalFn = std::function; void compile(const ::common::Expression& expr) { std::stack value_stack; @@ -202,7 +201,7 @@ class CsvRowFilter { value_stack.pop(); auto arith = opr.arith(); value_stack.push([left_fn, right_fn, arith]( - const execution::DataChunk& chunk, size_t row) { + const columnar::DataChunk& chunk, size_t row) { double l = value_to_double(left_fn(chunk, row)); double r = value_to_double(right_fn(chunk, row)); double result = 0; @@ -226,7 +225,7 @@ class CsvRowFilter { result = 0; break; } - return execution::Value::DOUBLE(result); + return columnar::Value::DOUBLE(result); }); return; } @@ -241,10 +240,10 @@ class CsvRowFilter { auto operand = value_stack.top(); value_stack.pop(); value_stack.push( - [operand](const execution::DataChunk& chunk, size_t row) { - return execution::Value::BOOLEAN( + [operand](const columnar::DataChunk& chunk, size_t row) { + return columnar::Value::BOOLEAN( compare_values(::common::Logical::NOT, operand(chunk, row), - execution::Value::BOOLEAN(false))); + columnar::Value::BOOLEAN(false))); }); return; } @@ -258,16 +257,16 @@ class CsvRowFilter { value_stack.pop(); auto logical = opr.logical(); value_stack.push([left_fn, right_fn, logical]( - const execution::DataChunk& chunk, size_t row) { + const columnar::DataChunk& chunk, size_t row) { auto left_val = left_fn(chunk, row); auto right_val = right_fn(chunk, row); if (logical == ::common::Logical::AND || logical == ::common::Logical::OR) { - return execution::Value::BOOLEAN(compare_values( - logical, execution::Value::BOOLEAN(left_val.GetValue()), - execution::Value::BOOLEAN(right_val.GetValue()))); + return columnar::Value::BOOLEAN(compare_values( + logical, columnar::Value::BOOLEAN(left_val.GetValue()), + columnar::Value::BOOLEAN(right_val.GetValue()))); } - return execution::Value::BOOLEAN( + return columnar::Value::BOOLEAN( compare_values(logical, left_val, right_val)); }); }; @@ -278,7 +277,7 @@ class CsvRowFilter { case ::common::ExprOpr::kConst: { auto value = proto_value_to_execution(opr.const_()); value_stack.push( - [value](const execution::DataChunk&, size_t) { return value; }); + [value](const columnar::DataChunk&, size_t) { return value; }); break; } case ::common::ExprOpr::kVar: { @@ -290,7 +289,7 @@ class CsvRowFilter { } int col_idx = iter->second; value_stack.push( - [col_idx](const execution::DataChunk& chunk, size_t row) { + [col_idx](const columnar::DataChunk& chunk, size_t row) { auto col = chunk.get(col_idx); if (!col) { THROW_RUNTIME_ERROR("Missing filter column at index " + @@ -347,7 +346,7 @@ class CsvRowFilter { case ::common::ExprOpr::kConst: { auto value = proto_value_to_execution(child_opr.const_()); value_stack.push( - [value](const execution::DataChunk&, size_t) { return value; }); + [value](const columnar::DataChunk&, size_t) { return value; }); break; } case ::common::ExprOpr::kVar: { @@ -359,7 +358,7 @@ class CsvRowFilter { } int idx = it->second; value_stack.push( - [idx](const execution::DataChunk& chunk, size_t row) { + [idx](const columnar::DataChunk& chunk, size_t row) { auto col = chunk.get(idx); if (!col) { THROW_RUNTIME_ERROR("Missing filter column at index " + @@ -397,7 +396,7 @@ class CsvRowFilter { THROW_INVALID_ARGUMENT_EXCEPTION("Invalid filter expression"); } auto value_fn = value_stack.top(); - evaluator_ = [value_fn](const execution::DataChunk& chunk, size_t row) { + evaluator_ = [value_fn](const columnar::DataChunk& chunk, size_t row) { return value_fn(chunk, row).GetValue(); }; } @@ -406,9 +405,9 @@ class CsvRowFilter { EvalFn evaluator_; }; -execution::DataChunk read_all_chunks( +columnar::DataChunk read_all_chunks( const std::vector>& suppliers) { - execution::DataChunk merged; + columnar::DataChunk merged; for (const auto& supplier : suppliers) { while (true) { auto chunk = supplier->GetNextChunk(); @@ -432,8 +431,8 @@ void build_name_to_index(const std::vector& column_names, } } -execution::DataChunk filter_chunk( - const execution::DataChunk& input, +columnar::DataChunk filter_chunk( + const columnar::DataChunk& input, const std::shared_ptr<::common::Expression>& filter_expr, const std::vector& column_names) { if (!filter_expr || input.row_num() == 0) { @@ -452,13 +451,13 @@ execution::DataChunk filter_chunk( } } - execution::DataChunk filtered = input; + columnar::DataChunk filtered = input; filtered.reshuffle(keep_offsets); return filtered; } -execution::DataChunk project_chunk( - const execution::DataChunk& input, +columnar::DataChunk project_chunk( + const columnar::DataChunk& input, const std::vector& column_names, const std::vector& project_columns) { if (project_columns.empty()) { @@ -468,7 +467,7 @@ execution::DataChunk project_chunk( std::unordered_map name_to_index; build_name_to_index(column_names, &name_to_index); - execution::DataChunk projected; + columnar::DataChunk projected; for (size_t i = 0; i < project_columns.size(); ++i) { auto iter = name_to_index.find(project_columns[i]); if (iter == name_to_index.end()) { @@ -568,8 +567,8 @@ std::shared_ptr CsvReader::full_read( : sharedState_->projectColumns); return std::make_shared( - std::vector>{ - std::make_shared(std::move(projected))}); + std::vector>{ + std::make_shared(std::move(projected))}); } std::shared_ptr CsvReader::batch_read( diff --git a/src/utils/io/read/json/json_reader.cc b/src/utils/io/read/json/json_reader.cc index e4aff6573..b23e50d66 100644 --- a/src/utils/io/read/json/json_reader.cc +++ b/src/utils/io/read/json/json_reader.cc @@ -28,11 +28,11 @@ #include #include -#include "neug/execution/common/columns/columns_utils.h" +#include "neug/columnar/columns/columns_utils.h" +#include "neug/columnar/value.h" #include "neug/execution/common/context.h" -#include "neug/execution/common/types/value.h" +#include "neug/execution/io/chunk_supplier.h" #include "neug/utils/exception/exception.h" -#include "neug/utils/io/read/common/chunk_supplier.h" #include "neug/utils/io/read/common/options.h" #include "neug/utils/io/read/common/row_expression_filter.h" #include "neug/utils/io/read/common/schema.h" @@ -88,64 +88,63 @@ std::vector convert_json_array_to_lines(const std::string& path) { return lines; } -execution::Value parse_json_value(const rapidjson::Value& value, - const DataType& data_type) { +columnar::Value parse_json_value(const rapidjson::Value& value, + const DataType& data_type) { if (value.IsNull()) { - return execution::Value(data_type); + return columnar::Value(data_type); } switch (data_type.id()) { case DataTypeId::kBoolean: if (value.IsBool()) { - return execution::Value::BOOLEAN(value.GetBool()); + return columnar::Value::BOOLEAN(value.GetBool()); } if (value.IsString()) { - return execution::Value::BOOLEAN( - execution::ValueConverter::typed_from_string( - value.GetString())); + return columnar::Value::BOOLEAN( + columnar::ValueConverter::typed_from_string(value.GetString())); } - return execution::Value::BOOLEAN(value.GetBool()); + return columnar::Value::BOOLEAN(value.GetBool()); case DataTypeId::kInt32: if (value.IsInt()) { - return execution::Value::INT32(value.GetInt()); + return columnar::Value::INT32(value.GetInt()); } - return execution::Value::INT32(static_cast(value.GetInt64())); + return columnar::Value::INT32(static_cast(value.GetInt64())); case DataTypeId::kUInt32: - return execution::Value::UINT32(value.GetUint()); + return columnar::Value::UINT32(value.GetUint()); case DataTypeId::kInt64: - return execution::Value::INT64(value.GetInt64()); + return columnar::Value::INT64(value.GetInt64()); case DataTypeId::kUInt64: - return execution::Value::UINT64(value.GetUint64()); + return columnar::Value::UINT64(value.GetUint64()); case DataTypeId::kFloat: - return execution::Value::FLOAT(static_cast(value.GetDouble())); + return columnar::Value::FLOAT(static_cast(value.GetDouble())); case DataTypeId::kDouble: - return execution::Value::DOUBLE(value.GetDouble()); + return columnar::Value::DOUBLE(value.GetDouble()); case DataTypeId::kVarchar: if (value.IsString()) { - return execution::Value::STRING(value.GetString()); + return columnar::Value::STRING(value.GetString()); } - return execution::Value::STRING(rapidjson_stringify(value)); + return columnar::Value::STRING(rapidjson_stringify(value)); case DataTypeId::kDate: if (value.IsString()) { - return execution::Value::DATE(Date(std::string(value.GetString()))); + return columnar::Value::DATE(Date(std::string(value.GetString()))); } - return execution::Value::STRING(rapidjson_stringify(value)); + return columnar::Value::STRING(rapidjson_stringify(value)); case DataTypeId::kTimestampMs: if (value.IsString()) { - return execution::Value::TIMESTAMPMS( + return columnar::Value::TIMESTAMPMS( DateTime(std::string(value.GetString()))); } - return execution::Value::STRING(rapidjson_stringify(value)); + return columnar::Value::STRING(rapidjson_stringify(value)); case DataTypeId::kInterval: if (value.IsString()) { - return execution::Value::INTERVAL( + return columnar::Value::INTERVAL( Interval(std::string(value.GetString()))); } - return execution::Value::STRING(rapidjson_stringify(value)); + return columnar::Value::STRING(rapidjson_stringify(value)); default: if (value.IsString()) { - return execution::Value::STRING(value.GetString()); + return columnar::Value::STRING(value.GetString()); } - return execution::Value::STRING(rapidjson_stringify(value)); + return columnar::Value::STRING(rapidjson_stringify(value)); } } @@ -173,7 +172,7 @@ class JsonChunkSupplier : public IDataChunkSupplier { chunk_size_ = resolve_chunk_size(config_); } - std::shared_ptr GetNextChunk() override { + std::shared_ptr GetNextChunk() override { const auto& selected_names = config_.include_columns.empty() ? config_.column_names : config_.include_columns; @@ -188,10 +187,10 @@ class JsonChunkSupplier : public IDataChunkSupplier { } } - std::vector> builders; + std::vector> builders; builders.reserve(selected_names.size()); for (const auto& type : selected_types) { - builders.push_back(execution::ColumnsUtils::create_builder(type)); + builders.push_back(columnar::ColumnsUtils::create_builder(type)); } size_t rows_in_chunk = 0; @@ -238,7 +237,7 @@ class JsonChunkSupplier : public IDataChunkSupplier { return nullptr; } - auto chunk = std::make_shared(); + auto chunk = std::make_shared(); for (size_t col = 0; col < builders.size(); ++col) { chunk->set(static_cast(col), builders[col]->finish()); } @@ -341,8 +340,8 @@ std::shared_ptr JsonReader::full_read( ? output_config.include_columns : sharedState_->projectColumns); return std::make_shared( - std::vector>{ - std::make_shared(std::move(projected))}); + std::vector>{ + std::make_shared(std::move(projected))}); } std::shared_ptr JsonReader::batch_read( diff --git a/src/utils/pb_utils.cc b/src/utils/pb_utils.cc index 61b597e56..495929e93 100644 --- a/src/utils/pb_utils.cc +++ b/src/utils/pb_utils.cc @@ -33,7 +33,7 @@ #include #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/generated/proto/plan/common.pb.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/utils/bolt_utils.h" @@ -249,55 +249,55 @@ bool data_type_to_property_type(const common::DataType& data_type, } bool common_value_to_value(const DataType& type, const common::Value& value, - execution::Value& out_value) { + columnar::Value& out_value) { switch (value.item_case()) { case common::Value::kBoolean: - out_value = execution::Value::BOOLEAN(value.boolean()); + out_value = columnar::Value::BOOLEAN(value.boolean()); break; case common::Value::kI32: - out_value = execution::Value::INT32(value.i32()); + out_value = columnar::Value::INT32(value.i32()); break; case common::Value::kI64: - out_value = execution::Value::INT64(value.i64()); + out_value = columnar::Value::INT64(value.i64()); break; case common::Value::kU32: - out_value = execution::Value::UINT32(value.u32()); + out_value = columnar::Value::UINT32(value.u32()); break; case common::Value::kU64: - out_value = execution::Value::UINT64(value.u64()); + out_value = columnar::Value::UINT64(value.u64()); break; case common::Value::kF32: - out_value = execution::Value::FLOAT(value.f32()); + out_value = columnar::Value::FLOAT(value.f32()); break; case common::Value::kF64: - out_value = execution::Value::DOUBLE(value.f64()); + out_value = columnar::Value::DOUBLE(value.f64()); break; case common::Value::kStr: if (type.id() == DataTypeId::kDate) { // Special handling for date stored as string Date date(value.str()); - out_value = execution::Value::DATE(date); + out_value = columnar::Value::DATE(date); break; } else if (type.id() == DataTypeId::kTimestampMs) { // Special handling for datetime stored as string DateTime datetime(value.str()); - out_value = execution::Value::TIMESTAMPMS(datetime); + out_value = columnar::Value::TIMESTAMPMS(datetime); break; } else if (type.id() == DataTypeId::kInterval) { // Special handling for interval stored as string Interval interval(value.str()); - out_value = execution::Value::INTERVAL(interval); + out_value = columnar::Value::INTERVAL(interval); break; } else { auto str_type_info = type.getExtraTypeInfo(); uint16_t max_length = str_type_info ? str_type_info->Cast().max_length : STRING_DEFAULT_MAX_LENGTH; - out_value = execution::Value::VARCHAR(value.str(), max_length); + out_value = columnar::Value::VARCHAR(value.str(), max_length); } break; case common::Value::kDate: - out_value = execution::Value::DATE(Date(value.date().item())); + out_value = columnar::Value::DATE(Date(value.date().item())); break; default: LOG(ERROR) << "Unknown value type: " << value.DebugString(); @@ -306,14 +306,14 @@ bool common_value_to_value(const DataType& type, const common::Value& value, return true; } -neug::result>> +neug::result>> property_defs_to_value( const google::protobuf::RepeatedPtrField& properties) { - std::vector> result; + std::vector> result; for (const auto& property : properties) { const auto& name = property.name(); - execution::Value default_value(DataType::SQLNULL); + columnar::Value default_value(DataType::SQLNULL); DataType type; if (!data_type_to_property_type(property.type(), type)) { RETURN_ERROR(Status(StatusCode::ERR_INVALID_ARGUMENT, diff --git a/src/utils/property/default_value.cc b/src/utils/property/default_value.cc index 2b5fd1ae3..0d200b64d 100644 --- a/src/utils/property/default_value.cc +++ b/src/utils/property/default_value.cc @@ -14,41 +14,41 @@ */ #include "neug/utils/property/default_value.h" -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" namespace neug { -execution::Value get_default_value(const DataType& type) { +columnar::Value get_default_value(const DataType& type) { switch (type.id()) { case DataTypeId::kEmpty: - return execution::Value(type); + return columnar::Value(type); case DataTypeId::kBoolean: - return execution::Value::BOOLEAN(false); + return columnar::Value::BOOLEAN(false); case DataTypeId::kInt32: - return execution::Value::INT32(0); + return columnar::Value::INT32(0); case DataTypeId::kUInt32: - return execution::Value::UINT32(0); + return columnar::Value::UINT32(0); case DataTypeId::kInt64: - return execution::Value::INT64(0); + return columnar::Value::INT64(0); case DataTypeId::kUInt64: - return execution::Value::UINT64(0); + return columnar::Value::UINT64(0); case DataTypeId::kFloat: - return execution::Value::FLOAT(0.0); + return columnar::Value::FLOAT(0.0); case DataTypeId::kDouble: - return execution::Value::DOUBLE(0.0); + return columnar::Value::DOUBLE(0.0); case DataTypeId::kVarchar: { int32_t width = type.getExtraTypeInfo() ? type.getExtraTypeInfo()->Cast().max_length : STRING_DEFAULT_MAX_LENGTH; - return execution::Value::VARCHAR("", width); + return columnar::Value::VARCHAR("", width); } case DataTypeId::kDate: - return execution::Value::DATE(Date(0)); + return columnar::Value::DATE(Date(0)); case DataTypeId::kTimestampMs: - return execution::Value::TIMESTAMPMS(DateTime(0)); + return columnar::Value::TIMESTAMPMS(DateTime(0)); case DataTypeId::kInterval: - return execution::Value::INTERVAL(Interval()); + return columnar::Value::INTERVAL(Interval()); default: THROW_NOT_SUPPORTED_EXCEPTION( "Unsupported property type for default value: " + type.ToString()); diff --git a/src/utils/property/table.cc b/src/utils/property/table.cc index 57c79c164..1a01dc9e4 100644 --- a/src/utils/property/table.cc +++ b/src/utils/property/table.cc @@ -101,7 +101,7 @@ void Table::reset_header(const std::vector& col_name) { void Table::add_columns( Checkpoint& ckp, const std::vector& col_names, const std::vector& col_types, - const std::vector& default_property_values, + const std::vector& default_property_values, size_t capacity, MemoryLevel memory_level) { if (default_property_values.size() != col_names.size()) { THROW_RUNTIME_ERROR("default_property_values size mismatch: expected " + @@ -210,8 +210,8 @@ const ColumnBase* Table::get_column(const std::string& name) const { return nullptr; } -std::vector Table::get_row(size_t row_id) const { - std::vector ret; +std::vector Table::get_row(size_t row_id) const { + std::vector ret; for (auto& ptr : columns_) { ret.push_back(ptr->get_any(row_id)); } @@ -236,7 +236,7 @@ const ColumnBase* Table::get_column_by_id(size_t index) const { size_t Table::col_num() const { return columns_.size(); } -void Table::insert(size_t index, const std::vector& values, +void Table::insert(size_t index, const std::vector& values, bool insert_safe) { assert(values.size() == columns_.size()); CHECK_EQ(values.size(), columns_.size()); @@ -253,7 +253,7 @@ void Table::resize(size_t row_num) { } void Table::resize(size_t row_num, - const std::vector& default_values) { + const std::vector& default_values) { if (default_values.size() != columns_.size()) { THROW_RUNTIME_ERROR("default_values size mismatch: expected " + std::to_string(columns_.size()) + " but got " + diff --git a/tests/execution/test_runtime_column.cc b/tests/execution/test_runtime_column.cc index 734649d8f..22d3f6a42 100644 --- a/tests/execution/test_runtime_column.cc +++ b/tests/execution/test_runtime_column.cc @@ -15,11 +15,11 @@ #include #include -#include "neug/execution/common/columns/edge_columns.h" -#include "neug/execution/common/columns/path_columns.h" -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/columns/vertex_columns.h" -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/columns/edge_columns.h" +#include "neug/columnar/columns/path_columns.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/columns/vertex_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" #include "neug/storages/loader/loader_utils.h" @@ -44,7 +44,7 @@ class VertexColumnTest : public ::testing::Test { if (is_optional) { col_builder.push_back_null(); } - std::shared_ptr col = col_builder.finish(); + std::shared_ptr col = col_builder.finish(); return std::dynamic_pointer_cast(col); } @@ -57,7 +57,7 @@ class VertexColumnTest : public ::testing::Test { if (is_optional) { col_builder.push_back_null(); } - std::shared_ptr col = col_builder.finish(); + std::shared_ptr col = col_builder.finish(); return std::dynamic_pointer_cast(col); } @@ -70,7 +70,7 @@ class VertexColumnTest : public ::testing::Test { if (is_optional) { col_builder.push_back_null(); } - std::shared_ptr col = col_builder.finish(); + std::shared_ptr col = col_builder.finish(); return std::dynamic_pointer_cast(col); } }; @@ -80,7 +80,7 @@ TEST_F(VertexColumnTest, SLVertexColumnBasic) { this->build_sl_vertex_column(kLabel0, false); EXPECT_EQ(sl_col->size(), 2); - EXPECT_EQ(sl_col->column_type(), ContextColumnType::kVertex); + EXPECT_EQ(sl_col->column_type(), ColumnKind::kVertex); EXPECT_EQ(sl_col->column_info(), "SLVertexColumn(0)[2]"); EXPECT_EQ(sl_col->elem_type().id(), DataTypeId::kVertex); @@ -99,7 +99,7 @@ TEST_F(VertexColumnTest, SLVertexColumnOptional) { this->build_sl_vertex_column(kLabel0, true); EXPECT_EQ(sl_optional_col->size(), 3); - EXPECT_EQ(sl_optional_col->column_type(), ContextColumnType::kVertex); + EXPECT_EQ(sl_optional_col->column_type(), ColumnKind::kVertex); EXPECT_EQ(sl_optional_col->vertex_column_type(), VertexColumnType::kSingle); EXPECT_TRUE(sl_optional_col->is_optional()); @@ -1303,7 +1303,7 @@ TEST_F(PathColumnTest, OptionalPathColumnBasic) { ASSERT_NE(col, nullptr); EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "PathColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kPath); + EXPECT_EQ(col->column_type(), ColumnKind::kPath); EXPECT_EQ(col->elem_type().id(), DataTypeId::kPath); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1430,12 +1430,12 @@ TEST_F(PathColumnTest, OptionalPathColumnForeach) { EXPECT_EQ(collected[0].second, p1); } -class ArrowContextColumnTest : public ::testing::Test { +class ArrowColumnTest : public ::testing::Test { protected: void SetUp() override {} }; -TEST_F(ArrowContextColumnTest, DataChunkSupplierBasic) { +TEST_F(ArrowColumnTest, DataChunkSupplierBasic) { const char* var = std::getenv("TEST_PATH"); std::string test_path = var ? var : "/workspaces/neug/tests"; std::string resource_path = test_path + "/execution/resources"; diff --git a/tests/execution/test_value.cc b/tests/execution/test_value.cc index 8a233d8f1..c336fff1e 100644 --- a/tests/execution/test_value.cc +++ b/tests/execution/test_value.cc @@ -14,7 +14,7 @@ */ #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" namespace neug { namespace execution { diff --git a/tests/execution/test_value_column.cc b/tests/execution/test_value_column.cc index ad5f4d9d2..74a2f9f0c 100644 --- a/tests/execution/test_value_column.cc +++ b/tests/execution/test_value_column.cc @@ -15,9 +15,9 @@ #include #include -#include "neug/execution/common/columns/list_columns.h" -#include "neug/execution/common/columns/struct_columns.h" -#include "neug/execution/common/columns/value_columns.h" +#include "neug/columnar/columns/list_columns.h" +#include "neug/columnar/columns/struct_columns.h" +#include "neug/columnar/columns/value_columns.h" namespace neug { namespace execution { @@ -42,7 +42,7 @@ TEST_F(ValueColumnTest, BoolValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), true); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kBoolean); // shuffle @@ -129,7 +129,7 @@ TEST_F(ValueColumnTest, I32ValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), 10); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInt32); // shuffle @@ -215,7 +215,7 @@ TEST_F(ValueColumnTest, I64ValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), 10); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInt64); // shuffle @@ -301,7 +301,7 @@ TEST_F(ValueColumnTest, U32ValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), 10); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kUInt32); // shuffle @@ -387,7 +387,7 @@ TEST_F(ValueColumnTest, U64ValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), 10); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kUInt64); // shuffle @@ -473,7 +473,7 @@ TEST_F(ValueColumnTest, F32ValueColumnBasic) { EXPECT_FLOAT_EQ(elem0.GetValue(), 10.42); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kFloat); // shuffle @@ -559,7 +559,7 @@ TEST_F(ValueColumnTest, F64ValueColumnBasic) { EXPECT_DOUBLE_EQ(elem0.GetValue(), 10.42); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kDouble); // shuffle @@ -649,7 +649,7 @@ TEST_F(ValueColumnTest, ValueColumnStringBasic) { Value elem0 = col->get_elem(0); EXPECT_EQ(StringValue::Get(elem0), "hello"); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kVarchar); // shuffle @@ -736,7 +736,7 @@ TEST_F(ValueColumnTest, DateValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), Date(10)); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kDate); // shuffle @@ -822,7 +822,7 @@ TEST_F(ValueColumnTest, DateTimeValueColumnBasic) { EXPECT_EQ(elem0.GetValue(), DateTime(1766386400000)); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kTimestampMs); // shuffle @@ -914,7 +914,7 @@ TEST_F(ValueColumnTest, IntervalValueColumnBasic) { Interval(std::string("3years 2months"))); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInterval); // shuffle @@ -1032,7 +1032,7 @@ TEST_F(ValueColumnTest, TupleValueColumnBasic) { EXPECT_DOUBLE_EQ(children[2].GetValue(), -3.0); EXPECT_EQ(col->column_info(), "StructColumn[3]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kStruct); // shuffle @@ -1165,7 +1165,7 @@ TEST_F(ValueColumnTest, ListColumnBasic) { EXPECT_EQ(col->size(), 2); EXPECT_EQ(col->column_info(), "ListColumn[2]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kList); // // shuffle @@ -1194,7 +1194,7 @@ TEST_F(OptionalValueColumnTest, BoolOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kBoolean); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1235,7 +1235,7 @@ TEST_F(OptionalValueColumnTest, I32OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInt32); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1276,7 +1276,7 @@ TEST_F(OptionalValueColumnTest, I64OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInt64); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1317,7 +1317,7 @@ TEST_F(OptionalValueColumnTest, U32OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kUInt32); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1358,7 +1358,7 @@ TEST_F(OptionalValueColumnTest, U64OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kUInt64); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1399,7 +1399,7 @@ TEST_F(OptionalValueColumnTest, F32OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kFloat); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1440,7 +1440,7 @@ TEST_F(OptionalValueColumnTest, F64OptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kDouble); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1485,7 +1485,7 @@ TEST_F(OptionalValueColumnTest, StringOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kVarchar); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1527,7 +1527,7 @@ TEST_F(OptionalValueColumnTest, DateOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kDate); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1568,7 +1568,7 @@ TEST_F(OptionalValueColumnTest, DateTimeOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kTimestampMs); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1609,7 +1609,7 @@ TEST_F(OptionalValueColumnTest, IntervalOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "ValueColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kInterval); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1673,7 +1673,7 @@ TEST_F(OptionalValueColumnTest, TupleOptionalValueColumnBasic) { EXPECT_EQ(col->size(), 3); EXPECT_EQ(col->column_info(), "StructColumn[3]"); EXPECT_EQ(col->elem_type().id(), DataTypeId::kStruct); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_TRUE(col->is_optional()); EXPECT_TRUE(col->has_value(0)); @@ -1732,7 +1732,7 @@ TEST_F(ListColumnTest, ListColumnBasic) { EXPECT_EQ(ListValue::GetChildren(col->get_elem(1)).size(), 1); EXPECT_EQ(col->column_info(), "ListColumn[2]"); - EXPECT_EQ(col->column_type(), ContextColumnType::kValue); + EXPECT_EQ(col->column_type(), ColumnKind::kValue); EXPECT_EQ(col->elem_type().id(), DataTypeId::kList); // Check first list [10, 20] diff --git a/tests/main/test_query_request.cc b/tests/main/test_query_request.cc index 1c080417f..e41015e8f 100644 --- a/tests/main/test_query_request.cc +++ b/tests/main/test_query_request.cc @@ -20,8 +20,8 @@ struct NumericParameterScenario { static std::tuple MakeRequest() { neug::execution::ParamsMap params = { - {"min_id", execution::Value::INT64(100)}, - {"limit", execution::Value::INT32(10)}, + {"min_id", columnar::Value::INT64(100)}, + {"limit", columnar::Value::INT32(10)}, }; return {"MATCH (n) WHERE n.id > $min_id RETURN n.id", "read", std::move(params)}; @@ -36,7 +36,7 @@ struct ListParameterScenario { static std::tuple MakeRequest() { neug::execution::ParamsMap params; - params.emplace("id_list", execution::Value::LIST(ListStorage())); + params.emplace("id_list", columnar::Value::LIST(ListStorage())); return {"MATCH (n) WHERE n.id IN $id_list RETURN n.id", "read", std::move(params)}; } @@ -46,10 +46,10 @@ struct ListParameterScenario { } private: - static std::vector ListStorage() { - static std::vector elements; + static std::vector ListStorage() { + static std::vector elements; for (int i = 1; i <= 5; ++i) { - elements.emplace_back(execution::Value::INT32(i)); + elements.emplace_back(columnar::Value::INT32(i)); } return elements; } diff --git a/tests/storage/alter_property_test.cc b/tests/storage/alter_property_test.cc index fc6598f80..f1a80e0c1 100644 --- a/tests/storage/alter_property_test.cc +++ b/tests/storage/alter_property_test.cc @@ -23,7 +23,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/csr/csr_base.h" #include "neug/storages/graph/property_graph.h" #include "neug/storages/graph/schema.h" @@ -207,15 +207,15 @@ void testOpenEmptyGraph(std::shared_ptr ckp, { LOG(INFO) << "Create vertex type PERSON"; std::string vertex_label_name = "PERSON"; - std::vector> properties; + std::vector> properties; std::vector primary_keys; primary_keys.emplace_back("id"); properties.emplace_back( - std::make_pair(std::string("id"), execution::Value::INT32(0))); + std::make_pair(std::string("id"), columnar::Value::INT32(0))); properties.emplace_back( - std::make_pair(std::string("name"), execution::Value::STRING(""))); + std::make_pair(std::string("name"), columnar::Value::STRING(""))); properties.emplace_back( - std::make_pair(std::string("age"), execution::Value::INT32(0))); + std::make_pair(std::string("age"), columnar::Value::INT32(0))); // testCreateVertexType(graph, vertex_label_name, properties, primary_keys); CreateVertexTypeParamBuilder builder; auto status = graph.CreateVertexType(builder.VertexLabel(vertex_label_name) @@ -233,9 +233,9 @@ void testOpenEmptyGraph(std::shared_ptr ckp, std::string src_vertex_label = "PERSON"; std::string edge_label_name = "KNOWS"; std::string dst_vertex_label = "PERSON"; - std::vector> edge_properties; + std::vector> edge_properties; edge_properties.emplace_back( - std::make_pair(std::string("weight"), execution::Value::FLOAT(0.0))); + std::make_pair(std::string("weight"), columnar::Value::FLOAT(0.0))); CreateEdgeTypeParamBuilder builder; auto status = graph.CreateEdgeType(builder.SrcLabel(src_vertex_label) .DstLabel(dst_vertex_label) @@ -293,10 +293,10 @@ void testOpenEmptyGraph(std::shared_ptr ckp, std::string src_vertex_type = "PERSON"; std::string dst_vertex_type = "PERSON"; std::string edge_type_name = "KNOWS"; - std::vector> add_properties; + std::vector> add_properties; add_properties.emplace_back( std::make_pair(std::string("creationDate"), - execution::Value::TIMESTAMPMS(DateTime(0)))); + columnar::Value::TIMESTAMPMS(DateTime(0)))); AddEdgePropertiesParamBuilder builder; graph.AddEdgeProperties(builder.SrcLabel(src_vertex_type) .DstLabel(dst_vertex_type) diff --git a/tests/storage/test_csr_batch_ops.cc b/tests/storage/test_csr_batch_ops.cc index aa4a623e1..631aa9297 100644 --- a/tests/storage/test_csr_batch_ops.cc +++ b/tests/storage/test_csr_batch_ops.cc @@ -1,8 +1,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/config.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/csr/immutable_csr.h" #include "neug/storages/csr/mutable_csr.h" @@ -52,7 +52,7 @@ class CsrBatchTest : public ::testing::Test { actual; auto view = this->csr->get_generic_view(0); auto ed_accessor = neug::EdgeDataAccessor( - neug::execution::ValueConverter::type().id(), + neug::columnar::ValueConverter::type().id(), nullptr); for (neug::vid_t src = 0; src < this->csr->size(); ++src) { auto es = view.get_edges(src); diff --git a/tests/storage/test_csr_stream_ops.cc b/tests/storage/test_csr_stream_ops.cc index 1564857f2..6dbf0cec2 100644 --- a/tests/storage/test_csr_stream_ops.cc +++ b/tests/storage/test_csr_stream_ops.cc @@ -61,7 +61,7 @@ class CsrStreamTest : public ::testing::Test { actual; auto view = this->csr->get_generic_view(ts); auto ed_accessor = neug::EdgeDataAccessor( - neug::execution::ValueConverter::type().id(), + neug::columnar::ValueConverter::type().id(), nullptr); for (neug::vid_t src = 0; src < this->csr->size(); ++src) { auto es = view.get_edges(src); diff --git a/tests/storage/test_edge_table.cc b/tests/storage/test_edge_table.cc index cbcbd8816..b91c5a47f 100644 --- a/tests/storage/test_edge_table.cc +++ b/tests/storage/test_edge_table.cc @@ -16,7 +16,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/execution/execute/ops/batch/batch_update_utils.h" #include "neug/storages/allocators.h" #include "neug/storages/checkpoint_manager.h" @@ -96,7 +96,7 @@ class EdgeTableTest : public ::testing::Test { neug::CheckpointManifest(), MemoryLevel::kInMemory); indexer.reserve(num); for (neug::vid_t i = 0; i < num; ++i) { - indexer.insert(neug::execution::Value::INT64(i), i); + indexer.insert(neug::columnar::Value::INT64(i), i); } } @@ -126,7 +126,7 @@ class EdgeTableTest : public ::testing::Test { } void BatchInsert( - std::vector>&& chunks) { + std::vector>&& chunks) { auto supplier = std::make_shared(std::move(chunks)); edge_table->BatchAddEdges(src_indexer, dst_indexer, supplier); } @@ -217,7 +217,7 @@ class EdgeTableTest : public ::testing::Test { } } - neug::vid_t GetSrcLid(const neug::execution::Value& src_oid) { + neug::vid_t GetSrcLid(const neug::columnar::Value& src_oid) { neug::vid_t src_lid; if (!src_indexer.get_index(src_oid, src_lid)) { LOG(FATAL) << "Cannot find src oid " << src_oid.to_string(); @@ -225,7 +225,7 @@ class EdgeTableTest : public ::testing::Test { return src_lid; } - neug::vid_t GetDstLid(const neug::execution::Value& dst_oid) { + neug::vid_t GetDstLid(const neug::columnar::Value& dst_oid) { neug::vid_t dst_lid; if (!dst_indexer.get_index(dst_oid, dst_lid)) { LOG(FATAL) << "Cannot find dst oid " << dst_oid.to_string(); @@ -592,9 +592,9 @@ TEST_F(EdgeTableTest, TestDeleteEdge) { for (size_t i = 0; i < edge_num; ++i) { if (i % 10 == 0) { neug::vid_t src_lid = - GetSrcLid(neug::execution::Value::INT64(src_list[i])); + GetSrcLid(neug::columnar::Value::INT64(src_list[i])); neug::vid_t dst_lid = - GetDstLid(neug::execution::Value::INT64(dst_list[i])); + GetDstLid(neug::columnar::Value::INT64(dst_list[i])); auto es = oe_view.get_edges(src_lid); auto is = ie_view.get_edges(dst_lid); for (auto it = es.begin(); it != es.end(); ++it) { @@ -683,9 +683,9 @@ TEST_F(EdgeTableTest, TestBatchAddEdgesBundled) { auto more_dst_list = generate_random_vertices( this->dst_indexer.size(), more_edge_num); auto more_data_list = generate_random_data(more_edge_num); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < more_edge_num; ++i) { - edge_data.push_back({neug::execution::Value::INT32(more_data_list[i])}); + edge_data.push_back({neug::columnar::Value::INT32(more_data_list[i])}); } // Insert more edges @@ -731,10 +731,10 @@ TEST_F(EdgeTableTest, TestBatchAddEdgesUnbundled) { this->dst_indexer.size(), more_edge_num); auto more_data_list0 = generate_random_data(more_edge_num); auto more_data_list1 = generate_random_data(more_edge_num); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < more_edge_num; ++i) { - edge_data.push_back({neug::execution::Value::STRING(more_data_list0[i]), - neug::execution::Value::INT32(more_data_list1[i])}); + edge_data.push_back({neug::columnar::Value::STRING(more_data_list0[i]), + neug::columnar::Value::INT32(more_data_list1[i])}); } // Insert more edges @@ -765,20 +765,20 @@ TEST_F(EdgeTableTest, TestAddEdgeAndDelete) { generate_random_vertices(dst_num, edge_num); for (auto src_oid : src_oids) { neug::vid_t src_lid = - this->src_indexer.insert(neug::execution::Value::INT64(src_oid), true); + this->src_indexer.insert(neug::columnar::Value::INT64(src_oid), true); src_lids.push_back(src_lid); } for (auto dst_oid : dst_oids) { neug::vid_t dst_lid = - this->dst_indexer.insert(neug::execution::Value::INT64(dst_oid), true); + this->dst_indexer.insert(neug::columnar::Value::INT64(dst_oid), true); dst_lids.push_back(dst_lid); } this->edge_table->EnsureCapacity(this->src_indexer.size(), this->dst_indexer.size()); this->ExpectBundledStats(0); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < src_lids.size(); ++i) { - edge_data.push_back({neug::execution::Value::INT32(static_cast(i))}); + edge_data.push_back({neug::columnar::Value::INT32(static_cast(i))}); } neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); @@ -884,21 +884,21 @@ TEST_F(EdgeTableTest, TestAddEdgeDeleteUnbundled) { generate_random_vertices(dst_num, edge_num); for (auto src_oid : src_oids) { neug::vid_t src_lid = - this->src_indexer.insert(neug::execution::Value::INT64(src_oid), true); + this->src_indexer.insert(neug::columnar::Value::INT64(src_oid), true); src_lids.push_back(src_lid); } for (auto dst_oid : dst_oids) { neug::vid_t dst_lid = - this->dst_indexer.insert(neug::execution::Value::INT64(dst_oid), true); + this->dst_indexer.insert(neug::columnar::Value::INT64(dst_oid), true); dst_lids.push_back(dst_lid); } this->edge_table->EnsureCapacity(this->src_indexer.size(), this->dst_indexer.size()); this->ExpectUnbundledStats(0, 0); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < src_lids.size(); ++i) { - edge_data.push_back({neug::execution::Value::STRING("edge_data"), - neug::execution::Value::INT32(static_cast(i))}); + edge_data.push_back({neug::columnar::Value::STRING("edge_data"), + neug::columnar::Value::INT32(static_cast(i))}); } neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); @@ -971,20 +971,20 @@ TEST_F(EdgeTableTest, TestEdgeTableCompaction) { generate_random_vertices(dst_num, edge_num); for (auto src_oid : src_oids) { neug::vid_t src_lid = - this->src_indexer.insert(neug::execution::Value::INT64(src_oid), true); + this->src_indexer.insert(neug::columnar::Value::INT64(src_oid), true); src_lids.push_back(src_lid); } for (auto dst_oid : dst_oids) { neug::vid_t dst_lid = - this->dst_indexer.insert(neug::execution::Value::INT64(dst_oid), true); + this->dst_indexer.insert(neug::columnar::Value::INT64(dst_oid), true); dst_lids.push_back(dst_lid); } this->edge_table->EnsureCapacity(this->src_indexer.size(), this->dst_indexer.size()); this->ExpectBundledStats(0); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < src_lids.size(); ++i) { - edge_data.push_back({neug::execution::Value::INT32(static_cast(i))}); + edge_data.push_back({neug::columnar::Value::INT32(static_cast(i))}); } neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); @@ -1046,21 +1046,21 @@ TEST_F(EdgeTableTest, TestUpdateEdgeData) { generate_random_vertices(dst_num, edge_num); for (auto src_oid : src_oids) { neug::vid_t src_lid = - this->src_indexer.insert(neug::execution::Value::INT64(src_oid), true); + this->src_indexer.insert(neug::columnar::Value::INT64(src_oid), true); src_lids.push_back(src_lid); } for (auto dst_oid : dst_oids) { neug::vid_t dst_lid = - this->dst_indexer.insert(neug::execution::Value::INT64(dst_oid), true); + this->dst_indexer.insert(neug::columnar::Value::INT64(dst_oid), true); dst_lids.push_back(dst_lid); } this->edge_table->EnsureCapacity(this->src_indexer.size(), this->dst_indexer.size()); this->ExpectUnbundledStats(0, 0); - std::vector> edge_data; + std::vector> edge_data; for (size_t i = 0; i < src_lids.size(); ++i) { - edge_data.push_back({neug::execution::Value::STRING("old_data"), - neug::execution::Value::INT32(static_cast(0))}); + edge_data.push_back({neug::columnar::Value::STRING("old_data"), + neug::columnar::Value::INT32(static_cast(0))}); } this->edge_table->EnsureCapacity(edge_data.size()); @@ -1071,9 +1071,9 @@ TEST_F(EdgeTableTest, TestUpdateEdgeData) { allocator, false); } this->ExpectUnbundledStats(edge_num, 4096); - std::vector new_data = { - neug::execution::Value::STRING(std::string("new_data")), - neug::execution::Value::INT32(static_cast(1))}; + std::vector new_data = { + neug::columnar::Value::STRING(std::string("new_data")), + neug::columnar::Value::INT32(static_cast(1))}; auto oe_view = this->edge_table->get_outgoing_view(neug::MAX_TIMESTAMP); auto ie_view = this->edge_table->get_incoming_view(neug::MAX_TIMESTAMP); auto ed_accessor_0 = this->edge_table->get_edge_data_accessor(0); @@ -1127,11 +1127,11 @@ TEST_F(EdgeTableTest, TestAddPropertiesTransitionFromEmptyToBundledUnbundled) { schema_.AddEdgeProperties("person", "comment", "create0", {"weight"}, {neug::DataTypeId::kInt32}, - {neug::execution::Value::INT32(7)}); + {neug::columnar::Value::INT32(7)}); this->edge_table->SetEdgeSchema( schema_.get_edge_schema(src_label_, dst_label_, edge_label_empty_)); this->edge_table->AddProperties(*ckp, {"weight"}, {neug::DataTypeId::kInt32}, - {neug::execution::Value::INT32(7)}); + {neug::columnar::Value::INT32(7)}); this->ExpectBundledStats(endpoints.size()); std::vector srcs, dsts; @@ -1146,12 +1146,12 @@ TEST_F(EdgeTableTest, TestAddPropertiesTransitionFromEmptyToBundledUnbundled) { schema_.AddEdgeProperties( "person", "comment", "create0", {"tag"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("new-tag"))}); + {neug::columnar::Value::STRING(std::string("new-tag"))}); this->edge_table->SetEdgeSchema( schema_.get_edge_schema(src_label_, dst_label_, edge_label_empty_)); this->edge_table->AddProperties( *ckp, {"tag"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("new-tag"))}); + {neug::columnar::Value::STRING(std::string("new-tag"))}); this->ExpectUnbundledStats(endpoints.size(), 4096); std::vector weights_after; @@ -1185,17 +1185,16 @@ TEST_F(EdgeTableTest, TestAddStringPropertyTransitionFromEmptyToUnbundled) { schema_.get_edge_schema(src_label_, dst_label_, edge_label_empty_)); schema_.get_edge_schema(src_label_, dst_label_, edge_label_empty_) ->add_properties({"tag"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("seed"))}); + {neug::columnar::Value::STRING(std::string("seed"))}); this->edge_table->AddProperties( *ckp, {"tag"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("seed"))}); + {neug::columnar::Value::STRING(std::string("seed"))}); schema_.get_edge_schema(src_label_, dst_label_, edge_label_empty_) - ->add_properties( - {"desc"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("unknown"))}); + ->add_properties({"desc"}, {neug::DataTypeId::kVarchar}, + {neug::columnar::Value::STRING(std::string("unknown"))}); this->edge_table->AddProperties( *ckp, {"desc"}, {neug::DataTypeId::kVarchar}, - {neug::execution::Value::STRING(std::string("unknown"))}); + {neug::columnar::Value::STRING(std::string("unknown"))}); this->ExpectUnbundledStats(src_list.size(), 4096); std::vector tags, descs; @@ -1225,12 +1224,12 @@ TEST_F(EdgeTableTest, {0, 1, "a", 11}, {1, 2, "b", 22}, {2, 3, "c", 33}}; neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); for (const auto& [src_oid, dst_oid, data0, data1] : input) { - auto src_lid = this->GetSrcLid(neug::execution::Value::INT64(src_oid)); - auto dst_lid = this->GetDstLid(neug::execution::Value::INT64(dst_oid)); + auto src_lid = this->GetSrcLid(neug::columnar::Value::INT64(src_oid)); + auto dst_lid = this->GetDstLid(neug::columnar::Value::INT64(dst_oid)); this->edge_table->AddEdge( src_lid, dst_lid, - {neug::execution::Value::STRING(std::string(data0)), - neug::execution::Value::INT32(data1)}, + {neug::columnar::Value::STRING(std::string(data0)), + neug::columnar::Value::INT32(data1)}, 0, allocator, false); } this->ExpectUnbundledStats(input.size(), 4096); @@ -1273,8 +1272,8 @@ TEST_F(EdgeTableTest, ASSERT_EQ(dsts.size(), input.size()); { - auto src_lid = this->GetSrcLid(neug::execution::Value::INT64(3)); - auto dst_lid = this->GetDstLid(neug::execution::Value::INT64(0)); + auto src_lid = this->GetSrcLid(neug::columnar::Value::INT64(3)); + auto dst_lid = this->GetDstLid(neug::columnar::Value::INT64(0)); this->edge_table->AddEdge(src_lid, dst_lid, {}, 0, allocator, false); } this->ExpectBundledStats(input.size() + 1); @@ -1298,11 +1297,11 @@ TEST_F(EdgeTableTest, TestDeletePropertiesTransitionFromUnbundledToBundled) { {0, 1, "a", 11}, {1, 2, "b", 22}, {2, 3, "c", 33}}; neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); for (const auto& [src_oid, dst_oid, data0, data1] : input) { - auto src_lid = this->GetSrcLid(neug::execution::Value::INT64(src_oid)); - auto dst_lid = this->GetDstLid(neug::execution::Value::INT64(dst_oid)); + auto src_lid = this->GetSrcLid(neug::columnar::Value::INT64(src_oid)); + auto dst_lid = this->GetDstLid(neug::columnar::Value::INT64(dst_oid)); this->edge_table->AddEdge(src_lid, dst_lid, - {neug::execution::Value::STRING(data0), - neug::execution::Value::INT32(data1)}, + {neug::columnar::Value::STRING(data0), + neug::columnar::Value::INT32(data1)}, 0, allocator, false); } this->ExpectUnbundledStats(input.size(), 4096); @@ -1338,10 +1337,10 @@ TEST_F(EdgeTableTest, TestDeletePropertiesTransitionFromUnbundledToBundled) { this->ExpectBundledStats(input.size()); { - auto src_lid = this->GetSrcLid(neug::execution::Value::INT64(3)); - auto dst_lid = this->GetDstLid(neug::execution::Value::INT64(0)); + auto src_lid = this->GetSrcLid(neug::columnar::Value::INT64(3)); + auto dst_lid = this->GetDstLid(neug::columnar::Value::INT64(0)); this->edge_table->AddEdge(src_lid, dst_lid, - {neug::execution::Value::INT32(44)}, 0, allocator, + {neug::columnar::Value::INT32(44)}, 0, allocator, false); } this->ExpectBundledStats(input.size() + 1); @@ -1360,23 +1359,23 @@ TEST_F(EdgeTableTest, TestAddAndDeletePropertiesStayUnbundled) { {0, 1, "a", 11}, {1, 2, "b", 22}, {2, 3, "c", 33}}; neug::Allocator allocator(neug::MemoryLevel::kInMemory, allocator_dir_); for (const auto& [src_oid, dst_oid, data0, data1] : input) { - auto src_lid = this->GetSrcLid(neug::execution::Value::INT64(src_oid)); - auto dst_lid = this->GetDstLid(neug::execution::Value::INT64(dst_oid)); + auto src_lid = this->GetSrcLid(neug::columnar::Value::INT64(src_oid)); + auto dst_lid = this->GetDstLid(neug::columnar::Value::INT64(dst_oid)); this->edge_table->AddEdge( src_lid, dst_lid, - {neug::execution::Value::STRING(std::string(data0)), - neug::execution::Value::INT32(data1)}, + {neug::columnar::Value::STRING(std::string(data0)), + neug::columnar::Value::INT32(data1)}, 0, allocator, false); } this->ExpectUnbundledStats(input.size(), 4096); schema_.AddEdgeProperties("person", "comment", "create3", {"score"}, {neug::DataTypeId::kInt32}, - {neug::execution::Value::INT32(99)}); + {neug::columnar::Value::INT32(99)}); this->edge_table->SetEdgeSchema( schema_.get_edge_schema(src_label_, dst_label_, edge_label_str_int_)); this->edge_table->AddProperties(*ckp, {"score"}, {neug::DataTypeId::kInt32}, - {neug::execution::Value::INT32(99)}); + {neug::columnar::Value::INT32(99)}); this->ExpectUnbundledStats(input.size(), 4096); std::vector score; @@ -1515,7 +1514,7 @@ TYPED_TEST(EdgeTableToolsTest, TestBatchAddEdges) { neug::CheckpointManifest(), MemoryLevel::kInMemory); indexer.reserve(10); for (uint32_t i = 0; i < 10; i++) { - auto oid = neug::execution::Value::UINT32(i); + auto oid = neug::columnar::Value::UINT32(i); indexer.insert(oid, false); } @@ -1566,7 +1565,7 @@ TYPED_TEST(EdgeTableToolsTest, TestAddProperties) { neug::CheckpointManifest(), MemoryLevel::kInMemory); indexer.reserve(10); for (uint32_t i = 0; i < 10; i++) { - auto oid = neug::execution::Value::UINT32(i); + auto oid = neug::columnar::Value::UINT32(i); indexer.insert(oid, false); } diff --git a/tests/storage/test_graph_snapshot_store_concurrency.cc b/tests/storage/test_graph_snapshot_store_concurrency.cc index 6f612cfef..3aec2e045 100644 --- a/tests/storage/test_graph_snapshot_store_concurrency.cc +++ b/tests/storage/test_graph_snapshot_store_concurrency.cc @@ -68,7 +68,7 @@ class GraphSnapshotStoreConcurrencyTest : public ::testing::Test { CreateVertexTypeParamBuilder person_builder; auto status = initial_pg_->CreateVertexType( person_builder.VertexLabel("person") - .AddProperty("id", execution::Value::INT64(0)) + .AddProperty("id", columnar::Value::INT64(0)) .AddPrimaryKeyName("id") .Build()); ASSERT_TRUE(status.ok()); @@ -293,7 +293,7 @@ TEST_F(GraphSnapshotStoreConcurrencyTest, CowPublishIsVisibleToNewReaders) { CreateVertexTypeParamBuilder builder; auto status = cow_pg->CreateVertexType( builder.VertexLabel("company") - .AddProperty("name", execution::Value::STRING("")) + .AddProperty("name", columnar::Value::STRING("")) .AddPrimaryKeyName("name") .Build()); ASSERT_TRUE(status.ok()); @@ -342,7 +342,7 @@ TEST_F(GraphSnapshotStoreConcurrencyTest, CowIsolationAfterCloneMutatePublish) { // Phase 1: seed the initial snapshot with a vertex. vid_t vid0 = 0; auto status = - initial_pg_->AddVertex(0, execution::Value::INT64(1), {}, vid0, 1); + initial_pg_->AddVertex(0, columnar::Value::INT64(1), {}, vid0, 1); ASSERT_TRUE(status.ok()); ASSERT_EQ(initial_pg_->VertexNum(0, MAX_TIMESTAMP), 1u); @@ -356,7 +356,7 @@ TEST_F(GraphSnapshotStoreConcurrencyTest, CowIsolationAfterCloneMutatePublish) { vt1.get_table().DetachAllColumns(*cow1->checkpoint_ptr(), cow1->memory_level()); vid_t vid1 = 0; - status = cow1->AddVertex(0, execution::Value::INT64(2), {}, vid1, 2); + status = cow1->AddVertex(0, columnar::Value::INT64(2), {}, vid1, 2); ASSERT_TRUE(status.ok()); ASSERT_EQ(cow1->VertexNum(0, MAX_TIMESTAMP), 2u); @@ -372,7 +372,7 @@ TEST_F(GraphSnapshotStoreConcurrencyTest, CowIsolationAfterCloneMutatePublish) { vt2.get_table().DetachAllColumns(*cow2->checkpoint_ptr(), cow2->memory_level()); vid_t vid2 = 0; - status = cow2->AddVertex(0, execution::Value::INT64(3), {}, vid2, 3); + status = cow2->AddVertex(0, columnar::Value::INT64(3), {}, vid2, 3); ASSERT_TRUE(status.ok()); // cow2 sees all three vertices. diff --git a/tests/storage/test_graph_view.cc b/tests/storage/test_graph_view.cc index 0c1ff5fa1..a1b5eaeeb 100644 --- a/tests/storage/test_graph_view.cc +++ b/tests/storage/test_graph_view.cc @@ -57,40 +57,39 @@ class GraphViewTest : public ::testing::Test { ASSERT_TRUE(graph_ ->CreateVertexType( person_builder.VertexLabel("person") - .AddProperty("id", execution::Value::INT64(0)) - .AddProperty("name", execution::Value::STRING("")) + .AddProperty("id", columnar::Value::INT64(0)) + .AddProperty("name", columnar::Value::STRING("")) .AddPrimaryKeyName("id") .Build()) .ok()); // Create edge type: knows CreateEdgeTypeParamBuilder knows_builder; - ASSERT_TRUE( - graph_ - ->CreateEdgeType( - knows_builder.SrcLabel("person") - .DstLabel("person") - .EdgeLabel("knows") - .AddProperty("weight", execution::Value::DOUBLE(0.0)) - .Build()) - .ok()); + ASSERT_TRUE(graph_ + ->CreateEdgeType( + knows_builder.SrcLabel("person") + .DstLabel("person") + .EdgeLabel("knows") + .AddProperty("weight", columnar::Value::DOUBLE(0.0)) + .Build()) + .ok()); // Add vertices label_t person_label = graph_->schema().get_vertex_label_id("person"); vid_t vid1, vid2, vid3; ASSERT_TRUE(graph_ - ->AddVertex(person_label, execution::Value::INT64(1), - {execution::Value::STRING("Alice")}, vid1, 0, + ->AddVertex(person_label, columnar::Value::INT64(1), + {columnar::Value::STRING("Alice")}, vid1, 0, false) .ok()); ASSERT_TRUE(graph_ - ->AddVertex(person_label, execution::Value::INT64(2), - {execution::Value::STRING("Bob")}, vid2, 0, + ->AddVertex(person_label, columnar::Value::INT64(2), + {columnar::Value::STRING("Bob")}, vid2, 0, false) .ok()); ASSERT_TRUE(graph_ - ->AddVertex(person_label, execution::Value::INT64(3), - {execution::Value::STRING("Charlie")}, vid3, 0, + ->AddVertex(person_label, columnar::Value::INT64(3), + {columnar::Value::STRING("Charlie")}, vid3, 0, false) .ok()); @@ -100,12 +99,12 @@ class GraphViewTest : public ::testing::Test { const void* edge_prop = nullptr; ASSERT_TRUE(graph_ ->AddEdge(person_label, vid1, person_label, vid2, - knows_label, {execution::Value::DOUBLE(0.5)}, 0, + knows_label, {columnar::Value::DOUBLE(0.5)}, 0, *alloc_, oe_offset, edge_prop, false) .ok()); ASSERT_TRUE(graph_ ->AddEdge(person_label, vid2, person_label, vid3, - knows_label, {execution::Value::DOUBLE(0.7)}, 0, + knows_label, {columnar::Value::DOUBLE(0.7)}, 0, *alloc_, oe_offset, edge_prop, false) .ok()); } @@ -130,11 +129,10 @@ TEST_F(GraphViewTest, GetLid) { label_t person_label = view.schema().get_vertex_label_id("person"); vid_t lid; - EXPECT_TRUE(view.get_lid(person_label, execution::Value::INT64(1), lid, 0)); - EXPECT_TRUE(view.get_lid(person_label, execution::Value::INT64(2), lid, 0)); - EXPECT_TRUE(view.get_lid(person_label, execution::Value::INT64(3), lid, 0)); - EXPECT_FALSE( - view.get_lid(person_label, execution::Value::INT64(999), lid, 0)); + EXPECT_TRUE(view.get_lid(person_label, columnar::Value::INT64(1), lid, 0)); + EXPECT_TRUE(view.get_lid(person_label, columnar::Value::INT64(2), lid, 0)); + EXPECT_TRUE(view.get_lid(person_label, columnar::Value::INT64(3), lid, 0)); + EXPECT_FALSE(view.get_lid(person_label, columnar::Value::INT64(999), lid, 0)); } TEST_F(GraphViewTest, GetOid) { diff --git a/tests/storage/test_property_graph.cc b/tests/storage/test_property_graph.cc index 83ad97c0e..d7047f458 100644 --- a/tests/storage/test_property_graph.cc +++ b/tests/storage/test_property_graph.cc @@ -15,7 +15,7 @@ #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/graph/property_graph.h" #include "unittest/utils.h" @@ -53,10 +53,10 @@ class PropertyGraphTest : public ::testing::Test { EXPECT_TRUE(graph_ ->CreateVertexType( person_builder.VertexLabel("person") - .AddProperty("id", execution::Value::INT64(0)) - .AddProperty("name", execution::Value::STRING("")) - .AddProperty("age", execution::Value::INT32(0)) - .AddProperty("score", execution::Value::DOUBLE(0.0)) + .AddProperty("id", columnar::Value::INT64(0)) + .AddProperty("name", columnar::Value::STRING("")) + .AddProperty("age", columnar::Value::INT32(0)) + .AddProperty("score", columnar::Value::DOUBLE(0.0)) .AddPrimaryKeyName("id") .Build()) .ok()); @@ -64,21 +64,20 @@ class PropertyGraphTest : public ::testing::Test { EXPECT_TRUE(graph_ ->CreateVertexType( company_builder.VertexLabel("company") - .AddProperty("id", execution::Value::INT64(0)) - .AddProperty("name", execution::Value::STRING("")) + .AddProperty("id", columnar::Value::INT64(0)) + .AddProperty("name", columnar::Value::STRING("")) .AddPrimaryKeyName("id") .Build()) .ok()); CreateEdgeTypeParamBuilder knows_builder; - EXPECT_TRUE( - graph_ - ->CreateEdgeType( - knows_builder.SrcLabel("person") - .DstLabel("person") - .EdgeLabel("knows") - .AddProperty("weight", execution::Value::DOUBLE(0.0)) - .Build()) - .ok()); + EXPECT_TRUE(graph_ + ->CreateEdgeType( + knows_builder.SrcLabel("person") + .DstLabel("person") + .EdgeLabel("knows") + .AddProperty("weight", columnar::Value::DOUBLE(0.0)) + .Build()) + .ok()); } }; @@ -89,17 +88,17 @@ TEST_F(PropertyGraphTest, TestOpenAndBulkInsert) { vid_t vid1, vid2; EXPECT_TRUE(graph_ - ->AddVertex(person_label, execution::Value::INT64(1), - {execution::Value::STRING("Alice"), - execution::Value::INT32(30), - execution::Value::DOUBLE(88.5)}, + ->AddVertex(person_label, columnar::Value::INT64(1), + {columnar::Value::STRING("Alice"), + columnar::Value::INT32(30), + columnar::Value::DOUBLE(88.5)}, vid1, 0) .ok()); EXPECT_TRUE(graph_ - ->AddVertex(person_label, execution::Value::INT64(2), - {execution::Value::STRING("Bob"), - execution::Value::INT32(25), - execution::Value::DOUBLE(92.0)}, + ->AddVertex(person_label, columnar::Value::INT64(2), + {columnar::Value::STRING("Bob"), + columnar::Value::INT32(25), + columnar::Value::DOUBLE(92.0)}, vid2, 0) .ok()); auto id_column = graph_->GetVertexPropertyColumn(person_label, "id"); @@ -110,19 +109,19 @@ TEST_F(PropertyGraphTest, TestOpenAndBulkInsert) { // By default, we will reserve 4096 slots for each vertex label. for (size_t i = 3; i <= 4096; ++i) { vid_t vid; - graph_->AddVertex(person_label, execution::Value::INT64(i), - {execution::Value::STRING("User" + std::to_string(i)), - execution::Value::INT32(20 + (i % 10)), - execution::Value::DOUBLE(80.0 + (i % 20))}, + graph_->AddVertex(person_label, columnar::Value::INT64(i), + {columnar::Value::STRING("User" + std::to_string(i)), + columnar::Value::INT32(20 + (i % 10)), + columnar::Value::DOUBLE(80.0 + (i % 20))}, vid, 0); } EXPECT_EQ(graph_->VertexNum(person_label), 4096); vid_t vid4097; EXPECT_FALSE(graph_ - ->AddVertex(person_label, execution::Value::INT64(4097), - {execution::Value::STRING("User4097"), - execution::Value::INT32(27), - execution::Value::DOUBLE(85.0)}, + ->AddVertex(person_label, columnar::Value::INT64(4097), + {columnar::Value::STRING("User4097"), + columnar::Value::INT32(27), + columnar::Value::DOUBLE(85.0)}, vid4097, 0) .ok()); @@ -131,7 +130,7 @@ TEST_F(PropertyGraphTest, TestOpenAndBulkInsert) { int32_t oe_offset = 0; const void* prop = nullptr; graph_->AddEdge(person_label, i, person_label, i + 1, knows_label, - {execution::Value::DOUBLE(1.0)}, MAX_TIMESTAMP, allocator, + {columnar::Value::DOUBLE(1.0)}, MAX_TIMESTAMP, allocator, oe_offset, prop); } { @@ -139,7 +138,7 @@ TEST_F(PropertyGraphTest, TestOpenAndBulkInsert) { const void* prop = nullptr; EXPECT_FALSE(graph_ ->AddEdge(person_label, 4095, person_label, 4096, - knows_label, {execution::Value::DOUBLE(1.0)}, + knows_label, {columnar::Value::DOUBLE(1.0)}, MAX_TIMESTAMP, allocator, oe_offset, prop) .ok()); } diff --git a/tests/storage/test_temporary_graph.cc b/tests/storage/test_temporary_graph.cc index 24fcfa013..5048a05d4 100644 --- a/tests/storage/test_temporary_graph.cc +++ b/tests/storage/test_temporary_graph.cc @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/connection.h" #include "neug/main/neug_db.h" #include "neug/storages/checkpoint_manager.h" @@ -37,7 +37,7 @@ using neug::label_t; using neug::MemoryLevel; using neug::PropertyGraph; using neug::Schema; -using neug::execution::Value; +using neug::columnar::Value; // ============================================================================ // Part 1: Schema layer temporary marking tests diff --git a/tests/storage/test_vertex_table.cc b/tests/storage/test_vertex_table.cc index d91796e74..46302bcc1 100644 --- a/tests/storage/test_vertex_table.cc +++ b/tests/storage/test_vertex_table.cc @@ -21,7 +21,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/neug_db.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/graph/schema.h" @@ -49,12 +49,12 @@ class VertexTableTest : public ::testing::Test { property_names_ = {"name", "age", "score"}; property_types_ = {neug::DataTypeId::kVarchar, neug::DataTypeId::kInt32, neug::DataTypeId::kDouble}; - property_values_ = {neug::execution::Value::STRING("Alice"), - neug::execution::Value::INT32(30), - neug::execution::Value::DOUBLE(88.5)}; - default_prop_values_ = {neug::execution::Value::STRING(""), - neug::execution::Value::INT32(0), - neug::execution::Value::DOUBLE(0.0)}; + property_values_ = {neug::columnar::Value::STRING("Alice"), + neug::columnar::Value::INT32(30), + neug::columnar::Value::DOUBLE(88.5)}; + default_prop_values_ = {neug::columnar::Value::STRING(""), + neug::columnar::Value::INT32(0), + neug::columnar::Value::DOUBLE(0.0)}; vertex_count_ = 1000000; schema_.AddVertexLabel(v_label_name_, property_types_, property_names_, {std::make_tuple(pk_type_, "id", 0)}, 4096, "", @@ -72,7 +72,7 @@ class VertexTableTest : public ::testing::Test { } } - std::vector> generate_data_chunks( + std::vector> generate_data_chunks( size_t num_vertices) { std::vector oid_values; std::vector name_values; @@ -98,8 +98,8 @@ class VertexTableTest : public ::testing::Test { neug::DataTypeId pk_type_; std::vector property_names_; std::vector property_types_; - std::vector property_values_; - std::vector default_prop_values_; + std::vector property_values_; + std::vector default_prop_values_; std::mt19937 generator_; neug::Schema schema_; neug::label_t v_label_id_ = 0; @@ -115,9 +115,9 @@ TEST_F(VertexTableTest, VertexTableBasicOps) { table.EnsureCapacity(vertex_count_); neug::vid_t lid1, lid2, lid3; - auto oid1 = neug::execution::Value::INT64(1); - auto oid2 = neug::execution::Value::INT64(2); - auto oid3 = neug::execution::Value::INT64(3); + auto oid1 = neug::columnar::Value::INT64(1); + auto oid2 = neug::columnar::Value::INT64(2); + auto oid3 = neug::columnar::Value::INT64(3); EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 1, false)); EXPECT_TRUE(table.AddVertex(oid2, property_values_, lid2, 2, false)); EXPECT_TRUE(table.AddVertex(oid3, property_values_, lid3, 3, false)); @@ -163,9 +163,9 @@ TEST_F(VertexTableTest, VertexTableDumpAndReload) { table.EnsureCapacity(vertex_count_); neug::vid_t lid1, lid2, lid3; - auto oid1 = neug::execution::Value::INT64(1); - auto oid2 = neug::execution::Value::INT64(2); - auto oid3 = neug::execution::Value::INT64(3); + auto oid1 = neug::columnar::Value::INT64(1); + auto oid2 = neug::columnar::Value::INT64(2); + auto oid3 = neug::columnar::Value::INT64(3); EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 1, false)); EXPECT_TRUE(table.AddVertex(oid2, property_values_, lid2, 2, false)); EXPECT_TRUE(table.AddVertex(oid3, property_values_, lid3, 3, false)); @@ -189,7 +189,7 @@ TEST_F(VertexTableTest, VertexTableAddAndDeleteAndReload) { auto ckp = make_checkpoint(Workspace()); neug::vid_t lid1, lid2, lid3; - neug::execution::Value oid1, oid2, oid3; + neug::columnar::Value oid1, oid2, oid3; neug::CheckpointManifest desc; { neug::VertexTable table(schema_.get_vertex_schema(v_label_id_)); @@ -197,9 +197,9 @@ TEST_F(VertexTableTest, VertexTableAddAndDeleteAndReload) { memory_level_); table.EnsureCapacity(vertex_count_); - oid1 = neug::execution::Value::INT64(1); - oid2 = neug::execution::Value::INT64(2); - oid3 = neug::execution::Value::INT64(3); + oid1 = neug::columnar::Value::INT64(1); + oid2 = neug::columnar::Value::INT64(2); + oid3 = neug::columnar::Value::INT64(3); EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 1, false)); EXPECT_TRUE(table.AddVertex(oid2, property_values_, lid2, 2, false)); EXPECT_TRUE(table.AddVertex(oid3, property_values_, lid3, 3, false)); @@ -250,9 +250,9 @@ TEST_F(VertexTableTest, AddVertexBasic) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid1 = neug::execution::Value::INT64(100); - auto oid2 = neug::execution::Value::INT64(200); - auto oid3 = neug::execution::Value::INT64(300); + auto oid1 = neug::columnar::Value::INT64(100); + auto oid2 = neug::columnar::Value::INT64(200); + auto oid3 = neug::columnar::Value::INT64(300); neug::vid_t lid1, lid2, lid3; EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 0, false)); EXPECT_TRUE(table.AddVertex(oid2, property_values_, lid2, 1, false)); @@ -291,16 +291,16 @@ TEST_F(VertexTableTest, AddVertex) { // AddVertex must return false on an opened table whose capacity is still 0 // (no EnsureCapacity call yet). neug::vid_t tmp_vid; - EXPECT_FALSE(table.AddVertex(neug::execution::Value::INT64(1), + EXPECT_FALSE(table.AddVertex(neug::columnar::Value::INT64(1), property_values_, tmp_vid, 0, false)); - std::vector oids; + std::vector oids; std::vector lids; table.EnsureCapacity(100); lids.resize(100); for (int64_t i = 0; i < 100; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); oids.push_back(oid); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], i % 10, false)); } @@ -323,9 +323,9 @@ TEST_F(VertexTableTest, DeleteVertexBasic) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid1 = neug::execution::Value::INT64(1); - auto oid2 = neug::execution::Value::INT64(2); - auto oid3 = neug::execution::Value::INT64(3); + auto oid1 = neug::columnar::Value::INT64(1); + auto oid2 = neug::columnar::Value::INT64(2); + auto oid3 = neug::columnar::Value::INT64(3); neug::vid_t lid1, lid2, lid3; EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 1, false)); @@ -356,7 +356,7 @@ TEST_F(VertexTableTest, RevertDeleteVertexBasic) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid1 = neug::execution::Value::INT64(1); + auto oid1 = neug::columnar::Value::INT64(1); neug::vid_t lid1; EXPECT_TRUE(table.AddVertex(oid1, property_values_, lid1, 1, false)); @@ -386,12 +386,12 @@ TEST_F(VertexTableTest, AddDeleteRevertCombination) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - std::vector oids; + std::vector oids; std::vector lids; lids.resize(10); for (int64_t i = 0; i < 10; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); oids.push_back(oid); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], i, false)); } @@ -431,7 +431,7 @@ TEST_F(VertexTableTest, MultipleDeletesAndReverts) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid = neug::execution::Value::INT64(42); + auto oid = neug::columnar::Value::INT64(42); neug::vid_t lid; EXPECT_TRUE(table.AddVertex(oid, property_values_, lid, 1, false)); @@ -471,7 +471,7 @@ TEST_F(VertexTableTest, MixedAddVertexAndAddVertexSafe) { // Add using both methods alternately for (int64_t i = 0; i < 20; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], i, false)); } @@ -490,9 +490,9 @@ TEST_F(VertexTableTest, TemporalVisibilityComplex) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid1 = neug::execution::Value::INT64(1); - auto oid2 = neug::execution::Value::INT64(2); - auto oid3 = neug::execution::Value::INT64(3); + auto oid1 = neug::columnar::Value::INT64(1); + auto oid2 = neug::columnar::Value::INT64(2); + auto oid3 = neug::columnar::Value::INT64(3); EXPECT_EQ(table.VertexNum(0), 0); neug::vid_t lid1; @@ -533,7 +533,7 @@ TEST_F(VertexTableTest, DeleteAlreadyDeletedVertex) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid = neug::execution::Value::INT64(1); + auto oid = neug::columnar::Value::INT64(1); neug::vid_t lid; EXPECT_TRUE(table.AddVertex(oid, property_values_, lid, 1, false)); @@ -556,7 +556,7 @@ TEST_F(VertexTableTest, RevertNonDeletedVertex) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - auto oid = neug::execution::Value::INT64(1); + auto oid = neug::columnar::Value::INT64(1); neug::vid_t lid; EXPECT_TRUE(table.AddVertex(oid, property_values_, lid, 1, false)); @@ -570,7 +570,7 @@ TEST_F(VertexTableTest, RevertNonDeletedVertex) { // Test complex combination with dump and reload TEST_F(VertexTableTest, ComplexAddDeleteRevertDumpReload) { - std::vector oids; + std::vector oids; std::vector lids; lids.resize(20); @@ -584,7 +584,7 @@ TEST_F(VertexTableTest, ComplexAddDeleteRevertDumpReload) { table.EnsureCapacity(100); for (int64_t i = 0; i < 20; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); oids.push_back(oid); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], i, false)); } @@ -636,12 +636,12 @@ TEST_F(VertexTableTest, StressAddDeleteRevert) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(1000); - std::vector oids; + std::vector oids; std::vector lids; lids.resize(100); for (int64_t i = 0; i < 100; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); oids.push_back(oid); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], 1, false)); } @@ -745,12 +745,12 @@ TEST_F(VertexTableTest, VertexSetForeachVertex) { OpenVertexTableLegacy(table, ckp, neug::CheckpointManifest(), memory_level_); table.EnsureCapacity(100); - std::vector oids; + std::vector oids; std::vector lids; lids.resize(10); for (int64_t i = 0; i < 10; ++i) { - auto oid = neug::execution::Value::INT64(i); + auto oid = neug::columnar::Value::INT64(i); oids.push_back(oid); EXPECT_TRUE(table.AddVertex(oid, property_values_, lids[i], i, false)); } diff --git a/tests/transaction/test_acid.cc b/tests/transaction/test_acid.cc index 138778d77..c8039f930 100644 --- a/tests/transaction/test_acid.cc +++ b/tests/transaction/test_acid.cc @@ -24,7 +24,7 @@ #include #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/neug_db.h" #include "neug/server/neug_db_service.h" #include "neug/server/neug_db_session.h" @@ -45,8 +45,8 @@ using oid_t = int64_t; // Utility: Generate unique id (thread-safe) static std::atomic neug_current_id(0); -neug::execution::Value neug_generate_id() { - return neug::execution::Value::INT64(neug_current_id.fetch_add(1)); +neug::columnar::Value neug_generate_id() { + return neug::columnar::Value::INT64(neug_current_id.fetch_add(1)); } std::string neug_generate_random_string(int length) { @@ -191,7 +191,7 @@ void neug_append_string_to_field(StorageTPUpdateInterface& gui, label_t label, cur_str += str; } gui.UpdateVertexProperty(label, vit, col_id, - neug::execution::Value::STRING(cur_str)); + neug::columnar::Value::STRING(cur_str)); } // Atomicity helpers and tests @@ -222,15 +222,15 @@ std::shared_ptr neug_AtomicityInit( vid_t vid; EXPECT_TRUE( gii.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(id1), - neug::execution::Value::STRING(std::string(name1)), - neug::execution::Value::STRING(std::string(email1))}, + {neug::columnar::Value::INT64(id1), + neug::columnar::Value::STRING(std::string(name1)), + neug::columnar::Value::STRING(std::string(email1))}, vid)); EXPECT_TRUE( gii.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(id2), - neug::execution::Value::STRING(std::string(name2)), - neug::execution::Value::STRING(std::string(email2))}, + {neug::columnar::Value::INT64(id2), + neug::columnar::Value::STRING(std::string(name2)), + neug::columnar::Value::STRING(std::string(email2))}, vid)); txn.Commit(); @@ -250,16 +250,16 @@ bool neug_AtomicityC(neug::NeugDBSession& db, int64_t person2_id, vid_t vid; if (!gui.AddVertex(person_label_id, p2_id, - {neug::execution::Value::INT64(person2_id), - neug::execution::Value::STRING(std::string(name)), - neug::execution::Value::STRING(std::string(email))}, + {neug::columnar::Value::INT64(person2_id), + neug::columnar::Value::STRING(std::string(name)), + neug::columnar::Value::STRING(std::string(email))}, vid)) { txn.Abort(); return false; } const void* edge_prop = nullptr; if (!gui.AddEdge(person_label_id, vit, person_label_id, vid, knows_label_id, - {neug::execution::Value::INT64(since)}, edge_prop)) { + {neug::columnar::Value::INT64(since)}, edge_prop)) { txn.Abort(); return false; } @@ -276,19 +276,18 @@ bool neug_AtomicityRB(neug::NeugDBSession& db, int64_t person2_id, neug_append_string_to_field(gui, person_label_id, vit1, 2, new_email); neug::vid_t vit2; if (gui.GetVertexIndex(person_label_id, - neug::execution::Value::INT64(person2_id), vit2)) { + neug::columnar::Value::INT64(person2_id), vit2)) { txn.Abort(); return false; } auto p2_id = neug_generate_id(); std::string name = "", email = ""; vid_t vid; - EXPECT_TRUE( - gui.AddVertex(person_label_id, p2_id, - {neug::execution::Value::INT64(person2_id), - neug::execution::Value::STRING(std::string(name)), - neug::execution::Value::STRING(std::string(email))}, - vid)); + EXPECT_TRUE(gui.AddVertex(person_label_id, p2_id, + {neug::columnar::Value::INT64(person2_id), + neug::columnar::Value::STRING(std::string(name)), + neug::columnar::Value::STRING(std::string(email))}, + vid)); EXPECT_TRUE(txn.Commit()); return true; } @@ -359,19 +358,19 @@ std::shared_ptr G0Init(NeugDB& db, int64_t p1_id_property = 2 * i + 1; vid_t vid0, vid1; CHECK(gii.AddVertex(person_label_id, p1_id, - {neug::execution::Value::INT64(p1_id_property), - neug::execution::Value::STRING(std::string(value))}, + {neug::columnar::Value::INT64(p1_id_property), + neug::columnar::Value::STRING(std::string(value))}, vid0)); auto p2_id = neug_generate_id(); int64_t p2_id_property = 2 * i + 2; CHECK(gii.AddVertex(person_label_id, p2_id, - {neug::execution::Value::INT64(p2_id_property), - neug::execution::Value::STRING(std::string(value))}, + {neug::columnar::Value::INT64(p2_id_property), + neug::columnar::Value::STRING(std::string(value))}, vid1)); const void* edge_prop = nullptr; CHECK(gii.AddEdge( person_label_id, vid0, person_label_id, vid1, knows_label_id, - {neug::execution::Value::STRING(std::string(value))}, edge_prop)); + {neug::columnar::Value::STRING(std::string(value))}, edge_prop)); } txn.Commit(); return svc; @@ -437,7 +436,7 @@ void G0(neug::NeugDBSession& db, int64_t person1_id, int64_t person2_id, cur_str += ";"; cur_str += std::to_string(txn_id); } - neug::execution::Value new_value = neug::execution::Value::STRING(cur_str); + neug::columnar::Value new_value = neug::columnar::Value::STRING(cur_str); ed_accessor.set_data(oeit, new_value, txn.timestamp()); @@ -531,8 +530,8 @@ std::shared_ptr InitPersonWithVersion( for (int i = 0; i < 100; ++i) { vid_t vid; CHECK(gii.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(i + 1), - neug::execution::Value::INT64(initial_version)}, + {neug::columnar::Value::INT64(i + 1), + neug::columnar::Value::INT64(initial_version)}, vid)); } txn.Commit(); @@ -547,10 +546,10 @@ void G1B1(neug::NeugDBSession& db, int64_t even, int64_t odd) { auto person_label_id = txn.schema().get_vertex_label_id("PERSON"); auto vit = neug_get_random_vertex(gui, person_label_id); gui.UpdateVertexProperty(person_label_id, vit, 1, - neug::execution::Value::INT64(even)); + neug::columnar::Value::INT64(even)); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MILLI_SEC)); gui.UpdateVertexProperty(person_label_id, vit, 1, - neug::execution::Value::INT64(odd)); + neug::columnar::Value::INT64(odd)); txn.Commit(); } @@ -588,7 +587,7 @@ int64_t G1C(neug::NeugDBSession& db, int64_t person1_id, int64_t person2_id, } } gui.UpdateVertexProperty(person_label_id, person1_vid, 1, - neug::execution::Value::INT64(txn_id)); + neug::columnar::Value::INT64(txn_id)); CHECK(flag); neug::vid_t person2_vid; @@ -622,7 +621,7 @@ void G1A1(neug::NeugDBSession& db) { std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MILLI_SEC)); // attempt to set version = 2 gui.UpdateVertexProperty(person_label_id, vit, 1, - neug::execution::Value::INT64(2)); + neug::columnar::Value::INT64(2)); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MILLI_SEC)); txn.Abort(); @@ -652,7 +651,7 @@ void IMP1(neug::NeugDBSession& db) { int64_t old_version = gui.GetVertexProperty(person_label_id, vit, 1).GetValue(); gui.UpdateVertexProperty(person_label_id, vit, 1, - neug::execution::Value::INT64(old_version + 1)); + neug::columnar::Value::INT64(old_version + 1)); txn.Commit(); } @@ -724,9 +723,9 @@ std::shared_ptr PMPInit(NeugDB& db, int64_t value = i + 1; vid_t vid; CHECK(gii.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(value)}, vid)); + {neug::columnar::Value::INT64(value)}, vid)); CHECK(gii.AddVertex(post_label_id, neug_generate_id(), - {neug::execution::Value::INT64(value)}, vid)); + {neug::columnar::Value::INT64(value)}, vid)); } txn.Commit(); return svc; @@ -856,9 +855,9 @@ std::shared_ptr OTVInit(NeugDB& db, string_props.push_back(std::to_string(j)); CHECK(gii.AddVertex( person_label_id, id, - {neug::execution::Value::INT64(id_property), - neug::execution::Value::STRING(std::string(string_props.back())), - neug::execution::Value::INT64(value)}, + {neug::columnar::Value::INT64(id_property), + neug::columnar::Value::STRING(std::string(string_props.back())), + neug::columnar::Value::INT64(value)}, vid)); vids.push_back(vid); } @@ -908,28 +907,28 @@ void OTV1(neug::NeugDBSession& db, int64_t person_id) { if (eit4.get_vertex() == vid1) { gui.UpdateVertexProperty( person_label_id, vid1, 2, - neug::execution::Value::INT64( + neug::columnar::Value::INT64( txn.GetVertexProperty(person_label_id, vid1, 2) .GetValue() + 1)); gui.UpdateVertexProperty( person_label_id, vid2, 2, - neug::execution::Value::INT64( + neug::columnar::Value::INT64( gui.GetVertexProperty(person_label_id, vid2, 2) .GetValue() + 1)); gui.UpdateVertexProperty( person_label_id, vid3, 2, - neug::execution::Value::INT64( + neug::columnar::Value::INT64( gui.GetVertexProperty(person_label_id, vid3, 2) .GetValue() + 1)); gui.UpdateVertexProperty( person_label_id, vid4, 2, - neug::execution::Value::INT64( + neug::columnar::Value::INT64( gui.GetVertexProperty(person_label_id, vid4, 2) .GetValue() + 1)); @@ -1051,8 +1050,8 @@ std::shared_ptr LUInit(NeugDB& db, int64_t id_property = i + 1; vid_t vid; CHECK(gii.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(id_property), - neug::execution::Value::INT64(num_property)}, + {neug::columnar::Value::INT64(id_property), + neug::columnar::Value::INT64(num_property)}, vid)); } @@ -1082,7 +1081,7 @@ bool LU1(neug::NeugDBSession& db, int64_t person_id) { int64_t num_friends = gui.GetVertexProperty(person_label_id, person_vid, 1).GetValue(); gui.UpdateVertexProperty(person_label_id, person_vid, 1, - neug::execution::Value::INT64(num_friends + 1)); + neug::columnar::Value::INT64(num_friends + 1)); txn.Commit(); return true; @@ -1135,14 +1134,14 @@ std::shared_ptr WSInit(NeugDB& db, int64_t version1 = 70; vid_t vid; CHECK(gi.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(id1), - neug::execution::Value::INT64(version1)}, + {neug::columnar::Value::INT64(id1), + neug::columnar::Value::INT64(version1)}, vid)); int64_t id2 = 2 * i; int64_t version2 = 80; CHECK(gi.AddVertex(person_label_id, neug_generate_id(), - {neug::execution::Value::INT64(id2), - neug::execution::Value::INT64(version2)}, + {neug::columnar::Value::INT64(id2), + neug::columnar::Value::INT64(version2)}, vid)); } txn.Commit(); @@ -1196,10 +1195,10 @@ void WS1(neug::NeugDBSession& db, int64_t person1_id, int64_t person2_id, // property if (dist(gen)) { gui.UpdateVertexProperty(person_label_id, person1_vid, 1, - neug::execution::Value::INT64(p1_value - 100)); + neug::columnar::Value::INT64(p1_value - 100)); } else { gui.UpdateVertexProperty(person_label_id, person2_vid, 1, - neug::execution::Value::INT64(p2_value - 100)); + neug::columnar::Value::INT64(p2_value - 100)); } txn.Commit(); } @@ -1592,9 +1591,9 @@ std::shared_ptr cc_init(NeugDB& db, const std::string& work_dir, std::string name = "person_" + std::to_string(i); int64_t age = 20 + i; vid_t vid; - CHECK(txn.AddVertex(person_label, execution::Value::INT64(i), - {execution::Value::STRING(std::string(name)), - execution::Value::INT64(age)}, + CHECK(txn.AddVertex(person_label, columnar::Value::INT64(i), + {columnar::Value::STRING(std::string(name)), + columnar::Value::INT64(age)}, vid)); vids.push_back(vid); } @@ -1607,7 +1606,7 @@ std::shared_ptr cc_init(NeugDB& db, const std::string& work_dir, d = (d + 1) % kSeedVertices; const void* edge_prop = nullptr; CHECK(txn.AddEdge(person_label, vids[s], person_label, vids[d], knows_label, - {execution::Value::DOUBLE(0.1 * e)}, edge_prop)); + {columnar::Value::DOUBLE(0.1 * e)}, edge_prop)); } txn.Commit(); return svc; @@ -1620,7 +1619,7 @@ int64_t cc_read_age(NeugDBService& svc, int64_t person_id) { StorageReadInterface gi(txn.view(), txn.timestamp()); auto person_label = svc.db().schema().get_vertex_label_id("person"); vid_t vid; - if (!gi.GetVertexIndex(person_label, execution::Value::INT64(person_id), + if (!gi.GetVertexIndex(person_label, columnar::Value::INT64(person_id), vid)) { return -1; } @@ -1634,7 +1633,7 @@ int64_t cc_read_age(NeugDBSession& sess, NeugDB& db, int64_t person_id) { StorageReadInterface gi(txn.view(), txn.timestamp()); auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; - if (!gi.GetVertexIndex(person_label, execution::Value::INT64(person_id), + if (!gi.GetVertexIndex(person_label, columnar::Value::INT64(person_id), vid)) { return -1; } @@ -1651,8 +1650,7 @@ std::pair cc_read_age_timed(NeugDBSession& sess, NeugDB& db, auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; int64_t age = -1; - if (gi.GetVertexIndex(person_label, execution::Value::INT64(person_id), - vid)) { + if (gi.GetVertexIndex(person_label, columnar::Value::INT64(person_id), vid)) { age = gi.GetVertexProperty(person_label, vid, 1).GetValue(); } auto t1 = std::chrono::high_resolution_clock::now(); @@ -1668,7 +1666,7 @@ int64_t cc_read_age_via(const ReadTransaction& txn, NeugDB& db, StorageReadInterface gi(txn.view(), txn.timestamp()); auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; - if (!gi.GetVertexIndex(person_label, execution::Value::INT64(person_id), + if (!gi.GetVertexIndex(person_label, columnar::Value::INT64(person_id), vid)) { return -1; } @@ -1700,7 +1698,7 @@ template vid_t cc_person_vid(Txn& txn, NeugDB& db, int64_t oid) { auto p_label = db.schema().get_vertex_label_id("person"); vid_t vid; - CHECK(txn.GetVertexIndex(p_label, execution::Value::INT64(oid), vid)); + CHECK(txn.GetVertexIndex(p_label, columnar::Value::INT64(oid), vid)); return vid; } @@ -1711,13 +1709,13 @@ bool cc_update_age(NeugDBService& svc, int64_t person_id, int64_t new_age) { StorageTPUpdateInterface gui(txn); auto person_label = svc.db().schema().get_vertex_label_id("person"); vid_t vid; - if (!gui.GetVertexIndex(person_label, execution::Value::INT64(person_id), + if (!gui.GetVertexIndex(person_label, columnar::Value::INT64(person_id), vid)) { txn.Abort(); return false; } gui.UpdateVertexProperty(person_label, vid, 1, - execution::Value::INT64(new_age)); + columnar::Value::INT64(new_age)); return txn.Commit(); } @@ -1803,9 +1801,9 @@ double cc_read_knows_weight_via(const ReadTransaction& txn, NeugDB& db, auto p_label = gi.schema().get_vertex_label_id("person"); auto e_label = gi.schema().get_edge_label_id("knows"); vid_t src_vid, dst_vid; - if (!gi.GetVertexIndex(p_label, execution::Value::INT64(src_oid), src_vid)) + if (!gi.GetVertexIndex(p_label, columnar::Value::INT64(src_oid), src_vid)) return std::nan(""); - if (!gi.GetVertexIndex(p_label, execution::Value::INT64(dst_oid), dst_vid)) + if (!gi.GetVertexIndex(p_label, columnar::Value::INT64(dst_oid), dst_vid)) return std::nan(""); auto view = gi.GetGenericOutgoingGraphView(p_label, p_label, e_label); auto accessor = gi.GetEdgeDataAccessor(p_label, p_label, e_label, 0); @@ -1832,8 +1830,8 @@ void cc_setup_unbundled_created(NeugDBService& svc) { ASSERT_TRUE( gui.CreateVertexType( sb.VertexLabel("software") - .AddProperty("id", execution::Value::INT64(0)) - .AddProperty("name", execution::Value::STRING(std::string(""))) + .AddProperty("id", columnar::Value::INT64(0)) + .AddProperty("name", columnar::Value::STRING(std::string(""))) .AddPrimaryKeyName("id") .Build()) .ok()); @@ -1843,8 +1841,8 @@ void cc_setup_unbundled_created(NeugDBService& svc) { eb.SrcLabel("person") .DstLabel("software") .EdgeLabel("created") - .AddProperty("weight", execution::Value::DOUBLE(0.0)) - .AddProperty("since", execution::Value::INT64(0)) + .AddProperty("weight", columnar::Value::DOUBLE(0.0)) + .AddProperty("since", columnar::Value::INT64(0)) .Build()) .ok()); @@ -1853,17 +1851,17 @@ void cc_setup_unbundled_created(NeugDBService& svc) { auto e_label = gui.schema().get_edge_label_id("created"); vid_t sw_vid; - ASSERT_TRUE(gui.AddVertex(sw_label, execution::Value::INT64(1), - {execution::Value::STRING(std::string("NeugDB"))}, + ASSERT_TRUE(gui.AddVertex(sw_label, columnar::Value::INT64(1), + {columnar::Value::STRING(std::string("NeugDB"))}, sw_vid)); vid_t p1_vid; - ASSERT_TRUE(gui.GetVertexIndex(p_label, execution::Value::INT64(1), p1_vid)); + ASSERT_TRUE(gui.GetVertexIndex(p_label, columnar::Value::INT64(1), p1_vid)); const void* add_edge_prop = nullptr; - ASSERT_TRUE(gui.AddEdge( - p_label, p1_vid, sw_label, sw_vid, e_label, - {execution::Value::DOUBLE(0.5), execution::Value::INT64(2020)}, - add_edge_prop)); + ASSERT_TRUE( + gui.AddEdge(p_label, p1_vid, sw_label, sw_vid, e_label, + {columnar::Value::DOUBLE(0.5), columnar::Value::INT64(2020)}, + add_edge_prop)); ASSERT_TRUE(txn.Commit()); } @@ -1876,9 +1874,9 @@ int64_t cc_read_created_since_via(const ReadTransaction& txn) { auto sw_label = gi.schema().get_vertex_label_id("software"); auto e_label = gi.schema().get_edge_label_id("created"); vid_t p1_vid, sw_vid; - if (!gi.GetVertexIndex(p_label, execution::Value::INT64(1), p1_vid)) + if (!gi.GetVertexIndex(p_label, columnar::Value::INT64(1), p1_vid)) return -1; - if (!gi.GetVertexIndex(sw_label, execution::Value::INT64(1), sw_vid)) + if (!gi.GetVertexIndex(sw_label, columnar::Value::INT64(1), sw_vid)) return -1; auto view = gi.GetGenericOutgoingGraphView(p_label, sw_label, e_label); auto accessor = gi.GetEdgeDataAccessor(p_label, sw_label, e_label, 1); @@ -1957,9 +1955,9 @@ TEST_F(NeugDBACIDTest, ConcurrentInsertsCommitInOrder) { auto txn = sess.GetInsertTransaction(); vid_t vid; ASSERT_TRUE( - txn.AddVertex(person_label, execution::Value::INT64(base + i), - {execution::Value::STRING(std::string("inserted")), - execution::Value::INT64(99)}, + txn.AddVertex(person_label, columnar::Value::INT64(base + i), + {columnar::Value::STRING(std::string("inserted")), + columnar::Value::INT64(99)}, vid)); ASSERT_TRUE(txn.Commit()); } @@ -2017,9 +2015,9 @@ TEST_F(NeugDBACIDTest, ConcurrentReadsAndInsertsDoNotInterfere) { int64_t id = next_id.fetch_add(1); auto txn = guard->GetInsertTransaction(); vid_t vid; - if (txn.AddVertex(person_label, execution::Value::INT64(id), - {execution::Value::STRING(std::string("x")), - execution::Value::INT64(99)}, + if (txn.AddVertex(person_label, columnar::Value::INT64(id), + {columnar::Value::STRING(std::string("x")), + columnar::Value::INT64(99)}, vid) && txn.Commit()) { insert_count.fetch_add(1); @@ -2066,9 +2064,9 @@ TEST_F(NeugDBACIDTest, SnapshotIsolationForUpdateAndInsert) { auto txn_w = sess_w->GetInsertTransaction(); auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; - ASSERT_TRUE(txn_w.AddVertex(person_label, execution::Value::INT64(9999), - {execution::Value::STRING(std::string("late")), - execution::Value::INT64(50)}, + ASSERT_TRUE(txn_w.AddVertex(person_label, columnar::Value::INT64(9999), + {columnar::Value::STRING(std::string("late")), + columnar::Value::INT64(50)}, vid)); ASSERT_TRUE(txn_w.Commit()); } @@ -2098,9 +2096,9 @@ TEST_F(NeugDBACIDTest, UpdateCowCloneDoesNotAffectActiveReaders) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid_u; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(5), vid_u)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(5), vid_u)); gui.UpdateVertexProperty(person_label, vid_u, 1, - execution::Value::INT64(7777)); + columnar::Value::INT64(7777)); // R still sees pre-commit state (no concurrent commit). EXPECT_EQ(cc_read_age_via(txn_r, db, 5), 25); @@ -2124,7 +2122,7 @@ TEST_F(NeugDBACIDTest, UpdateRollbackLeavesOriginalIntact) { auto txn = sess->GetUpdateTransaction(); StorageTPUpdateInterface gui(txn); gui.UpdateVertexProperty(person_label, cc_person_vid(gui, db, 5), 1, - execution::Value::INT64(125)); + columnar::Value::INT64(125)); txn.Abort(); } EXPECT_EQ(cc_read_age(*svc, 5), 25); @@ -2138,7 +2136,7 @@ TEST_F(NeugDBACIDTest, UpdateRollbackLeavesOriginalIntact) { CreateVertexTypeParamBuilder b; auto status = gui.CreateVertexType(b.VertexLabel("foo") - .AddProperty("x", execution::Value::INT64(0)) + .AddProperty("x", columnar::Value::INT64(0)) .AddPrimaryKeyName("x") .Build()); ASSERT_TRUE(status.ok()) << "CreateVertexType setup failed"; @@ -2194,7 +2192,7 @@ TEST_F(NeugDBACIDTest, DMLCommitDoesNotAffectHeldReader) { vid_t r_v1; { StorageReadInterface gi(txn_r.view(), txn_r.timestamp()); - ASSERT_TRUE(gi.GetVertexIndex(p_label, execution::Value::INT64(1), r_v1)); + ASSERT_TRUE(gi.GetVertexIndex(p_label, columnar::Value::INT64(1), r_v1)); } size_t oe_v1_pre = cc_count_oe_from_via(txn_r, p_label, p_label, e_label, r_v1); @@ -2203,9 +2201,9 @@ TEST_F(NeugDBACIDTest, DMLCommitDoesNotAffectHeldReader) { cc_run_update(*svc, [&](auto& txn) { StorageTPUpdateInterface gui(txn); vid_t vid; - ASSERT_TRUE(gui.AddVertex(p_label, execution::Value::INT64(900001), - {execution::Value::STRING(std::string("late")), - execution::Value::INT64(77)}, + ASSERT_TRUE(gui.AddVertex(p_label, columnar::Value::INT64(900001), + {columnar::Value::STRING(std::string("late")), + columnar::Value::INT64(77)}, vid)); }); // Held reader: unaffected. @@ -2213,8 +2211,7 @@ TEST_F(NeugDBACIDTest, DMLCommitDoesNotAffectHeldReader) { { StorageReadInterface gi(txn_r.view(), txn_r.timestamp()); vid_t v; - EXPECT_FALSE( - gi.GetVertexIndex(p_label, execution::Value::INT64(900001), v)); + EXPECT_FALSE(gi.GetVertexIndex(p_label, columnar::Value::INT64(900001), v)); } // Fresh reader: sees new vertex. EXPECT_EQ(cc_count_persons(*svc), n_pre + 1); @@ -2237,7 +2234,7 @@ TEST_F(NeugDBACIDTest, DMLCommitDoesNotAffectHeldReader) { const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(p_label, cc_person_vid(gui, db, 1), p_label, cc_person_vid(gui, db, 2), e_label, - {execution::Value::DOUBLE(0.55)}, edge_prop)); + {columnar::Value::DOUBLE(0.55)}, edge_prop)); }); // Held reader: edge counts unchanged. EXPECT_EQ(cc_count_oe_from_via(txn_r, p_label, p_label, e_label, r_v1), @@ -2251,7 +2248,7 @@ TEST_F(NeugDBACIDTest, DMLCommitDoesNotAffectHeldReader) { const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(p_label, cc_person_vid(gui, db, 1), p_label, cc_person_vid(gui, db, 2), e_label, - {execution::Value::DOUBLE(0.42)}, edge_prop)); + {columnar::Value::DOUBLE(0.42)}, edge_prop)); }); size_t total_after_adds = cc_count_all_oe(*svc, "person", "person", "knows"); cc_run_update(*svc, [&](auto& txn) { @@ -2294,14 +2291,14 @@ TEST_F(NeugDBACIDTest, for (auto it = edges.begin(); it != edges.end(); ++it, ++oe_off) { if (it.get_vertex() == d) { gui.UpdateEdgeProperty(p_label, s, p_label, d, e_label, oe_off, 0, 0, - execution::Value::DOUBLE(w)); + columnar::Value::DOUBLE(w)); return; } } // No existing edge — add one. const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(p_label, s, p_label, d, e_label, - {execution::Value::DOUBLE(w)}, edge_prop)); + {columnar::Value::DOUBLE(w)}, edge_prop)); }); }; set_or_add_weight(0.42); @@ -2324,8 +2321,8 @@ TEST_F(NeugDBACIDTest, auto view = gi.GetGenericOutgoingGraphView(p_label, p_label, e_label); auto accessor = gi.GetEdgeDataAccessor(p_label, p_label, e_label, 0); vid_t s, d; - ASSERT_TRUE(gi.GetVertexIndex(p_label, execution::Value::INT64(1), s)); - ASSERT_TRUE(gi.GetVertexIndex(p_label, execution::Value::INT64(2), d)); + ASSERT_TRUE(gi.GetVertexIndex(p_label, columnar::Value::INT64(1), s)); + ASSERT_TRUE(gi.GetVertexIndex(p_label, columnar::Value::INT64(2), d)); auto edges = view.get_edges(s); for (auto it = edges.begin(); it != edges.end(); ++it) { if (it.get_vertex() == d && @@ -2365,10 +2362,10 @@ TEST_F(NeugDBACIDTest, auto sw_label = txn.schema().get_vertex_label_id("software"); auto e_label = txn.schema().get_edge_label_id("created"); vid_t p1, sw1; - ASSERT_TRUE(txn.GetVertexIndex(p_label, execution::Value::INT64(1), p1)); - ASSERT_TRUE(txn.GetVertexIndex(sw_label, execution::Value::INT64(1), sw1)); + ASSERT_TRUE(txn.GetVertexIndex(p_label, columnar::Value::INT64(1), p1)); + ASSERT_TRUE(txn.GetVertexIndex(sw_label, columnar::Value::INT64(1), sw1)); gui.UpdateEdgeProperty(p_label, p1, sw_label, sw1, e_label, 0, 0, 1, - execution::Value::INT64(2099)); + columnar::Value::INT64(2099)); }); // Held reader: still sees 2020 via its snapshot. @@ -2408,9 +2405,9 @@ TEST_F(NeugDBACIDTest, VertexPropertyDDLCommitDoesNotAffectHeldReader) { AddVertexPropertiesParamBuilder b; EXPECT_TRUE(gui.AddVertexProperties( b.VertexLabel("person") - .AddProperty("email", execution::Value::STRING( + .AddProperty("email", columnar::Value::STRING( std::string(""))) - .AddProperty("height", execution::Value::DOUBLE(0.0)) + .AddProperty("height", columnar::Value::DOUBLE(0.0)) .Build()) .ok()); }); @@ -2500,7 +2497,7 @@ TEST_F(NeugDBACIDTest, EdgePropertyDDLCommitDoesNotAffectHeldReader) { b.SrcLabel("person") .DstLabel("person") .EdgeLabel("knows") - .AddProperty("license", execution::Value::STRING( + .AddProperty("license", columnar::Value::STRING( std::string(""))) .Build()) .ok()); @@ -2608,14 +2605,14 @@ TEST_F(NeugDBACIDTest, SchemaTypeDDLCommitDoesNotAffectHeldReader) { cc_run_update(*svc, [&](auto& txn) { StorageTPUpdateInterface gui(txn); CreateVertexTypeParamBuilder b; - EXPECT_TRUE( - gui.CreateVertexType(b.VertexLabel("company") - .AddProperty("id", execution::Value::INT64(0)) - .AddProperty("name", execution::Value::STRING( - std::string(""))) - .AddPrimaryKeyName("id") - .Build()) - .ok()); + EXPECT_TRUE(gui.CreateVertexType( + b.VertexLabel("company") + .AddProperty("id", columnar::Value::INT64(0)) + .AddProperty( + "name", columnar::Value::STRING(std::string(""))) + .AddPrimaryKeyName("id") + .Build()) + .ok()); }); // Held reader: no `company`. { @@ -2661,7 +2658,7 @@ TEST_F(NeugDBACIDTest, SchemaTypeDDLCommitDoesNotAffectHeldReader) { EXPECT_TRUE(gi.schema().is_vertex_label_valid("person")); EXPECT_TRUE(gi.schema().is_edge_label_valid("knows")); vid_t v; - ASSERT_TRUE(gi.GetVertexIndex(p_label, execution::Value::INT64(5), v)); + ASSERT_TRUE(gi.GetVertexIndex(p_label, columnar::Value::INT64(5), v)); EXPECT_EQ(gi.GetVertexProperty(p_label, v, age_col_id).GetValue(), 25); } @@ -2735,7 +2732,7 @@ TEST_F(NeugDBACIDTest, UpdateStringPropertyCommitDoesNotAffectHeldReader) { auto read_name_via = [&](const ReadTransaction& txn, int64_t oid) { StorageReadInterface gi(txn.view(), txn.timestamp()); vid_t v; - if (!gi.GetVertexIndex(p_label, execution::Value::INT64(oid), v)) + if (!gi.GetVertexIndex(p_label, columnar::Value::INT64(oid), v)) return std::string(); return std::string( gi.GetVertexProperty(p_label, v, 0).GetValue()); @@ -2749,9 +2746,8 @@ TEST_F(NeugDBACIDTest, UpdateStringPropertyCommitDoesNotAffectHeldReader) { // Writer updates person 5's name to a new string. cc_run_update(*svc, [&](auto& txn) { StorageTPUpdateInterface gui(txn); - gui.UpdateVertexProperty( - p_label, cc_person_vid(txn, db, 5), 0, - execution::Value::STRING(std::string("renamed_5"))); + gui.UpdateVertexProperty(p_label, cc_person_vid(txn, db, 5), 0, + columnar::Value::STRING(std::string("renamed_5"))); }); // Held reader: still sees old name. @@ -2793,9 +2789,9 @@ TEST_F(NeugDBACIDTest, WriteMutexExclusionSemantics) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(1), vid)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(1), vid)); gui.UpdateVertexProperty(person_label, vid, 1, - execution::Value::INT64(100)); + columnar::Value::INT64(100)); EXPECT_TRUE(txn.Commit()); u1_committed.store(true); }); @@ -2811,9 +2807,9 @@ TEST_F(NeugDBACIDTest, WriteMutexExclusionSemantics) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(2), vid)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(2), vid)); gui.UpdateVertexProperty(person_label, vid, 1, - execution::Value::INT64(200)); + columnar::Value::INT64(200)); EXPECT_TRUE(txn.Commit()); }); @@ -2839,9 +2835,9 @@ TEST_F(NeugDBACIDTest, WriteMutexExclusionSemantics) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(1), vid)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(1), vid)); gui.UpdateVertexProperty(person_label, vid, 1, - execution::Value::INT64(777)); + columnar::Value::INT64(777)); EXPECT_TRUE(txn.Commit()); update_committed.store(true); }); @@ -2856,9 +2852,9 @@ TEST_F(NeugDBACIDTest, WriteMutexExclusionSemantics) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - txn.AddVertex(person_label, execution::Value::INT64(999999), - {execution::Value::STRING(std::string("blocked")), - execution::Value::INT64(42)}, + txn.AddVertex(person_label, columnar::Value::INT64(999999), + {columnar::Value::STRING(std::string("blocked")), + columnar::Value::INT64(42)}, vid)); EXPECT_TRUE(txn.Commit()); }); @@ -2893,7 +2889,7 @@ TEST_F(NeugDBACIDTest, LongRunningReadDoesNotBlockUpdateCommit) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - gi.GetVertexIndex(person_label, execution::Value::INT64(1), vid)); + gi.GetVertexIndex(person_label, columnar::Value::INT64(1), vid)); // Hold the read for 300ms — well beyond Update::Commit's typical // microsecond-scale publish window. std::this_thread::sleep_for(std::chrono::milliseconds(300)); @@ -2912,9 +2908,8 @@ TEST_F(NeugDBACIDTest, LongRunningReadDoesNotBlockUpdateCommit) { auto person_label = db.schema().get_vertex_label_id("person"); vid_t vid; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(1), vid)); - gui.UpdateVertexProperty(person_label, vid, 1, - execution::Value::INT64(999)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(1), vid)); + gui.UpdateVertexProperty(person_label, vid, 1, columnar::Value::INT64(999)); auto t0 = std::chrono::steady_clock::now(); EXPECT_TRUE(txn.Commit()); auto elapsed = std::chrono::steady_clock::now() - t0; @@ -2976,7 +2971,7 @@ TEST_F(NeugDBACIDTest, CommitVisibilitySemantics) { StorageTPUpdateInterface gui(txn_u); gui.UpdateVertexProperty(db.schema().get_vertex_label_id("person"), cc_person_vid(gui, db, 5), 1, - execution::Value::INT64(9999)); + columnar::Value::INT64(9999)); expect_all_readers_see(*svc, 25); txn_u.Abort(); } @@ -3043,9 +3038,9 @@ TEST_F(NeugDBACIDTest, ConcurrentReadsAndCommitsObserveConsistentValues) { StorageTPUpdateInterface gui(txn_u); vid_t vid_u; ASSERT_TRUE( - gui.GetVertexIndex(person_label, execution::Value::INT64(5), vid_u)); + gui.GetVertexIndex(person_label, columnar::Value::INT64(5), vid_u)); gui.UpdateVertexProperty(person_label, vid_u, 1, - execution::Value::INT64(post_value)); + columnar::Value::INT64(post_value)); ready.fetch_add(1); while (ready.load() < 2) {} txn_u.Commit(); diff --git a/tests/transaction/test_insert_transaction.cc b/tests/transaction/test_insert_transaction.cc index 2dbc5d623..3382613e8 100644 --- a/tests/transaction/test_insert_transaction.cc +++ b/tests/transaction/test_insert_transaction.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/neug.h" #include "neug/server/neug_db_service.h" #include "neug/storages/csr/csr_view_utils.h" @@ -128,9 +128,9 @@ TEST_F(InsertTransactionTest, AddVertex) { auto person_label = interface.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE( - interface.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + interface.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid)); EXPECT_TRUE(txn.Commit()); } @@ -158,16 +158,16 @@ TEST_F(InsertTransactionTest, AddEdge) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid; - EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid)); + EXPECT_TRUE( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); neug::vid_t vid2; EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); const void* edge_prop = nullptr; EXPECT_TRUE(interface.AddEdge(person_label, vid, software_label, vid2, created_label, - {neug::execution::Value::DOUBLE(0.9), - neug::execution::Value::INT64(2022)}, + {neug::columnar::Value::DOUBLE(0.9), + neug::columnar::Value::INT64(2022)}, edge_prop)); EXPECT_TRUE(txn.Commit()); } diff --git a/tests/transaction/test_update_transaction.cc b/tests/transaction/test_update_transaction.cc index baab0b527..6d025d099 100644 --- a/tests/transaction/test_update_transaction.cc +++ b/tests/transaction/test_update_transaction.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/neug.h" #include "neug/server/neug_db_service.h" #include "neug/storages/csr/csr_view_utils.h" @@ -132,15 +132,14 @@ class UpdateTransactionTest : public ::testing::Test { neug::label_t& employ_label) { auto person_label = interface.schema().get_vertex_label_id("person"); auto software_label = interface.schema().get_vertex_label_id("software"); - std::vector> edge_props = { - std::make_pair("rating", neug::execution::Value::DOUBLE(0.0)), - std::make_pair("year", neug::execution::Value::INT64(2000))}; + std::vector> edge_props = { + std::make_pair("rating", neug::columnar::Value::DOUBLE(0.0)), + std::make_pair("year", neug::columnar::Value::INT64(2000))}; EXPECT_TRUE(interface.CreateEdgeType(BuildCreateEdgeTypeParam( "person", "software", "developed", edge_props))); - std::vector> v_props = { - std::make_pair("id", neug::execution::Value::INT64(0)), - std::make_pair("name", - neug::execution::Value::STRING(std::string("")))}; + std::vector> v_props = { + std::make_pair("id", neug::columnar::Value::INT64(0)), + std::make_pair("name", neug::columnar::Value::STRING(std::string("")))}; EXPECT_TRUE(interface.CreateVertexType( BuildCreateVertexTypeParam("company", v_props, {"id"}))); EXPECT_TRUE(interface.CreateEdgeType( @@ -150,22 +149,22 @@ class UpdateTransactionTest : public ::testing::Test { dev_label = interface.schema().get_edge_label_id("developed"); neug::vid_t vid; EXPECT_TRUE(interface.AddVertex( - cmp_label, neug::execution::Value::INT64(1), - {neug::execution::Value::STRING(std::string("TechCorp"))}, vid)); + cmp_label, neug::columnar::Value::INT64(1), + {neug::columnar::Value::STRING(std::string("TechCorp"))}, vid)); neug::vid_t p1_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); neug::vid_t software_vid; EXPECT_TRUE(txn.GetVertexIndex( - software_label, neug::execution::Value::INT64(1), software_vid)); + software_label, neug::columnar::Value::INT64(1), software_vid)); neug::vid_t cmp_vid; - EXPECT_TRUE(txn.GetVertexIndex(cmp_label, neug::execution::Value::INT64(1), + EXPECT_TRUE(txn.GetVertexIndex(cmp_label, neug::columnar::Value::INT64(1), cmp_vid)); const void* edge_prop = nullptr; EXPECT_TRUE(interface.AddEdge(person_label, p1_vid, software_label, software_vid, dev_label, - {neug::execution::Value::DOUBLE(4.5), - neug::execution::Value::INT64(2023)}, + {neug::columnar::Value::DOUBLE(4.5), + neug::columnar::Value::INT64(2023)}, edge_prop)); EXPECT_TRUE(interface.AddEdge(person_label, p1_vid, cmp_label, cmp_vid, employ_label, {}, edge_prop)); @@ -201,18 +200,18 @@ class UpdateTransactionTest : public ::testing::Test { neug::StorageTPUpdateInterface& graph, int num_edges) { auto person_label = graph.schema().get_vertex_label_id("person"); auto software_label = graph.schema().get_vertex_label_id("software"); - std::vector> edge_props = { - std::make_pair("review", neug::execution::Value::STRING( - std::string("no review")))}; + std::vector> edge_props = { + std::make_pair( + "review", neug::columnar::Value::STRING(std::string("no review")))}; EXPECT_TRUE(graph.CreateEdgeType(BuildCreateEdgeTypeParam( "person", "software", "reviewed", edge_props))); neug::label_t review_label = graph.schema().get_edge_label_id("reviewed"); neug::vid_t p1_vid; EXPECT_TRUE(graph.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); neug::vid_t s1_vid; EXPECT_TRUE(graph.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), s1_vid)); + neug::columnar::Value::INT64(1), s1_vid)); std::string review_text("Review number: "); std::vector reviews; for (int i = 0; i < num_edges; i++) { @@ -221,7 +220,7 @@ class UpdateTransactionTest : public ::testing::Test { const void* edge_prop = nullptr; EXPECT_TRUE(graph.AddEdge( person_label, p1_vid, software_label, s1_vid, review_label, - {neug::execution::Value::STRING(std::string(full_review))}, + {neug::columnar::Value::STRING(std::string(full_review))}, edge_prop)); } return reviews; @@ -262,7 +261,7 @@ class UpdateTransactionTest : public ::testing::Test { static neug::CreateVertexTypeParam BuildCreateVertexTypeParam( const std::string& vertex_type, - const std::vector>& + const std::vector>& properties, const std::vector& primary_keys) { neug::CreateVertexTypeParamBuilder builder; @@ -275,7 +274,7 @@ class UpdateTransactionTest : public ::testing::Test { static neug::CreateEdgeTypeParam BuildCreateEdgeTypeParam( const std::string& src_type, const std::string& dst_type, const std::string& edge_type, - const std::vector>& + const std::vector>& properties, neug::EdgeStrategy oe_strategy = neug::EdgeStrategy::kMultiple, neug::EdgeStrategy ie_strategy = neug::EdgeStrategy::kMultiple) { @@ -291,7 +290,7 @@ class UpdateTransactionTest : public ::testing::Test { static neug::AddVertexPropertiesParam BuildAddVertexPropertiesParam( const std::string& vertex_type, - const std::vector>& + const std::vector>& properties) { neug::AddVertexPropertiesParamBuilder builder; return builder.VertexLabel(vertex_type).Properties(properties).Build(); @@ -300,7 +299,7 @@ class UpdateTransactionTest : public ::testing::Test { static neug::AddEdgePropertiesParam BuildAddEdgePropertiesParam( const std::string& src_type, const std::string& dst_type, const std::string& edge_type, - const std::vector>& + const std::vector>& properties) { neug::AddEdgePropertiesParamBuilder builder; return builder.SrcLabel(src_type) @@ -366,9 +365,9 @@ TEST_F(UpdateTransactionTest, AddVertex) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid)); EXPECT_TRUE(txn.Commit()); } @@ -398,9 +397,9 @@ TEST_F(UpdateTransactionTest, AddVertexBatch) { for (int i = 4; i <= 10000; i++) { neug::vid_t vid; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(i), - {neug::execution::Value::STRING(std::string("User")), - neug::execution::Value::INT64(20 + i % 10)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(i), + {neug::columnar::Value::STRING(std::string("User")), + neug::columnar::Value::INT64(20 + i % 10)}, vid)); } EXPECT_TRUE(txn.Commit()); @@ -429,16 +428,16 @@ TEST_F(UpdateTransactionTest, AddEdge) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid; - EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid)); + EXPECT_TRUE( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); neug::vid_t vid2; EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, vid, software_label, vid2, created_label, - {neug::execution::Value::DOUBLE(0.9), - neug::execution::Value::INT64(2022)}, + {neug::columnar::Value::DOUBLE(0.9), + neug::columnar::Value::INT64(2022)}, edge_prop)); EXPECT_TRUE(txn.Commit()); } @@ -483,34 +482,34 @@ TEST_F(UpdateTransactionTest, AddVertexEdge) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid2, vid4, vid3; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(4), - {neug::execution::Value::STRING(std::string("David")), - neug::execution::Value::INT64(32)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(4), + {neug::columnar::Value::STRING(std::string("David")), + neug::columnar::Value::INT64(32)}, vid4)); EXPECT_TRUE( - gui.AddVertex(software_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("NeugDB")), - neug::execution::Value::STRING(std::string("C++"))}, + gui.AddVertex(software_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("NeugDB")), + neug::columnar::Value::STRING(std::string("C++"))}, vid3)); const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, vid4, software_label, vid3, created_label, - {neug::execution::Value::DOUBLE(0.85), - neug::execution::Value::INT64(2023)}, + {neug::columnar::Value::DOUBLE(0.85), + neug::columnar::Value::INT64(2023)}, edge_prop)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); EXPECT_TRUE(gui.AddEdge(person_label, vid2, software_label, vid3, created_label, - {neug::execution::Value::DOUBLE(0.75), - neug::execution::Value::INT64(2021)}, + {neug::columnar::Value::DOUBLE(0.75), + neug::columnar::Value::INT64(2021)}, edge_prop)); neug::vid_t vid1; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); EXPECT_TRUE(gui.AddEdge(person_label, vid4, person_label, vid1, txn.schema().get_edge_label_id("knows"), - {neug::execution::Value::DOUBLE(0.95)}, edge_prop)); + {neug::columnar::Value::DOUBLE(0.95)}, edge_prop)); EXPECT_TRUE(txn.Commit()); } { @@ -524,14 +523,14 @@ TEST_F(UpdateTransactionTest, AddVertexEdge) { auto created_label = gi.schema().get_edge_label_id("created"); auto knows_label = gi.schema().get_edge_label_id("knows"); neug::vid_t david_vid; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(4), david_vid)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(4), + david_vid)); EXPECT_EQ(count_edges_filter_src(gi, person_label, software_label, created_label, david_vid, true), 1); neug::vid_t neugdb_vid; - EXPECT_TRUE(gi.GetVertexIndex( - software_label, neug::execution::Value::INT64(3), neugdb_vid)); + EXPECT_TRUE(gi.GetVertexIndex(software_label, + neug::columnar::Value::INT64(3), neugdb_vid)); EXPECT_EQ(count_edges_filter_src(gi, software_label, person_label, created_label, neugdb_vid, false), 2); @@ -558,20 +557,20 @@ TEST_F(UpdateTransactionTest, AddVertexEdgeAbort) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid5, vid4; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(5), - {neug::execution::Value::STRING(std::string("Frank")), - neug::execution::Value::INT64(27)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(5), + {neug::columnar::Value::STRING(std::string("Frank")), + neug::columnar::Value::INT64(27)}, vid5)); - EXPECT_TRUE(gui.AddVertex( - software_label, neug::execution::Value::INT64(4), - {neug::execution::Value::STRING(std::string("UltraGraph")), - neug::execution::Value::STRING(std::string("Go"))}, - vid4)); + EXPECT_TRUE( + gui.AddVertex(software_label, neug::columnar::Value::INT64(4), + {neug::columnar::Value::STRING(std::string("UltraGraph")), + neug::columnar::Value::STRING(std::string("Go"))}, + vid4)); const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, vid5, software_label, vid4, created_label, - {neug::execution::Value::DOUBLE(0.65), - neug::execution::Value::INT64(2022)}, + {neug::columnar::Value::DOUBLE(0.65), + neug::columnar::Value::INT64(2022)}, edge_prop)); txn.Abort(); } @@ -611,10 +610,10 @@ TEST_F(UpdateTransactionTest, UpdateVertexProperty) { neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vertex_id)); gui.UpdateVertexProperty(person_label, vertex_id, 1, - neug::execution::Value::INT64(26)); + neug::columnar::Value::INT64(26)); EXPECT_TRUE(txn.Commit()); } @@ -650,7 +649,7 @@ TEST_F(UpdateTransactionTest, UpdateEdgeProperty) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vertex_id)); update_edge_property( txn, person_label, software_label, created_label, vertex_id, @@ -658,7 +657,7 @@ TEST_F(UpdateTransactionTest, UpdateEdgeProperty) { [&](neug::vid_t dst_vid, int32_t oe_offset, int32_t ie_offset) { gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 0, neug::execution::Value::DOUBLE(0.99)); + 0, neug::columnar::Value::DOUBLE(0.99)); }); EXPECT_TRUE(txn.Commit()); @@ -701,9 +700,9 @@ TEST_F(UpdateTransactionTest, AddVertexAbort) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(4), - {neug::execution::Value::STRING(std::string("Charlie")), - neug::execution::Value::INT64(29)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(4), + {neug::columnar::Value::STRING(std::string("Charlie")), + neug::columnar::Value::INT64(29)}, vid)); txn.Abort(); } @@ -738,14 +737,14 @@ TEST_F(UpdateTransactionTest, AddEdgeAbort) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid2, vid1; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, vid2, software_label, vid1, created_label, - {neug::execution::Value::DOUBLE(0.8), - neug::execution::Value::INT64(2021)}, + {neug::columnar::Value::DOUBLE(0.8), + neug::columnar::Value::INT64(2021)}, edge_prop)); txn.Abort(); } @@ -786,10 +785,10 @@ TEST_F(UpdateTransactionTest, UpdateVertexAbort) { neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vertex_id)); gui.UpdateVertexProperty(person_label, vertex_id, 1, - neug::execution::Value::INT64(27)); + neug::columnar::Value::INT64(27)); txn.Abort(); } { @@ -834,7 +833,7 @@ TEST_F(UpdateTransactionTest, UpdateEdgeAbort) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vertex_id)); update_edge_property( @@ -843,10 +842,10 @@ TEST_F(UpdateTransactionTest, UpdateEdgeAbort) { [&](neug::vid_t dst_vid, int32_t oe_offset, int32_t ie_offset) { gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 0, neug::execution::Value::DOUBLE(0.9)); + 0, neug::columnar::Value::DOUBLE(0.9)); gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 1, neug::execution::Value::INT64(2023)); + 1, neug::columnar::Value::INT64(2023)); }); txn.Abort(); @@ -930,7 +929,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithIntraLabelEdgeAbort) { neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid2; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vid2)); EXPECT_TRUE(gui.DeleteVertex(person_label, vid2)); txn.Abort(); @@ -995,8 +994,8 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenInsertVertex) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE(interface.AddVertex(person_label, - neug::execution::Value::INT64(3), - {neug::execution::Value::INT64(28)}, vid)); + neug::columnar::Value::INT64(3), + {neug::columnar::Value::INT64(28)}, vid)); EXPECT_TRUE(txn.Commit()); } @@ -1010,7 +1009,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenInsertVertex) { EXPECT_EQ(count_vertices(gi, person_label), 3); neug::vid_t vid; ASSERT_TRUE( - gi.GetVertexIndex(person_label, neug::execution::Value::INT64(3), vid)); + gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(3), vid)); auto age_col = std::dynamic_pointer_cast< neug::StorageReadInterface::vertex_column_t>( gi.GetVertexPropColumn(person_label, "age")); @@ -1037,23 +1036,22 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { auto sess = svc->AcquireSession(); auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface gui(txn); - std::vector> new_props = { - std::make_pair("email", - neug::execution::Value::STRING(std::string(""))), - std::make_pair("score", neug::execution::Value::DOUBLE(0.0))}; + std::vector> new_props = { + std::make_pair("email", neug::columnar::Value::STRING(std::string(""))), + std::make_pair("score", neug::columnar::Value::DOUBLE(0.0))}; EXPECT_TRUE(gui.AddVertexProperties( BuildAddVertexPropertiesParam("person", new_props))); // Set initial values for person id=1 auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), - vid)); + CHECK( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); // name(0), age(1), email(2), score(3) gui.UpdateVertexProperty( person_label, vid, 2, - neug::execution::Value::STRING(std::string("alice@test.com"))); + neug::columnar::Value::STRING(std::string("alice@test.com"))); gui.UpdateVertexProperty(person_label, vid, 3, - neug::execution::Value::DOUBLE(95.5)); + neug::columnar::Value::DOUBLE(95.5)); EXPECT_TRUE(txn.Commit()); } @@ -1073,12 +1071,12 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { neug::StorageTPUpdateInterface interface(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), - vid)); + CHECK( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); // Step 1: update "age" (col 1) to trigger detachment interface.UpdateVertexProperty(person_label, vid, 1, - neug::execution::Value::INT64(31)); + neug::columnar::Value::INT64(31)); // Step 2: delete "name" (col 0) — shifts column indices EXPECT_TRUE(interface.DeleteVertexProperties( @@ -1088,9 +1086,9 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { // Step 3: update remaining properties with shifted indices interface.UpdateVertexProperty( person_label, vid, 1, - neug::execution::Value::STRING(std::string("new@test.com"))); + neug::columnar::Value::STRING(std::string("new@test.com"))); interface.UpdateVertexProperty(person_label, vid, 2, - neug::execution::Value::DOUBLE(88.0)); + neug::columnar::Value::DOUBLE(88.0)); // Step 4: insert a new vertex — without the fix, // detachVertexTableForInsert iterates stale columns_detached @@ -1098,10 +1096,10 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { // out-of-bounds crash. neug::vid_t new_vid; EXPECT_TRUE(interface.AddVertex( - person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::INT64(22), - neug::execution::Value::STRING(std::string("charlie@test.com")), - neug::execution::Value::DOUBLE(77.0)}, + person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::INT64(22), + neug::columnar::Value::STRING(std::string("charlie@test.com")), + neug::columnar::Value::DOUBLE(77.0)}, new_vid)); EXPECT_TRUE(txn.Commit()); } @@ -1119,7 +1117,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { // person id=1: age=31, email=new@test.com, score=88.0 { neug::vid_t vid; - CHECK(gi.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); auto age_col = std::dynamic_pointer_cast< neug::StorageReadInterface::vertex_column_t>( @@ -1142,7 +1140,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexPropertiesThenUpdateRemaining) { // person id=3: age=22, email=charlie@test.com, score=77.0 { neug::vid_t vid; - CHECK(gi.GetVertexIndex(person_label, neug::execution::Value::INT64(3), + CHECK(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(3), vid)); auto age_col = std::dynamic_pointer_cast< neug::StorageReadInterface::vertex_column_t>( @@ -1171,8 +1169,8 @@ TEST_F(UpdateTransactionTest, DeleteEdgePropertiesThenInsertEdge) { auto sess = svc->AcquireSession(); auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface gui(txn); - std::vector> new_props = { - std::make_pair("rating", neug::execution::Value::DOUBLE(0.0))}; + std::vector> new_props = { + std::make_pair("rating", neug::columnar::Value::DOUBLE(0.0))}; EXPECT_TRUE(gui.AddEdgeProperties(BuildAddEdgePropertiesParam( "person", "software", "created", new_props))); EXPECT_TRUE(txn.Commit()); @@ -1196,15 +1194,15 @@ TEST_F(UpdateTransactionTest, DeleteEdgePropertiesThenInsertEdge) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t p1_vid, s1_vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), p1_vid)); - CHECK(txn.GetVertexIndex(software_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(software_label, neug::columnar::Value::INT64(1), s1_vid)); const void* edge_prop = nullptr; EXPECT_TRUE(interface.AddEdge(person_label, p1_vid, software_label, s1_vid, created_label, - {neug::execution::Value::DOUBLE(0.9), - neug::execution::Value::DOUBLE(4.5)}, + {neug::columnar::Value::DOUBLE(0.9), + neug::columnar::Value::DOUBLE(4.5)}, edge_prop)); EXPECT_TRUE(txn.Commit()); } @@ -1232,7 +1230,7 @@ TEST_F(UpdateTransactionTest, DeleteEdgePropertiesThenInsertEdge) { auto view = gi.GetGenericOutgoingGraphView(person_label, software_label, created_label); neug::vid_t p1_vid; - CHECK(gi.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), p1_vid)); int edge_count = 0; auto edge_iter = view.get_edges(p1_vid); @@ -1241,7 +1239,7 @@ TEST_F(UpdateTransactionTest, DeleteEdgePropertiesThenInsertEdge) { if (it.get_vertex() == [&]() { neug::vid_t s1_vid; CHECK(gi.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), s1_vid)); + neug::columnar::Value::INT64(1), s1_vid)); return s1_vid; }()) { // One of the edges to software(1) should have the new values @@ -1277,10 +1275,9 @@ TEST_F(UpdateTransactionTest, DeleteVertexTypeWithEdgesThenCreateNewTypes) { EXPECT_TRUE(interface.DeleteVertexType("software")); // Create a new vertex type "company" and edge type "employed_by" - std::vector> v_props = { - std::make_pair("id", neug::execution::Value::INT64(0)), - std::make_pair("name", - neug::execution::Value::STRING(std::string("")))}; + std::vector> v_props = { + std::make_pair("id", neug::columnar::Value::INT64(0)), + std::make_pair("name", neug::columnar::Value::STRING(std::string("")))}; EXPECT_TRUE(interface.CreateVertexType( BuildCreateVertexTypeParam("company", v_props, {"id"}))); EXPECT_TRUE(interface.CreateEdgeType( @@ -1290,13 +1287,13 @@ TEST_F(UpdateTransactionTest, DeleteVertexTypeWithEdgesThenCreateNewTypes) { auto company_label = interface.schema().get_vertex_label_id("company"); neug::vid_t cmp_vid; EXPECT_TRUE(interface.AddVertex( - company_label, neug::execution::Value::INT64(1), - {neug::execution::Value::STRING(std::string("TechCorp"))}, cmp_vid)); + company_label, neug::columnar::Value::INT64(1), + {neug::columnar::Value::STRING(std::string("TechCorp"))}, cmp_vid)); auto person_label = interface.schema().get_vertex_label_id("person"); auto employ_label = interface.schema().get_edge_label_id("employed_by"); neug::vid_t p1_vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), p1_vid)); const void* edge_prop = nullptr; EXPECT_TRUE(interface.AddEdge(person_label, p1_vid, company_label, cmp_vid, @@ -1344,8 +1341,8 @@ TEST_F(UpdateTransactionTest, DeleteEdgeTypeThenCreateNewEdgeType) { EXPECT_TRUE(interface.DeleteEdgeType("person", "person", "knows")); // Create a new edge type "friend_of" between person and person - std::vector> e_props = { - std::make_pair("closeness", neug::execution::Value::DOUBLE(0.0))}; + std::vector> e_props = { + std::make_pair("closeness", neug::columnar::Value::DOUBLE(0.0))}; EXPECT_TRUE(interface.CreateEdgeType( BuildCreateEdgeTypeParam("person", "person", "friend_of", e_props))); @@ -1353,14 +1350,14 @@ TEST_F(UpdateTransactionTest, DeleteEdgeTypeThenCreateNewEdgeType) { auto person_label = interface.schema().get_vertex_label_id("person"); auto friend_label = interface.schema().get_edge_label_id("friend_of"); neug::vid_t p1_vid, p2_vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), p1_vid)); - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), p2_vid)); const void* edge_prop = nullptr; EXPECT_TRUE(interface.AddEdge( person_label, p1_vid, person_label, p2_vid, friend_label, - {neug::execution::Value::DOUBLE(0.75)}, edge_prop)); + {neug::columnar::Value::DOUBLE(0.75)}, edge_prop)); EXPECT_TRUE(txn.Commit()); } @@ -1383,7 +1380,7 @@ TEST_F(UpdateTransactionTest, DeleteEdgeTypeThenCreateNewEdgeType) { auto view = gi.GetGenericOutgoingGraphView(person_label, person_label, friend_label); neug::vid_t p1_vid; - CHECK(gi.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), p1_vid)); auto edges = view.get_edges(p1_vid); for (auto it = edges.begin(); it != edges.end(); ++it) { @@ -1407,7 +1404,7 @@ TEST_F(UpdateTransactionTest, UpdateEdgeAbort2) { auto person_label = txn.schema().get_vertex_label_id("person"); auto knows_label = txn.schema().get_edge_label_id("knows"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vertex_id)); update_edge_property( @@ -1416,7 +1413,7 @@ TEST_F(UpdateTransactionTest, UpdateEdgeAbort2) { [&](neug::vid_t dst_vid, int32_t oe_offset, int32_t ie_offset) { gui.UpdateEdgeProperty(person_label, vertex_id, person_label, dst_vid, knows_label, oe_offset, ie_offset, 0, - neug::execution::Value::DOUBLE(0.95)); + neug::columnar::Value::DOUBLE(0.95)); }); txn.Abort(); @@ -1475,17 +1472,17 @@ TEST_F(UpdateTransactionTest, AddEdgeAndUpdateAndAbort) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid1, vid2; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); const void* edge_prop = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, vid1, software_label, vid2, created_label, - {neug::execution::Value::DOUBLE(0.85), - neug::execution::Value::INT64(2023)}, + {neug::columnar::Value::DOUBLE(0.85), + neug::columnar::Value::INT64(2023)}, edge_prop)); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vertex_id)); update_edge_property( @@ -1494,7 +1491,7 @@ TEST_F(UpdateTransactionTest, AddEdgeAndUpdateAndAbort) { [&](neug::vid_t dst_vid, int32_t oe_offset, int32_t ie_offset) { gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 0, neug::execution::Value::DOUBLE(0.9)); + 0, neug::columnar::Value::DOUBLE(0.9)); }); txn.Abort(); @@ -1545,7 +1542,7 @@ TEST_F(UpdateTransactionTest, DeleteVertex) { neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vertex_id)); EXPECT_TRUE(gui.DeleteVertex(person_label, vertex_id)); EXPECT_TRUE(txn.Commit()); @@ -1559,8 +1556,8 @@ TEST_F(UpdateTransactionTest, DeleteVertex) { auto software_label = gi.schema().get_vertex_label_id("software"); EXPECT_EQ(count_vertices(gi, person_label), 1); neug::vid_t vertex_id; - EXPECT_FALSE(gi.GetVertexIndex( - person_label, neug::execution::Value::INT64(2), vertex_id)); + EXPECT_FALSE(gi.GetVertexIndex(person_label, + neug::columnar::Value::INT64(2), vertex_id)); EXPECT_EQ( count_edges(gi, person_label, software_label, created_label, true), 1); EXPECT_EQ( @@ -1574,8 +1571,8 @@ TEST_F(UpdateTransactionTest, DeleteVertex) { auto person_label = txn.schema().get_vertex_label_id("person"); EXPECT_TRUE(gui.DeleteVertexType("person")); neug::vid_t vertex_id; - EXPECT_THROW(txn.GetVertexIndex( - person_label, neug::execution::Value::INT64(1), vertex_id), + EXPECT_THROW(txn.GetVertexIndex(person_label, + neug::columnar::Value::INT64(1), vertex_id), neug::exception::Exception); } db.Close(); @@ -1597,9 +1594,9 @@ TEST_F(UpdateTransactionTest, DeleteEdgeAbort) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vid2, vid1; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid2)); + neug::columnar::Value::INT64(1), vid2)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); EXPECT_TRUE(gui.DeleteEdges(person_label, vid2, software_label, vid1, created_label)); EXPECT_TRUE(txn.Commit()); @@ -1612,9 +1609,9 @@ TEST_F(UpdateTransactionTest, DeleteEdgeAbort) { auto knows_label = txn.schema().get_edge_label_id("knows"); neug::vid_t vid1, vid2; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); EXPECT_TRUE( gui.DeleteEdges(person_label, vid1, person_label, vid2, knows_label)); txn.Abort(); @@ -1627,9 +1624,9 @@ TEST_F(UpdateTransactionTest, DeleteEdgeAbort) { auto knows_label = txn.schema().get_edge_label_id("knows"); neug::vid_t vid1, vid2; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), vid1)); + neug::columnar::Value::INT64(1), vid1)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), vid2)); + neug::columnar::Value::INT64(2), vid2)); auto oe_edges = txn.GetGenericOutgoingGraphView(person_label, person_label, knows_label) .get_edges(vid1); @@ -1691,14 +1688,14 @@ TEST_F(UpdateTransactionTest, AddDeleteVertexAbort) { neug::StorageTPUpdateInterface interface(txn); auto person_label = interface.schema().get_vertex_label_id("person"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vertex_id)); EXPECT_TRUE(interface.DeleteVertex(person_label, vertex_id)); neug::vid_t vid; EXPECT_TRUE( - interface.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + interface.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid)); txn.Abort(); } @@ -1709,10 +1706,10 @@ TEST_F(UpdateTransactionTest, AddDeleteVertexAbort) { auto person_label = gi.schema().get_vertex_label_id("person"); EXPECT_EQ(count_vertices(gi, person_label), 2); neug::vid_t vertex_id; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), vertex_id)); - EXPECT_FALSE(gi.GetVertexIndex( - person_label, neug::execution::Value::INT64(3), vertex_id)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), + vertex_id)); + EXPECT_FALSE(gi.GetVertexIndex(person_label, + neug::columnar::Value::INT64(3), vertex_id)); } { // Add again @@ -1722,9 +1719,9 @@ TEST_F(UpdateTransactionTest, AddDeleteVertexAbort) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE( - gui.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + gui.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid)); EXPECT_TRUE(txn.Commit()); } @@ -1735,8 +1732,8 @@ TEST_F(UpdateTransactionTest, AddDeleteVertexAbort) { auto person_label = gi.schema().get_vertex_label_id("person"); EXPECT_EQ(count_vertices(gi, person_label), 3); neug::vid_t vertex_id; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(3), vertex_id)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(3), + vertex_id)); EXPECT_EQ(count_vertices(gi, person_label), 3); } db.Close(); @@ -1859,19 +1856,18 @@ TEST_F(UpdateTransactionTest, AddVertexProperties) { auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); - std::vector> new_props = { - std::make_pair("email", - neug::execution::Value::STRING(std::string(""))), - std::make_pair("height", neug::execution::Value::DOUBLE(0.0))}; + std::vector> new_props = { + std::make_pair("email", neug::columnar::Value::STRING(std::string(""))), + std::make_pair("height", neug::columnar::Value::DOUBLE(0.0))}; EXPECT_TRUE(gui.AddVertexProperties( BuildAddVertexPropertiesParam("person", new_props))); auto email_accessor = txn.get_vertex_property_column(person_label, "email"); neug::vid_t vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), - vid)); + CHECK( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); gui.UpdateVertexProperty( person_label, vid, 2, - neug::execution::Value::STRING(std::string("eve@example.com"))); + neug::columnar::Value::STRING(std::string("eve@example.com"))); EXPECT_TRUE(txn.Commit()); } { @@ -1881,16 +1877,16 @@ TEST_F(UpdateTransactionTest, AddVertexProperties) { auto person_label = txn.schema().get_vertex_label_id("person"); auto height_accessor = txn.get_vertex_property_column(person_label, "height"); - std::vector> new_props = { + std::vector> new_props = { std::make_pair("address", - neug::execution::Value::STRING(std::string("")))}; + neug::columnar::Value::STRING(std::string("")))}; EXPECT_TRUE(gui.AddVertexProperties( BuildAddVertexPropertiesParam("person", new_props))); neug::vid_t vid; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(2), - vid)); + CHECK( + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vid)); gui.UpdateVertexProperty(person_label, vid, 3, - neug::execution::Value::DOUBLE(175.5)); + neug::columnar::Value::DOUBLE(175.5)); txn.Abort(); } { @@ -1908,11 +1904,11 @@ TEST_F(UpdateTransactionTest, AddVertexProperties) { gi.GetVertexPropColumn(person_label, "height")); neug::vid_t vid; CHECK( - gi.GetVertexIndex(person_label, neug::execution::Value::INT64(1), vid)); + gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid)); EXPECT_EQ(email_accessor->get_any(vid).GetValue(), "eve@example.com"); CHECK( - gi.GetVertexIndex(person_label, neug::execution::Value::INT64(2), vid)); + gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), vid)); EXPECT_EQ(height_accessor->get_any(vid).GetValue(), 0.0); } db.Close(); @@ -1929,10 +1925,10 @@ TEST_F(UpdateTransactionTest, AddEdgeProperties) { auto sess = svc->AcquireSession(); auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface interface(txn); - std::vector> new_props = { - std::make_pair("version", neug::execution::Value::INT64(0)), + std::vector> new_props = { + std::make_pair("version", neug::columnar::Value::INT64(0)), std::make_pair("license", - neug::execution::Value::STRING(std::string("")))}; + neug::columnar::Value::STRING(std::string("")))}; EXPECT_TRUE(interface.AddEdgeProperties(BuildAddEdgePropertiesParam( "person", "software", "created", new_props))); EXPECT_TRUE(txn.Commit()); @@ -1941,8 +1937,8 @@ TEST_F(UpdateTransactionTest, AddEdgeProperties) { auto sess = svc->AcquireSession(); auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface interface(txn); - std::vector> new_props = { - std::make_pair("contributions", neug::execution::Value::DOUBLE(0.0))}; + std::vector> new_props = { + std::make_pair("contributions", neug::columnar::Value::DOUBLE(0.0))}; EXPECT_TRUE(interface.AddEdgeProperties(BuildAddEdgePropertiesParam( "person", "software", "created", new_props))); txn.Abort(); @@ -2085,8 +2081,8 @@ TEST_F(UpdateTransactionTest, DeleteEdgeProperties) { neug::StorageTPUpdateInterface interface(txn); EXPECT_TRUE(interface.DeleteEdgeProperties(BuildDeleteEdgePropertiesParam( "person", "software", "created", {"since"}))); - std::vector> new_props = { - std::make_pair("contributions", neug::execution::Value::DOUBLE(0.0))}; + std::vector> new_props = { + std::make_pair("contributions", neug::columnar::Value::DOUBLE(0.0))}; LOG(INFO) << "Adding new edge property 'contributions'."; EXPECT_TRUE(interface.AddEdgeProperties(BuildAddEdgePropertiesParam( "person", "software", "created", new_props))); @@ -2158,9 +2154,9 @@ TEST_F(UpdateTransactionTest, DeleteVertexProperties) { BuildDeleteVertexPropertiesParam("person", {"age"}))); EXPECT_TRUE(interface.DeleteVertexProperties( BuildDeleteVertexPropertiesParam("software", {"lang"}))); - std::vector> new_props = { + std::vector> new_props = { std::make_pair("authors", - neug::execution::Value::STRING(std::string("")))}; + neug::columnar::Value::STRING(std::string("")))}; EXPECT_TRUE(interface.AddVertexProperties( BuildAddVertexPropertiesParam("software", new_props))); EXPECT_TRUE(txn.Commit()); @@ -2207,15 +2203,15 @@ TEST_F(UpdateTransactionTest, TestReplayWal) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t vid; EXPECT_TRUE( - interface.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + interface.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid)); EXPECT_TRUE(interface.CreateVertexType(BuildCreateVertexTypeParam( "company", - {std::make_pair("id", neug::execution::Value::INT64(0)), + {std::make_pair("id", neug::columnar::Value::INT64(0)), std::make_pair("name", - neug::execution::Value::STRING(std::string("")))}, + neug::columnar::Value::STRING(std::string("")))}, {"id"}))); EXPECT_TRUE(interface.CreateEdgeType( BuildCreateEdgeTypeParam("person", "company", "employed_by", {}))); @@ -2223,12 +2219,12 @@ TEST_F(UpdateTransactionTest, TestReplayWal) { EXPECT_TRUE(interface.DeleteVertexType("software")); neug::vid_t src_p, dst_p; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), src_p)); + neug::columnar::Value::INT64(1), src_p)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), dst_p)); + neug::columnar::Value::INT64(2), dst_p)); interface.UpdateVertexProperty(person_label, src_p, 1, - neug::execution::Value::INT64(29)); + neug::columnar::Value::INT64(29)); update_edge_property( txn, person_label, person_label, txn.schema().get_edge_label_id("knows"), src_p, @@ -2237,7 +2233,7 @@ TEST_F(UpdateTransactionTest, TestReplayWal) { interface.UpdateEdgeProperty(person_label, src_p, person_label, dst_p, txn.schema().get_edge_label_id("knows"), oe_offset, ie_offset, 0, - neug::execution::Value::DOUBLE(0.5)); + neug::columnar::Value::DOUBLE(0.5)); }); EXPECT_TRUE(txn.Commit()); db.Close(); @@ -2252,10 +2248,10 @@ TEST_F(UpdateTransactionTest, TestReplayWal) { auto person_label = gi.schema().get_vertex_label_id("person"); EXPECT_EQ(count_vertices(gi, person_label), 3); neug::vid_t src_p, dst_p; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), src_p)); - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), dst_p)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), + src_p)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), + dst_p)); auto vprop_accessor = std::dynamic_pointer_cast< neug::StorageReadInterface::vertex_column_t>( gi.GetVertexPropColumn(person_label, "age")); @@ -2293,10 +2289,10 @@ TEST_F(UpdateTransactionTest, TestReplayWal) { auto person_label = gi.schema().get_vertex_label_id("person"); auto knows_label = gi.schema().get_edge_label_id("knows"); neug::vid_t src_p, dst_p; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), src_p)); - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), dst_p)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), + src_p)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(2), + dst_p)); auto ed_accessor = gi.GetEdgeDataAccessor(person_label, person_label, knows_label, 0); auto view = @@ -2325,21 +2321,21 @@ TEST_F(UpdateTransactionTest, TestAPIAfterDeleteVertexLabel) { EXPECT_TRUE(interface.DeleteVertexType("person")); neug::vid_t vid; EXPECT_THROW( - txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), vid), + txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vid), neug::exception::Exception); EXPECT_THROW( - interface.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + interface.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid), neug::exception::Exception); EXPECT_THROW(interface.UpdateVertexProperty( - person_label, 0, 1, neug::execution::Value::INT64(30)), + person_label, 0, 1, neug::columnar::Value::INT64(30)), neug::exception::Exception); EXPECT_THROW( - interface.AddVertex(person_label, neug::execution::Value::INT64(3), - {neug::execution::Value::STRING(std::string("Eve")), - neug::execution::Value::INT64(28)}, + interface.AddVertex(person_label, neug::columnar::Value::INT64(3), + {neug::columnar::Value::STRING(std::string("Eve")), + neug::columnar::Value::INT64(28)}, vid), neug::exception::Exception); EXPECT_THROW(interface.DeleteVertex(person_label, 0), @@ -2365,8 +2361,8 @@ TEST_F(UpdateTransactionTest, TestAPIAfterDeleteVertexLabel) { EXPECT_EQ(txn.get_vertex_property_column(person_label, "age"), nullptr); // add back age property - std::vector> new_props = { - std::make_pair("age", neug::execution::Value::INT32(0))}; + std::vector> new_props = { + std::make_pair("age", neug::columnar::Value::INT32(0))}; EXPECT_NO_THROW(interface.AddVertexProperties( BuildAddVertexPropertiesParam("person", new_props))); EXPECT_NO_THROW(txn.get_vertex_property_column(person_label, "age")); @@ -2391,9 +2387,9 @@ TEST_F(UpdateTransactionTest, TestAPIAfterDeleteEdgeLabel) { auto knows_label = interface.schema().get_edge_label_id("knows"); neug::vid_t src_vid, dst_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), src_vid)); + neug::columnar::Value::INT64(1), src_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), dst_vid)); + neug::columnar::Value::INT64(2), dst_vid)); int32_t oe_offset = -1, ie_offset = -1; { auto oe_view = interface.GetGenericOutgoingGraphView( @@ -2421,13 +2417,13 @@ TEST_F(UpdateTransactionTest, TestAPIAfterDeleteEdgeLabel) { EXPECT_FALSE(interface.UpdateEdgeProperty( person_label, src_vid, person_label, dst_vid, knows_label,0,0, - 0, neug::execution::Value::DOUBLE(0.8)).ok()); + 0, neug::columnar::Value::DOUBLE(0.8)).ok()); { const void* edge_prop = nullptr; EXPECT_THROW( interface.AddEdge(person_label, src_vid, person_label, dst_vid, - knows_label, {neug::execution::Value::DOUBLE(0.7)}, + knows_label, {neug::columnar::Value::DOUBLE(0.7)}, edge_prop), neug::exception::Exception); } @@ -2456,9 +2452,9 @@ TEST_F(UpdateTransactionTest, TestAPIAfterDeleteEdgeLabel) { {std::make_pair("closeness", "importance")}))); neug::vid_t src_vid, dst_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), src_vid)); + neug::columnar::Value::INT64(1), src_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), dst_vid)); + neug::columnar::Value::INT64(2), dst_vid)); EXPECT_THROW( txn.GetEdgeDataAccessor(person_label, person_label, knows_label, 0), neug::exception::Exception); @@ -2481,7 +2477,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithOutgoingEdges) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t p1_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(gui.DeleteVertex(person_label, p1_vid)); EXPECT_TRUE(txn.Commit()); } @@ -2496,7 +2492,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithOutgoingEdges) { neug::vid_t p1_vid; EXPECT_FALSE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_EQ(count_vertices(gi, person_label), 1); EXPECT_EQ( count_edges(gi, person_label, software_label, created_label, true), 1); @@ -2521,12 +2517,12 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithBidirectionalEdges) { auto knows_label = txn.schema().get_edge_label_id("knows"); neug::vid_t p1_vid, p2_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), p2_vid)); + neug::columnar::Value::INT64(2), p2_vid)); const void* edge_prop_p2_p1 = nullptr; EXPECT_TRUE(gui.AddEdge(person_label, p2_vid, person_label, p1_vid, - knows_label, {neug::execution::Value::DOUBLE(0.85)}, + knows_label, {neug::columnar::Value::DOUBLE(0.85)}, edge_prop_p2_p1)); EXPECT_TRUE(txn.Commit()); } @@ -2546,7 +2542,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithBidirectionalEdges) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t p1_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(gui.DeleteVertex(person_label, p1_vid)); EXPECT_TRUE(txn.Commit()); } @@ -2582,9 +2578,9 @@ TEST_F(UpdateTransactionTest, DeleteVertexAbortRestoresEdges) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t p1_vid, p2_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), p2_vid)); + neug::columnar::Value::INT64(1), p2_vid)); auto oe_view = txn.GetGenericOutgoingGraphView(person_label, software_label, created_label); auto ie_view = txn.GetGenericIncomingGraphView(software_label, person_label, @@ -2628,7 +2624,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexAbortRestoresEdges) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t p1_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(gui.DeleteVertex(person_label, p1_vid)); txn.Abort(); } @@ -2642,8 +2638,8 @@ TEST_F(UpdateTransactionTest, DeleteVertexAbortRestoresEdges) { auto created_label = gi.schema().get_edge_label_id("created"); auto knows_label = gi.schema().get_edge_label_id("knows"); neug::vid_t p1_vid; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), + p1_vid)); EXPECT_EQ(count_vertices(gi, person_label), 2); EXPECT_EQ( count_edges(gi, person_label, software_label, created_label, true), @@ -2667,21 +2663,21 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithMultipleEdgeTypes) { auto txn = sess->GetUpdateTransaction(); neug::StorageTPUpdateInterface gui(txn); auto person_label = txn.schema().get_vertex_label_id("person"); - std::vector> edge_props = { - std::make_pair("since", neug::execution::Value::INT64(2020))}; + std::vector> edge_props = { + std::make_pair("since", neug::columnar::Value::INT64(2020))}; EXPECT_TRUE(gui.CreateEdgeType( BuildCreateEdgeTypeParam("person", "person", "follows", edge_props))); neug::vid_t p1_vid, p2_vid; auto follows_label = txn.schema().get_edge_label_id("follows"); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), p2_vid)); + neug::columnar::Value::INT64(2), p2_vid)); const void* edge_prop_follows = nullptr; - EXPECT_TRUE( - gui.AddEdge(person_label, p1_vid, person_label, p2_vid, follows_label, - {neug::execution::Value::INT64(2022)}, edge_prop_follows)); + EXPECT_TRUE(gui.AddEdge(person_label, p1_vid, person_label, p2_vid, + follows_label, {neug::columnar::Value::INT64(2022)}, + edge_prop_follows)); EXPECT_TRUE(txn.Commit()); } { @@ -2691,7 +2687,7 @@ TEST_F(UpdateTransactionTest, DeleteVertexWithMultipleEdgeTypes) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t p1_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(gui.DeleteVertex(person_label, p1_vid)); EXPECT_TRUE(txn.Commit()); } @@ -2765,10 +2761,10 @@ TEST_F(UpdateTransactionTest, BatchDeleteVertices) { neug::StorageTPUpdateInterface interface(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t alice_vid, bob_vid; - EXPECT_TRUE(txn.GetVertexIndex( - person_label, neug::execution::Value::INT64(1), alice_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), bob_vid)); + neug::columnar::Value::INT64(1), alice_vid)); + EXPECT_TRUE(txn.GetVertexIndex(person_label, + neug::columnar::Value::INT64(2), bob_vid)); std::vector lids = {alice_vid, bob_vid}; EXPECT_EQ(interface.BatchDeleteVertices(person_label, lids).error_code(), neug::StatusCode::OK); @@ -2800,13 +2796,13 @@ TEST_F(UpdateTransactionTest, BatchDeleteEdges) { auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t p1_vid, p2_vid, s1_vid, s2_vid; EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(txn.GetVertexIndex(person_label, - neug::execution::Value::INT64(2), p2_vid)); + neug::columnar::Value::INT64(2), p2_vid)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(1), s1_vid)); + neug::columnar::Value::INT64(1), s1_vid)); EXPECT_TRUE(txn.GetVertexIndex(software_label, - neug::execution::Value::INT64(2), s2_vid)); + neug::columnar::Value::INT64(2), s2_vid)); std::vector> edges = { std::make_tuple(p1_vid, s1_vid), std::make_tuple(p2_vid, s2_vid)}; EXPECT_EQ(interface.BatchDeleteEdges(person_label, software_label, @@ -2843,8 +2839,8 @@ TEST_F(UpdateTransactionTest, BatchDeleteVerticesFailure) { neug::StorageTPUpdateInterface interface(txn); auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t alice_vid; - EXPECT_TRUE(txn.GetVertexIndex( - person_label, neug::execution::Value::INT64(1), alice_vid)); + EXPECT_TRUE(txn.GetVertexIndex(person_label, + neug::columnar::Value::INT64(1), alice_vid)); auto invalid_vid = std::numeric_limits::max(); EXPECT_FALSE( interface.BatchDeleteVertices(person_label, {alice_vid, invalid_vid}) @@ -2911,20 +2907,20 @@ TEST_F(UpdateTransactionTest, TestUpdateStringProperty) { auto person_label = txn.schema().get_vertex_label_id("person"); neug::vid_t p1_vid, p2_vid; EXPECT_TRUE(interface.GetVertexIndex( - person_label, neug::execution::Value::INT64(1), p1_vid)); + person_label, neug::columnar::Value::INT64(1), p1_vid)); EXPECT_TRUE(interface.GetVertexIndex( - person_label, neug::execution::Value::INT64(2), p2_vid)); + person_label, neug::columnar::Value::INT64(2), p2_vid)); std::string long_name(neug::STRING_DEFAULT_MAX_LENGTH + 10, 'a'); interface.UpdateVertexProperty( person_label, p1_vid, 0, - neug::execution::Value::STRING(std::string(long_name))); + neug::columnar::Value::STRING(std::string(long_name))); auto prop = interface.GetVertexProperty(person_label, p1_vid, 0); EXPECT_EQ(prop.GetValue(), std::string(neug::STRING_DEFAULT_MAX_LENGTH, 'a')); // truncated std::string valid_name(neug::STRING_DEFAULT_MAX_LENGTH - 10, 'b'); EXPECT_NO_THROW(interface.UpdateVertexProperty( person_label, p1_vid, 0, - neug::execution::Value::STRING(std::string(valid_name)))); + neug::columnar::Value::STRING(std::string(valid_name)))); prop = interface.GetVertexProperty(person_label, p1_vid, 0); EXPECT_EQ(prop.GetValue(), valid_name); auto p2_prop = interface.GetVertexProperty(person_label, p2_vid, 0); @@ -2937,8 +2933,8 @@ TEST_F(UpdateTransactionTest, TestUpdateStringProperty) { neug::StorageReadInterface gi(txn.view(), txn.timestamp()); auto person_label = gi.schema().get_vertex_label_id("person"); neug::vid_t p1_vid; - EXPECT_TRUE(gi.GetVertexIndex(person_label, - neug::execution::Value::INT64(1), p1_vid)); + EXPECT_TRUE(gi.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), + p1_vid)); auto vprop_accessor = std::dynamic_pointer_cast< neug::StorageReadInterface::vertex_column_t>( gi.GetVertexPropColumn(person_label, "name")); @@ -3017,7 +3013,7 @@ TEST_F(UpdateTransactionTest, TestUpdateEdgeStringPropertyCompact) { interface.UpdateEdgeProperty( person_label, vid, software_label, it.get_vertex(), review_label, oe_offset, ie_offset, 0, - neug::execution::Value::STRING(std::string(updated_review))); + neug::columnar::Value::STRING(std::string(updated_review))); updated_views.push_back(updated_review); } } @@ -3082,7 +3078,7 @@ TEST_F(UpdateTransactionTest, TestTPServiceStart) { auto software_label = txn.schema().get_vertex_label_id("software"); auto created_label = txn.schema().get_edge_label_id("created"); neug::vid_t vertex_id; - CHECK(txn.GetVertexIndex(person_label, neug::execution::Value::INT64(1), + CHECK(txn.GetVertexIndex(person_label, neug::columnar::Value::INT64(1), vertex_id)); update_edge_property( @@ -3091,10 +3087,10 @@ TEST_F(UpdateTransactionTest, TestTPServiceStart) { [&](neug::vid_t dst_vid, int32_t oe_offset, int32_t ie_offset) { gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 0, neug::execution::Value::DOUBLE(0.9)); + 0, neug::columnar::Value::DOUBLE(0.9)); gui.UpdateEdgeProperty(person_label, vertex_id, software_label, dst_vid, created_label, oe_offset, ie_offset, - 1, neug::execution::Value::INT64(2023)); + 1, neug::columnar::Value::INT64(2023)); }); txn.Abort(); diff --git a/tests/unittest/logical_delete_test.cc b/tests/unittest/logical_delete_test.cc index ff544e012..4687804d6 100644 --- a/tests/unittest/logical_delete_test.cc +++ b/tests/unittest/logical_delete_test.cc @@ -15,7 +15,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/property_graph.h" #include "neug/utils/property/types.h" #include "neug/utils/yaml_utils.h" @@ -52,7 +52,7 @@ class PropertyGraphLogicalDeleteTest : public ::testing::Test { CreateVertexTypeParam BuildCreateVertexTypeParam( const std::string& name, - const std::vector>& properties, + const std::vector>& properties, const std::vector& primary_keys) { CreateVertexTypeParamBuilder builder; builder.VertexLabel(name) @@ -64,7 +64,7 @@ class PropertyGraphLogicalDeleteTest : public ::testing::Test { CreateEdgeTypeParam BuildCreateEdgeTypeParam( const std::string& src_type, const std::string& dst_type, const std::string& edge_type, - const std::vector>& properties, + const std::vector>& properties, EdgeStrategy oe_strategy = EdgeStrategy::kMultiple, EdgeStrategy ie_strategy = EdgeStrategy::kMultiple) { CreateEdgeTypeParamBuilder builder; @@ -101,11 +101,11 @@ class PropertyGraphLogicalDeleteTest : public ::testing::Test { // Test DeleteVertexType - physically removes vertex type and data TEST_F(PropertyGraphLogicalDeleteTest, DeleteVertexType_RemovesTypeAndData) { // Create a vertex type with properties - std::vector> properties = { - {"age", execution::Value::INT32(0)}, - {"name", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"age", columnar::Value::INT32(0)}, + {"name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; - properties.insert(properties.begin(), {"id", execution::Value::INT64(0L)}); + properties.insert(properties.begin(), {"id", columnar::Value::INT64(0L)}); auto status = graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", properties, pk_names)); @@ -126,9 +126,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, DeleteVertexType_RemovesTypeAndData) { // Test corner case: Create -> Delete Physical -> Create again TEST_F(PropertyGraphLogicalDeleteTest, CreateDeletePhysicalRecreate_Succeeds) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; // First creation @@ -155,9 +155,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, CreateDeletePhysicalRecreate_Succeeds) { TEST_F(PropertyGraphLogicalDeleteTest, CreateDeleteLogicalRecreate_ActsAsRevert) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; auto status = graph_.CreateVertexType( @@ -179,8 +179,8 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test DeleteEdgeType TEST_F(PropertyGraphLogicalDeleteTest, DeleteEdgeTypePhysical_RemovesEdgeType) { // Create source and destination vertex types - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}}; std::vector pk_names = {"id"}; auto status = graph_.CreateVertexType( @@ -191,8 +191,8 @@ TEST_F(PropertyGraphLogicalDeleteTest, DeleteEdgeTypePhysical_RemovesEdgeType) { ASSERT_TRUE(status.ok()); // Create edge type - std::vector> e_props = { - {"years", execution::Value::INT32(0)}}; + std::vector> e_props = { + {"years", columnar::Value::INT32(0)}}; status = graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props)); ASSERT_TRUE(status.ok()); @@ -212,10 +212,10 @@ TEST_F(PropertyGraphLogicalDeleteTest, DeleteEdgeTypePhysical_RemovesEdgeType) { // Test DeleteVertexProperties TEST_F(PropertyGraphLogicalDeleteTest, DeleteVertexPropertiesPhysical_RemovesProperties) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}, - {"age", execution::Value::INT32(0)}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}, + {"age", columnar::Value::INT32(0)}}; std::vector pk_names = {"id"}; auto status = graph_.CreateVertexType( @@ -240,10 +240,10 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test DeleteVertexPropertiesSoft TEST_F(PropertyGraphLogicalDeleteTest, DeleteVertexPropertiesLogical_MarksPropertiesDeleted) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}, - {"age", execution::Value::INT32(0)}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}, + {"age", columnar::Value::INT32(0)}}; std::vector pk_names = {"id"}; auto status = graph_.CreateVertexType( @@ -266,8 +266,8 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test DeleteEdgeProperties TEST_F(PropertyGraphLogicalDeleteTest, DeleteEdgePropertiesPhysical_RemovesProperties) { - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( @@ -275,9 +275,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, graph_.CreateVertexType( BuildCreateVertexTypeParam("Company", v_props, pk_names)); - std::vector> e_props = { - {"years", execution::Value::INT32(0)}, - {"position", execution::Value::STRING(std::string("string"))}}; + std::vector> e_props = { + {"years", columnar::Value::INT32(0)}, + {"position", columnar::Value::STRING(std::string("string"))}}; auto status = graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props)); ASSERT_TRUE(status.ok()); @@ -306,8 +306,8 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test DeleteEdgePropertiesSoft TEST_F(PropertyGraphLogicalDeleteTest, DeleteEdgePropertiesLogical_MarksPropertiesDeleted) { - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( @@ -315,9 +315,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, graph_.CreateVertexType( BuildCreateVertexTypeParam("Company", v_props, pk_names)); - std::vector> e_props = { - {"years", execution::Value::INT32(0)}, - {"position", execution::Value::STRING(std::string("string"))}}; + std::vector> e_props = { + {"years", columnar::Value::INT32(0)}, + {"position", columnar::Value::STRING(std::string("string"))}}; graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props)); @@ -338,11 +338,11 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test corner case: Multiple logical deletes TEST_F(PropertyGraphLogicalDeleteTest, MultipleLogicalDeletes_WorksCorrectly) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}, - {"age", execution::Value::INT32(0)}, - {"email", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}, + {"age", columnar::Value::INT32(0)}, + {"email", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( @@ -362,9 +362,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, MultipleLogicalDeletes_WorksCorrectly) { // Test corner case: Cannot delete primary key property TEST_F(PropertyGraphLogicalDeleteTest, DeletePrimaryKeyProperty_ShouldFail) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( @@ -381,10 +381,10 @@ TEST_F(PropertyGraphLogicalDeleteTest, DeletePrimaryKeyProperty_ShouldFail) { // Test physical delete of properties after logical delete TEST_F(PropertyGraphLogicalDeleteTest, PhysicalDeletePropertiesAfterLogicalDelete_Succeeds) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}, - {"age", execution::Value::INT32(0)}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}, + {"age", columnar::Value::INT32(0)}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", properties, pk_names)); @@ -404,16 +404,16 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test physical delete of edge properties after logical delete TEST_F(PropertyGraphLogicalDeleteTest, PhysicalDeleteEdgePropertiesAfterLogicalDelete_Succeeds) { - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", v_props, pk_names)); graph_.CreateVertexType( BuildCreateVertexTypeParam("Company", v_props, pk_names)); - std::vector> e_props = { - {"years", execution::Value::INT32(0)}, - {"position", execution::Value::STRING(std::string("string"))}}; + std::vector> e_props = { + {"years", columnar::Value::INT32(0)}, + {"position", columnar::Value::STRING(std::string("string"))}}; graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props)); label_t src_label = graph_.schema().get_vertex_label_id("Person"); @@ -437,9 +437,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, // contains the Delete label and properties. TEST_F(PropertyGraphLogicalDeleteTest, StatisticsAfterLogicalDelete_DoesNotContainDeletedInfo) { - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}, - {"Name", execution::Value::STRING(std::string("string"))}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}, + {"Name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", v_props, pk_names)); @@ -447,12 +447,12 @@ TEST_F(PropertyGraphLogicalDeleteTest, BuildCreateVertexTypeParam("Company", v_props, pk_names)); graph_.CreateVertexType( BuildCreateVertexTypeParam("Location", v_props, pk_names)); - std::vector> e_props_workat = { - {"years", execution::Value::INT32(0)}, - {"position", execution::Value::STRING(std::string("string"))}}; - std::vector> e_props_locatedat = { - {"since", execution::Value::INT32(0)}, - {"city", execution::Value::STRING(std::string("string"))}}; + std::vector> e_props_workat = { + {"years", columnar::Value::INT32(0)}, + {"position", columnar::Value::STRING(std::string("string"))}}; + std::vector> e_props_locatedat = { + {"since", columnar::Value::INT32(0)}, + {"city", columnar::Value::STRING(std::string("string"))}}; graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props_workat)); graph_.CreateEdgeType(BuildCreateEdgeTypeParam( @@ -492,9 +492,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, // Test deleting primary key: should raise an error TEST_F(PropertyGraphLogicalDeleteTest, DeletePrimaryKeyProperty_ShouldRaiseError) { - std::vector> properties = { - {"id", execution::Value::INT64(0L)}, - {"name", execution::Value::STRING(std::string("string"))}}; + std::vector> properties = { + {"id", columnar::Value::INT64(0L)}, + {"name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; auto status = graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", properties, pk_names)); @@ -508,9 +508,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, TEST_F(PropertyGraphLogicalDeleteTest, TestStatistics) { // Insert vertex types and edge types to an empty schema, and check // whether the statistics are correct. - std::vector> v_props = { - {"id", execution::Value::INT64(0L)}, - {"Name", execution::Value::STRING(std::string("string"))}}; + std::vector> v_props = { + {"id", columnar::Value::INT64(0L)}, + {"Name", columnar::Value::STRING(std::string("string"))}}; std::vector pk_names = {"id"}; graph_.CreateVertexType( BuildCreateVertexTypeParam("Person", v_props, pk_names)); @@ -518,9 +518,9 @@ TEST_F(PropertyGraphLogicalDeleteTest, TestStatistics) { BuildCreateVertexTypeParam("Company", v_props, pk_names)); graph_.CreateVertexType( BuildCreateVertexTypeParam("Location", v_props, pk_names)); - std::vector> e_props = { - {"years", execution::Value::INT32(0)}, - {"position", execution::Value::STRING(std::string("string"))}}; + std::vector> e_props = { + {"years", columnar::Value::INT32(0)}, + {"position", columnar::Value::STRING(std::string("string"))}}; graph_.CreateEdgeType( BuildCreateEdgeTypeParam("Person", "Company", "WorksAt", e_props)); graph_.CreateEdgeType( diff --git a/tests/unittest/schema_test.cc b/tests/unittest/schema_test.cc index e6dc56082..f2934beeb 100644 --- a/tests/unittest/schema_test.cc +++ b/tests/unittest/schema_test.cc @@ -23,7 +23,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/graph/schema.h" #include "neug/utils/property/types.h" @@ -80,7 +80,7 @@ TEST(SchemaTest, AddVertexLabel_AddRenameDeleteVertexProperties_Physical) { // 2) Add vertex properties std::vector add_names = {"age", "score"}; std::vector add_types = {DataTypeId::kInt32, DataTypeId::kDouble}; - std::vector add_defaults; // not used currently + std::vector add_defaults; // not used currently schema.AddVertexProperties("Person", add_names, add_types, add_defaults); ASSERT_EQ(schema.get_vertex_properties("Person").size(), 3); @@ -159,7 +159,7 @@ TEST(SchemaTest, AddEdgeLabel_AddRenameDeleteEdgeProperties_Physical) { std::vector add_e_names = {"role", "salary"}; std::vector add_e_types = {DataTypeId::kVarchar, DataTypeId::kInt64}; - std::vector dummy_defaults; + std::vector dummy_defaults; schema.AddEdgeProperties("Person", "Company", "WorksAt", add_e_names, add_e_types, dummy_defaults); auto names_after_add = diff --git a/tests/unittest/test_connection.cc b/tests/unittest/test_connection.cc index 026d8835a..f5109cd5a 100644 --- a/tests/unittest/test_connection.cc +++ b/tests/unittest/test_connection.cc @@ -205,8 +205,8 @@ TEST_F(ConnectionTest, TestParameterizedQuery) { auto res = conn->Query( "MATCH (n:PERSON {id: $person_id}) SET n.id2 = n.id2 + $increment;", "update", - {{"person_id", execution::Value::INT64(1)}, - {"increment", execution::Value::INT64(5)}}); + {{"person_id", columnar::Value::INT64(1)}, + {"increment", columnar::Value::INT64(5)}}); EXPECT_TRUE(res); LOG(INFO) << res.value().ToString(); } diff --git a/tests/unittest/test_indexer.cc b/tests/unittest/test_indexer.cc index dd38aa9ff..017b9d388 100644 --- a/tests/unittest/test_indexer.cc +++ b/tests/unittest/test_indexer.cc @@ -23,8 +23,8 @@ #include #include +#include "neug/columnar/value.h" #include "neug/common/extra_type_info.h" -#include "neug/execution/common/types/value.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/container/file_header.h" #include "neug/storages/module/module_factory.h" @@ -62,7 +62,7 @@ class LFIndexerTest : public ::testing::Test { ASSERT_EQ(indexer.size(), values.size()); for (size_t i = 0; i < values.size(); ++i) { INDEX_T lid; - ASSERT_TRUE(indexer.get_index(execution::Value::INT64(values[i]), lid)); + ASSERT_TRUE(indexer.get_index(columnar::Value::INT64(values[i]), lid)); EXPECT_EQ(lid, static_cast(i)); const auto& key = indexer.get_key(static_cast(i)); @@ -79,7 +79,7 @@ class LFIndexerTest : public ::testing::Test { ASSERT_EQ(indexer.size(), values.size()); for (size_t i = 0; i < values.size(); ++i) { INDEX_T lid; - ASSERT_TRUE(indexer.get_index(execution::Value::STRING(values[i]), lid)); + ASSERT_TRUE(indexer.get_index(columnar::Value::STRING(values[i]), lid)); EXPECT_EQ(lid, static_cast(i)); const auto& key = indexer.get_key(static_cast(i)); @@ -109,9 +109,9 @@ TEST_F(LFIndexerTest, SupportsCoreMutableInterfacesInMemory) { EXPECT_GE(indexer.capacity(), 8U); std::vector values = {7, 11, 13, 17, 19, 23, 29, 31, 37, 41}; - EXPECT_EQ(indexer.insert(execution::Value::INT64(values[0]), false), 0U); + EXPECT_EQ(indexer.insert(columnar::Value::INT64(values[0]), false), 0U); for (size_t i = 1; i < values.size(); ++i) { - EXPECT_EQ(indexer.insert(execution::Value::INT64(values[i]), true), + EXPECT_EQ(indexer.insert(columnar::Value::INT64(values[i]), true), static_cast(i)); } @@ -120,12 +120,12 @@ TEST_F(LFIndexerTest, SupportsCoreMutableInterfacesInMemory) { ExpectInt64Values(indexer, values); uint32_t lid = std::numeric_limits::max(); - EXPECT_TRUE(indexer.get_index(execution::Value::INT64(23), lid)); + EXPECT_TRUE(indexer.get_index(columnar::Value::INT64(23), lid)); EXPECT_EQ(lid, 5U); - EXPECT_FALSE(indexer.get_index(execution::Value::INT32(23), lid)); - EXPECT_TRUE(indexer.contains(execution::Value::INT64(37))); - EXPECT_FALSE(indexer.contains(execution::Value::INT64(1001))); - EXPECT_EQ(indexer.get_index(execution::Value::INT64(1001)), + EXPECT_FALSE(indexer.get_index(columnar::Value::INT32(23), lid)); + EXPECT_TRUE(indexer.contains(columnar::Value::INT64(37))); + EXPECT_FALSE(indexer.contains(columnar::Value::INT64(1001))); + EXPECT_EQ(indexer.get_index(columnar::Value::INT64(1001)), std::numeric_limits::max()); indexer.rehash(64); @@ -148,7 +148,7 @@ TEST_F(LFIndexerTest, DumpsAndOpensAcrossBackends) { OpenIndexerLegacy(writable, *ckp, int64_type, CheckpointManifest(), MemoryLevel::kInMemory); for (const auto& value : values) { - writable.insert(execution::Value::INT64(value), true); + writable.insert(columnar::Value::INT64(value), true); } desc = DumpIndexerLegacy(writable, *ckp); } @@ -208,10 +208,10 @@ TEST_F(LFIndexerTest, SupportsBuildEmptySwapAndVarcharKeys) { std::vector lhs_values = {"alice", "bob"}; std::vector rhs_values = {"carol", "dave", "erin"}; for (const auto& value : lhs_values) { - lhs.insert(execution::Value::STRING(value), true); + lhs.insert(columnar::Value::STRING(value), true); } for (const auto& value : rhs_values) { - rhs.insert(execution::Value::STRING(value), true); + rhs.insert(columnar::Value::STRING(value), true); } EXPECT_EQ(lhs.get_type(), DataTypeId::kVarchar); @@ -245,7 +245,7 @@ TEST_F(LFIndexerTest, VarcharReserveEnablesNonSafeInsert) { std::vector values = {"alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta"}; for (const auto& v : values) { - indexer.insert(execution::Value::STRING(v), false); + indexer.insert(columnar::Value::STRING(v), false); } ExpectStringValues(indexer, values); indexer.Close(); @@ -272,7 +272,7 @@ TEST_F(LFIndexerTest, VarcharReserveMaxWidthStrings) { values.push_back(std::string(kMaxWidth - 1, static_cast('a' + i))); } for (const auto& v : values) { - indexer.insert(execution::Value::STRING(v), false); + indexer.insert(columnar::Value::STRING(v), false); } ExpectStringValues(indexer, values); indexer.Close(); @@ -292,14 +292,14 @@ TEST_F(LFIndexerTest, VarcharMultipleReservesAccumulateDataSpace) { indexer.reserve(4); std::vector batch1 = {"alice", "bob", "carol", "dave"}; for (const auto& v : batch1) { - indexer.insert(execution::Value::STRING(v), false); + indexer.insert(columnar::Value::STRING(v), false); } ExpectStringValues(indexer, batch1); indexer.reserve(8); std::vector batch2 = {"erin", "frank", "grace", "heidi"}; for (const auto& v : batch2) { - indexer.insert(execution::Value::STRING(v), false); + indexer.insert(columnar::Value::STRING(v), false); } std::vector all = {"alice", "bob", "carol", "dave", @@ -322,10 +322,10 @@ TEST_F(LFIndexerTest, VarcharReserveSmallerThanCapacityIsNoop) { indexer.reserve(16); EXPECT_GE(indexer.capacity(), 16U); size_t size_before = indexer.size(); - indexer.insert(execution::Value::STRING(std::string("foo")), false); - indexer.insert(execution::Value::STRING(std::string("bar")), false); - indexer.insert(execution::Value::STRING(std::string("baz")), false); - indexer.insert(execution::Value::STRING(std::string("qux")), false); + indexer.insert(columnar::Value::STRING(std::string("foo")), false); + indexer.insert(columnar::Value::STRING(std::string("bar")), false); + indexer.insert(columnar::Value::STRING(std::string("baz")), false); + indexer.insert(columnar::Value::STRING(std::string("qux")), false); indexer.reserve(4); EXPECT_GE(indexer.capacity(), size_before); @@ -346,7 +346,7 @@ TEST_F(LFIndexerTest, VarcharRehashPreservesData) { std::vector values = {"foo", "bar", "baz", "qux", "quux", "corge", "grault"}; for (const auto& v : values) { - indexer.insert(execution::Value::STRING(v), true); + indexer.insert(columnar::Value::STRING(v), true); } ExpectStringValues(indexer, values); @@ -373,7 +373,7 @@ TEST_F(LFIndexerTest, VarcharReserveInsertDumpReload) { std::vector values = {"one", "two", "three", "four", "five"}; for (const auto& v : values) { - writable.insert(execution::Value::STRING(v), false); + writable.insert(columnar::Value::STRING(v), false); } ExpectStringValues(writable, values); @@ -402,7 +402,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenReserveThenInsertLong_InMemory) { OpenIndexerLegacy(writer, *ckp, string_type, CheckpointManifest(), MemoryLevel::kInMemory); for (const auto& v : short_values) { - writer.insert(execution::Value::STRING(v), true); + writer.insert(columnar::Value::STRING(v), true); } dump_desc = DumpIndexerLegacy(writer, *ckp); } @@ -421,7 +421,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenReserveThenInsertLong_InMemory) { long_values.push_back(std::string(60, static_cast('d' + i))); } for (const auto& v : long_values) { - indexer.insert(execution::Value::STRING(v), true); + indexer.insert(columnar::Value::STRING(v), true); } std::vector all = short_values; @@ -447,7 +447,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenInsertSafeLong_InMemory) { MemoryLevel::kInMemory); writer.reserve(short_values.size()); for (const auto& v : short_values) { - writer.insert(execution::Value::STRING(v), false); + writer.insert(columnar::Value::STRING(v), false); } dump_desc = DumpIndexerLegacy(writer, *ckp); writer.Close(); @@ -463,7 +463,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenInsertSafeLong_InMemory) { long_values.push_back(std::string(45, static_cast('A' + i))); } for (const auto& v : long_values) { - indexer.insert(execution::Value::STRING(v), true); + indexer.insert(columnar::Value::STRING(v), true); } std::vector all = short_values; @@ -488,7 +488,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenReserveThenInsertLong_SyncToFile) { OpenIndexerLegacy(writer, *ckp, string_type, CheckpointManifest(), MemoryLevel::kInMemory); for (const auto& v : short_values) { - writer.insert(execution::Value::STRING(v), true); + writer.insert(columnar::Value::STRING(v), true); } dump_desc = DumpIndexerLegacy(writer, *ckp); writer.Close(); @@ -508,7 +508,7 @@ TEST_F(LFIndexerTest, VarcharShortDumpReopenReserveThenInsertLong_SyncToFile) { long_values.push_back(std::string(30, static_cast('p' + i))); } for (const auto& v : long_values) { - indexer.insert(execution::Value::STRING(v), true); + indexer.insert(columnar::Value::STRING(v), true); } std::vector all = short_values; @@ -537,7 +537,7 @@ TEST_F(LFIndexerTest, VarcharStringOverflow) { }; for (const auto& v : valid_strings) { - indexer.insert(execution::Value::STRING(v), false); + indexer.insert(columnar::Value::STRING(v), false); } ExpectStringValues(indexer, valid_strings); indexer.reserve(8); @@ -546,12 +546,12 @@ TEST_F(LFIndexerTest, VarcharStringOverflow) { for (size_t i = 0; i < 2; ++i) { std::string test_string = overflow_string + std::to_string(i); // 31 chars + 1 char = 32 chars - indexer.insert(execution::Value::STRING(test_string), false); + indexer.insert(columnar::Value::STRING(test_string), false); valid_strings.push_back(test_string); } ExpectStringValues(indexer, valid_strings); - EXPECT_THROW(indexer.insert(execution::Value::STRING(overflow_string), false), + EXPECT_THROW(indexer.insert(columnar::Value::STRING(overflow_string), false), neug::exception::StorageException); indexer.Close(); diff --git a/tests/unittest/utils.h b/tests/unittest/utils.h index 8b3e973b0..ac2869103 100644 --- a/tests/unittest/utils.h +++ b/tests/unittest/utils.h @@ -24,8 +24,8 @@ #include #include -#include "neug/execution/common/columns/value_columns.h" -#include "neug/execution/common/data_chunk.h" +#include "neug/columnar/columns/value_columns.h" +#include "neug/columnar/data_chunk.h" #include "neug/main/connection.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/checkpoint_manifest.h" @@ -43,11 +43,11 @@ class GeneratedChunkSupplier : public neug::IDataChunkSupplier { public: explicit GeneratedChunkSupplier( - std::vector>&& chunks) + std::vector>&& chunks) : chunks_(std::move(chunks)) {} ~GeneratedChunkSupplier() override = default; - std::shared_ptr GetNextChunk() override { + std::shared_ptr GetNextChunk() override { if (chunks_.empty()) { return nullptr; } @@ -67,24 +67,24 @@ class GeneratedChunkSupplier : public neug::IDataChunkSupplier { } private: - std::vector> chunks_; + std::vector> chunks_; }; template -std::shared_ptr build_value_column_slice( +std::shared_ptr build_value_column_slice( const std::vector& data, size_t begin, size_t end) { - neug::execution::ValueColumnBuilder builder; + neug::columnar::ValueColumnBuilder builder; for (size_t i = begin; i < end && i < data.size(); ++i) { - builder.push_back_elem(neug::execution::Value::CreateValue(data[i])); + builder.push_back_elem(neug::columnar::Value::CreateValue(data[i])); } return builder.finish(); } template -std::vector> -split_column_to_chunks(const std::vector& data, int num_chunks) { +std::vector> split_column_to_chunks( + const std::vector& data, int num_chunks) { size_t chunk_size = (data.size() + num_chunks - 1) / num_chunks; - std::vector> columns; + std::vector> columns; for (int i = 0; i < num_chunks; ++i) { size_t begin = i * chunk_size; size_t end = std::min(begin + chunk_size, data.size()); @@ -96,10 +96,9 @@ split_column_to_chunks(const std::vector& data, int num_chunks) { return columns; } -inline std::vector> +inline std::vector> convert_to_data_chunks( - const std::vector< - std::vector>>& + const std::vector>>& column_chunks) { if (column_chunks.empty()) { return {}; @@ -118,14 +117,14 @@ convert_to_data_chunks( } } } - std::vector> chunks; + std::vector> chunks; for (size_t i = 0; i < chunk_sizes.size(); ++i) { - neug::execution::DataChunk chunk; + neug::columnar::DataChunk chunk; for (size_t col = 0; col < column_chunks.size(); ++col) { chunk.set(static_cast(col), column_chunks[col][i]); } chunks.push_back( - std::make_shared(std::move(chunk))); + std::make_shared(std::move(chunk))); } return chunks; } diff --git a/tests/utils/json_test.cc b/tests/utils/json_test.cc index 6d34df3e4..71f371318 100644 --- a/tests/utils/json_test.cc +++ b/tests/utils/json_test.cc @@ -20,12 +20,12 @@ #include #include +#include "neug/columnar/columns/value_columns.h" #include "neug/compiler/common/case_insensitive_map.h" -#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/json/json_reader.h" @@ -122,18 +122,19 @@ TEST_F(JsonTest, TestJsonArray) { {createUInt32Type(), createStringType(), createDoubleType()}, {{"batch_read", "false"}}); auto reader = createJsonReader(sharedState); - execution::Context ctx = reader::toContext(reader->read(), *sharedState); + execution::Context ctx = + execution::io::fromChunkSupplier(reader->read(), *sharedState); EXPECT_EQ(ctx.col_num(), 3); EXPECT_EQ(ctx.row_num(), 2); auto col0 = ctx.chunk(0).columns()[0]; - ASSERT_EQ(col0->column_type(), execution::ContextColumnType::kValue); + ASSERT_EQ(col0->column_type(), columnar::ColumnKind::kValue); EXPECT_EQ(col0->get_elem(0).GetValue(), 1u); EXPECT_EQ(col0->get_elem(1).GetValue(), 2u); auto col2 = ctx.chunk(0).columns()[2]; - ASSERT_EQ(col2->column_type(), execution::ContextColumnType::kValue); + ASSERT_EQ(col2->column_type(), columnar::ColumnKind::kValue); EXPECT_DOUBLE_EQ(col2->get_elem(0).GetValue(), 25.0); EXPECT_DOUBLE_EQ(col2->get_elem(1).GetValue(), 30.0); } diff --git a/tests/utils/test_json_io.cc b/tests/utils/test_json_io.cc index 4bc195fb2..a490de783 100644 --- a/tests/utils/test_json_io.cc +++ b/tests/utils/test_json_io.cc @@ -22,13 +22,13 @@ #include #include +#include "neug/columnar/columns/value_columns.h" #include "neug/compiler/common/case_insensitive_map.h" -#include "neug/execution/common/columns/value_columns.h" #include "neug/execution/common/context.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/utils/exception/exception.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/json/json_reader.h" @@ -137,7 +137,7 @@ class JsonIOTest : public ::testing::Test { execution::Context readToContext( const std::shared_ptr& reader, const std::shared_ptr& sharedState) { - return reader::toContext(reader->read(), *sharedState); + return execution::io::fromChunkSupplier(reader->read(), *sharedState); } }; diff --git a/tests/utils/test_reader.cc b/tests/utils/test_reader.cc index 6cac92d36..c34b82d5a 100644 --- a/tests/utils/test_reader.cc +++ b/tests/utils/test_reader.cc @@ -336,12 +336,12 @@ TEST_F(ReaderTest, TestForceColumnTypeConversion) { // Verify the first column (id) is int32 ValueColumn auto column0 = ctx.chunk(0).columns()[0]; - ASSERT_EQ(column0->column_type(), execution::ContextColumnType::kValue); + ASSERT_EQ(column0->column_type(), columnar::ColumnKind::kValue); EXPECT_EQ(column0->elem_type().id(), DataTypeId::kInt32); // Verify the third column (value) is int64 ValueColumn auto column2 = ctx.chunk(0).columns()[2]; - ASSERT_EQ(column2->column_type(), execution::ContextColumnType::kValue); + ASSERT_EQ(column2->column_type(), columnar::ColumnKind::kValue); EXPECT_EQ(column2->elem_type().id(), DataTypeId::kInt64); } diff --git a/tests/utils/test_reader.h b/tests/utils/test_reader.h index c232aabbd..75f663984 100644 --- a/tests/utils/test_reader.h +++ b/tests/utils/test_reader.h @@ -26,13 +26,13 @@ #include #include +#include "neug/columnar/data_chunk.h" #include "neug/compiler/common/case_insensitive_map.h" #include "neug/execution/common/context.h" -#include "neug/execution/common/data_chunk.h" +#include "neug/execution/io/chunk_stream_adapter.h" #include "neug/generated/proto/plan/basic_type.pb.h" #include "neug/generated/proto/plan/expr.pb.h" #include "neug/utils/io/read/common/options.h" -#include "neug/utils/io/read/common/reader_utils.h" #include "neug/utils/io/read/common/schema.h" #include "neug/utils/io/read/common/type_converter.h" #include "neug/utils/io/reader.h" @@ -269,8 +269,8 @@ class ReaderTest : public ::testing::Test { const std::shared_ptr& reader, const std::shared_ptr& sharedState, size_t fallback_column_count = 0) { - return reader::toContext(reader->read(), *sharedState, - fallback_column_count); + return execution::io::fromChunkSupplier(reader->read(), *sharedState, + fallback_column_count); } std::shared_ptr createCsvReader( diff --git a/tests/utils/test_table.cc b/tests/utils/test_table.cc index 0b93ce8b7..1906b98c8 100644 --- a/tests/utils/test_table.cc +++ b/tests/utils/test_table.cc @@ -16,7 +16,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/storages/checkpoint_manager.h" #include "neug/storages/checkpoint_manifest.h" #include "neug/storages/module/module_broker.h" @@ -162,61 +162,59 @@ TEST_F(TableTest, TestTableBasic) { size_t index = 0; for (size_t i = 0; i < 10; i++) { disk_table.get_column("bool_column") - ->set_any(index, execution::Value::BOOLEAN(bool_data[i]), false); + ->set_any(index, columnar::Value::BOOLEAN(bool_data[i]), false); mem_table.get_column("bool_column") - ->set_any(index, execution::Value::BOOLEAN(bool_data[i]), false); + ->set_any(index, columnar::Value::BOOLEAN(bool_data[i]), false); disk_table.get_column("int32_column") - ->set_any(index, execution::Value::INT32(int32_data[i]), false); + ->set_any(index, columnar::Value::INT32(int32_data[i]), false); mem_table.get_column("int32_column") - ->set_any(index, execution::Value::INT32(int32_data[i]), false); + ->set_any(index, columnar::Value::INT32(int32_data[i]), false); disk_table.get_column("uint32_column") - ->set_any(index, execution::Value::UINT32(uint32_data[i]), false); + ->set_any(index, columnar::Value::UINT32(uint32_data[i]), false); mem_table.get_column("uint32_column") - ->set_any(index, execution::Value::UINT32(uint32_data[i]), false); + ->set_any(index, columnar::Value::UINT32(uint32_data[i]), false); disk_table.get_column("int64_column") - ->set_any(index, execution::Value::INT64(int64_data[i]), false); + ->set_any(index, columnar::Value::INT64(int64_data[i]), false); mem_table.get_column("int64_column") - ->set_any(index, execution::Value::INT64(int64_data[i]), false); + ->set_any(index, columnar::Value::INT64(int64_data[i]), false); disk_table.get_column("uint64_column") - ->set_any(index, execution::Value::UINT64(uint64_data[i]), false); + ->set_any(index, columnar::Value::UINT64(uint64_data[i]), false); mem_table.get_column("uint64_column") - ->set_any(index, execution::Value::UINT64(uint64_data[i]), false); + ->set_any(index, columnar::Value::UINT64(uint64_data[i]), false); disk_table.get_column("float_column") - ->set_any(index, execution::Value::FLOAT(float_data[i]), false); + ->set_any(index, columnar::Value::FLOAT(float_data[i]), false); mem_table.get_column("float_column") - ->set_any(index, execution::Value::FLOAT(float_data[i]), false); + ->set_any(index, columnar::Value::FLOAT(float_data[i]), false); disk_table.get_column("double_column") - ->set_any(index, execution::Value::DOUBLE(double_data[i]), false); + ->set_any(index, columnar::Value::DOUBLE(double_data[i]), false); mem_table.get_column("double_column") - ->set_any(index, execution::Value::DOUBLE(double_data[i]), false); + ->set_any(index, columnar::Value::DOUBLE(double_data[i]), false); disk_table.get_column("date_column") - ->set_any(index, execution::Value::DATE(date_data[i]), false); + ->set_any(index, columnar::Value::DATE(date_data[i]), false); mem_table.get_column("date_column") - ->set_any(index, execution::Value::DATE(date_data[i]), false); + ->set_any(index, columnar::Value::DATE(date_data[i]), false); disk_table.get_column("datetime_column") - ->set_any(index, execution::Value::TIMESTAMPMS(datetime_data[i]), - false); + ->set_any(index, columnar::Value::TIMESTAMPMS(datetime_data[i]), false); mem_table.get_column("datetime_column") - ->set_any(index, execution::Value::TIMESTAMPMS(datetime_data[i]), - false); + ->set_any(index, columnar::Value::TIMESTAMPMS(datetime_data[i]), false); disk_table.get_column("interval_column") - ->set_any(index, execution::Value::INTERVAL(interval_data[i]), false); + ->set_any(index, columnar::Value::INTERVAL(interval_data[i]), false); mem_table.get_column("interval_column") - ->set_any(index, execution::Value::INTERVAL(interval_data[i]), false); + ->set_any(index, columnar::Value::INTERVAL(interval_data[i]), false); disk_table.get_column("string_column") - ->set_any(index, execution::Value::STRING(string_data[i]), true); + ->set_any(index, columnar::Value::STRING(string_data[i]), true); mem_table.get_column("string_column") - ->set_any(index, execution::Value::STRING(string_data[i]), true); + ->set_any(index, columnar::Value::STRING(string_data[i]), true); index++; } @@ -399,8 +397,8 @@ TEST_F(TableTest, StringColumnDistinguishesUnsetFromEmptyString) { Table table(col_name, property_types); OpenTableLegacy(table, *ckp, CheckpointManifest(), MemoryLevel::kInMemory, property_types); - table.resize(2, std::vector{ - execution::Value::STRING(std::string("default_value"))}); + table.resize(2, std::vector{ + columnar::Value::STRING(std::string("default_value"))}); auto string_column = dynamic_cast(table.get_column("string_column")); @@ -408,11 +406,11 @@ TEST_F(TableTest, StringColumnDistinguishesUnsetFromEmptyString) { EXPECT_EQ(string_column->get_any(0).GetValue(), "default_value"); - string_column->set_any(1, execution::Value::STRING(std::string("")), true); + string_column->set_any(1, columnar::Value::STRING(std::string("")), true); EXPECT_TRUE(string_column->get_any(1).GetValue().empty()); EXPECT_EQ(string_column->get_any(1).type().id(), DataTypeId::kVarchar); string_column->set_any( - 1, execution::Value::STRING(std::string("new value new value new value")), + 1, columnar::Value::STRING(std::string("new value new value new value")), true); EXPECT_EQ(string_column->get_any(1).GetValue(), "new value new value new value"); diff --git a/tests/utils/test_types.cc b/tests/utils/test_types.cc index 6cfb2d88c..0c70076fc 100644 --- a/tests/utils/test_types.cc +++ b/tests/utils/test_types.cc @@ -15,7 +15,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/property/column.h" #include "neug/utils/property/table.h" #include "neug/utils/serialization/in_archive.h" @@ -249,37 +249,37 @@ class ValueTest : public ::testing::Test { }; TEST_F(ValueTest, DefaultConstructor) { - execution::Value v; + columnar::Value v; EXPECT_TRUE(v.IsNull()); } TEST_F(ValueTest, BoolValue) { - auto v1 = execution::Value::BOOLEAN(true); + auto v1 = columnar::Value::BOOLEAN(true); EXPECT_EQ(v1.type().id(), DataTypeId::kBoolean); EXPECT_TRUE(v1.GetValue()); - auto v2 = execution::Value::BOOLEAN(false); + auto v2 = columnar::Value::BOOLEAN(false); EXPECT_FALSE(v2.GetValue()); } TEST_F(ValueTest, IntegerValues) { { - auto v = execution::Value::INT32(42); + auto v = columnar::Value::INT32(42); EXPECT_EQ(v.type().id(), DataTypeId::kInt32); EXPECT_EQ(v.GetValue(), 42); } { - auto v = execution::Value::UINT32(100U); + auto v = columnar::Value::UINT32(100U); EXPECT_EQ(v.type().id(), DataTypeId::kUInt32); EXPECT_EQ(v.GetValue(), 100U); } { - auto v = execution::Value::INT64(-1234567890123LL); + auto v = columnar::Value::INT64(-1234567890123LL); EXPECT_EQ(v.type().id(), DataTypeId::kInt64); EXPECT_EQ(v.GetValue(), -1234567890123LL); } { - auto v = execution::Value::UINT64(9876543210ULL); + auto v = columnar::Value::UINT64(9876543210ULL); EXPECT_EQ(v.type().id(), DataTypeId::kUInt64); EXPECT_EQ(v.GetValue(), 9876543210ULL); } @@ -287,12 +287,12 @@ TEST_F(ValueTest, IntegerValues) { TEST_F(ValueTest, FloatValues) { { - auto v = execution::Value::FLOAT(3.14f); + auto v = columnar::Value::FLOAT(3.14f); EXPECT_EQ(v.type().id(), DataTypeId::kFloat); EXPECT_FLOAT_EQ(v.GetValue(), 3.14f); } { - auto v = execution::Value::DOUBLE(2.718281828); + auto v = columnar::Value::DOUBLE(2.718281828); EXPECT_EQ(v.type().id(), DataTypeId::kDouble); EXPECT_DOUBLE_EQ(v.GetValue(), 2.718281828); } @@ -300,14 +300,14 @@ TEST_F(ValueTest, FloatValues) { TEST_F(ValueTest, StringValue) { std::string str = "hello world"; - auto v = execution::Value::STRING(str); + auto v = columnar::Value::STRING(str); EXPECT_EQ(v.type().id(), DataTypeId::kVarchar); EXPECT_EQ(v.GetValue(), str); } TEST_F(ValueTest, TemplateConstructor) { - auto v1 = execution::Value::INT32(100); - auto v2 = execution::Value::INT32(100); + auto v1 = columnar::Value::INT32(100); + auto v2 = columnar::Value::INT32(100); EXPECT_EQ(v1.type().id(), v2.type().id()); EXPECT_EQ(v1.GetValue(), v2.GetValue()); @@ -315,18 +315,18 @@ TEST_F(ValueTest, TemplateConstructor) { TEST_F(ValueTest, GetStringValueUnified) { { - auto v = execution::Value::STRING(std::string("hello")); + auto v = columnar::Value::STRING(std::string("hello")); EXPECT_EQ(v.GetValue(), "hello"); } { - auto v = execution::Value::STRING(std::string("world")); + auto v = columnar::Value::STRING(std::string("world")); EXPECT_EQ(v.GetValue(), "world"); } } TEST_F(ValueTest, LessThan) { - auto v1 = execution::Value::INT32(10); - auto v2 = execution::Value::INT32(20); + auto v1 = columnar::Value::INT32(10); + auto v2 = columnar::Value::INT32(20); EXPECT_TRUE(v1 < v2); EXPECT_FALSE(v2 < v1); } @@ -334,17 +334,17 @@ TEST_F(ValueTest, LessThan) { TEST_F(ValueTest, DateAndTimeValues) { Date d; d.from_u32(33189664); - auto v_date = execution::Value::DATE(d); + auto v_date = columnar::Value::DATE(d); EXPECT_EQ(v_date.type().id(), DataTypeId::kDate); EXPECT_EQ(v_date.GetValue().to_u32(), 33189664U); - auto v_dt = execution::Value::TIMESTAMPMS(DateTime(int64_t{1763365457000})); + auto v_dt = columnar::Value::TIMESTAMPMS(DateTime(int64_t{1763365457000})); EXPECT_EQ(v_dt.type().id(), DataTypeId::kTimestampMs); EXPECT_EQ(v_dt.GetValue().to_string(), "2025-11-17 07:44:17.000"); Interval iv( std::string("4years3months2days20hours3minutes12seconds200milliseconds")); - auto v_iv = execution::Value::INTERVAL(iv); + auto v_iv = columnar::Value::INTERVAL(iv); EXPECT_EQ(v_iv.type().id(), DataTypeId::kInterval); EXPECT_EQ( v_iv.GetValue().to_string(), @@ -352,19 +352,19 @@ TEST_F(ValueTest, DateAndTimeValues) { } TEST_F(ValueTest, AssignmentOperator) { - auto v1 = execution::Value::INT32(42); + auto v1 = columnar::Value::INT32(42); auto v2 = v1; EXPECT_TRUE(v1 == v2); } TEST_F(ValueTest, EqualityOperator) { - auto v1 = execution::Value::INT32(42); - auto v2 = execution::Value::INT32(42); - auto v3 = execution::Value::INT32(43); - auto v4 = execution::Value::STRING(std::string("same")); - auto v5 = execution::Value::STRING(std::string("same")); - auto v6 = execution::Value::STRING(std::string("diff")); + auto v1 = columnar::Value::INT32(42); + auto v2 = columnar::Value::INT32(42); + auto v3 = columnar::Value::INT32(43); + auto v4 = columnar::Value::STRING(std::string("same")); + auto v5 = columnar::Value::STRING(std::string("same")); + auto v6 = columnar::Value::STRING(std::string("diff")); EXPECT_TRUE(v1 == v2); EXPECT_FALSE(v1 == v3); diff --git a/tests/utils/test_utils.cc b/tests/utils/test_utils.cc index 65dd85712..55e8002e7 100644 --- a/tests/utils/test_utils.cc +++ b/tests/utils/test_utils.cc @@ -18,7 +18,7 @@ #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/utils/bitset.h" #include "neug/utils/datetime_parsers.h" #include "neug/utils/encoder.h" diff --git a/tools/nodejs_bind/src/node_connection.h b/tools/nodejs_bind/src/node_connection.h index 1618f2adb..bedf81418 100644 --- a/tools/nodejs_bind/src/node_connection.h +++ b/tools/nodejs_bind/src/node_connection.h @@ -21,7 +21,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/connection.h" #include "neug/main/neug_db.h" #include "node_query_result.h" diff --git a/tools/nodejs_bind/src/node_query_request.cc b/tools/nodejs_bind/src/node_query_request.cc index b21cedfac..2b46f68fe 100644 --- a/tools/nodejs_bind/src/node_query_request.cc +++ b/tools/nodejs_bind/src/node_query_request.cc @@ -18,7 +18,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/query_request.h" #include "neug/utils/access_mode.h" #include "neug/utils/exception/exception.h" diff --git a/tools/python_bind/src/py_connection.h b/tools/python_bind/src/py_connection.h index 47856656b..631e117d4 100644 --- a/tools/python_bind/src/py_connection.h +++ b/tools/python_bind/src/py_connection.h @@ -19,7 +19,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/connection.h" #include "neug/main/neug_db.h" #include "py_query_result.h" diff --git a/tools/python_bind/src/py_query_request.cc b/tools/python_bind/src/py_query_request.cc index a4f3413f8..d7f761687 100644 --- a/tools/python_bind/src/py_query_request.cc +++ b/tools/python_bind/src/py_query_request.cc @@ -17,7 +17,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "neug/main/query_request.h" #include "neug/utils/access_mode.h" #include "neug/utils/exception/exception.h" diff --git a/tools/python_bind/src/py_query_request.h b/tools/python_bind/src/py_query_request.h index 95c385d7f..39e6f17dd 100644 --- a/tools/python_bind/src/py_query_request.h +++ b/tools/python_bind/src/py_query_request.h @@ -17,7 +17,7 @@ #include #include -#include "neug/execution/common/types/value.h" +#include "neug/columnar/value.h" #include "pybind11/include/pybind11/pybind11.h" namespace neug {