diff --git a/internal/core/src/common/QueryResult.h b/internal/core/src/common/QueryResult.h index f07b3d2c1d..ceb8074324 100644 --- a/internal/core/src/common/QueryResult.h +++ b/internal/core/src/common/QueryResult.h @@ -26,9 +26,8 @@ #include #include +#include "common/FieldMeta.h" #include "pb/schema.pb.h" -#include "utils/Types.h" -#include "FieldMeta.h" namespace milvus { struct SearchResult { diff --git a/internal/core/src/common/Types.cpp b/internal/core/src/common/Types.cpp index 26fe01cd54..02db2032b3 100644 --- a/internal/core/src/common/Types.cpp +++ b/internal/core/src/common/Types.cpp @@ -58,7 +58,7 @@ MetricTypeToName(MetricType metric_type) { bool IsPrimaryKeyDataType(DataType data_type) { - return data_type == engine::DataType::INT64 || data_type == DataType::VARCHAR; + return data_type == DataType::INT64 || data_type == DataType::VARCHAR; } } // namespace milvus diff --git a/internal/core/src/common/Types.h b/internal/core/src/common/Types.h index e06b71b7d6..84f16e07bd 100644 --- a/internal/core/src/common/Types.h +++ b/internal/core/src/common/Types.h @@ -30,16 +30,35 @@ #include "knowhere/common/MetricType.h" #include "pb/schema.pb.h" #include "pb/segcore.pb.h" -#include "utils/Types.h" namespace milvus { +using idx_t = int64_t; +using offset_t = int32_t; +using date_t = int32_t; +using distance_t = float; + +enum class DataType { + NONE = 0, + BOOL = 1, + INT8 = 2, + INT16 = 3, + INT32 = 4, + INT64 = 5, + + FLOAT = 10, + DOUBLE = 11, + + STRING = 20, + VARCHAR = 21, + + VECTOR_BINARY = 100, + VECTOR_FLOAT = 101, +}; + using Timestamp = uint64_t; // TODO: use TiKV-like timestamp constexpr auto MAX_TIMESTAMP = std::numeric_limits::max(); - -using engine::DataType; -using engine::idx_t; -constexpr auto MAX_ROW_COUNT = std::numeric_limits::max(); +constexpr auto MAX_ROW_COUNT = std::numeric_limits::max(); using ScalarArray = proto::schema::ScalarField; using DataArray = proto::schema::FieldData; diff --git a/internal/core/src/index/IndexFactory.h b/internal/core/src/index/IndexFactory.h index 57b6571070..9487498176 100644 --- a/internal/core/src/index/IndexFactory.h +++ b/internal/core/src/index/IndexFactory.h @@ -11,12 +11,12 @@ #pragma once -#include -#include "index/Index.h" +#include + #include "common/type_c.h" +#include "index/Index.h" #include "index/ScalarIndex.h" #include "index/StringIndex.h" -#include namespace milvus::scalar { diff --git a/internal/core/src/segcore/SegmentInterface.cpp b/internal/core/src/segcore/SegmentInterface.cpp index f1c0780f1d..cdb9002d47 100644 --- a/internal/core/src/segcore/SegmentInterface.cpp +++ b/internal/core/src/segcore/SegmentInterface.cpp @@ -30,7 +30,7 @@ SegmentInternalInterface::FillPrimaryKeys(const query::Plan* plan, SearchResult& AssertInfo(IsPrimaryKeyDataType(get_schema()[pk_field_id].get_data_type()), "Primary key field is not INT64 or VARCHAR type"); auto field_data = bulk_subscript(pk_field_id, results.seg_offsets_.data(), size); - results.pk_type_ = engine::DataType(field_data->type()); + results.pk_type_ = DataType(field_data->type()); std::vector pks(size); ParsePksFromFieldData(pks, *field_data.get()); diff --git a/internal/core/src/segcore/SegmentSealedImpl.cpp b/internal/core/src/segcore/SegmentSealedImpl.cpp index 670c356068..cf2df789c8 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.cpp +++ b/internal/core/src/segcore/SegmentSealedImpl.cpp @@ -165,7 +165,7 @@ SegmentSealedImpl::LoadFieldData(const LoadFieldDataInfo& info) { // prepare data auto& field_meta = schema_->operator[](field_id); auto data_type = field_meta.get_data_type(); - AssertInfo(data_type == engine::DataType(info.field_data->type()), + AssertInfo(data_type == DataType(info.field_data->type()), "field type of load data is inconsistent with the schema"); auto field_data = insert_record_.get_field_data_base(field_id); AssertInfo(field_data->empty(), "already exists"); diff --git a/internal/core/src/utils/Types.h b/internal/core/src/utils/Types.h deleted file mode 100644 index 1808337be1..0000000000 --- a/internal/core/src/utils/Types.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// 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 -#include -#include -#include -#include -#include - -namespace milvus::engine { - -using idx_t = int64_t; -using offset_t = int32_t; -using date_t = int32_t; -using distance_t = float; - -using IDNumbers = std::vector; - -enum class DataType { - NONE = 0, - BOOL = 1, - INT8 = 2, - INT16 = 3, - INT32 = 4, - INT64 = 5, - - FLOAT = 10, - DOUBLE = 11, - - STRING = 20, - VARCHAR = 21, - - VECTOR_BINARY = 100, - VECTOR_FLOAT = 101, -}; - -} // namespace milvus::engine diff --git a/internal/core/unittest/test_c_api.cpp b/internal/core/unittest/test_c_api.cpp index 242532335e..a106ca9c73 100644 --- a/internal/core/unittest/test_c_api.cpp +++ b/internal/core/unittest/test_c_api.cpp @@ -29,7 +29,6 @@ #include "segcore/reduce_c.h" #include "segcore/Reduce.h" #include "test_utils/DataGen.h" -#include "utils/Types.h" namespace chrono = std::chrono; @@ -2226,7 +2225,7 @@ TEST(CApiTest, SealedSegmentTest) { age = e() % 2000; } auto blob = (void*)(&ages[0]); - FieldMeta field_meta(FieldName("age"), FieldId(101), engine::DataType::INT64); + FieldMeta field_meta(FieldName("age"), FieldId(101), DataType::INT64); auto array = CreateScalarDataArrayFrom(ages.data(), N, field_meta); std::string age_data; auto marshal = google::protobuf::TextFormat::PrintToString(*array.get(), &age_data); @@ -2257,19 +2256,19 @@ TEST(CApiTest, SealedSegment_search_float_Predicate_Range) { auto query_ptr = vec_col.data() + 42000 * DIM; auto counter_col = dataset.get_col(FieldId(101)); - FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), engine::DataType::INT64); + FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), DataType::INT64); auto count_array = CreateScalarDataArrayFrom(counter_col.data(), N, counter_field_meta); std::string counter_data; auto marshal = google::protobuf::TextFormat::PrintToString(*count_array.get(), &counter_data); assert(marshal == true); - FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, engine::DataType::INT64); + FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, DataType::INT64); auto row_ids_array = CreateScalarDataArrayFrom(dataset.row_ids_.data(), N, row_id_field_meta); std::string row_ids_data; marshal = google::protobuf::TextFormat::PrintToString(*row_ids_array.get(), &row_ids_data); assert(marshal == true); - FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, engine::DataType::INT64); + FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, DataType::INT64); auto timestamps_array = CreateScalarDataArrayFrom(dataset.timestamps_.data(), N, timestamp_field_meta); std::string timestamps_data; marshal = google::protobuf::TextFormat::PrintToString(*timestamps_array.get(), ×tamps_data); @@ -2431,19 +2430,19 @@ TEST(CApiTest, SealedSegment_search_without_predicates) { assert(marshal == true); auto counter_col = dataset.get_col(FieldId(101)); - FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), engine::DataType::INT64); + FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), DataType::INT64); auto count_array = CreateScalarDataArrayFrom(counter_col.data(), N, counter_field_meta); std::string counter_data; marshal = google::protobuf::TextFormat::PrintToString(*count_array.get(), &counter_data); assert(marshal == true); - FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, engine::DataType::INT64); + FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, DataType::INT64); auto row_ids_array = CreateScalarDataArrayFrom(dataset.row_ids_.data(), N, row_id_field_meta); std::string row_ids_data; marshal = google::protobuf::TextFormat::PrintToString(*row_ids_array.get(), &row_ids_data); assert(marshal == true); - FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, engine::DataType::INT64); + FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, DataType::INT64); auto timestamps_array = CreateScalarDataArrayFrom(dataset.timestamps_.data(), N, timestamp_field_meta); std::string timestamps_data; marshal = google::protobuf::TextFormat::PrintToString(*timestamps_array.get(), ×tamps_data); @@ -2542,19 +2541,19 @@ TEST(CApiTest, SealedSegment_search_float_With_Expr_Predicate_Range) { auto query_ptr = vec_col.data() + 42000 * DIM; auto counter_col = dataset.get_col(FieldId(101)); - FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), engine::DataType::INT64); + FieldMeta counter_field_meta(FieldName("counter"), FieldId(101), DataType::INT64); auto count_array = CreateScalarDataArrayFrom(counter_col.data(), N, counter_field_meta); std::string counter_data; auto marshal = google::protobuf::TextFormat::PrintToString(*count_array.get(), &counter_data); assert(marshal == true); - FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, engine::DataType::INT64); + FieldMeta row_id_field_meta(FieldName("RowID"), RowFieldID, DataType::INT64); auto row_ids_array = CreateScalarDataArrayFrom(dataset.row_ids_.data(), N, row_id_field_meta); std::string row_ids_data; marshal = google::protobuf::TextFormat::PrintToString(*row_ids_array.get(), &row_ids_data); assert(marshal == true); - FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, engine::DataType::INT64); + FieldMeta timestamp_field_meta(FieldName("Timestamp"), TimestampFieldID, DataType::INT64); auto timestamps_array = CreateScalarDataArrayFrom(dataset.timestamps_.data(), N, timestamp_field_meta); std::string timestamps_data; marshal = google::protobuf::TextFormat::PrintToString(*timestamps_array.get(), ×tamps_data); diff --git a/internal/core/unittest/test_concurrent_vector.cpp b/internal/core/unittest/test_concurrent_vector.cpp index 8ecc7b3826..eea65bd4fa 100644 --- a/internal/core/unittest/test_concurrent_vector.cpp +++ b/internal/core/unittest/test_concurrent_vector.cpp @@ -19,7 +19,6 @@ #include "segcore/SegmentGrowing.h" #include "segcore/AckResponder.h" -using namespace milvus::engine; using namespace milvus::segcore; using std::vector; diff --git a/internal/core/unittest/test_segcore.cpp b/internal/core/unittest/test_segcore.cpp index e55c4c17fe..15be832905 100644 --- a/internal/core/unittest/test_segcore.cpp +++ b/internal/core/unittest/test_segcore.cpp @@ -46,7 +46,6 @@ generate_data(int N) { TEST(SegmentCoreTest, NormalDistributionTest) { using namespace milvus::segcore; - using namespace milvus::engine; auto schema = std::make_shared(); schema->AddDebugField("fakevec", DataType::VECTOR_FLOAT, 16, MetricType::METRIC_L2); schema->AddDebugField("age", DataType::INT32); @@ -60,7 +59,6 @@ TEST(SegmentCoreTest, NormalDistributionTest) { // Test insert column-based data TEST(SegmentCoreTest, MockTest2) { using namespace milvus::segcore; - using namespace milvus::engine; // schema auto schema = std::make_shared(); @@ -77,7 +75,6 @@ TEST(SegmentCoreTest, MockTest2) { TEST(SegmentCoreTest, SmallIndex) { using namespace milvus::segcore; - using namespace milvus::engine; auto schema = std::make_shared(); schema->AddDebugField("fakevec", DataType::VECTOR_FLOAT, 16, MetricType::METRIC_L2); schema->AddDebugField("age", DataType::INT32); diff --git a/internal/core/unittest/test_utils/DataGen.h b/internal/core/unittest/test_utils/DataGen.h index 9922f67ade..bcc434dc18 100644 --- a/internal/core/unittest/test_utils/DataGen.h +++ b/internal/core/unittest/test_utils/DataGen.h @@ -142,7 +142,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) for (auto field_id : schema->get_field_ids()) { auto field_meta = schema->operator[](field_id); switch (field_meta.get_data_type()) { - case engine::DataType::VECTOR_FLOAT: { + case DataType::VECTOR_FLOAT: { auto dim = field_meta.get_dim(); vector final(dim * N); bool is_ip = starts_with(field_meta.get_name().get(), "normalized"); @@ -169,7 +169,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(final, N, field_meta); break; } - case engine::DataType::VECTOR_BINARY: { + case DataType::VECTOR_BINARY: { auto dim = field_meta.get_dim(); Assert(dim % 8 == 0); vector data(dim / 8 * N); @@ -179,7 +179,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::INT64: { + case DataType::INT64: { vector data(N); // begin with counter if (starts_with(field_meta.get_name().get(), "counter")) { @@ -198,7 +198,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::INT32: { + case DataType::INT32: { vector data(N); for (auto& x : data) { x = er() % (2 * N); @@ -206,7 +206,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::INT16: { + case DataType::INT16: { vector data(N); for (auto& x : data) { x = er() % (2 * N); @@ -214,7 +214,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::INT8: { + case DataType::INT8: { vector data(N); for (auto& x : data) { x = er() % (2 * N); @@ -222,7 +222,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::FLOAT: { + case DataType::FLOAT: { vector data(N); for (auto& x : data) { x = distr(er); @@ -230,7 +230,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::DOUBLE: { + case DataType::DOUBLE: { vector data(N); for (auto& x : data) { x = distr(er); @@ -238,7 +238,7 @@ DataGen(SchemaPtr schema, int64_t N, uint64_t seed = 42, uint64_t ts_offset = 0) insert_cols(data, N, field_meta); break; } - case engine::DataType::VARCHAR: { + case DataType::VARCHAR: { vector data(N); for (auto& x : data) { x = std::to_string(er()); @@ -367,7 +367,7 @@ SealedLoader(const GeneratedData& dataset, SegmentSealed& seg) { auto row_count = dataset.row_ids_.size(); { LoadFieldDataInfo info; - FieldMeta field_meta(FieldName("RowID"), RowFieldID, engine::DataType::INT64); + FieldMeta field_meta(FieldName("RowID"), RowFieldID, DataType::INT64); auto array = CreateScalarDataArrayFrom(dataset.row_ids_.data(), row_count, field_meta); info.field_data = array.release(); info.row_count = dataset.row_ids_.size(); @@ -376,7 +376,7 @@ SealedLoader(const GeneratedData& dataset, SegmentSealed& seg) { } { LoadFieldDataInfo info; - FieldMeta field_meta(FieldName("Timestamp"), TimestampFieldID, engine::DataType::INT64); + FieldMeta field_meta(FieldName("Timestamp"), TimestampFieldID, DataType::INT64); auto array = CreateScalarDataArrayFrom(dataset.timestamps_.data(), row_count, field_meta); info.field_data = array.release(); info.row_count = dataset.timestamps_.size(); diff --git a/internal/core/unittest/test_utils/indexbuilder_test_utils.h b/internal/core/unittest/test_utils/indexbuilder_test_utils.h index 23cffc3cdc..bbc98ca316 100644 --- a/internal/core/unittest/test_utils/indexbuilder_test_utils.h +++ b/internal/core/unittest/test_utils/indexbuilder_test_utils.h @@ -244,10 +244,10 @@ GenDataset(int64_t N, const knowhere::MetricType& metric_type, bool is_binary, i auto schema = std::make_shared(); auto faiss_metric_type = knowhere::GetMetricType(metric_type); if (!is_binary) { - schema->AddDebugField("fakevec", milvus::engine::DataType::VECTOR_FLOAT, dim, faiss_metric_type); + schema->AddDebugField("fakevec", milvus::DataType::VECTOR_FLOAT, dim, faiss_metric_type); return milvus::segcore::DataGen(schema, N); } else { - schema->AddDebugField("fakebinvec", milvus::engine::DataType::VECTOR_BINARY, dim, faiss_metric_type); + schema->AddDebugField("fakebinvec", milvus::DataType::VECTOR_BINARY, dim, faiss_metric_type); return milvus::segcore::DataGen(schema, N); } }