From 4b244f9d45d097e4cb2cb568aa5e671f2c3cf3e1 Mon Sep 17 00:00:00 2001 From: groot Date: Mon, 27 May 2019 19:57:09 +0800 Subject: [PATCH 1/3] redefine thrift api Former-commit-id: 8d7d1c47202341521cf06a567e8f7cf3cfc55074 --- cpp/CMakeLists.txt | 1 - cpp/src/CMakeLists.txt | 7 +- cpp/src/sdk/CMakeLists.txt | 35 + cpp/src/sdk/MegaSearch.cpp | 96 - cpp/src/sdk/examples/CMakeLists.txt | 7 + cpp/src/sdk/examples/simple/CMakeLists.txt | 24 + .../sdk/examples/simple}/main.cpp | 51 +- .../sdk/examples/simple/src/ClientTest.cpp | 71 + .../sdk/examples/simple}/src/ClientTest.h | 11 +- cpp/src/sdk/{ => include}/MegaSearch.h | 0 cpp/src/sdk/{ => include}/Status.h | 0 cpp/src/sdk/src/client/ClientProxy.cpp | 337 ++ cpp/src/sdk/src/client/ClientProxy.h | 59 + .../sdk/src/client/ThriftClient.cpp} | 64 +- cpp/src/sdk/src/client/ThriftClient.h | 38 + cpp/src/sdk/src/interface/ConnectionImpl.cpp | 109 + cpp/src/sdk/src/interface/ConnectionImpl.h | 57 + cpp/src/sdk/{ => src/interface}/Status.cpp | 9 +- cpp/src/sdk/src/util/ConvertUtil.cpp | 43 + .../sdk/src/util/ConvertUtil.h} | 13 +- cpp/src/server/MegasearchHandler.cpp | 82 + cpp/src/server/MegasearchHandler.h | 143 + ...eScheduler.cpp => MegasearchScheduler.cpp} | 77 +- ...rviceScheduler.h => MegasearchScheduler.h} | 12 +- ...erviceWrapper.cpp => MegasearchServer.cpp} | 46 +- ...VecServiceWrapper.h => MegasearchServer.h} | 5 +- cpp/src/server/MegasearchTask.cpp | 371 ++ cpp/src/server/MegasearchTask.h | 113 + cpp/src/server/Server.cpp | 6 +- cpp/src/server/VecServiceHandler.cpp | 235 - cpp/src/server/VecServiceHandler.h | 85 - cpp/src/server/VecServiceTask.cpp | 721 --- cpp/src/server/VecServiceTask.h | 190 - cpp/src/thrift/gen-cpp/MegasearchService.cpp | 3810 +++++++++++++ cpp/src/thrift/gen-cpp/MegasearchService.h | 1454 +++++ .../MegasearchService_server.skeleton.cpp | 178 + cpp/src/thrift/gen-cpp/VecService.cpp | 4869 ----------------- cpp/src/thrift/gen-cpp/VecService.h | 1766 ------ .../gen-cpp/VecService_server.skeleton.cpp | 117 - .../thrift/gen-cpp/megasearch_constants.cpp | 6 +- cpp/src/thrift/gen-cpp/megasearch_constants.h | 6 +- cpp/src/thrift/gen-cpp/megasearch_types.cpp | 2163 ++++---- cpp/src/thrift/gen-cpp/megasearch_types.h | 659 +-- cpp/src/thrift/gen-py/py_sample.py | 68 - cpp/src/thrift/megasearch.thrift | 296 +- cpp/test_client/CMakeLists.txt | 62 - cpp/test_client/src/ClientSession.h | 30 - cpp/test_client/src/ClientTest.cpp | 361 -- cpp/test_client/src/FaissTest.cpp | 254 - cpp/test_client/src/Log.h | 26 - 50 files changed, 8632 insertions(+), 10611 deletions(-) create mode 100644 cpp/src/sdk/CMakeLists.txt delete mode 100644 cpp/src/sdk/MegaSearch.cpp create mode 100644 cpp/src/sdk/examples/CMakeLists.txt create mode 100644 cpp/src/sdk/examples/simple/CMakeLists.txt rename cpp/{test_client => src/sdk/examples/simple}/main.cpp (51%) create mode 100644 cpp/src/sdk/examples/simple/src/ClientTest.cpp rename cpp/{test_client => src/sdk/examples/simple}/src/ClientTest.h (80%) rename cpp/src/sdk/{ => include}/MegaSearch.h (100%) rename cpp/src/sdk/{ => include}/Status.h (100%) create mode 100644 cpp/src/sdk/src/client/ClientProxy.cpp create mode 100644 cpp/src/sdk/src/client/ClientProxy.h rename cpp/{test_client/src/ClientSession.cpp => src/sdk/src/client/ThriftClient.cpp} (61%) create mode 100644 cpp/src/sdk/src/client/ThriftClient.h create mode 100644 cpp/src/sdk/src/interface/ConnectionImpl.cpp create mode 100644 cpp/src/sdk/src/interface/ConnectionImpl.h rename cpp/src/sdk/{ => src/interface}/Status.cpp (84%) create mode 100644 cpp/src/sdk/src/util/ConvertUtil.cpp rename cpp/{test_client/src/FaissTest.h => src/sdk/src/util/ConvertUtil.h} (64%) create mode 100644 cpp/src/server/MegasearchHandler.cpp create mode 100644 cpp/src/server/MegasearchHandler.h rename cpp/src/server/{VecServiceScheduler.cpp => MegasearchScheduler.cpp} (54%) rename cpp/src/server/{VecServiceScheduler.h => MegasearchScheduler.h} (88%) rename cpp/src/server/{VecServiceWrapper.cpp => MegasearchServer.cpp} (68%) rename cpp/src/server/{VecServiceWrapper.h => MegasearchServer.h} (91%) create mode 100644 cpp/src/server/MegasearchTask.cpp create mode 100644 cpp/src/server/MegasearchTask.h delete mode 100644 cpp/src/server/VecServiceHandler.cpp delete mode 100644 cpp/src/server/VecServiceHandler.h delete mode 100644 cpp/src/server/VecServiceTask.cpp delete mode 100644 cpp/src/server/VecServiceTask.h create mode 100644 cpp/src/thrift/gen-cpp/MegasearchService.cpp create mode 100644 cpp/src/thrift/gen-cpp/MegasearchService.h create mode 100644 cpp/src/thrift/gen-cpp/MegasearchService_server.skeleton.cpp delete mode 100644 cpp/src/thrift/gen-cpp/VecService.cpp delete mode 100644 cpp/src/thrift/gen-cpp/VecService.h delete mode 100644 cpp/src/thrift/gen-cpp/VecService_server.skeleton.cpp delete mode 100644 cpp/src/thrift/gen-py/py_sample.py delete mode 100644 cpp/test_client/CMakeLists.txt delete mode 100644 cpp/test_client/src/ClientSession.h delete mode 100644 cpp/test_client/src/ClientTest.cpp delete mode 100644 cpp/test_client/src/FaissTest.cpp delete mode 100644 cpp/test_client/src/Log.h diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 6fcb31a257..f640857dd7 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -99,7 +99,6 @@ link_directories(${VECWISE_THIRD_PARTY_BUILD}/lib64) add_subdirectory(src) -add_subdirectory(test_client) if (BUILD_UNIT_TEST) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unittest) diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index a3d9effb46..f7a4c77916 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -22,7 +22,7 @@ set(license_generator_src ) set(service_files - thrift/gen-cpp/VecService.cpp + thrift/gen-cpp/MegasearchService.cpp thrift/gen-cpp/megasearch_constants.cpp thrift/gen-cpp/megasearch_types.cpp ) @@ -39,6 +39,7 @@ set(get_sys_info_src include_directories(/usr/include) include_directories(/usr/local/cuda/include) +include_directories(thrift/gen-cpp) if (GPU_VERSION STREQUAL "ON") link_directories(/usr/local/cuda/lib64) @@ -126,4 +127,6 @@ if (ENABLE_LICENSE STREQUAL "ON") install(TARGETS get_sys_info DESTINATION bin) endif () -install(TARGETS vecwise_server DESTINATION bin) \ No newline at end of file +install(TARGETS vecwise_server DESTINATION bin) + +add_subdirectory(sdk) \ No newline at end of file diff --git a/cpp/src/sdk/CMakeLists.txt b/cpp/src/sdk/CMakeLists.txt new file mode 100644 index 0000000000..600eecb4ad --- /dev/null +++ b/cpp/src/sdk/CMakeLists.txt @@ -0,0 +1,35 @@ +#------------------------------------------------------------------------------- +# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved +# Unauthorized copying of this file, via any medium is strictly prohibited. +# Proprietary and confidential. +#------------------------------------------------------------------------------- + +aux_source_directory(src/interface interface_files) +aux_source_directory(src/client client_files) +aux_source_directory(src/util util_files) + +include_directories(src) +include_directories(include) +include_directories(/usr/include) +include_directories(${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp) + +set(service_files + ${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp/MegasearchService.cpp + ${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp/megasearch_constants.cpp + ${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp/megasearch_types.cpp + ) + +add_library(megasearch_sdk STATIC + ${interface_files} + ${client_files} + ${util_files} + ${service_files} + ) + +link_directories(../../third_party/build/lib) +target_link_libraries(megasearch_sdk + libthrift.a + pthread + ) + +add_subdirectory(examples) diff --git a/cpp/src/sdk/MegaSearch.cpp b/cpp/src/sdk/MegaSearch.cpp deleted file mode 100644 index 66c7dceb15..0000000000 --- a/cpp/src/sdk/MegaSearch.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "MegaSearch.h" - - -namespace megasearch { -std::shared_ptr -Create() { - return nullptr; -} - -Status -Destroy(std::shared_ptr &connection_ptr) { - return Status::OK(); -} - -/** -Status -Connection::Connect(const ConnectParam ¶m) { - return Status::NotSupported("Connect interface is not supported."); -} - -Status -Connection::Connect(const std::string &uri) { - return Status::NotSupported("Connect interface is not supported."); -} - -Status -Connection::Connected() const { - return Status::NotSupported("Connected interface is not supported."); -} - -Status -Connection::Disconnect() { - return Status::NotSupported("Disconnect interface is not supported."); -} - -std::string -Connection::ClientVersion() const { - return std::string("Current Version"); -} - -Status -Connection::CreateTable(const TableSchema ¶m) { - return Status::NotSupported("Create table interface interface is not supported."); -} - -Status -Connection::CreateTablePartition(const CreateTablePartitionParam ¶m) { - return Status::NotSupported("Create table partition interface is not supported."); -} - -Status -Connection::DeleteTablePartition(const DeleteTablePartitionParam ¶m) { - return Status::NotSupported("Delete table partition interface is not supported."); -} - -Status -Connection::DeleteTable(const std::string &table_name) { - return Status::NotSupported("Create table interface is not supported."); -} - -Status -Connection::AddVector(const std::string &table_name, - const std::vector &record_array, - std::vector &id_array) { - return Status::NotSupported("Add vector array interface is not supported."); -} - -Status -Connection::SearchVector(const std::string &table_name, - const std::vector &query_record_array, - std::vector &topk_query_result_array, - int64_t topk) { - return Status::NotSupported("Query vector array interface is not supported."); -} - -Status -Connection::DescribeTable(const std::string &table_name, TableSchema &table_schema) { - return Status::NotSupported("Show table interface is not supported."); -} - -Status -Connection::ShowTables(std::vector &table_array) { - return Status::NotSupported("List table array interface is not supported."); -} - -std::string -Connection::ServerVersion() const { - return std::string("Server version."); -} - -std::string -Connection::ServerStatus() const { - return std::string("Server status"); -} -**/ -} \ No newline at end of file diff --git a/cpp/src/sdk/examples/CMakeLists.txt b/cpp/src/sdk/examples/CMakeLists.txt new file mode 100644 index 0000000000..5a0435f47f --- /dev/null +++ b/cpp/src/sdk/examples/CMakeLists.txt @@ -0,0 +1,7 @@ +#------------------------------------------------------------------------------- +# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved +# Unauthorized copying of this file, via any medium is strictly prohibited. +# Proprietary and confidential. +#------------------------------------------------------------------------------- + +add_subdirectory(simple) diff --git a/cpp/src/sdk/examples/simple/CMakeLists.txt b/cpp/src/sdk/examples/simple/CMakeLists.txt new file mode 100644 index 0000000000..5a249bd609 --- /dev/null +++ b/cpp/src/sdk/examples/simple/CMakeLists.txt @@ -0,0 +1,24 @@ +#------------------------------------------------------------------------------- +# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved +# Unauthorized copying of this file, via any medium is strictly prohibited. +# Proprietary and confidential. +#------------------------------------------------------------------------------- + +aux_source_directory(src src_files) + +include_directories(src) +include_directories(../../megasearch_sdk/include) +include_directories(/usr/include) + +link_directories(${CMAKE_BINARY_DIR}/megasearch_sdk) + +add_executable(sdk_simple + ./main.cpp + ${src_files} + ${service_files} + ) + +target_link_libraries(sdk_simple + megasearch_sdk + pthread + ) diff --git a/cpp/test_client/main.cpp b/cpp/src/sdk/examples/simple/main.cpp similarity index 51% rename from cpp/test_client/main.cpp rename to cpp/src/sdk/examples/simple/main.cpp index 52bc7e3c24..2701f9e660 100644 --- a/cpp/test_client/main.cpp +++ b/cpp/src/sdk/examples/simple/main.cpp @@ -8,16 +8,8 @@ #include #include #include -#include -#include -#include -#include "src/FaissTest.h" -#include "src/Log.h" #include "src/ClientTest.h" -#include "server/ServerConfig.h" - -INITIALIZE_EASYLOGGINGPP void print_help(const std::string &app_name); @@ -26,58 +18,47 @@ int main(int argc, char *argv[]) { printf("Client start...\n"); -// FaissTest::test(); -// return 0; - std::string app_name = basename(argv[0]); static struct option long_options[] = {{"conf_file", optional_argument, 0, 'c'}, {"help", no_argument, 0, 'h'}, {NULL, 0, 0, 0}}; int option_index = 0; - std::string config_filename = "../../conf/server_config.yaml"; + std::string address = "127.0.0.1", port = "33001"; app_name = argv[0]; int value; while ((value = getopt_long(argc, argv, "c:p:dh", long_options, &option_index)) != -1) { switch (value) { - case 'c': { - char *config_filename_ptr = strdup(optarg); - config_filename = config_filename_ptr; - free(config_filename_ptr); + case 'h': { + char *address_ptr = strdup(optarg); + address = address_ptr; + free(address_ptr); + break; + } + case 'p': { + char *port_ptr = strdup(optarg); + address = port_ptr; + free(port_ptr); break; } - case 'h': - print_help(app_name); - return EXIT_SUCCESS; - case '?': - print_help(app_name); - return EXIT_FAILURE; default: - print_help(app_name); break; } } - zilliz::vecwise::server::ServerConfig& config = zilliz::vecwise::server::ServerConfig::GetInstance(); - config.LoadConfigFile(config_filename); + ClientTest test; + test.Test(address, port); - CLIENT_LOG_INFO << "Load config file:" << config_filename; - -#if 1 - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -#else - zilliz::vecwise::client::ClientTest::LoopTest(); + printf("Client stop...\n"); return 0; -#endif } void print_help(const std::string &app_name) { printf("\n Usage: %s [OPTIONS]\n\n", app_name.c_str()); printf(" Options:\n"); - printf(" -h --help Print this help\n"); - printf(" -c --conf_file filename Read configuration from the file\n"); + printf(" -h Megasearch server address\n"); + printf(" -p Megasearch server port\n"); printf("\n"); } \ No newline at end of file diff --git a/cpp/src/sdk/examples/simple/src/ClientTest.cpp b/cpp/src/sdk/examples/simple/src/ClientTest.cpp new file mode 100644 index 0000000000..d6547079c3 --- /dev/null +++ b/cpp/src/sdk/examples/simple/src/ClientTest.cpp @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#include "ClientTest.h" +#include "MegaSearch.h" + +#include + +namespace { + static const std::string TABLE_NAME = "human face"; + static const int64_t TABLE_DIMENSION = 512; + + void PrintTableSchema(const megasearch::TableSchema& tb_schema) { + std::cout << "===========================================" << std::endl; + std::cout << "Table name: " << tb_schema.table_name << std::endl; + std::cout << "Table vectors: " << tb_schema.vector_column_array.size() << std::endl; + std::cout << "Table attributes: " << tb_schema.attribute_column_array.size() << std::endl; + std::cout << "Table partitions: " << tb_schema.partition_column_name_array.size() << std::endl; + std::cout << "===========================================" << std::endl; + } +} + +void +ClientTest::Test(const std::string& address, const std::string& port) { + std::shared_ptr conn = megasearch::Connection::Create(); + megasearch::ConnectParam param = { address, port }; + conn->Connect(param); + + {//create table + megasearch::TableSchema tb_schema; + megasearch::VectorColumn col1; + col1.name = "face"; + col1.dimension = TABLE_DIMENSION; + col1.store_raw_vector = true; + tb_schema.vector_column_array.emplace_back(col1); + + megasearch::Column col2; + col2.name = "age"; + tb_schema.attribute_column_array.emplace_back(col2); + + tb_schema.table_name = TABLE_NAME; + + PrintTableSchema(tb_schema); + megasearch::Status stat = conn->CreateTable(tb_schema); + std::cout << "Create table result: " << stat.ToString() << std::endl; + } + + {//describe table + megasearch::TableSchema tb_schema; + megasearch::Status stat = conn->DescribeTable(TABLE_NAME, tb_schema); + std::cout << "Describe table result: " << stat.ToString() << std::endl; + PrintTableSchema(tb_schema); + } + + {//add vectors + + } + + {//search vectors + + } + + {//delete table + megasearch::Status stat = conn->DeleteTable(TABLE_NAME); + std::cout << "Delete table result: " << stat.ToString() << std::endl; + } + + megasearch::Connection::Destroy(conn); +} \ No newline at end of file diff --git a/cpp/test_client/src/ClientTest.h b/cpp/src/sdk/examples/simple/src/ClientTest.h similarity index 80% rename from cpp/test_client/src/ClientTest.h rename to cpp/src/sdk/examples/simple/src/ClientTest.h index e035ece2c3..effbaf9eb2 100644 --- a/cpp/test_client/src/ClientTest.h +++ b/cpp/src/sdk/examples/simple/src/ClientTest.h @@ -5,16 +5,9 @@ ******************************************************************************/ #pragma once -namespace zilliz { -namespace vecwise { -namespace client { +#include class ClientTest { public: - static void LoopTest(); + void Test(const std::string& address, const std::string& port); }; - - -} -} -} diff --git a/cpp/src/sdk/MegaSearch.h b/cpp/src/sdk/include/MegaSearch.h similarity index 100% rename from cpp/src/sdk/MegaSearch.h rename to cpp/src/sdk/include/MegaSearch.h diff --git a/cpp/src/sdk/Status.h b/cpp/src/sdk/include/Status.h similarity index 100% rename from cpp/src/sdk/Status.h rename to cpp/src/sdk/include/Status.h diff --git a/cpp/src/sdk/src/client/ClientProxy.cpp b/cpp/src/sdk/src/client/ClientProxy.cpp new file mode 100644 index 0000000000..90d55ca1e0 --- /dev/null +++ b/cpp/src/sdk/src/client/ClientProxy.cpp @@ -0,0 +1,337 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#include "ClientProxy.h" +#include "util/ConvertUtil.h" + +namespace megasearch { + +std::shared_ptr& +ClientProxy::ClientPtr() const { + if(client_ptr == nullptr) { + client_ptr = std::make_shared(); + } + return client_ptr; +} + +Status +ClientProxy::Connect(const ConnectParam ¶m) { + Disconnect(); + + int32_t port = atoi(param.port.c_str()); + return ClientPtr()->Connect(param.ip_address, port, "json"); +} + +Status +ClientProxy::Connect(const std::string &uri) { + Disconnect(); + + return Status::NotSupported("Connect interface is not supported."); +} + +Status +ClientProxy::Connected() const { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + std::string info; + ClientPtr()->interface()->Ping(info, ""); + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "connection lost: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::Disconnect() { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + return ClientPtr()->Disconnect(); +} + +std::string +ClientProxy::ClientVersion() const { + return std::string("Current Version"); +} + +Status +ClientProxy::CreateTable(const TableSchema ¶m) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + thrift::TableSchema schema; + schema.__set_table_name(param.table_name); + + std::vector vector_column_array; + for(auto& column : param.vector_column_array) { + thrift::VectorColumn col; + col.__set_dimension(column.dimension); + col.__set_index_type(ConvertUtil::IndexType2Str(column.index_type)); + col.__set_store_raw_vector(column.store_raw_vector); + vector_column_array.emplace_back(col); + } + schema.__set_vector_column_array(vector_column_array); + + std::vector attribute_column_array; + for(auto& column : param.attribute_column_array) { + thrift::Column col; + col.__set_name(col.name); + col.__set_type(col.type); + attribute_column_array.emplace_back(col); + } + schema.__set_attribute_column_array(attribute_column_array); + + schema.__set_partition_column_name_array(param.partition_column_name_array); + + ClientPtr()->interface()->CreateTable(schema); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to create table: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::CreateTablePartition(const CreateTablePartitionParam ¶m) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + thrift::CreateTablePartitionParam partition_param; + partition_param.__set_table_name(param.table_name); + partition_param.__set_partition_name(param.partition_name); + + std::map range_map; + for(auto& pair : param.range_map) { + thrift::Range range; + range.__set_start_value(pair.second.start_value); + range.__set_end_value(pair.second.end_value); + range_map.insert(std::make_pair(pair.first, range)); + } + partition_param.__set_range_map(range_map); + + ClientPtr()->interface()->CreateTablePartition(partition_param); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to create table partition: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::DeleteTablePartition(const DeleteTablePartitionParam ¶m) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + thrift::DeleteTablePartitionParam partition_param; + partition_param.__set_table_name(param.table_name); + partition_param.__set_partition_name_array(param.partition_name_array); + + ClientPtr()->interface()->DeleteTablePartition(partition_param); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to delete table partition: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::DeleteTable(const std::string &table_name) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + ClientPtr()->interface()->DeleteTable(table_name); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to delete table: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::AddVector(const std::string &table_name, + const std::vector &record_array, + std::vector &id_array) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + std::vector thrift_records; + for(auto& record : record_array) { + thrift::RowRecord thrift_record; + thrift_record.__set_attribute_map(record.attribute_map); + + for(auto& pair : record.vector_map) { + size_t dim = pair.second.size(); + std::string& thrift_vector = thrift_record.vector_map[pair.first]; + thrift_vector.resize(dim * sizeof(double)); + double *dbl = (double *) (const_cast(thrift_vector.data())); + for (size_t i = 0; i < dim; i++) { + dbl[i] = (double) (pair.second[i]); + } + } + thrift_records.emplace_back(thrift_record); + } + ClientPtr()->interface()->AddVector(id_array, table_name, thrift_records); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to add vector: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::SearchVector(const std::string &table_name, + const std::vector &query_record_array, + std::vector &topk_query_result_array, + int64_t topk) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + std::vector thrift_records; + for(auto& record : query_record_array) { + thrift::QueryRecord thrift_record; + thrift_record.__set_selected_column_array(record.selected_column_array); + + for(auto& pair : record.vector_map) { + size_t dim = pair.second.size(); + std::string& thrift_vector = thrift_record.vector_map[pair.first]; + thrift_vector.resize(dim * sizeof(double)); + double *dbl = (double *) (const_cast(thrift_vector.data())); + for (size_t i = 0; i < dim; i++) { + dbl[i] = (double) (pair.second[i]); + } + } + thrift_records.emplace_back(thrift_record); + } + + std::vector result_array; + ClientPtr()->interface()->SearchVector(result_array, table_name, thrift_records, topk); + + for(auto& thrift_topk_result : result_array) { + TopKQueryResult result; + + for(auto& thrift_query_result : thrift_topk_result.query_result_arrays) { + QueryResult query_result; + query_result.id = thrift_query_result.id; + query_result.column_map = thrift_query_result.column_map; + query_result.score = thrift_query_result.score; + result.query_result_arrays.emplace_back(query_result); + } + + topk_query_result_array.emplace_back(result); + } + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to create table partition: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::DescribeTable(const std::string &table_name, TableSchema &table_schema) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + thrift::TableSchema thrift_schema; + ClientPtr()->interface()->DescribeTable(thrift_schema, table_name); + + table_schema.table_name = thrift_schema.table_name; + table_schema.partition_column_name_array = thrift_schema.partition_column_name_array; + + for(auto& thrift_col : thrift_schema.attribute_column_array) { + Column col; + col.name = col.name; + col.type = col.type; + table_schema.attribute_column_array.emplace_back(col); + } + + for(auto& thrift_col : thrift_schema.vector_column_array) { + VectorColumn col; + col.store_raw_vector = thrift_col.store_raw_vector; + col.index_type = ConvertUtil::Str2IndexType(thrift_col.index_type); + col.dimension = thrift_col.dimension; + col.name = thrift_col.base.name; + col.type = (ColumnType)thrift_col.base.type; + table_schema.vector_column_array.emplace_back(col); + } + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to describe table: " + std::string(ex.what())); + } + + return Status::OK(); +} + +Status +ClientProxy::ShowTables(std::vector &table_array) { + if(client_ptr == nullptr) { + return Status(StatusCode::UnknownError, "not connected"); + } + + try { + ClientPtr()->interface()->ShowTables(table_array); + + } catch ( std::exception& ex) { + return Status(StatusCode::UnknownError, "failed to show tables: " + std::string(ex.what())); + } + + return Status::OK(); +} + +std::string +ClientProxy::ServerVersion() const { + if(client_ptr == nullptr) { + return ""; + } + + try { + std::string version; + ClientPtr()->interface()->Ping(version, "version"); + return version; + } catch ( std::exception& ex) { + return ""; + } +} + +std::string +ClientProxy::ServerStatus() const { + if(client_ptr == nullptr) { + return "not connected"; + } + + try { + std::string dummy; + ClientPtr()->interface()->Ping(dummy, ""); + return "server alive"; + } catch ( std::exception& ex) { + return "connection lost"; + } +} + +} diff --git a/cpp/src/sdk/src/client/ClientProxy.h b/cpp/src/sdk/src/client/ClientProxy.h new file mode 100644 index 0000000000..d105717534 --- /dev/null +++ b/cpp/src/sdk/src/client/ClientProxy.h @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include "MegaSearch.h" +#include "ThriftClient.h" + +namespace megasearch { + +class ClientProxy : public Connection { +public: + // Implementations of the Connection interface + virtual Status Connect(const ConnectParam ¶m) override; + + virtual Status Connect(const std::string &uri) override; + + virtual Status Connected() const override; + + virtual Status Disconnect() override; + + virtual Status CreateTable(const TableSchema ¶m) override; + + virtual Status DeleteTable(const std::string &table_name) override; + + virtual Status CreateTablePartition(const CreateTablePartitionParam ¶m) override; + + virtual Status DeleteTablePartition(const DeleteTablePartitionParam ¶m) override; + + virtual Status AddVector(const std::string &table_name, + const std::vector &record_array, + std::vector &id_array) override; + + virtual Status SearchVector(const std::string &table_name, + const std::vector &query_record_array, + std::vector &topk_query_result_array, + int64_t topk) override; + + virtual Status DescribeTable(const std::string &table_name, TableSchema &table_schema) override; + + virtual Status ShowTables(std::vector &table_array) override; + + virtual std::string ClientVersion() const override; + + virtual std::string ServerVersion() const override; + + virtual std::string ServerStatus() const override; + +private: + std::shared_ptr& ClientPtr() const; + +private: + mutable std::shared_ptr client_ptr; + +}; + +} diff --git a/cpp/test_client/src/ClientSession.cpp b/cpp/src/sdk/src/client/ThriftClient.cpp similarity index 61% rename from cpp/test_client/src/ClientSession.cpp rename to cpp/src/sdk/src/client/ThriftClient.cpp index dac71d1ff5..d492ee69d4 100644 --- a/cpp/test_client/src/ClientSession.cpp +++ b/cpp/src/sdk/src/client/ThriftClient.cpp @@ -3,11 +3,10 @@ * Unauthorized copying of this file, via any medium is strictly prohibited. * Proprietary and confidential. ******************************************************************************/ -#include "ClientSession.h" -#include "Log.h" +#include "ThriftClient.h" -#include "thrift/gen-cpp/megasearch_types.h" -#include "thrift/gen-cpp/megasearch_constants.h" +#include "megasearch_types.h" +#include "megasearch_constants.h" #include @@ -22,19 +21,31 @@ #include #include -namespace zilliz { -namespace vecwise { -namespace client { - -using namespace megasearch; +namespace megasearch { using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::concurrency; -ClientSession::ClientSession(const std::string &address, int32_t port, const std::string &protocol) -: client_(nullptr) { +ThriftClient::ThriftClient() { + +} + +ThriftClient::~ThriftClient() { + +} + +MegasearchServiceClientPtr +ThriftClient::interface() { + if(client_ == nullptr) { + throw std::exception(); + } + return client_; +} + +Status +ThriftClient::Connect(const std::string& address, int32_t port, const std::string& protocol) { try { stdcxx::shared_ptr socket_ptr(new transport::TSocket(address, port)); stdcxx::shared_ptr transport_ptr(new TBufferedTransport(socket_ptr)); @@ -48,19 +59,21 @@ ClientSession::ClientSession(const std::string &address, int32_t port, const std } else if(protocol == "debug") { protocol_ptr.reset(new TDebugProtocol(transport_ptr)); } else { - CLIENT_LOG_ERROR << "Service protocol: " << protocol << " is not supported currently"; - return; + //CLIENT_LOG_ERROR << "Service protocol: " << protocol << " is not supported currently"; + return Status(StatusCode::Invalid, "unsupported protocol"); } transport_ptr->open(); - client_ = std::make_shared(protocol_ptr); + client_ = std::make_shared(protocol_ptr); } catch ( std::exception& ex) { - CLIENT_LOG_ERROR << "connect encounter exception: " << ex.what(); + //CLIENT_LOG_ERROR << "connect encounter exception: " << ex.what(); + return Status(StatusCode::UnknownError, "failed to connect megasearch server" + std::string(ex.what())); } + return Status::OK(); } - -ClientSession::~ClientSession() { +Status +ThriftClient::Disconnect() { try { if(client_ != nullptr) { auto protocol = client_->getInputProtocol(); @@ -72,17 +85,20 @@ ClientSession::~ClientSession() { } } } catch ( std::exception& ex) { - CLIENT_LOG_ERROR << "disconnect encounter exception: " << ex.what(); + //CLIENT_LOG_ERROR << "disconnect encounter exception: " << ex.what(); + return Status(StatusCode::UnknownError, "failed to disconnect: " + std::string(ex.what())); } + + return Status::OK(); } -VecServiceClientPtr ClientSession::interface() { - if(client_ == nullptr) { - throw std::exception(); - } - return client_; +///////////////////////////////////////////////////////////////////////////////////////////////////////// +ThriftClientSession::ThriftClientSession(const std::string& address, int32_t port, const std::string& protocol) { + Connect(address, port, protocol); } +ThriftClientSession::~ThriftClientSession() { + Disconnect(); } -} + } \ No newline at end of file diff --git a/cpp/src/sdk/src/client/ThriftClient.h b/cpp/src/sdk/src/client/ThriftClient.h new file mode 100644 index 0000000000..ccfca6b47c --- /dev/null +++ b/cpp/src/sdk/src/client/ThriftClient.h @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include "MegasearchService.h" +#include "Status.h" + +#include + +namespace megasearch { + +using MegasearchServiceClientPtr = std::shared_ptr; + +class ThriftClient { +public: + ThriftClient(); + virtual ~ThriftClient(); + + MegasearchServiceClientPtr interface(); + + Status Connect(const std::string& address, int32_t port, const std::string& protocol); + Status Disconnect(); + +private: + MegasearchServiceClientPtr client_; +}; + + +class ThriftClientSession : public ThriftClient { +public: + ThriftClientSession(const std::string& address, int32_t port, const std::string& protocol); + ~ThriftClientSession(); +}; + +} diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.cpp b/cpp/src/sdk/src/interface/ConnectionImpl.cpp new file mode 100644 index 0000000000..26fb5ff209 --- /dev/null +++ b/cpp/src/sdk/src/interface/ConnectionImpl.cpp @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#include "ConnectionImpl.h" + +namespace megasearch { + +std::shared_ptr +Connection::Create() { + return std::shared_ptr(new ConnectionImpl()); +} + +Status +Connection::Destroy(std::shared_ptr connection_ptr) { + if(connection_ptr != nullptr) { + return connection_ptr->Disconnect(); + } + return Status::OK(); +} + +////////////////////////////////////////////////////////////////////////////////////////////// +ConnectionImpl::ConnectionImpl() { + client_proxy = std::make_shared(); +} + +Status +ConnectionImpl::Connect(const ConnectParam ¶m) { + return client_proxy->Connect(param); +} + +Status +ConnectionImpl::Connect(const std::string &uri) { + return client_proxy->Connect(uri); +} + +Status +ConnectionImpl::Connected() const { + return client_proxy->Connected(); +} + +Status +ConnectionImpl::Disconnect() { + return client_proxy->Disconnect(); +} + +std::string +ConnectionImpl::ClientVersion() const { + return client_proxy->ClientVersion(); +} + +Status +ConnectionImpl::CreateTable(const TableSchema ¶m) { + return client_proxy->CreateTable(param); +} + +Status +ConnectionImpl::CreateTablePartition(const CreateTablePartitionParam ¶m) { + return client_proxy->CreateTablePartition(param); +} + +Status +ConnectionImpl::DeleteTablePartition(const DeleteTablePartitionParam ¶m) { + return client_proxy->DeleteTablePartition(param); +} + +Status +ConnectionImpl::DeleteTable(const std::string &table_name) { + return client_proxy->DeleteTable(table_name); +} + +Status +ConnectionImpl::AddVector(const std::string &table_name, + const std::vector &record_array, + std::vector &id_array) { + return client_proxy->AddVector(table_name, record_array, id_array); +} + +Status +ConnectionImpl::SearchVector(const std::string &table_name, + const std::vector &query_record_array, + std::vector &topk_query_result_array, + int64_t topk) { + return client_proxy->SearchVector(table_name, query_record_array, topk_query_result_array, topk); +} + +Status +ConnectionImpl::DescribeTable(const std::string &table_name, TableSchema &table_schema) { + return client_proxy->DescribeTable(table_name, table_schema); +} + +Status +ConnectionImpl::ShowTables(std::vector &table_array) { + return client_proxy->ShowTables(table_array); +} + +std::string +ConnectionImpl::ServerVersion() const { + return client_proxy->ServerVersion(); +} + +std::string +ConnectionImpl::ServerStatus() const { + return client_proxy->ServerStatus(); +} + +} + diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.h b/cpp/src/sdk/src/interface/ConnectionImpl.h new file mode 100644 index 0000000000..624bbebde5 --- /dev/null +++ b/cpp/src/sdk/src/interface/ConnectionImpl.h @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include "MegaSearch.h" +#include "client/ClientProxy.h" + +namespace megasearch { + +class ConnectionImpl : public Connection { +public: + ConnectionImpl(); + + // Implementations of the Connection interface + virtual Status Connect(const ConnectParam ¶m) override; + + virtual Status Connect(const std::string &uri) override; + + virtual Status Connected() const override; + + virtual Status Disconnect() override; + + virtual Status CreateTable(const TableSchema ¶m) override; + + virtual Status DeleteTable(const std::string &table_name) override; + + virtual Status CreateTablePartition(const CreateTablePartitionParam ¶m) override; + + virtual Status DeleteTablePartition(const DeleteTablePartitionParam ¶m) override; + + virtual Status AddVector(const std::string &table_name, + const std::vector &record_array, + std::vector &id_array) override; + + virtual Status SearchVector(const std::string &table_name, + const std::vector &query_record_array, + std::vector &topk_query_result_array, + int64_t topk) override; + + virtual Status DescribeTable(const std::string &table_name, TableSchema &table_schema) override; + + virtual Status ShowTables(std::vector &table_array) override; + + virtual std::string ClientVersion() const override; + + virtual std::string ServerVersion() const override; + + virtual std::string ServerStatus() const override; + +private: + std::shared_ptr client_proxy; +}; + +} diff --git a/cpp/src/sdk/Status.cpp b/cpp/src/sdk/src/interface/Status.cpp similarity index 84% rename from cpp/src/sdk/Status.cpp rename to cpp/src/sdk/src/interface/Status.cpp index 8e82affd2a..58a65133c4 100644 --- a/cpp/src/sdk/Status.cpp +++ b/cpp/src/sdk/src/interface/Status.cpp @@ -1,3 +1,8 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ #include "Status.h" @@ -22,7 +27,7 @@ void Status::MoveFrom(Status &s) { } Status::Status(const Status &s) - : state_((s.state_ == nullptr) ? nullptr : new State(*s.state_)) {} + : state_((s.state_ == nullptr) ? nullptr : new State(*s.state_)) {} Status &Status::operator=(const Status &s) { if (state_ != s.state_) { @@ -112,4 +117,4 @@ std::string Status::ToString() const { return result; } -} \ No newline at end of file +} diff --git a/cpp/src/sdk/src/util/ConvertUtil.cpp b/cpp/src/sdk/src/util/ConvertUtil.cpp new file mode 100644 index 0000000000..90cab3fdb4 --- /dev/null +++ b/cpp/src/sdk/src/util/ConvertUtil.cpp @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#include "ConvertUtil.h" + +#include + +namespace megasearch { + +static const std::string INDEX_RAW = "raw"; +static const std::string INDEX_IVFFLAT = "ivfflat"; + +std::string ConvertUtil::IndexType2Str(megasearch::IndexType index) { + static const std::map s_index2str = { + {megasearch::IndexType::raw, INDEX_RAW}, + {megasearch::IndexType::ivfflat, INDEX_IVFFLAT} + }; + + const auto& iter = s_index2str.find(index); + if(iter == s_index2str.end()) { + return INDEX_RAW; + } + + return iter->second; +} + +megasearch::IndexType ConvertUtil::Str2IndexType(const std::string& type) { + static const std::map s_str2index = { + {INDEX_RAW, megasearch::IndexType::raw}, + {INDEX_IVFFLAT, megasearch::IndexType::ivfflat} + }; + + const auto& iter = s_str2index.find(type); + if(iter == s_str2index.end()) { + return megasearch::IndexType::raw; + } + + return iter->second; +} + +} \ No newline at end of file diff --git a/cpp/test_client/src/FaissTest.h b/cpp/src/sdk/src/util/ConvertUtil.h similarity index 64% rename from cpp/test_client/src/FaissTest.h rename to cpp/src/sdk/src/util/ConvertUtil.h index 3a4e57f04f..7b48ad6f92 100644 --- a/cpp/test_client/src/FaissTest.h +++ b/cpp/src/sdk/src/util/ConvertUtil.h @@ -5,15 +5,14 @@ ******************************************************************************/ #pragma once -namespace zilliz { -namespace vecwise { -namespace client { +#include "MegaSearch.h" -class FaissTest { +namespace megasearch { + +class ConvertUtil { public: - static void test(); + static std::string IndexType2Str(megasearch::IndexType index); + static megasearch::IndexType Str2IndexType(const std::string& type); }; } -} -} diff --git a/cpp/src/server/MegasearchHandler.cpp b/cpp/src/server/MegasearchHandler.cpp new file mode 100644 index 0000000000..54310d72be --- /dev/null +++ b/cpp/src/server/MegasearchHandler.cpp @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ + +#include "MegasearchHandler.h" +#include "MegasearchTask.h" +#include "utils/TimeRecorder.h" + +namespace zilliz { +namespace vecwise { +namespace server { + +using namespace megasearch; + +MegasearchServiceHandler::MegasearchServiceHandler() { + +} + +void +MegasearchServiceHandler::CreateTable(const thrift::TableSchema ¶m) { + BaseTaskPtr task_ptr = CreateTableTask::Create(param); + MegasearchScheduler::ExecTask(task_ptr); +} + +void +MegasearchServiceHandler::DeleteTable(const std::string &table_name) { + BaseTaskPtr task_ptr = DeleteTableTask::Create(table_name); + MegasearchScheduler::ExecTask(task_ptr); +} + +void +MegasearchServiceHandler::CreateTablePartition(const thrift::CreateTablePartitionParam ¶m) { + // Your implementation goes here + printf("CreateTablePartition\n"); +} + +void +MegasearchServiceHandler::DeleteTablePartition(const thrift::DeleteTablePartitionParam ¶m) { + // Your implementation goes here + printf("DeleteTablePartition\n"); +} + +void +MegasearchServiceHandler::AddVector(std::vector &_return, + const std::string &table_name, + const std::vector &record_array) { + BaseTaskPtr task_ptr = AddVectorTask::Create(table_name, record_array, _return); + MegasearchScheduler::ExecTask(task_ptr); +} + +void +MegasearchServiceHandler::SearchVector(std::vector &_return, + const std::string &table_name, + const std::vector &query_record_array, + const int64_t topk) { + BaseTaskPtr task_ptr = SearchVectorTask::Create(table_name, query_record_array, topk, _return); + MegasearchScheduler::ExecTask(task_ptr); +} + +void +MegasearchServiceHandler::DescribeTable(thrift::TableSchema &_return, const std::string &table_name) { + BaseTaskPtr task_ptr = DescribeTableTask::Create(table_name, _return); + MegasearchScheduler::ExecTask(task_ptr); +} + +void +MegasearchServiceHandler::ShowTables(std::vector &_return) { + // Your implementation goes here + printf("ShowTables\n"); +} + +void +MegasearchServiceHandler::Ping(std::string& _return, const std::string& cmd) { + // Your implementation goes here + printf("Ping\n"); +} + +} +} +} diff --git a/cpp/src/server/MegasearchHandler.h b/cpp/src/server/MegasearchHandler.h new file mode 100644 index 0000000000..10d90c14cf --- /dev/null +++ b/cpp/src/server/MegasearchHandler.h @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include +#include + +#include "MegasearchService.h" + +namespace zilliz { +namespace vecwise { +namespace server { + +class MegasearchServiceHandler : virtual public megasearch::thrift::MegasearchServiceIf { +public: + MegasearchServiceHandler(); + + /** + * @brief Create table method + * + * This method is used to create table + * + * @param param, use to provide table information to be created. + * + * + * @param param + */ + void CreateTable(const megasearch::thrift::TableSchema& param); + + /** + * @brief Delete table method + * + * This method is used to delete table. + * + * @param table_name, table name is going to be deleted. + * + * + * @param table_name + */ + void DeleteTable(const std::string& table_name); + + /** + * @brief Create table partition + * + * This method is used to create table partition. + * + * @param param, use to provide partition information to be created. + * + * + * @param param + */ + void CreateTablePartition(const megasearch::thrift::CreateTablePartitionParam& param); + + /** + * @brief Delete table partition + * + * This method is used to delete table partition. + * + * @param param, use to provide partition information to be deleted. + * + * + * @param param + */ + void DeleteTablePartition(const megasearch::thrift::DeleteTablePartitionParam& param); + + /** + * @brief Add vector array to table + * + * This method is used to add vector array to table. + * + * @param table_name, table_name is inserted. + * @param record_array, vector array is inserted. + * + * @return vector id array + * + * @param table_name + * @param record_array + */ + void AddVector(std::vector & _return, + const std::string& table_name, + const std::vector & record_array); + + /** + * @brief Query vector + * + * This method is used to query vector in table. + * + * @param table_name, table_name is queried. + * @param query_record_array, all vector are going to be queried. + * @param topk, how many similarity vectors will be searched. + * + * @return query result array. + * + * @param table_name + * @param query_record_array + * @param topk + */ + void SearchVector(std::vector & _return, + const std::string& table_name, + const std::vector & query_record_array, + const int64_t topk); + + /** + * @brief Show table information + * + * This method is used to show table information. + * + * @param table_name, which table is show. + * + * @return table schema + * + * @param table_name + */ + void DescribeTable(megasearch::thrift::TableSchema& _return, const std::string& table_name); + + /** + * @brief List all tables in database + * + * This method is used to list all tables. + * + * + * @return table names. + */ + void ShowTables(std::vector & _return); + + /** + * @brief Give the server status + * + * This method is used to give the server status. + * + * @return Server status. + * + * @param cmd + */ + void Ping(std::string& _return, const std::string& cmd); +}; + +} +} +} diff --git a/cpp/src/server/VecServiceScheduler.cpp b/cpp/src/server/MegasearchScheduler.cpp similarity index 54% rename from cpp/src/server/VecServiceScheduler.cpp rename to cpp/src/server/MegasearchScheduler.cpp index 5d6906838e..c0a34b5432 100644 --- a/cpp/src/server/VecServiceScheduler.cpp +++ b/cpp/src/server/MegasearchScheduler.cpp @@ -3,12 +3,51 @@ * Unauthorized copying of this file, via any medium is strictly prohibited. * Proprietary and confidential. ******************************************************************************/ -#include "VecServiceScheduler.h" +#include "MegasearchScheduler.h" #include "utils/Log.h" +#include "megasearch_types.h" +#include "megasearch_constants.h" + namespace zilliz { namespace vecwise { namespace server { + +using namespace megasearch; + +namespace { + const std::map &ErrorMap() { + static const std::map code_map = { + {SERVER_UNEXPECTED_ERROR, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_NULL_POINTER, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_INVALID_ARGUMENT, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_FILE_NOT_FOUND, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_NOT_IMPLEMENT, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_BLOCKING_QUEUE_EMPTY, thrift::ErrorCode::ILLEGAL_ARGUMENT}, + {SERVER_GROUP_NOT_EXIST, thrift::ErrorCode::TABLE_NOT_EXISTS}, + {SERVER_INVALID_TIME_RANGE, thrift::ErrorCode::ILLEGAL_RANGE}, + {SERVER_INVALID_VECTOR_DIMENSION, thrift::ErrorCode::ILLEGAL_DIMENSION}, + }; + + return code_map; + } + + const std::map &ErrorMessage() { + static const std::map msg_map = { + {SERVER_UNEXPECTED_ERROR, "unexpected error occurs"}, + {SERVER_NULL_POINTER, "null pointer error"}, + {SERVER_INVALID_ARGUMENT, "invalid argument"}, + {SERVER_FILE_NOT_FOUND, "file not found"}, + {SERVER_NOT_IMPLEMENT, "not implemented"}, + {SERVER_BLOCKING_QUEUE_EMPTY, "queue empty"}, + {SERVER_GROUP_NOT_EXIST, "group not exist"}, + {SERVER_INVALID_TIME_RANGE, "invalid time range"}, + {SERVER_INVALID_VECTOR_DIMENSION, "invalid vector dimension"}, + }; + + return msg_map; + } +} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BaseTask::BaseTask(const std::string& task_group, bool async) @@ -38,16 +77,40 @@ ServerError BaseTask::WaitToFinish() { } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -VecServiceScheduler::VecServiceScheduler() +MegasearchScheduler::MegasearchScheduler() : stopped_(false) { Start(); } -VecServiceScheduler::~VecServiceScheduler() { +MegasearchScheduler::~MegasearchScheduler() { Stop(); } -void VecServiceScheduler::Start() { +void MegasearchScheduler::ExecTask(BaseTaskPtr& task_ptr) { + if(task_ptr == nullptr) { + return; + } + + MegasearchScheduler& scheduler = MegasearchScheduler::GetInstance(); + scheduler.ExecuteTask(task_ptr); + + if(!task_ptr->IsAsync()) { + task_ptr->WaitToFinish(); + ServerError err = task_ptr->ErrorCode(); + if (err != SERVER_SUCCESS) { + thrift::Exception ex; + ex.__set_code(ErrorMap().at(err)); + std::string msg = task_ptr->ErrorMsg(); + if(msg.empty()){ + msg = ErrorMessage().at(err); + } + ex.__set_reason(msg); + throw ex; + } + } +} + +void MegasearchScheduler::Start() { if(!stopped_) { return; } @@ -55,7 +118,7 @@ void VecServiceScheduler::Start() { stopped_ = false; } -void VecServiceScheduler::Stop() { +void MegasearchScheduler::Stop() { if(stopped_) { return; } @@ -80,7 +143,7 @@ void VecServiceScheduler::Stop() { SERVER_LOG_INFO << "Scheduler stopped"; } -ServerError VecServiceScheduler::ExecuteTask(const BaseTaskPtr& task_ptr) { +ServerError MegasearchScheduler::ExecuteTask(const BaseTaskPtr& task_ptr) { if(task_ptr == nullptr) { return SERVER_NULL_POINTER; } @@ -121,7 +184,7 @@ namespace { } } -ServerError VecServiceScheduler::PutTaskToQueue(const BaseTaskPtr& task_ptr) { +ServerError MegasearchScheduler::PutTaskToQueue(const BaseTaskPtr& task_ptr) { std::lock_guard lock(queue_mtx_); std::string group_name = task_ptr->TaskGroup(); diff --git a/cpp/src/server/VecServiceScheduler.h b/cpp/src/server/MegasearchScheduler.h similarity index 88% rename from cpp/src/server/VecServiceScheduler.h rename to cpp/src/server/MegasearchScheduler.h index 65b234c84d..89648599cf 100644 --- a/cpp/src/server/VecServiceScheduler.h +++ b/cpp/src/server/MegasearchScheduler.h @@ -50,10 +50,10 @@ using TaskQueue = BlockingQueue; using TaskQueuePtr = std::shared_ptr; using ThreadPtr = std::shared_ptr; -class VecServiceScheduler { +class MegasearchScheduler { public: - static VecServiceScheduler& GetInstance() { - static VecServiceScheduler scheduler; + static MegasearchScheduler& GetInstance() { + static MegasearchScheduler scheduler; return scheduler; } @@ -62,9 +62,11 @@ public: ServerError ExecuteTask(const BaseTaskPtr& task_ptr); + static void ExecTask(BaseTaskPtr& task_ptr); + protected: - VecServiceScheduler(); - virtual ~VecServiceScheduler(); + MegasearchScheduler(); + virtual ~MegasearchScheduler(); ServerError PutTaskToQueue(const BaseTaskPtr& task_ptr); diff --git a/cpp/src/server/VecServiceWrapper.cpp b/cpp/src/server/MegasearchServer.cpp similarity index 68% rename from cpp/src/server/VecServiceWrapper.cpp rename to cpp/src/server/MegasearchServer.cpp index 6e9fd8b3a4..5940d20bbc 100644 --- a/cpp/src/server/VecServiceWrapper.cpp +++ b/cpp/src/server/MegasearchServer.cpp @@ -3,22 +3,17 @@ * Unauthorized copying of this file, via any medium is strictly prohibited. * Proprietary and confidential. ******************************************************************************/ -#include "VecServiceWrapper.h" -#include "VecServiceHandler.h" -#include "VecServiceScheduler.h" +#include "MegasearchServer.h" +#include "MegasearchHandler.h" +#include "megasearch_types.h" +#include "megasearch_constants.h" #include "ServerConfig.h" -#include "utils/Log.h" - -#include "thrift/gen-cpp/megasearch_types.h" -#include "thrift/gen-cpp/megasearch_constants.h" - #include #include #include #include #include -//#include #include #include #include @@ -30,6 +25,7 @@ namespace zilliz { namespace vecwise { namespace server { +using namespace megasearch::thrift; using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; @@ -38,7 +34,8 @@ using namespace ::apache::thrift::concurrency; static stdcxx::shared_ptr s_server; -void VecServiceWrapper::StartService() { +void +MegasearchServer::StartService() { if(s_server != nullptr){ StopService(); } @@ -52,11 +49,12 @@ void VecServiceWrapper::StartService() { std::string mode = server_config.GetValue(CONFIG_SERVER_MODE, "thread_pool"); try { - stdcxx::shared_ptr handler(new VecServiceHandler()); - stdcxx::shared_ptr processor(new VecServiceProcessor(handler)); + stdcxx::shared_ptr handler(new MegasearchServiceHandler()); + stdcxx::shared_ptr processor(new MegasearchServiceProcessor(handler)); stdcxx::shared_ptr server_transport(new TServerSocket(address, port)); stdcxx::shared_ptr transport_factory(new TBufferedTransportFactory()); + std::string protocol = "json"; stdcxx::shared_ptr protocol_factory; if (protocol == "binary") { protocol_factory.reset(new TBinaryProtocolFactory()); @@ -67,24 +65,14 @@ void VecServiceWrapper::StartService() { } else if (protocol == "debug") { protocol_factory.reset(new TDebugProtocolFactory()); } else { - SERVER_LOG_INFO << "Service protocol: " << protocol << " is not supported currently"; + //SERVER_LOG_INFO << "Service protocol: " << protocol << " is not supported currently"; return; } + std::string mode = "thread_pool"; if (mode == "simple") { s_server.reset(new TSimpleServer(processor, server_transport, transport_factory, protocol_factory)); s_server->serve(); -// } else if(mode == "non_blocking") { -// ::apache::thrift::stdcxx::shared_ptr nb_server_transport(new TServerSocket(address, port)); -// ::apache::thrift::stdcxx::shared_ptr threadManager(ThreadManager::newSimpleThreadManager()); -// ::apache::thrift::stdcxx::shared_ptr threadFactory(new PosixThreadFactory()); -// threadManager->threadFactory(threadFactory); -// threadManager->start(); -// -// s_server.reset(new TNonblockingServer(processor, -// protocol_factory, -// nb_server_transport, -// threadManager)); } else if (mode == "thread_pool") { stdcxx::shared_ptr threadManager(ThreadManager::newSimpleThreadManager()); stdcxx::shared_ptr threadFactory(new PosixThreadFactory()); @@ -98,19 +86,17 @@ void VecServiceWrapper::StartService() { threadManager)); s_server->serve(); } else { - SERVER_LOG_INFO << "Service mode: " << mode << " is not supported currently"; + //SERVER_LOG_INFO << "Service mode: " << mode << " is not supported currently"; return; } } catch (apache::thrift::TException& ex) { - SERVER_LOG_ERROR << "Server encounter exception: " << ex.what(); + //SERVER_LOG_ERROR << "Server encounter exception: " << ex.what(); } } -void VecServiceWrapper::StopService() { +void +MegasearchServer::StopService() { auto stop_server_worker = [&]{ - VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance(); - scheduler.Stop(); - if(s_server != nullptr) { s_server->stop(); } diff --git a/cpp/src/server/VecServiceWrapper.h b/cpp/src/server/MegasearchServer.h similarity index 91% rename from cpp/src/server/VecServiceWrapper.h rename to cpp/src/server/MegasearchServer.h index 7af9cb5e56..62675e2484 100644 --- a/cpp/src/server/VecServiceWrapper.h +++ b/cpp/src/server/MegasearchServer.h @@ -5,8 +5,6 @@ ******************************************************************************/ #pragma once -#include "utils/Error.h" - #include #include @@ -14,13 +12,12 @@ namespace zilliz { namespace vecwise { namespace server { -class VecServiceWrapper { +class MegasearchServer { public: static void StartService(); static void StopService(); }; - } } } diff --git a/cpp/src/server/MegasearchTask.cpp b/cpp/src/server/MegasearchTask.cpp new file mode 100644 index 0000000000..077f217d68 --- /dev/null +++ b/cpp/src/server/MegasearchTask.cpp @@ -0,0 +1,371 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#include "MegasearchTask.h" +#include "ServerConfig.h" +#include "VecIdMapper.h" +#include "utils/CommonUtil.h" +#include "utils/Log.h" +#include "utils/TimeRecorder.h" +#include "utils/ThreadPool.h" +#include "db/DB.h" +#include "db/Env.h" +#include "db/Meta.h" + + +namespace zilliz { +namespace vecwise { +namespace server { + +static const std::string DQL_TASK_GROUP = "dql"; +static const std::string DDL_DML_TASK_GROUP = "ddl_dml"; + +static const std::string VECTOR_UID = "uid"; +static const uint64_t USE_MT = 5000; + +using DB_META = zilliz::vecwise::engine::meta::Meta; +using DB_DATE = zilliz::vecwise::engine::meta::DateT; + +namespace { + class DBWrapper { + public: + DBWrapper() { + zilliz::vecwise::engine::Options opt; + ConfigNode& config = ServerConfig::GetInstance().GetConfig(CONFIG_DB); + opt.meta.backend_uri = config.GetValue(CONFIG_DB_URL); + std::string db_path = config.GetValue(CONFIG_DB_PATH); + opt.memory_sync_interval = (uint16_t)config.GetInt32Value(CONFIG_DB_FLUSH_INTERVAL, 10); + opt.meta.path = db_path + "/db"; + + CommonUtil::CreateDirectory(opt.meta.path); + + zilliz::vecwise::engine::DB::Open(opt, &db_); + if(db_ == nullptr) { + SERVER_LOG_ERROR << "Failed to open db"; + throw ServerException(SERVER_NULL_POINTER, "Failed to open db"); + } + } + + zilliz::vecwise::engine::DB* DB() { return db_; } + + private: + zilliz::vecwise::engine::DB* db_ = nullptr; + }; + + zilliz::vecwise::engine::DB* DB() { + static DBWrapper db_wrapper; + return db_wrapper.DB(); + } + + ThreadPool& GetThreadPool() { + static ThreadPool pool(6); + return pool; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +CreateTableTask::CreateTableTask(const thrift::TableSchema& schema) +: BaseTask(DDL_DML_TASK_GROUP), + schema_(schema) { + +} + +BaseTaskPtr CreateTableTask::Create(const thrift::TableSchema& schema) { + return std::shared_ptr(new CreateTableTask(schema)); +} + +ServerError CreateTableTask::OnExecute() { + TimeRecorder rc("CreateTableTask"); + + try { + if(schema_.vector_column_array.empty()) { + return SERVER_INVALID_ARGUMENT; + } + + IVecIdMapper::GetInstance()->AddGroup(schema_.table_name); + engine::meta::GroupSchema group_info; + group_info.dimension = (uint16_t)schema_.vector_column_array[0].dimension; + group_info.group_id = schema_.table_name; + engine::Status stat = DB()->add_group(group_info); + if(!stat.ok()) {//could exist + error_msg_ = "Engine failed: " + stat.ToString(); + SERVER_LOG_ERROR << error_msg_; + return SERVER_SUCCESS; + } + + } catch (std::exception& ex) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = ex.what(); + SERVER_LOG_ERROR << error_msg_; + return SERVER_UNEXPECTED_ERROR; + } + + rc.Record("done"); + + return SERVER_SUCCESS; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +DescribeTableTask::DescribeTableTask(const std::string &table_name, thrift::TableSchema &schema) + : BaseTask(DDL_DML_TASK_GROUP), + table_name_(table_name), + schema_(schema) { + schema_.table_name = table_name_; +} + +BaseTaskPtr DescribeTableTask::Create(const std::string& table_name, thrift::TableSchema& schema) { + return std::shared_ptr(new DescribeTableTask(table_name, schema)); +} + +ServerError DescribeTableTask::OnExecute() { + TimeRecorder rc("DescribeTableTask"); + + try { + engine::meta::GroupSchema group_info; + group_info.group_id = table_name_; + engine::Status stat = DB()->get_group(group_info); + if(!stat.ok()) { + error_code_ = SERVER_GROUP_NOT_EXIST; + error_msg_ = "Engine failed: " + stat.ToString(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } else { + + } + + } catch (std::exception& ex) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = ex.what(); + SERVER_LOG_ERROR << error_msg_; + return SERVER_UNEXPECTED_ERROR; + } + + rc.Record("done"); + + return SERVER_SUCCESS; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +DeleteTableTask::DeleteTableTask(const std::string& table_name) + : BaseTask(DDL_DML_TASK_GROUP), + table_name_(table_name) { + +} + +BaseTaskPtr DeleteTableTask::Create(const std::string& group_id) { + return std::shared_ptr(new DeleteTableTask(group_id)); +} + +ServerError DeleteTableTask::OnExecute() { + error_code_ = SERVER_NOT_IMPLEMENT; + error_msg_ = "delete table not implemented"; + SERVER_LOG_ERROR << error_msg_; + + //IVecIdMapper::GetInstance()->DeleteGroup(table_name_); + + return SERVER_NOT_IMPLEMENT; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +AddVectorTask::AddVectorTask(const std::string& table_name, + const std::vector& record_array, + std::vector& record_ids) + : BaseTask(DDL_DML_TASK_GROUP), + table_name_(table_name), + record_array_(record_array), + record_ids_(record_ids) { + record_ids_.clear(); + record_ids_.resize(record_array.size()); +} + +BaseTaskPtr AddVectorTask::Create(const std::string& table_name, + const std::vector& record_array, + std::vector& record_ids) { + return std::shared_ptr(new AddVectorTask(table_name, record_array, record_ids)); +} + +ServerError AddVectorTask::OnExecute() { + try { + TimeRecorder rc("AddVectorTask"); + + if(record_array_.empty()) { + return SERVER_SUCCESS; + } + + engine::meta::GroupSchema group_info; + group_info.group_id = table_name_; + engine::Status stat = DB()->get_group(group_info); + if(!stat.ok()) { + error_code_ = SERVER_GROUP_NOT_EXIST; + error_msg_ = "Engine failed: " + stat.ToString(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + rc.Record("get group info"); + + uint64_t vec_count = (uint64_t)record_array_.size(); + uint64_t group_dim = group_info.dimension; + std::vector vec_f; + vec_f.resize(vec_count*group_dim);//allocate enough memory + for(uint64_t i = 0; i < vec_count; i++) { + const auto& record = record_array_[i]; + if(record.vector_map.empty()) { + error_code_ = SERVER_INVALID_ARGUMENT; + error_msg_ = "No vector provided in record"; + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + uint64_t vec_dim = record.vector_map.begin()->second.size()/sizeof(double);//how many double value? + if(vec_dim != group_dim) { + SERVER_LOG_ERROR << "Invalid vector dimension: " << vec_dim + << " vs. group dimension:" << group_dim; + error_code_ = SERVER_INVALID_VECTOR_DIMENSION; + error_msg_ = "Engine failed: " + stat.ToString(); + return error_code_; + } + + const double* d_p = reinterpret_cast(record.vector_map.begin()->second.data()); + for(uint64_t d = 0; d < vec_dim; d++) { + vec_f[i*vec_dim + d] = (float)(d_p[d]); + } + } + + rc.Record("prepare vectors data"); + + stat = DB()->add_vectors(table_name_, vec_count, vec_f.data(), record_ids_); + rc.Record("add vectors to engine"); + if(!stat.ok()) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = "Engine failed: " + stat.ToString(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + if(record_ids_.size() < vec_count) { + SERVER_LOG_ERROR << "Vector ID not returned"; + return SERVER_UNEXPECTED_ERROR; + } + + rc.Record("done"); + + } catch (std::exception& ex) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = ex.what(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + return SERVER_SUCCESS; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +SearchVectorTask::SearchVectorTask(const std::string& table_name, + const int64_t top_k, + const std::vector& record_array, + std::vector& result_array) + : BaseTask(DQL_TASK_GROUP), + table_name_(table_name), + top_k_(top_k), + record_array_(record_array), + result_array_(result_array) { + +} + +BaseTaskPtr SearchVectorTask::Create(const std::string& table_name, + const std::vector& record_array, + const int64_t top_k, + std::vector& result_array) { + return std::shared_ptr(new SearchVectorTask(table_name, top_k, record_array, result_array)); +} + +ServerError SearchVectorTask::OnExecute() { + try { + TimeRecorder rc("SearchVectorTask"); + + if(top_k_ <= 0 || record_array_.empty()) { + error_code_ = SERVER_INVALID_ARGUMENT; + error_msg_ = "Invalid topk value, or query record array is empty"; + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + engine::meta::GroupSchema group_info; + group_info.group_id = table_name_; + engine::Status stat = DB()->get_group(group_info); + if(!stat.ok()) { + error_code_ = SERVER_GROUP_NOT_EXIST; + error_msg_ = "Engine failed: " + stat.ToString(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + std::vector vec_f; + uint64_t record_count = (uint64_t)record_array_.size(); + vec_f.resize(record_count*group_info.dimension); + + for(uint64_t i = 0; i < record_array_.size(); i++) { + const auto& record = record_array_[i]; + if (record.vector_map.empty()) { + error_code_ = SERVER_INVALID_ARGUMENT; + error_msg_ = "Query record has no vector"; + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + uint64_t vec_dim = record.vector_map.begin()->second.size() / sizeof(double);//how many double value? + if (vec_dim != group_info.dimension) { + SERVER_LOG_ERROR << "Invalid vector dimension: " << vec_dim + << " vs. group dimension:" << group_info.dimension; + error_code_ = SERVER_INVALID_VECTOR_DIMENSION; + error_msg_ = "Engine failed: " + stat.ToString(); + return error_code_; + } + + const double* d_p = reinterpret_cast(record.vector_map.begin()->second.data()); + for(uint64_t d = 0; d < vec_dim; d++) { + vec_f[i*vec_dim + d] = (float)(d_p[d]); + } + } + + rc.Record("prepare vector data"); + + std::vector dates; + engine::QueryResults results; + stat = DB()->search(table_name_, (size_t)top_k_, record_count, vec_f.data(), dates, results); + if(!stat.ok()) { + SERVER_LOG_ERROR << "Engine failed: " << stat.ToString(); + return SERVER_UNEXPECTED_ERROR; + } else { + rc.Record("do searching"); + for(engine::QueryResult& result : results){ + thrift::TopKQueryResult thrift_topk_result; + for(auto id : result) { + thrift::QueryResult thrift_result; + thrift_result.__set_id(id); + thrift_topk_result.query_result_arrays.emplace_back(thrift_result); + } + + result_array_.push_back(thrift_topk_result); + } + rc.Record("construct result"); + } + + rc.Record("done"); + + } catch (std::exception& ex) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = ex.what(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + return SERVER_SUCCESS; +} + +} +} +} diff --git a/cpp/src/server/MegasearchTask.h b/cpp/src/server/MegasearchTask.h new file mode 100644 index 0000000000..26c23e1b26 --- /dev/null +++ b/cpp/src/server/MegasearchTask.h @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include "MegasearchScheduler.h" +#include "utils/Error.h" +#include "utils/AttributeSerializer.h" +#include "db/Types.h" + +#include "megasearch_types.h" + +#include +#include + +namespace zilliz { +namespace vecwise { +namespace server { + +using namespace megasearch; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class CreateTableTask : public BaseTask { +public: + static BaseTaskPtr Create(const thrift::TableSchema& schema); + +protected: + CreateTableTask(const thrift::TableSchema& schema); + + ServerError OnExecute() override; + +private: + const thrift::TableSchema& schema_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class DescribeTableTask : public BaseTask { +public: + static BaseTaskPtr Create(const std::string& table_name, thrift::TableSchema& schema); + +protected: + DescribeTableTask(const std::string& table_name, thrift::TableSchema& schema); + + ServerError OnExecute() override; + + +private: + std::string table_name_; + thrift::TableSchema& schema_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class DeleteTableTask : public BaseTask { +public: + static BaseTaskPtr Create(const std::string& table_name); + +protected: + DeleteTableTask(const std::string& table_name); + + ServerError OnExecute() override; + + +private: + std::string table_name_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class AddVectorTask : public BaseTask { +public: + static BaseTaskPtr Create(const std::string& table_name, + const std::vector& record_array, + std::vector& record_ids_); + +protected: + AddVectorTask(const std::string& table_name, + const std::vector& record_array, + std::vector& record_ids_); + + ServerError OnExecute() override; + +private: + std::string table_name_; + const std::vector& record_array_; + std::vector& record_ids_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class SearchVectorTask : public BaseTask { +public: + static BaseTaskPtr Create(const std::string& table_name, + const std::vector& record_array, + const int64_t top_k, + std::vector& result_array); + +protected: + SearchVectorTask(const std::string& table_name, + const int64_t top_k, + const std::vector& record_array, + std::vector& result_array); + + ServerError OnExecute() override; + +private: + std::string table_name_; + int64_t top_k_; + const std::vector& record_array_; + std::vector& result_array_; +}; + +} +} +} \ No newline at end of file diff --git a/cpp/src/server/Server.cpp b/cpp/src/server/Server.cpp index 3f51929baf..9b4fc4ec07 100644 --- a/cpp/src/server/Server.cpp +++ b/cpp/src/server/Server.cpp @@ -5,7 +5,7 @@ //////////////////////////////////////////////////////////////////////////////// #include "Server.h" #include "ServerConfig.h" -#include "VecServiceWrapper.h" +#include "MegasearchServer.h" #include "utils/Log.h" #include "utils/SignalUtil.h" #include "utils/TimeRecorder.h" @@ -225,12 +225,12 @@ Server::LoadConfig() { void Server::StartService() { - VecServiceWrapper::StartService(); + MegasearchServer::StartService(); } void Server::StopService() { - VecServiceWrapper::StopService(); + MegasearchServer::StopService(); } } diff --git a/cpp/src/server/VecServiceHandler.cpp b/cpp/src/server/VecServiceHandler.cpp deleted file mode 100644 index c8db470e63..0000000000 --- a/cpp/src/server/VecServiceHandler.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#include "VecServiceHandler.h" -#include "VecServiceTask.h" -#include "ServerConfig.h" -#include "utils/Log.h" -#include "utils/CommonUtil.h" -#include "utils/TimeRecorder.h" - -#include "db/DB.h" -#include "db/Env.h" - -namespace zilliz { -namespace vecwise { -namespace server { - -using namespace megasearch; - -namespace { - class TimeRecordWrapper { - public: - TimeRecordWrapper(const std::string& func_name) - : recorder_(func_name), func_name_(func_name) { - //SERVER_LOG_TRACE << func_name << " called"; - } - - ~TimeRecordWrapper() { - recorder_.Elapse("cost"); - //SERVER_LOG_TRACE << func_name_ << " finished"; - } - - private: - TimeRecorder recorder_; - std::string func_name_; - }; - void TimeRecord(const std::string& func_name) { - - } - - const std::map& ErrorMap() { - static const std::map code_map = { - {SERVER_UNEXPECTED_ERROR, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_NULL_POINTER, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_INVALID_ARGUMENT, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_FILE_NOT_FOUND, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_NOT_IMPLEMENT, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_BLOCKING_QUEUE_EMPTY, VecErrCode::ILLEGAL_ARGUMENT}, - {SERVER_GROUP_NOT_EXIST, VecErrCode::GROUP_NOT_EXISTS}, - {SERVER_INVALID_TIME_RANGE, VecErrCode::ILLEGAL_TIME_RANGE}, - {SERVER_INVALID_VECTOR_DIMENSION, VecErrCode::ILLEGAL_VECTOR_DIMENSION}, - }; - - return code_map; - } - - const std::map& ErrorMessage() { - static const std::map msg_map = { - {SERVER_UNEXPECTED_ERROR, "unexpected error occurs"}, - {SERVER_NULL_POINTER, "null pointer error"}, - {SERVER_INVALID_ARGUMENT, "invalid argument"}, - {SERVER_FILE_NOT_FOUND, "file not found"}, - {SERVER_NOT_IMPLEMENT, "not implemented"}, - {SERVER_BLOCKING_QUEUE_EMPTY, "queue empty"}, - {SERVER_GROUP_NOT_EXIST, "group not exist"}, - {SERVER_INVALID_TIME_RANGE, "invalid time range"}, - {SERVER_INVALID_VECTOR_DIMENSION, "invalid vector dimension"}, - }; - - return msg_map; - } - - void ExecTask(BaseTaskPtr& task_ptr) { - if(task_ptr == nullptr) { - return; - } - - VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance(); - scheduler.ExecuteTask(task_ptr); - - if(!task_ptr->IsAsync()) { - task_ptr->WaitToFinish(); - ServerError err = task_ptr->ErrorCode(); - if (err != SERVER_SUCCESS) { - VecException ex; - ex.__set_code(ErrorMap().at(err)); - std::string msg = task_ptr->ErrorMsg(); - if(msg.empty()){ - msg = ErrorMessage().at(err); - } - ex.__set_reason(msg); - throw ex; - } - } - } -} - -void -VecServiceHandler::add_group(const VecGroup &group) { - std::string info = "add_group() " + group.id + " dimension = " + std::to_string(group.dimension) - + " index_type = " + std::to_string(group.index_type); - TimeRecordWrapper rc(info); - - BaseTaskPtr task_ptr = AddGroupTask::Create(group.dimension, group.id); - ExecTask(task_ptr); -} - -void -VecServiceHandler::get_group(VecGroup &_return, const std::string &group_id) { - TimeRecordWrapper rc("get_group() " + group_id); - - _return.id = group_id; - BaseTaskPtr task_ptr = GetGroupTask::Create(group_id, _return.dimension); - ExecTask(task_ptr); -} - -void -VecServiceHandler::del_group(const std::string &group_id) { - TimeRecordWrapper rc("del_group() " + group_id); - - BaseTaskPtr task_ptr = DeleteGroupTask::Create(group_id); - ExecTask(task_ptr); -} - - -void -VecServiceHandler::add_vector(std::string& _return, const std::string &group_id, const VecTensor &tensor) { - TimeRecordWrapper rc("add_vector() to " + group_id); - - BaseTaskPtr task_ptr = AddVectorTask::Create(group_id, &tensor, _return); - ExecTask(task_ptr); -} - -void -VecServiceHandler::add_vector_batch(std::vector & _return, - const std::string &group_id, - const VecTensorList &tensor_list) { - TimeRecordWrapper rc("add_vector_batch() to " + group_id); - - BaseTaskPtr task_ptr = AddBatchVectorTask::Create(group_id, &tensor_list, _return); - ExecTask(task_ptr); -} - -void -VecServiceHandler::add_binary_vector(std::string& _return, - const std::string& group_id, - const VecBinaryTensor& tensor) { - TimeRecordWrapper rc("add_binary_vector() to " + group_id); - - BaseTaskPtr task_ptr = AddVectorTask::Create(group_id, &tensor, _return); - ExecTask(task_ptr); -} - -void -VecServiceHandler::add_binary_vector_batch(std::vector & _return, - const std::string& group_id, - const VecBinaryTensorList& tensor_list) { - TimeRecordWrapper rc("add_binary_vector_batch() to " + group_id); - - BaseTaskPtr task_ptr = AddBatchVectorTask::Create(group_id, &tensor_list, _return); - ExecTask(task_ptr); -} - -void -VecServiceHandler::search_vector(VecSearchResult &_return, - const std::string &group_id, - const int64_t top_k, - const VecTensor &tensor, - const VecSearchFilter& filter) { - TimeRecordWrapper rc("search_vector() in " + group_id); - - VecTensorList tensor_list; - tensor_list.tensor_list.push_back(tensor); - VecSearchResultList result; - BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, result); - ExecTask(task_ptr); - - if(!result.result_list.empty()) { - _return = result.result_list[0]; - } else { - SERVER_LOG_ERROR << "No search result returned"; - } -} - -void -VecServiceHandler::search_vector_batch(VecSearchResultList &_return, - const std::string &group_id, - const int64_t top_k, - const VecTensorList &tensor_list, - const VecSearchFilter& filter) { - TimeRecordWrapper rc("search_vector_batch() in " + group_id); - - BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, _return); - ExecTask(task_ptr); -} - -void -VecServiceHandler::search_binary_vector(VecSearchResult& _return, - const std::string& group_id, - const int64_t top_k, - const VecBinaryTensor& tensor, - const VecSearchFilter& filter) { - TimeRecordWrapper rc("search_binary_vector() in " + group_id); - - VecBinaryTensorList tensor_list; - tensor_list.tensor_list.push_back(tensor); - VecSearchResultList result; - BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, result); - ExecTask(task_ptr); - - if(!result.result_list.empty()) { - _return = result.result_list[0]; - } else { - SERVER_LOG_ERROR << "No search result returned"; - } -} - -void -VecServiceHandler::search_binary_vector_batch(VecSearchResultList& _return, - const std::string& group_id, - const int64_t top_k, - const VecBinaryTensorList& tensor_list, - const VecSearchFilter& filter) { - TimeRecordWrapper rc("search_binary_vector_batch() in " + group_id); - - BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, _return); - ExecTask(task_ptr); -} - - -} -} -} diff --git a/cpp/src/server/VecServiceHandler.h b/cpp/src/server/VecServiceHandler.h deleted file mode 100644 index 7a6ccc4b18..0000000000 --- a/cpp/src/server/VecServiceHandler.h +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#pragma once -#include "utils/Error.h" -#include "thrift/gen-cpp/VecService.h" - -#include -#include - -namespace zilliz { -namespace vecwise { -namespace engine { - class DB; -} -} -} - -namespace zilliz { -namespace vecwise { -namespace server { - -using namespace megasearch; - -class VecServiceHandler : virtual public VecServiceIf { -public: - VecServiceHandler() { - // Your initialization goes here - } - - /** - * group interfaces - * - * @param group - */ - void add_group(const VecGroup& group); - - void get_group(VecGroup& _return, const std::string& group_id); - - void del_group(const std::string& group_id); - - /** - * insert vector interfaces - * - * - * @param group_id - * @param tensor - */ - void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor); - - void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list); - - void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor); - - void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list); - - /** - * search interfaces - * you can use filter to reduce search result - * filter.attrib_filter can specify which attribute you need, for example: - * set attrib_filter = {"color":""} means you want to get "color" attribute for result vector - * set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" - * if filter.time_range is empty, engine will search without time limit - * - * @param group_id - * @param top_k - * @param tensor - * @param filter - */ - void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter); - - void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter); - - void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter); - - void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter); - -}; - - -} -} -} diff --git a/cpp/src/server/VecServiceTask.cpp b/cpp/src/server/VecServiceTask.cpp deleted file mode 100644 index c2435ff51b..0000000000 --- a/cpp/src/server/VecServiceTask.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#include "VecServiceTask.h" -#include "ServerConfig.h" -#include "VecIdMapper.h" -#include "utils/CommonUtil.h" -#include "utils/Log.h" -#include "utils/TimeRecorder.h" -#include "utils/ThreadPool.h" -#include "db/DB.h" -#include "db/Env.h" -#include "db/Meta.h" - - -namespace zilliz { -namespace vecwise { -namespace server { - -static const std::string DQL_TASK_GROUP = "dql"; -static const std::string DDL_DML_TASK_GROUP = "ddl_dml"; - -static const std::string VECTOR_UID = "uid"; -static const uint64_t USE_MT = 5000; - -using DB_META = zilliz::vecwise::engine::meta::Meta; -using DB_DATE = zilliz::vecwise::engine::meta::DateT; - -namespace { - class DBWrapper { - public: - DBWrapper() { - zilliz::vecwise::engine::Options opt; - ConfigNode& config = ServerConfig::GetInstance().GetConfig(CONFIG_DB); - opt.meta.backend_uri = config.GetValue(CONFIG_DB_URL); - std::string db_path = config.GetValue(CONFIG_DB_PATH); - opt.memory_sync_interval = (uint16_t)config.GetInt32Value(CONFIG_DB_FLUSH_INTERVAL, 10); - opt.meta.path = db_path + "/db"; - - CommonUtil::CreateDirectory(opt.meta.path); - - zilliz::vecwise::engine::DB::Open(opt, &db_); - if(db_ == nullptr) { - SERVER_LOG_ERROR << "Failed to open db"; - throw ServerException(SERVER_NULL_POINTER, "Failed to open db"); - } - } - - zilliz::vecwise::engine::DB* DB() { return db_; } - - private: - zilliz::vecwise::engine::DB* db_ = nullptr; - }; - - zilliz::vecwise::engine::DB* DB() { - static DBWrapper db_wrapper; - return db_wrapper.DB(); - } - - DB_DATE MakeDbDate(const VecDateTime& dt) { - time_t t_t; - CommonUtil::ConvertTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, t_t); - return DB_META::GetDate(t_t); - } - - ThreadPool& GetThreadPool() { - static ThreadPool pool(6); - return pool; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -AddGroupTask::AddGroupTask(int32_t dimension, - const std::string& group_id) -: BaseTask(DDL_DML_TASK_GROUP), - dimension_(dimension), - group_id_(group_id) { - -} - -BaseTaskPtr AddGroupTask::Create(int32_t dimension, - const std::string& group_id) { - return std::shared_ptr(new AddGroupTask(dimension,group_id)); -} - -ServerError AddGroupTask::OnExecute() { - try { - IVecIdMapper::GetInstance()->AddGroup(group_id_); - engine::meta::GroupSchema group_info; - group_info.dimension = (size_t)dimension_; - group_info.group_id = group_id_; - engine::Status stat = DB()->add_group(group_info); - if(!stat.ok()) {//could exist - SERVER_LOG_ERROR << "Engine failed: " << stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return SERVER_SUCCESS; - } - - } catch (std::exception& ex) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = ex.what(); - SERVER_LOG_ERROR << error_msg_; - return SERVER_UNEXPECTED_ERROR; - } - - return SERVER_SUCCESS; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -GetGroupTask::GetGroupTask(const std::string& group_id, int32_t& dimension) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id), - dimension_(dimension) { - -} - -BaseTaskPtr GetGroupTask::Create(const std::string& group_id, int32_t& dimension) { - return std::shared_ptr(new GetGroupTask(group_id, dimension)); -} - -ServerError GetGroupTask::OnExecute() { - try { - dimension_ = 0; - - engine::meta::GroupSchema group_info; - group_info.group_id = group_id_; - engine::Status stat = DB()->get_group(group_info); - if(!stat.ok()) { - error_code_ = SERVER_GROUP_NOT_EXIST; - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } else { - dimension_ = (int32_t)group_info.dimension; - } - - } catch (std::exception& ex) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = ex.what(); - SERVER_LOG_ERROR << error_msg_; - return SERVER_UNEXPECTED_ERROR; - } - - return SERVER_SUCCESS; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -DeleteGroupTask::DeleteGroupTask(const std::string& group_id) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id) { - -} - -BaseTaskPtr DeleteGroupTask::Create(const std::string& group_id) { - return std::shared_ptr(new DeleteGroupTask(group_id)); -} - -ServerError DeleteGroupTask::OnExecute() { - error_code_ = SERVER_NOT_IMPLEMENT; - error_msg_ = "delete group not implemented"; - SERVER_LOG_ERROR << error_msg_; - - //IVecIdMapper::GetInstance()->DeleteGroup(group_id_); - - return SERVER_NOT_IMPLEMENT; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -AddVectorTask::AddVectorTask(const std::string& group_id, - const VecTensor* tensor, - std::string& id) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id), - tensor_(tensor), - bin_tensor_(nullptr), - tensor_id_(id) { - -} - -BaseTaskPtr AddVectorTask::Create(const std::string& group_id, - const VecTensor* tensor, - std::string& id) { - return std::shared_ptr(new AddVectorTask(group_id, tensor, id)); -} - -AddVectorTask::AddVectorTask(const std::string& group_id, - const VecBinaryTensor* tensor, - std::string& id) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id), - tensor_(nullptr), - bin_tensor_(tensor), - tensor_id_(id) { - -} - -BaseTaskPtr AddVectorTask::Create(const std::string& group_id, - const VecBinaryTensor* tensor, - std::string& id) { - return std::shared_ptr(new AddVectorTask(group_id, tensor, id)); -} - - -uint64_t AddVectorTask::GetVecDimension() const { - if(tensor_) { - return (uint64_t) tensor_->tensor.size(); - } else if(bin_tensor_) { - return (uint64_t) bin_tensor_->tensor.size()/8; - } else { - return 0; - } -} - -const double* AddVectorTask::GetVecData() const { - if(tensor_) { - return (const double*)(tensor_->tensor.data()); - } else if(bin_tensor_) { - return (const double*)(bin_tensor_->tensor.data()); - } else { - return nullptr; - } - -} - -std::string AddVectorTask::GetVecID() const { - if(tensor_) { - return tensor_->uid; - } else if(bin_tensor_) { - return bin_tensor_->uid; - } else { - return ""; - } -} - -const AttribMap& AddVectorTask::GetVecAttrib() const { - if(tensor_) { - return tensor_->attrib; - } else { - return bin_tensor_->attrib; - } -} - -ServerError AddVectorTask::OnExecute() { - try { - if(!IVecIdMapper::GetInstance()->IsGroupExist(group_id_)) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = "group not exist"; - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - uint64_t vec_dim = GetVecDimension(); - std::vector vec_f; - vec_f.resize(vec_dim); - const double* d_p = GetVecData(); - for(uint64_t d = 0; d < vec_dim; d++) { - vec_f[d] = (float)(d_p[d]); - } - - engine::IDNumbers vector_ids; - engine::Status stat = DB()->add_vectors(group_id_, 1, vec_f.data(), vector_ids); - if(!stat.ok()) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } else { - if(vector_ids.empty()) { - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return SERVER_UNEXPECTED_ERROR; - } else { - std::string uid = GetVecID(); - std::string num_id = std::to_string(vector_ids[0]); - if(uid.empty()) { - tensor_id_ = num_id; - } else { - tensor_id_ = uid; - } - - std::string nid = group_id_ + "_" + num_id; - AttribMap attrib = GetVecAttrib(); - attrib[VECTOR_UID] = tensor_id_; - std::string attrib_str; - AttributeSerializer::Encode(attrib, attrib_str); - IVecIdMapper::GetInstance()->Put(nid, attrib_str, group_id_); - //SERVER_LOG_TRACE << "nid = " << vector_ids[0] << ", uid = " << uid; - } - } - - } catch (std::exception& ex) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = ex.what(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - return SERVER_SUCCESS; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -AddBatchVectorTask::AddBatchVectorTask(const std::string& group_id, - const VecTensorList* tensor_list, - std::vector& ids) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id), - tensor_list_(tensor_list), - bin_tensor_list_(nullptr), - tensor_ids_(ids) { - tensor_ids_.clear(); - tensor_ids_.resize(tensor_list->tensor_list.size()); -} - -BaseTaskPtr AddBatchVectorTask::Create(const std::string& group_id, - const VecTensorList* tensor_list, - std::vector& ids) { - return std::shared_ptr(new AddBatchVectorTask(group_id, tensor_list, ids)); -} - -AddBatchVectorTask::AddBatchVectorTask(const std::string& group_id, - const VecBinaryTensorList* tensor_list, - std::vector& ids) - : BaseTask(DDL_DML_TASK_GROUP), - group_id_(group_id), - tensor_list_(nullptr), - bin_tensor_list_(tensor_list), - tensor_ids_(ids) { - tensor_ids_.clear(); -} - -BaseTaskPtr AddBatchVectorTask::Create(const std::string& group_id, - const VecBinaryTensorList* tensor_list, - std::vector& ids) { - return std::shared_ptr(new AddBatchVectorTask(group_id, tensor_list, ids)); -} - -uint64_t AddBatchVectorTask::GetVecListCount() const { - if(tensor_list_) { - return (uint64_t) tensor_list_->tensor_list.size(); - } else if(bin_tensor_list_) { - return (uint64_t) bin_tensor_list_->tensor_list.size(); - } else { - return 0; - } -} - -uint64_t AddBatchVectorTask::GetVecDimension(uint64_t index) const { - if(tensor_list_) { - if(index >= tensor_list_->tensor_list.size()){ - return 0; - } - return (uint64_t) tensor_list_->tensor_list[index].tensor.size(); - } else if(bin_tensor_list_) { - if(index >= bin_tensor_list_->tensor_list.size()){ - return 0; - } - return (uint64_t) bin_tensor_list_->tensor_list[index].tensor.size()/8; - } else { - return 0; - } -} - -const double* AddBatchVectorTask::GetVecData(uint64_t index) const { - if(tensor_list_) { - if(index >= tensor_list_->tensor_list.size()){ - return nullptr; - } - return tensor_list_->tensor_list[index].tensor.data(); - } else if(bin_tensor_list_) { - if(index >= bin_tensor_list_->tensor_list.size()){ - return nullptr; - } - return (const double*)bin_tensor_list_->tensor_list[index].tensor.data(); - } else { - return nullptr; - } -} - -std::string AddBatchVectorTask::GetVecID(uint64_t index) const { - if(tensor_list_) { - if(index >= tensor_list_->tensor_list.size()){ - return 0; - } - return tensor_list_->tensor_list[index].uid; - } else if(bin_tensor_list_) { - if(index >= bin_tensor_list_->tensor_list.size()){ - return 0; - } - return bin_tensor_list_->tensor_list[index].uid; - } else { - return ""; - } -} - -const AttribMap& AddBatchVectorTask::GetVecAttrib(uint64_t index) const { - if(tensor_list_) { - return tensor_list_->tensor_list[index].attrib; - } else { - return bin_tensor_list_->tensor_list[index].attrib; - } -} - -void AddBatchVectorTask::ProcessIdMapping(engine::IDNumbers& vector_ids, - uint64_t from, uint64_t to, - std::vector& tensor_ids) { - std::string nid_prefix = group_id_ + "_"; - for(size_t i = from; i < to; i++) { - std::string uid = GetVecID(i); - std::string num_id = std::to_string(vector_ids[i]); - if(uid.empty()) { - uid = num_id; - } - tensor_ids_[i] = uid; - - std::string nid = nid_prefix + num_id; - AttribMap attrib = GetVecAttrib(i); - attrib[VECTOR_UID] = uid; - std::string attrib_str; - AttributeSerializer::Encode(attrib, attrib_str); - IVecIdMapper::GetInstance()->Put(nid, attrib_str, group_id_); - } -} - -ServerError AddBatchVectorTask::OnExecute() { - try { - TimeRecorder rc("AddBatchVectorTask"); - - uint64_t vec_count = GetVecListCount(); - if(vec_count == 0) { - return SERVER_SUCCESS; - } - - engine::meta::GroupSchema group_info; - group_info.group_id = group_id_; - engine::Status stat = DB()->get_group(group_info); - if(!stat.ok()) { - error_code_ = SERVER_GROUP_NOT_EXIST; - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - rc.Record("check group dimension"); - - uint64_t group_dim = group_info.dimension; - std::vector vec_f; - vec_f.resize(vec_count*group_dim);//allocate enough memory - for(uint64_t i = 0; i < vec_count; i ++) { - uint64_t vec_dim = GetVecDimension(i); - if(vec_dim != group_dim) { - SERVER_LOG_ERROR << "Invalid vector dimension: " << vec_dim - << " vs. group dimension:" << group_dim; - error_code_ = SERVER_INVALID_VECTOR_DIMENSION; - error_msg_ = "Engine failed: " + stat.ToString(); - return error_code_; - } - - const double* d_p = GetVecData(i); - for(uint64_t d = 0; d < vec_dim; d++) { - vec_f[i*vec_dim + d] = (float)(d_p[d]); - } - } - - rc.Record("prepare vectors data"); - - engine::IDNumbers vector_ids; - stat = DB()->add_vectors(group_id_, vec_count, vec_f.data(), vector_ids); - rc.Record("add vectors to engine"); - if(!stat.ok()) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - if(vector_ids.size() < vec_count) { - SERVER_LOG_ERROR << "Vector ID not returned"; - return SERVER_UNEXPECTED_ERROR; - } else { - tensor_ids_.resize(vector_ids.size()); - if(vec_count < USE_MT) { - ProcessIdMapping(vector_ids, 0, vec_count, tensor_ids_); - rc.Record("built id mapping"); - } else { - std::list> threads_list; - - uint64_t begin_index = 0, end_index = USE_MT; - while(true) { - threads_list.push_back( - GetThreadPool().enqueue(&AddBatchVectorTask::ProcessIdMapping, - this, vector_ids, begin_index, end_index, tensor_ids_)); - if(end_index >= vec_count) { - break; - } - - begin_index = end_index; - end_index += USE_MT; - if(end_index > vec_count) { - end_index = vec_count; - } - } - - for (std::list>::iterator it = threads_list.begin(); it != threads_list.end(); it++) { - it->wait(); - } - - rc.Record("built id mapping by multi-threads:" + std::to_string(threads_list.size())); - } - } - - } catch (std::exception& ex) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = ex.what(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - return SERVER_SUCCESS; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -SearchVectorTask::SearchVectorTask(const std::string& group_id, - const int64_t top_k, - const VecTensorList* tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result) - : BaseTask(DQL_TASK_GROUP), - group_id_(group_id), - top_k_(top_k), - tensor_list_(tensor_list), - bin_tensor_list_(nullptr), - filter_(filter), - result_(result) { - -} - -SearchVectorTask::SearchVectorTask(const std::string& group_id, - const int64_t top_k, - const VecBinaryTensorList* bin_tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result) - : BaseTask(DQL_TASK_GROUP), - group_id_(group_id), - top_k_(top_k), - tensor_list_(nullptr), - bin_tensor_list_(bin_tensor_list), - filter_(filter), - result_(result) { - -} - -BaseTaskPtr SearchVectorTask::Create(const std::string& group_id, - const int64_t top_k, - const VecTensorList* tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result) { - return std::shared_ptr(new SearchVectorTask(group_id, top_k, tensor_list, filter, result)); -} - -BaseTaskPtr SearchVectorTask::Create(const std::string& group_id, - const int64_t top_k, - const VecBinaryTensorList* bin_tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result) { - return std::shared_ptr(new SearchVectorTask(group_id, top_k, bin_tensor_list, filter, result)); -} - - -ServerError SearchVectorTask::GetTargetData(std::vector& data) const { - if(tensor_list_ && !tensor_list_->tensor_list.empty()) { - uint64_t count = tensor_list_->tensor_list.size(); - uint64_t dim = tensor_list_->tensor_list[0].tensor.size(); - data.resize(count*dim); - for(size_t i = 0; i < count; i++) { - if(tensor_list_->tensor_list[i].tensor.size() != dim) { - SERVER_LOG_ERROR << "Invalid vector dimension: " << tensor_list_->tensor_list[i].tensor.size(); - return SERVER_INVALID_ARGUMENT; - } - const double* d_p = tensor_list_->tensor_list[i].tensor.data(); - for(int64_t k = 0; k < dim; k++) { - data[i*dim + k] = (float)(d_p[k]); - } - } - } else if(bin_tensor_list_ && !bin_tensor_list_->tensor_list.empty()) { - uint64_t count = bin_tensor_list_->tensor_list.size(); - uint64_t dim = bin_tensor_list_->tensor_list[0].tensor.size()/8; - data.resize(count*dim); - for(size_t i = 0; i < count; i++) { - if(bin_tensor_list_->tensor_list[i].tensor.size()/8 != dim) { - SERVER_LOG_ERROR << "Invalid vector dimension: " << bin_tensor_list_->tensor_list[i].tensor.size()/8; - return SERVER_INVALID_ARGUMENT; - } - const double* d_p = (const double*)(bin_tensor_list_->tensor_list[i].tensor.data()); - for(int64_t k = 0; k < dim; k++) { - data[i*dim + k] = (float)(d_p[k]); - } - } - } - - return SERVER_SUCCESS; -} - -uint64_t SearchVectorTask::GetTargetDimension() const { - if(tensor_list_ && !tensor_list_->tensor_list.empty()) { - return tensor_list_->tensor_list[0].tensor.size(); - } else if(bin_tensor_list_ && !bin_tensor_list_->tensor_list.empty()) { - return bin_tensor_list_->tensor_list[0].tensor.size()/8; - } - - return 0; -} - -uint64_t SearchVectorTask::GetTargetCount() const { - if(tensor_list_) { - return tensor_list_->tensor_list.size(); - } else if(bin_tensor_list_) { - return bin_tensor_list_->tensor_list.size(); - } -} - -ServerError SearchVectorTask::OnExecute() { - try { - TimeRecorder rc("SearchVectorTask"); - - engine::meta::GroupSchema group_info; - group_info.group_id = group_id_; - engine::Status stat = DB()->get_group(group_info); - if(!stat.ok()) { - error_code_ = SERVER_GROUP_NOT_EXIST; - error_msg_ = "Engine failed: " + stat.ToString(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - uint64_t vec_dim = GetTargetDimension(); - if(vec_dim != group_info.dimension) { - SERVER_LOG_ERROR << "Invalid vector dimension: " << vec_dim - << " vs. group dimension:" << group_info.dimension; - error_code_ = SERVER_INVALID_VECTOR_DIMENSION; - error_msg_ = "Engine failed: " + stat.ToString(); - return error_code_; - } - - rc.Record("check group dimension"); - - std::vector vec_f; - ServerError err = GetTargetData(vec_f); - if(err != SERVER_SUCCESS) { - return err; - } - - uint64_t vec_count = GetTargetCount(); - - std::vector dates; - for(const VecTimeRange& tr : filter_.time_ranges) { - dates.push_back(MakeDbDate(tr.time_begin)); - dates.push_back(MakeDbDate(tr.time_end)); - } - - rc.Record("prepare input data"); - - engine::QueryResults results; - stat = DB()->search(group_id_, (size_t)top_k_, vec_count, vec_f.data(), dates, results); - if(!stat.ok()) { - SERVER_LOG_ERROR << "Engine failed: " << stat.ToString(); - return SERVER_UNEXPECTED_ERROR; - } else { - rc.Record("do search"); - for(engine::QueryResult& res : results){ - VecSearchResult v_res; - std::string nid_prefix = group_id_ + "_"; - for(auto id : res) { - std::string attrib_str; - std::string nid = nid_prefix + std::to_string(id); - IVecIdMapper::GetInstance()->Get(nid, attrib_str, group_id_); - - AttribMap attrib_map; - AttributeSerializer::Decode(attrib_str, attrib_map); - - AttribMap attrib_return; - VecSearchResultItem item; - item.uid = attrib_map[VECTOR_UID]; - - if(filter_.return_attribs.empty()) {//return all attributes - attrib_return.swap(attrib_map); - } else {//filter attributes - for(auto& name : filter_.return_attribs) { - if(attrib_map.count(name) == 0) - continue; - - attrib_return[name] = attrib_map[name]; - } - } - item.__set_attrib(attrib_return); - item.distance = 0.0;////TODO: return distance - v_res.result_list.emplace_back(item); - - //SERVER_LOG_TRACE << "nid = " << nid << ", uid = " << item.uid; - } - - result_.result_list.push_back(v_res); - } - rc.Record("construct result"); - } - - } catch (std::exception& ex) { - error_code_ = SERVER_UNEXPECTED_ERROR; - error_msg_ = ex.what(); - SERVER_LOG_ERROR << error_msg_; - return error_code_; - } - - return SERVER_SUCCESS; -} - -} -} -} diff --git a/cpp/src/server/VecServiceTask.h b/cpp/src/server/VecServiceTask.h deleted file mode 100644 index e046e36083..0000000000 --- a/cpp/src/server/VecServiceTask.h +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#pragma once - -#include "VecServiceScheduler.h" -#include "utils/Error.h" -#include "utils/AttributeSerializer.h" -#include "db/Types.h" - -#include "thrift/gen-cpp/megasearch_types.h" - -#include -#include - -namespace zilliz { -namespace vecwise { -namespace server { - -using namespace megasearch; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AddGroupTask : public BaseTask { -public: - static BaseTaskPtr Create(int32_t dimension, - const std::string& group_id); - -protected: - AddGroupTask(int32_t dimension, - const std::string& group_id); - - ServerError OnExecute() override; - -private: - int32_t dimension_; - std::string group_id_; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class GetGroupTask : public BaseTask { -public: - static BaseTaskPtr Create(const std::string& group_id, int32_t& dimension); - -protected: - GetGroupTask(const std::string& group_id, int32_t& dimension); - - ServerError OnExecute() override; - - -private: - std::string group_id_; - int32_t& dimension_; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class DeleteGroupTask : public BaseTask { -public: - static BaseTaskPtr Create(const std::string& group_id); - -protected: - DeleteGroupTask(const std::string& group_id); - - ServerError OnExecute() override; - - -private: - std::string group_id_; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AddVectorTask : public BaseTask { -public: - static BaseTaskPtr Create(const std::string& group_id, - const VecTensor* tensor, - std::string& id); - - static BaseTaskPtr Create(const std::string& group_id, - const VecBinaryTensor* tensor, - std::string& id); - -protected: - AddVectorTask(const std::string& group_id, - const VecTensor* tensor, - std::string& id); - - AddVectorTask(const std::string& group_id, - const VecBinaryTensor* tensor, - std::string& id); - - uint64_t GetVecDimension() const; - const double* GetVecData() const; - std::string GetVecID() const; - const AttribMap& GetVecAttrib() const; - - ServerError OnExecute() override; - -private: - std::string group_id_; - const VecTensor* tensor_; - const VecBinaryTensor* bin_tensor_; - std::string& tensor_id_; -}; - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AddBatchVectorTask : public BaseTask { -public: - static BaseTaskPtr Create(const std::string& group_id, - const VecTensorList* tensor_list, - std::vector& ids); - - static BaseTaskPtr Create(const std::string& group_id, - const VecBinaryTensorList* tensor_list, - std::vector& ids); - -protected: - AddBatchVectorTask(const std::string& group_id, - const VecTensorList* tensor_list, - std::vector& ids); - - AddBatchVectorTask(const std::string& group_id, - const VecBinaryTensorList* tensor_list, - std::vector& ids); - - uint64_t GetVecListCount() const; - uint64_t GetVecDimension(uint64_t index) const; - const double* GetVecData(uint64_t index) const; - std::string GetVecID(uint64_t index) const; - const AttribMap& GetVecAttrib(uint64_t index) const; - - void ProcessIdMapping(engine::IDNumbers& vector_ids, - uint64_t from, uint64_t to, - std::vector& tensor_ids); - - ServerError OnExecute() override; - -private: - std::string group_id_; - const VecTensorList* tensor_list_; - const VecBinaryTensorList* bin_tensor_list_; - std::vector& tensor_ids_; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class SearchVectorTask : public BaseTask { -public: - static BaseTaskPtr Create(const std::string& group_id, - const int64_t top_k, - const VecTensorList* tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result); - - static BaseTaskPtr Create(const std::string& group_id, - const int64_t top_k, - const VecBinaryTensorList* bin_tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result); - -protected: - SearchVectorTask(const std::string& group_id, - const int64_t top_k, - const VecTensorList* tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result); - - SearchVectorTask(const std::string& group_id, - const int64_t top_k, - const VecBinaryTensorList* bin_tensor_list, - const VecSearchFilter& filter, - VecSearchResultList& result); - - ServerError GetTargetData(std::vector& data) const; - uint64_t GetTargetDimension() const; - uint64_t GetTargetCount() const; - - ServerError OnExecute() override; - -private: - std::string group_id_; - int64_t top_k_; - const VecTensorList* tensor_list_; - const VecBinaryTensorList* bin_tensor_list_; - const VecSearchFilter& filter_; - VecSearchResultList& result_; -}; - -} -} -} \ No newline at end of file diff --git a/cpp/src/thrift/gen-cpp/MegasearchService.cpp b/cpp/src/thrift/gen-cpp/MegasearchService.cpp new file mode 100644 index 0000000000..6947c5be8f --- /dev/null +++ b/cpp/src/thrift/gen-cpp/MegasearchService.cpp @@ -0,0 +1,3810 @@ +/** + * Autogenerated by Thrift Compiler (0.12.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "MegasearchService.h" + +namespace megasearch { namespace thrift { + + +MegasearchService_CreateTable_args::~MegasearchService_CreateTable_args() throw() { +} + + +uint32_t MegasearchService_CreateTable_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->param.read(iprot); + this->__isset.param = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_CreateTable_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_CreateTable_args"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += this->param.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTable_pargs::~MegasearchService_CreateTable_pargs() throw() { +} + + +uint32_t MegasearchService_CreateTable_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_CreateTable_pargs"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += (*(this->param)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTable_result::~MegasearchService_CreateTable_result() throw() { +} + + +uint32_t MegasearchService_CreateTable_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_CreateTable_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_CreateTable_result"); + + if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTable_presult::~MegasearchService_CreateTable_presult() throw() { +} + + +uint32_t MegasearchService_CreateTable_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_DeleteTable_args::~MegasearchService_DeleteTable_args() throw() { +} + + +uint32_t MegasearchService_DeleteTable_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->table_name); + this->__isset.table_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DeleteTable_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DeleteTable_args"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTable_pargs::~MegasearchService_DeleteTable_pargs() throw() { +} + + +uint32_t MegasearchService_DeleteTable_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DeleteTable_pargs"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->table_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTable_result::~MegasearchService_DeleteTable_result() throw() { +} + + +uint32_t MegasearchService_DeleteTable_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DeleteTable_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_DeleteTable_result"); + + if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTable_presult::~MegasearchService_DeleteTable_presult() throw() { +} + + +uint32_t MegasearchService_DeleteTable_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_CreateTablePartition_args::~MegasearchService_CreateTablePartition_args() throw() { +} + + +uint32_t MegasearchService_CreateTablePartition_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->param.read(iprot); + this->__isset.param = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_CreateTablePartition_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_CreateTablePartition_args"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += this->param.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTablePartition_pargs::~MegasearchService_CreateTablePartition_pargs() throw() { +} + + +uint32_t MegasearchService_CreateTablePartition_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_CreateTablePartition_pargs"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += (*(this->param)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTablePartition_result::~MegasearchService_CreateTablePartition_result() throw() { +} + + +uint32_t MegasearchService_CreateTablePartition_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_CreateTablePartition_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_CreateTablePartition_result"); + + if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_CreateTablePartition_presult::~MegasearchService_CreateTablePartition_presult() throw() { +} + + +uint32_t MegasearchService_CreateTablePartition_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_DeleteTablePartition_args::~MegasearchService_DeleteTablePartition_args() throw() { +} + + +uint32_t MegasearchService_DeleteTablePartition_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->param.read(iprot); + this->__isset.param = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DeleteTablePartition_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DeleteTablePartition_args"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += this->param.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTablePartition_pargs::~MegasearchService_DeleteTablePartition_pargs() throw() { +} + + +uint32_t MegasearchService_DeleteTablePartition_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DeleteTablePartition_pargs"); + + xfer += oprot->writeFieldBegin("param", ::apache::thrift::protocol::T_STRUCT, 2); + xfer += (*(this->param)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTablePartition_result::~MegasearchService_DeleteTablePartition_result() throw() { +} + + +uint32_t MegasearchService_DeleteTablePartition_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DeleteTablePartition_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_DeleteTablePartition_result"); + + if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DeleteTablePartition_presult::~MegasearchService_DeleteTablePartition_presult() throw() { +} + + +uint32_t MegasearchService_DeleteTablePartition_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_AddVector_args::~MegasearchService_AddVector_args() throw() { +} + + +uint32_t MegasearchService_AddVector_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->table_name); + this->__isset.table_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->record_array.clear(); + uint32_t _size113; + ::apache::thrift::protocol::TType _etype116; + xfer += iprot->readListBegin(_etype116, _size113); + this->record_array.resize(_size113); + uint32_t _i117; + for (_i117 = 0; _i117 < _size113; ++_i117) + { + xfer += this->record_array[_i117].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.record_array = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_AddVector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_AddVector_args"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("record_array", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->record_array.size())); + std::vector ::const_iterator _iter118; + for (_iter118 = this->record_array.begin(); _iter118 != this->record_array.end(); ++_iter118) + { + xfer += (*_iter118).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_AddVector_pargs::~MegasearchService_AddVector_pargs() throw() { +} + + +uint32_t MegasearchService_AddVector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_AddVector_pargs"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->table_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("record_array", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast((*(this->record_array)).size())); + std::vector ::const_iterator _iter119; + for (_iter119 = (*(this->record_array)).begin(); _iter119 != (*(this->record_array)).end(); ++_iter119) + { + xfer += (*_iter119).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_AddVector_result::~MegasearchService_AddVector_result() throw() { +} + + +uint32_t MegasearchService_AddVector_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size120; + ::apache::thrift::protocol::TType _etype123; + xfer += iprot->readListBegin(_etype123, _size120); + this->success.resize(_size120); + uint32_t _i124; + for (_i124 = 0; _i124 < _size120; ++_i124) + { + xfer += iprot->readI64(this->success[_i124]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_AddVector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_AddVector_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I64, static_cast(this->success.size())); + std::vector ::const_iterator _iter125; + for (_iter125 = this->success.begin(); _iter125 != this->success.end(); ++_iter125) + { + xfer += oprot->writeI64((*_iter125)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_AddVector_presult::~MegasearchService_AddVector_presult() throw() { +} + + +uint32_t MegasearchService_AddVector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size126; + ::apache::thrift::protocol::TType _etype129; + xfer += iprot->readListBegin(_etype129, _size126); + (*(this->success)).resize(_size126); + uint32_t _i130; + for (_i130 = 0; _i130 < _size126; ++_i130) + { + xfer += iprot->readI64((*(this->success))[_i130]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_SearchVector_args::~MegasearchService_SearchVector_args() throw() { +} + + +uint32_t MegasearchService_SearchVector_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->table_name); + this->__isset.table_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->query_record_array.clear(); + uint32_t _size131; + ::apache::thrift::protocol::TType _etype134; + xfer += iprot->readListBegin(_etype134, _size131); + this->query_record_array.resize(_size131); + uint32_t _i135; + for (_i135 = 0; _i135 < _size131; ++_i135) + { + xfer += this->query_record_array[_i135].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.query_record_array = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->topk); + this->__isset.topk = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_SearchVector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_SearchVector_args"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("query_record_array", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->query_record_array.size())); + std::vector ::const_iterator _iter136; + for (_iter136 = this->query_record_array.begin(); _iter136 != this->query_record_array.end(); ++_iter136) + { + xfer += (*_iter136).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("topk", ::apache::thrift::protocol::T_I64, 4); + xfer += oprot->writeI64(this->topk); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_SearchVector_pargs::~MegasearchService_SearchVector_pargs() throw() { +} + + +uint32_t MegasearchService_SearchVector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_SearchVector_pargs"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->table_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("query_record_array", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast((*(this->query_record_array)).size())); + std::vector ::const_iterator _iter137; + for (_iter137 = (*(this->query_record_array)).begin(); _iter137 != (*(this->query_record_array)).end(); ++_iter137) + { + xfer += (*_iter137).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("topk", ::apache::thrift::protocol::T_I64, 4); + xfer += oprot->writeI64((*(this->topk))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_SearchVector_result::~MegasearchService_SearchVector_result() throw() { +} + + +uint32_t MegasearchService_SearchVector_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size138; + ::apache::thrift::protocol::TType _etype141; + xfer += iprot->readListBegin(_etype141, _size138); + this->success.resize(_size138); + uint32_t _i142; + for (_i142 = 0; _i142 < _size138; ++_i142) + { + xfer += this->success[_i142].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_SearchVector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_SearchVector_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->success.size())); + std::vector ::const_iterator _iter143; + for (_iter143 = this->success.begin(); _iter143 != this->success.end(); ++_iter143) + { + xfer += (*_iter143).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_SearchVector_presult::~MegasearchService_SearchVector_presult() throw() { +} + + +uint32_t MegasearchService_SearchVector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size144; + ::apache::thrift::protocol::TType _etype147; + xfer += iprot->readListBegin(_etype147, _size144); + (*(this->success)).resize(_size144); + uint32_t _i148; + for (_i148 = 0; _i148 < _size144; ++_i148) + { + xfer += (*(this->success))[_i148].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_DescribeTable_args::~MegasearchService_DescribeTable_args() throw() { +} + + +uint32_t MegasearchService_DescribeTable_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->table_name); + this->__isset.table_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DescribeTable_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DescribeTable_args"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DescribeTable_pargs::~MegasearchService_DescribeTable_pargs() throw() { +} + + +uint32_t MegasearchService_DescribeTable_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_DescribeTable_pargs"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->table_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DescribeTable_result::~MegasearchService_DescribeTable_result() throw() { +} + + +uint32_t MegasearchService_DescribeTable_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->success.read(iprot); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_DescribeTable_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_DescribeTable_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); + xfer += this->success.write(oprot); + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_DescribeTable_presult::~MegasearchService_DescribeTable_presult() throw() { +} + + +uint32_t MegasearchService_DescribeTable_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += (*(this->success)).read(iprot); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_ShowTables_args::~MegasearchService_ShowTables_args() throw() { +} + + +uint32_t MegasearchService_ShowTables_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + xfer += iprot->skip(ftype); + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_ShowTables_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_ShowTables_args"); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_ShowTables_pargs::~MegasearchService_ShowTables_pargs() throw() { +} + + +uint32_t MegasearchService_ShowTables_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_ShowTables_pargs"); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_ShowTables_result::~MegasearchService_ShowTables_result() throw() { +} + + +uint32_t MegasearchService_ShowTables_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size149; + ::apache::thrift::protocol::TType _etype152; + xfer += iprot->readListBegin(_etype152, _size149); + this->success.resize(_size149); + uint32_t _i153; + for (_i153 = 0; _i153 < _size149; ++_i153) + { + xfer += iprot->readString(this->success[_i153]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_ShowTables_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_ShowTables_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->success.size())); + std::vector ::const_iterator _iter154; + for (_iter154 = this->success.begin(); _iter154 != this->success.end(); ++_iter154) + { + xfer += oprot->writeString((*_iter154)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_ShowTables_presult::~MegasearchService_ShowTables_presult() throw() { +} + + +uint32_t MegasearchService_ShowTables_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size155; + ::apache::thrift::protocol::TType _etype158; + xfer += iprot->readListBegin(_etype158, _size155); + (*(this->success)).resize(_size155); + uint32_t _i159; + for (_i159 = 0; _i159 < _size155; ++_i159) + { + xfer += iprot->readString((*(this->success))[_i159]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + +MegasearchService_Ping_args::~MegasearchService_Ping_args() throw() { +} + + +uint32_t MegasearchService_Ping_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->cmd); + this->__isset.cmd = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_Ping_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_Ping_args"); + + xfer += oprot->writeFieldBegin("cmd", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->cmd); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_Ping_pargs::~MegasearchService_Ping_pargs() throw() { +} + + +uint32_t MegasearchService_Ping_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MegasearchService_Ping_pargs"); + + xfer += oprot->writeFieldBegin("cmd", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->cmd))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_Ping_result::~MegasearchService_Ping_result() throw() { +} + + +uint32_t MegasearchService_Ping_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->success); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MegasearchService_Ping_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MegasearchService_Ping_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRING, 0); + xfer += oprot->writeString(this->success); + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MegasearchService_Ping_presult::~MegasearchService_Ping_presult() throw() { +} + + +uint32_t MegasearchService_Ping_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString((*(this->success))); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +void MegasearchServiceClient::CreateTable(const TableSchema& param) +{ + send_CreateTable(param); + recv_CreateTable(); +} + +void MegasearchServiceClient::send_CreateTable(const TableSchema& param) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("CreateTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_CreateTable_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_CreateTable() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("CreateTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_CreateTable_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + throw result.e; + } + return; +} + +void MegasearchServiceClient::DeleteTable(const std::string& table_name) +{ + send_DeleteTable(table_name); + recv_DeleteTable(); +} + +void MegasearchServiceClient::send_DeleteTable(const std::string& table_name) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("DeleteTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DeleteTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_DeleteTable() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DeleteTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_DeleteTable_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + throw result.e; + } + return; +} + +void MegasearchServiceClient::CreateTablePartition(const CreateTablePartitionParam& param) +{ + send_CreateTablePartition(param); + recv_CreateTablePartition(); +} + +void MegasearchServiceClient::send_CreateTablePartition(const CreateTablePartitionParam& param) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("CreateTablePartition", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_CreateTablePartition_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_CreateTablePartition() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("CreateTablePartition") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_CreateTablePartition_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + throw result.e; + } + return; +} + +void MegasearchServiceClient::DeleteTablePartition(const DeleteTablePartitionParam& param) +{ + send_DeleteTablePartition(param); + recv_DeleteTablePartition(); +} + +void MegasearchServiceClient::send_DeleteTablePartition(const DeleteTablePartitionParam& param) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("DeleteTablePartition", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DeleteTablePartition_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_DeleteTablePartition() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DeleteTablePartition") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_DeleteTablePartition_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + throw result.e; + } + return; +} + +void MegasearchServiceClient::AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array) +{ + send_AddVector(table_name, record_array); + recv_AddVector(_return); +} + +void MegasearchServiceClient::send_AddVector(const std::string& table_name, const std::vector & record_array) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("AddVector", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_AddVector_pargs args; + args.table_name = &table_name; + args.record_array = &record_array; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_AddVector(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("AddVector") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_AddVector_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "AddVector failed: unknown result"); +} + +void MegasearchServiceClient::SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk) +{ + send_SearchVector(table_name, query_record_array, topk); + recv_SearchVector(_return); +} + +void MegasearchServiceClient::send_SearchVector(const std::string& table_name, const std::vector & query_record_array, const int64_t topk) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("SearchVector", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_SearchVector_pargs args; + args.table_name = &table_name; + args.query_record_array = &query_record_array; + args.topk = &topk; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_SearchVector(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("SearchVector") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_SearchVector_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "SearchVector failed: unknown result"); +} + +void MegasearchServiceClient::DescribeTable(TableSchema& _return, const std::string& table_name) +{ + send_DescribeTable(table_name); + recv_DescribeTable(_return); +} + +void MegasearchServiceClient::send_DescribeTable(const std::string& table_name) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("DescribeTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DescribeTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_DescribeTable(TableSchema& _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DescribeTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_DescribeTable_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "DescribeTable failed: unknown result"); +} + +void MegasearchServiceClient::ShowTables(std::vector & _return) +{ + send_ShowTables(); + recv_ShowTables(_return); +} + +void MegasearchServiceClient::send_ShowTables() +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("ShowTables", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_ShowTables_pargs args; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_ShowTables(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("ShowTables") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_ShowTables_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "ShowTables failed: unknown result"); +} + +void MegasearchServiceClient::Ping(std::string& _return, const std::string& cmd) +{ + send_Ping(cmd); + recv_Ping(_return); +} + +void MegasearchServiceClient::send_Ping(const std::string& cmd) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("Ping", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_Ping_pargs args; + args.cmd = &cmd; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void MegasearchServiceClient::recv_Ping(std::string& _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("Ping") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + MegasearchService_Ping_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "Ping failed: unknown result"); +} + +bool MegasearchServiceProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { + ProcessMap::iterator pfn; + pfn = processMap_.find(fname); + if (pfn == processMap_.end()) { + iprot->skip(::apache::thrift::protocol::T_STRUCT); + iprot->readMessageEnd(); + iprot->getTransport()->readEnd(); + ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); + oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return true; + } + (this->*(pfn->second))(seqid, iprot, oprot, callContext); + return true; +} + +void MegasearchServiceProcessor::process_CreateTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.CreateTable", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.CreateTable"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.CreateTable"); + } + + MegasearchService_CreateTable_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.CreateTable", bytes); + } + + MegasearchService_CreateTable_result result; + try { + iface_->CreateTable(args.param); + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.CreateTable"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("CreateTable", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.CreateTable"); + } + + oprot->writeMessageBegin("CreateTable", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.CreateTable", bytes); + } +} + +void MegasearchServiceProcessor::process_DeleteTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.DeleteTable", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.DeleteTable"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.DeleteTable"); + } + + MegasearchService_DeleteTable_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.DeleteTable", bytes); + } + + MegasearchService_DeleteTable_result result; + try { + iface_->DeleteTable(args.table_name); + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.DeleteTable"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("DeleteTable", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.DeleteTable"); + } + + oprot->writeMessageBegin("DeleteTable", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.DeleteTable", bytes); + } +} + +void MegasearchServiceProcessor::process_CreateTablePartition(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.CreateTablePartition", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.CreateTablePartition"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.CreateTablePartition"); + } + + MegasearchService_CreateTablePartition_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.CreateTablePartition", bytes); + } + + MegasearchService_CreateTablePartition_result result; + try { + iface_->CreateTablePartition(args.param); + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.CreateTablePartition"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("CreateTablePartition", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.CreateTablePartition"); + } + + oprot->writeMessageBegin("CreateTablePartition", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.CreateTablePartition", bytes); + } +} + +void MegasearchServiceProcessor::process_DeleteTablePartition(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.DeleteTablePartition", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.DeleteTablePartition"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.DeleteTablePartition"); + } + + MegasearchService_DeleteTablePartition_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.DeleteTablePartition", bytes); + } + + MegasearchService_DeleteTablePartition_result result; + try { + iface_->DeleteTablePartition(args.param); + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.DeleteTablePartition"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("DeleteTablePartition", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.DeleteTablePartition"); + } + + oprot->writeMessageBegin("DeleteTablePartition", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.DeleteTablePartition", bytes); + } +} + +void MegasearchServiceProcessor::process_AddVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.AddVector", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.AddVector"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.AddVector"); + } + + MegasearchService_AddVector_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.AddVector", bytes); + } + + MegasearchService_AddVector_result result; + try { + iface_->AddVector(result.success, args.table_name, args.record_array); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.AddVector"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("AddVector", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.AddVector"); + } + + oprot->writeMessageBegin("AddVector", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.AddVector", bytes); + } +} + +void MegasearchServiceProcessor::process_SearchVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.SearchVector", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.SearchVector"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.SearchVector"); + } + + MegasearchService_SearchVector_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.SearchVector", bytes); + } + + MegasearchService_SearchVector_result result; + try { + iface_->SearchVector(result.success, args.table_name, args.query_record_array, args.topk); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.SearchVector"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("SearchVector", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.SearchVector"); + } + + oprot->writeMessageBegin("SearchVector", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.SearchVector", bytes); + } +} + +void MegasearchServiceProcessor::process_DescribeTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.DescribeTable", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.DescribeTable"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.DescribeTable"); + } + + MegasearchService_DescribeTable_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.DescribeTable", bytes); + } + + MegasearchService_DescribeTable_result result; + try { + iface_->DescribeTable(result.success, args.table_name); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.DescribeTable"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("DescribeTable", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.DescribeTable"); + } + + oprot->writeMessageBegin("DescribeTable", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.DescribeTable", bytes); + } +} + +void MegasearchServiceProcessor::process_ShowTables(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.ShowTables", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.ShowTables"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.ShowTables"); + } + + MegasearchService_ShowTables_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.ShowTables", bytes); + } + + MegasearchService_ShowTables_result result; + try { + iface_->ShowTables(result.success); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.ShowTables"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("ShowTables", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.ShowTables"); + } + + oprot->writeMessageBegin("ShowTables", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.ShowTables", bytes); + } +} + +void MegasearchServiceProcessor::process_Ping(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MegasearchService.Ping", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MegasearchService.Ping"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MegasearchService.Ping"); + } + + MegasearchService_Ping_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MegasearchService.Ping", bytes); + } + + MegasearchService_Ping_result result; + try { + iface_->Ping(result.success, args.cmd); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MegasearchService.Ping"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("Ping", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MegasearchService.Ping"); + } + + oprot->writeMessageBegin("Ping", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MegasearchService.Ping", bytes); + } +} + +::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > MegasearchServiceProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { + ::apache::thrift::ReleaseHandler< MegasearchServiceIfFactory > cleanup(handlerFactory_); + ::apache::thrift::stdcxx::shared_ptr< MegasearchServiceIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > processor(new MegasearchServiceProcessor(handler)); + return processor; +} + +void MegasearchServiceConcurrentClient::CreateTable(const TableSchema& param) +{ + int32_t seqid = send_CreateTable(param); + recv_CreateTable(seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_CreateTable(const TableSchema& param) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("CreateTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_CreateTable_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_CreateTable(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("CreateTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_CreateTable_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + sentry.commit(); + return; + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::DeleteTable(const std::string& table_name) +{ + int32_t seqid = send_DeleteTable(table_name); + recv_DeleteTable(seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_DeleteTable(const std::string& table_name) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("DeleteTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DeleteTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_DeleteTable(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DeleteTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_DeleteTable_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + sentry.commit(); + return; + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::CreateTablePartition(const CreateTablePartitionParam& param) +{ + int32_t seqid = send_CreateTablePartition(param); + recv_CreateTablePartition(seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_CreateTablePartition(const CreateTablePartitionParam& param) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("CreateTablePartition", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_CreateTablePartition_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_CreateTablePartition(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("CreateTablePartition") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_CreateTablePartition_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + sentry.commit(); + return; + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::DeleteTablePartition(const DeleteTablePartitionParam& param) +{ + int32_t seqid = send_DeleteTablePartition(param); + recv_DeleteTablePartition(seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_DeleteTablePartition(const DeleteTablePartitionParam& param) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("DeleteTablePartition", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DeleteTablePartition_pargs args; + args.param = ¶m; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_DeleteTablePartition(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DeleteTablePartition") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_DeleteTablePartition_presult result; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + sentry.commit(); + return; + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array) +{ + int32_t seqid = send_AddVector(table_name, record_array); + recv_AddVector(_return, seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_AddVector(const std::string& table_name, const std::vector & record_array) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("AddVector", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_AddVector_pargs args; + args.table_name = &table_name; + args.record_array = &record_array; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_AddVector(std::vector & _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("AddVector") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_AddVector_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "AddVector failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk) +{ + int32_t seqid = send_SearchVector(table_name, query_record_array, topk); + recv_SearchVector(_return, seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_SearchVector(const std::string& table_name, const std::vector & query_record_array, const int64_t topk) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("SearchVector", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_SearchVector_pargs args; + args.table_name = &table_name; + args.query_record_array = &query_record_array; + args.topk = &topk; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_SearchVector(std::vector & _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("SearchVector") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_SearchVector_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "SearchVector failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::DescribeTable(TableSchema& _return, const std::string& table_name) +{ + int32_t seqid = send_DescribeTable(table_name); + recv_DescribeTable(_return, seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_DescribeTable(const std::string& table_name) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("DescribeTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_DescribeTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_DescribeTable(TableSchema& _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("DescribeTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_DescribeTable_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "DescribeTable failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::ShowTables(std::vector & _return) +{ + int32_t seqid = send_ShowTables(); + recv_ShowTables(_return, seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_ShowTables() +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("ShowTables", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_ShowTables_pargs args; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_ShowTables(std::vector & _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("ShowTables") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_ShowTables_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "ShowTables failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +void MegasearchServiceConcurrentClient::Ping(std::string& _return, const std::string& cmd) +{ + int32_t seqid = send_Ping(cmd); + recv_Ping(_return, seqid); +} + +int32_t MegasearchServiceConcurrentClient::send_Ping(const std::string& cmd) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("Ping", ::apache::thrift::protocol::T_CALL, cseqid); + + MegasearchService_Ping_pargs args; + args.cmd = &cmd; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void MegasearchServiceConcurrentClient::recv_Ping(std::string& _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("Ping") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + MegasearchService_Ping_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "Ping failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + +}} // namespace + diff --git a/cpp/src/thrift/gen-cpp/MegasearchService.h b/cpp/src/thrift/gen-cpp/MegasearchService.h new file mode 100644 index 0000000000..50e773970a --- /dev/null +++ b/cpp/src/thrift/gen-cpp/MegasearchService.h @@ -0,0 +1,1454 @@ +/** + * Autogenerated by Thrift Compiler (0.12.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef MegasearchService_H +#define MegasearchService_H + +#include +#include +#include "megasearch_types.h" + +namespace megasearch { namespace thrift { + +#ifdef _MSC_VER + #pragma warning( push ) + #pragma warning (disable : 4250 ) //inheriting methods via dominance +#endif + +class MegasearchServiceIf { + public: + virtual ~MegasearchServiceIf() {} + + /** + * @brief Create table method + * + * This method is used to create table + * + * @param param, use to provide table information to be created. + * + * + * @param param + */ + virtual void CreateTable(const TableSchema& param) = 0; + + /** + * @brief Delete table method + * + * This method is used to delete table. + * + * @param table_name, table name is going to be deleted. + * + * + * @param table_name + */ + virtual void DeleteTable(const std::string& table_name) = 0; + + /** + * @brief Create table partition + * + * This method is used to create table partition. + * + * @param param, use to provide partition information to be created. + * + * + * @param param + */ + virtual void CreateTablePartition(const CreateTablePartitionParam& param) = 0; + + /** + * @brief Delete table partition + * + * This method is used to delete table partition. + * + * @param param, use to provide partition information to be deleted. + * + * + * @param param + */ + virtual void DeleteTablePartition(const DeleteTablePartitionParam& param) = 0; + + /** + * @brief Add vector array to table + * + * This method is used to add vector array to table. + * + * @param table_name, table_name is inserted. + * @param record_array, vector array is inserted. + * + * @return vector id array + * + * @param table_name + * @param record_array + */ + virtual void AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array) = 0; + + /** + * @brief Query vector + * + * This method is used to query vector in table. + * + * @param table_name, table_name is queried. + * @param query_record_array, all vector are going to be queried. + * @param topk, how many similarity vectors will be searched. + * + * @return query result array. + * + * @param table_name + * @param query_record_array + * @param topk + */ + virtual void SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk) = 0; + + /** + * @brief Show table information + * + * This method is used to show table information. + * + * @param table_name, which table is show. + * + * @return table schema + * + * @param table_name + */ + virtual void DescribeTable(TableSchema& _return, const std::string& table_name) = 0; + + /** + * @brief List all tables in database + * + * This method is used to list all tables. + * + * + * @return table names. + */ + virtual void ShowTables(std::vector & _return) = 0; + + /** + * @brief Give the server status + * + * This method is used to give the server status. + * + * @return Server status. + * + * @param cmd + */ + virtual void Ping(std::string& _return, const std::string& cmd) = 0; +}; + +class MegasearchServiceIfFactory { + public: + typedef MegasearchServiceIf Handler; + + virtual ~MegasearchServiceIfFactory() {} + + virtual MegasearchServiceIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0; + virtual void releaseHandler(MegasearchServiceIf* /* handler */) = 0; +}; + +class MegasearchServiceIfSingletonFactory : virtual public MegasearchServiceIfFactory { + public: + MegasearchServiceIfSingletonFactory(const ::apache::thrift::stdcxx::shared_ptr& iface) : iface_(iface) {} + virtual ~MegasearchServiceIfSingletonFactory() {} + + virtual MegasearchServiceIf* getHandler(const ::apache::thrift::TConnectionInfo&) { + return iface_.get(); + } + virtual void releaseHandler(MegasearchServiceIf* /* handler */) {} + + protected: + ::apache::thrift::stdcxx::shared_ptr iface_; +}; + +class MegasearchServiceNull : virtual public MegasearchServiceIf { + public: + virtual ~MegasearchServiceNull() {} + void CreateTable(const TableSchema& /* param */) { + return; + } + void DeleteTable(const std::string& /* table_name */) { + return; + } + void CreateTablePartition(const CreateTablePartitionParam& /* param */) { + return; + } + void DeleteTablePartition(const DeleteTablePartitionParam& /* param */) { + return; + } + void AddVector(std::vector & /* _return */, const std::string& /* table_name */, const std::vector & /* record_array */) { + return; + } + void SearchVector(std::vector & /* _return */, const std::string& /* table_name */, const std::vector & /* query_record_array */, const int64_t /* topk */) { + return; + } + void DescribeTable(TableSchema& /* _return */, const std::string& /* table_name */) { + return; + } + void ShowTables(std::vector & /* _return */) { + return; + } + void Ping(std::string& /* _return */, const std::string& /* cmd */) { + return; + } +}; + +typedef struct _MegasearchService_CreateTable_args__isset { + _MegasearchService_CreateTable_args__isset() : param(false) {} + bool param :1; +} _MegasearchService_CreateTable_args__isset; + +class MegasearchService_CreateTable_args { + public: + + MegasearchService_CreateTable_args(const MegasearchService_CreateTable_args&); + MegasearchService_CreateTable_args& operator=(const MegasearchService_CreateTable_args&); + MegasearchService_CreateTable_args() { + } + + virtual ~MegasearchService_CreateTable_args() throw(); + TableSchema param; + + _MegasearchService_CreateTable_args__isset __isset; + + void __set_param(const TableSchema& val); + + bool operator == (const MegasearchService_CreateTable_args & rhs) const + { + if (!(param == rhs.param)) + return false; + return true; + } + bool operator != (const MegasearchService_CreateTable_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_CreateTable_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_CreateTable_pargs { + public: + + + virtual ~MegasearchService_CreateTable_pargs() throw(); + const TableSchema* param; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_CreateTable_result__isset { + _MegasearchService_CreateTable_result__isset() : e(false) {} + bool e :1; +} _MegasearchService_CreateTable_result__isset; + +class MegasearchService_CreateTable_result { + public: + + MegasearchService_CreateTable_result(const MegasearchService_CreateTable_result&); + MegasearchService_CreateTable_result& operator=(const MegasearchService_CreateTable_result&); + MegasearchService_CreateTable_result() { + } + + virtual ~MegasearchService_CreateTable_result() throw(); + Exception e; + + _MegasearchService_CreateTable_result__isset __isset; + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_CreateTable_result & rhs) const + { + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_CreateTable_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_CreateTable_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_CreateTable_presult__isset { + _MegasearchService_CreateTable_presult__isset() : e(false) {} + bool e :1; +} _MegasearchService_CreateTable_presult__isset; + +class MegasearchService_CreateTable_presult { + public: + + + virtual ~MegasearchService_CreateTable_presult() throw(); + Exception e; + + _MegasearchService_CreateTable_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_DeleteTable_args__isset { + _MegasearchService_DeleteTable_args__isset() : table_name(false) {} + bool table_name :1; +} _MegasearchService_DeleteTable_args__isset; + +class MegasearchService_DeleteTable_args { + public: + + MegasearchService_DeleteTable_args(const MegasearchService_DeleteTable_args&); + MegasearchService_DeleteTable_args& operator=(const MegasearchService_DeleteTable_args&); + MegasearchService_DeleteTable_args() : table_name() { + } + + virtual ~MegasearchService_DeleteTable_args() throw(); + std::string table_name; + + _MegasearchService_DeleteTable_args__isset __isset; + + void __set_table_name(const std::string& val); + + bool operator == (const MegasearchService_DeleteTable_args & rhs) const + { + if (!(table_name == rhs.table_name)) + return false; + return true; + } + bool operator != (const MegasearchService_DeleteTable_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DeleteTable_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_DeleteTable_pargs { + public: + + + virtual ~MegasearchService_DeleteTable_pargs() throw(); + const std::string* table_name; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DeleteTable_result__isset { + _MegasearchService_DeleteTable_result__isset() : e(false) {} + bool e :1; +} _MegasearchService_DeleteTable_result__isset; + +class MegasearchService_DeleteTable_result { + public: + + MegasearchService_DeleteTable_result(const MegasearchService_DeleteTable_result&); + MegasearchService_DeleteTable_result& operator=(const MegasearchService_DeleteTable_result&); + MegasearchService_DeleteTable_result() { + } + + virtual ~MegasearchService_DeleteTable_result() throw(); + Exception e; + + _MegasearchService_DeleteTable_result__isset __isset; + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_DeleteTable_result & rhs) const + { + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_DeleteTable_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DeleteTable_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DeleteTable_presult__isset { + _MegasearchService_DeleteTable_presult__isset() : e(false) {} + bool e :1; +} _MegasearchService_DeleteTable_presult__isset; + +class MegasearchService_DeleteTable_presult { + public: + + + virtual ~MegasearchService_DeleteTable_presult() throw(); + Exception e; + + _MegasearchService_DeleteTable_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_CreateTablePartition_args__isset { + _MegasearchService_CreateTablePartition_args__isset() : param(false) {} + bool param :1; +} _MegasearchService_CreateTablePartition_args__isset; + +class MegasearchService_CreateTablePartition_args { + public: + + MegasearchService_CreateTablePartition_args(const MegasearchService_CreateTablePartition_args&); + MegasearchService_CreateTablePartition_args& operator=(const MegasearchService_CreateTablePartition_args&); + MegasearchService_CreateTablePartition_args() { + } + + virtual ~MegasearchService_CreateTablePartition_args() throw(); + CreateTablePartitionParam param; + + _MegasearchService_CreateTablePartition_args__isset __isset; + + void __set_param(const CreateTablePartitionParam& val); + + bool operator == (const MegasearchService_CreateTablePartition_args & rhs) const + { + if (!(param == rhs.param)) + return false; + return true; + } + bool operator != (const MegasearchService_CreateTablePartition_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_CreateTablePartition_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_CreateTablePartition_pargs { + public: + + + virtual ~MegasearchService_CreateTablePartition_pargs() throw(); + const CreateTablePartitionParam* param; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_CreateTablePartition_result__isset { + _MegasearchService_CreateTablePartition_result__isset() : e(false) {} + bool e :1; +} _MegasearchService_CreateTablePartition_result__isset; + +class MegasearchService_CreateTablePartition_result { + public: + + MegasearchService_CreateTablePartition_result(const MegasearchService_CreateTablePartition_result&); + MegasearchService_CreateTablePartition_result& operator=(const MegasearchService_CreateTablePartition_result&); + MegasearchService_CreateTablePartition_result() { + } + + virtual ~MegasearchService_CreateTablePartition_result() throw(); + Exception e; + + _MegasearchService_CreateTablePartition_result__isset __isset; + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_CreateTablePartition_result & rhs) const + { + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_CreateTablePartition_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_CreateTablePartition_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_CreateTablePartition_presult__isset { + _MegasearchService_CreateTablePartition_presult__isset() : e(false) {} + bool e :1; +} _MegasearchService_CreateTablePartition_presult__isset; + +class MegasearchService_CreateTablePartition_presult { + public: + + + virtual ~MegasearchService_CreateTablePartition_presult() throw(); + Exception e; + + _MegasearchService_CreateTablePartition_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_DeleteTablePartition_args__isset { + _MegasearchService_DeleteTablePartition_args__isset() : param(false) {} + bool param :1; +} _MegasearchService_DeleteTablePartition_args__isset; + +class MegasearchService_DeleteTablePartition_args { + public: + + MegasearchService_DeleteTablePartition_args(const MegasearchService_DeleteTablePartition_args&); + MegasearchService_DeleteTablePartition_args& operator=(const MegasearchService_DeleteTablePartition_args&); + MegasearchService_DeleteTablePartition_args() { + } + + virtual ~MegasearchService_DeleteTablePartition_args() throw(); + DeleteTablePartitionParam param; + + _MegasearchService_DeleteTablePartition_args__isset __isset; + + void __set_param(const DeleteTablePartitionParam& val); + + bool operator == (const MegasearchService_DeleteTablePartition_args & rhs) const + { + if (!(param == rhs.param)) + return false; + return true; + } + bool operator != (const MegasearchService_DeleteTablePartition_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DeleteTablePartition_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_DeleteTablePartition_pargs { + public: + + + virtual ~MegasearchService_DeleteTablePartition_pargs() throw(); + const DeleteTablePartitionParam* param; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DeleteTablePartition_result__isset { + _MegasearchService_DeleteTablePartition_result__isset() : e(false) {} + bool e :1; +} _MegasearchService_DeleteTablePartition_result__isset; + +class MegasearchService_DeleteTablePartition_result { + public: + + MegasearchService_DeleteTablePartition_result(const MegasearchService_DeleteTablePartition_result&); + MegasearchService_DeleteTablePartition_result& operator=(const MegasearchService_DeleteTablePartition_result&); + MegasearchService_DeleteTablePartition_result() { + } + + virtual ~MegasearchService_DeleteTablePartition_result() throw(); + Exception e; + + _MegasearchService_DeleteTablePartition_result__isset __isset; + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_DeleteTablePartition_result & rhs) const + { + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_DeleteTablePartition_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DeleteTablePartition_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DeleteTablePartition_presult__isset { + _MegasearchService_DeleteTablePartition_presult__isset() : e(false) {} + bool e :1; +} _MegasearchService_DeleteTablePartition_presult__isset; + +class MegasearchService_DeleteTablePartition_presult { + public: + + + virtual ~MegasearchService_DeleteTablePartition_presult() throw(); + Exception e; + + _MegasearchService_DeleteTablePartition_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_AddVector_args__isset { + _MegasearchService_AddVector_args__isset() : table_name(false), record_array(false) {} + bool table_name :1; + bool record_array :1; +} _MegasearchService_AddVector_args__isset; + +class MegasearchService_AddVector_args { + public: + + MegasearchService_AddVector_args(const MegasearchService_AddVector_args&); + MegasearchService_AddVector_args& operator=(const MegasearchService_AddVector_args&); + MegasearchService_AddVector_args() : table_name() { + } + + virtual ~MegasearchService_AddVector_args() throw(); + std::string table_name; + std::vector record_array; + + _MegasearchService_AddVector_args__isset __isset; + + void __set_table_name(const std::string& val); + + void __set_record_array(const std::vector & val); + + bool operator == (const MegasearchService_AddVector_args & rhs) const + { + if (!(table_name == rhs.table_name)) + return false; + if (!(record_array == rhs.record_array)) + return false; + return true; + } + bool operator != (const MegasearchService_AddVector_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_AddVector_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_AddVector_pargs { + public: + + + virtual ~MegasearchService_AddVector_pargs() throw(); + const std::string* table_name; + const std::vector * record_array; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_AddVector_result__isset { + _MegasearchService_AddVector_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_AddVector_result__isset; + +class MegasearchService_AddVector_result { + public: + + MegasearchService_AddVector_result(const MegasearchService_AddVector_result&); + MegasearchService_AddVector_result& operator=(const MegasearchService_AddVector_result&); + MegasearchService_AddVector_result() { + } + + virtual ~MegasearchService_AddVector_result() throw(); + std::vector success; + Exception e; + + _MegasearchService_AddVector_result__isset __isset; + + void __set_success(const std::vector & val); + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_AddVector_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_AddVector_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_AddVector_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_AddVector_presult__isset { + _MegasearchService_AddVector_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_AddVector_presult__isset; + +class MegasearchService_AddVector_presult { + public: + + + virtual ~MegasearchService_AddVector_presult() throw(); + std::vector * success; + Exception e; + + _MegasearchService_AddVector_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_SearchVector_args__isset { + _MegasearchService_SearchVector_args__isset() : table_name(false), query_record_array(false), topk(false) {} + bool table_name :1; + bool query_record_array :1; + bool topk :1; +} _MegasearchService_SearchVector_args__isset; + +class MegasearchService_SearchVector_args { + public: + + MegasearchService_SearchVector_args(const MegasearchService_SearchVector_args&); + MegasearchService_SearchVector_args& operator=(const MegasearchService_SearchVector_args&); + MegasearchService_SearchVector_args() : table_name(), topk(0) { + } + + virtual ~MegasearchService_SearchVector_args() throw(); + std::string table_name; + std::vector query_record_array; + int64_t topk; + + _MegasearchService_SearchVector_args__isset __isset; + + void __set_table_name(const std::string& val); + + void __set_query_record_array(const std::vector & val); + + void __set_topk(const int64_t val); + + bool operator == (const MegasearchService_SearchVector_args & rhs) const + { + if (!(table_name == rhs.table_name)) + return false; + if (!(query_record_array == rhs.query_record_array)) + return false; + if (!(topk == rhs.topk)) + return false; + return true; + } + bool operator != (const MegasearchService_SearchVector_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_SearchVector_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_SearchVector_pargs { + public: + + + virtual ~MegasearchService_SearchVector_pargs() throw(); + const std::string* table_name; + const std::vector * query_record_array; + const int64_t* topk; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_SearchVector_result__isset { + _MegasearchService_SearchVector_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_SearchVector_result__isset; + +class MegasearchService_SearchVector_result { + public: + + MegasearchService_SearchVector_result(const MegasearchService_SearchVector_result&); + MegasearchService_SearchVector_result& operator=(const MegasearchService_SearchVector_result&); + MegasearchService_SearchVector_result() { + } + + virtual ~MegasearchService_SearchVector_result() throw(); + std::vector success; + Exception e; + + _MegasearchService_SearchVector_result__isset __isset; + + void __set_success(const std::vector & val); + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_SearchVector_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_SearchVector_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_SearchVector_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_SearchVector_presult__isset { + _MegasearchService_SearchVector_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_SearchVector_presult__isset; + +class MegasearchService_SearchVector_presult { + public: + + + virtual ~MegasearchService_SearchVector_presult() throw(); + std::vector * success; + Exception e; + + _MegasearchService_SearchVector_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_DescribeTable_args__isset { + _MegasearchService_DescribeTable_args__isset() : table_name(false) {} + bool table_name :1; +} _MegasearchService_DescribeTable_args__isset; + +class MegasearchService_DescribeTable_args { + public: + + MegasearchService_DescribeTable_args(const MegasearchService_DescribeTable_args&); + MegasearchService_DescribeTable_args& operator=(const MegasearchService_DescribeTable_args&); + MegasearchService_DescribeTable_args() : table_name() { + } + + virtual ~MegasearchService_DescribeTable_args() throw(); + std::string table_name; + + _MegasearchService_DescribeTable_args__isset __isset; + + void __set_table_name(const std::string& val); + + bool operator == (const MegasearchService_DescribeTable_args & rhs) const + { + if (!(table_name == rhs.table_name)) + return false; + return true; + } + bool operator != (const MegasearchService_DescribeTable_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DescribeTable_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_DescribeTable_pargs { + public: + + + virtual ~MegasearchService_DescribeTable_pargs() throw(); + const std::string* table_name; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DescribeTable_result__isset { + _MegasearchService_DescribeTable_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_DescribeTable_result__isset; + +class MegasearchService_DescribeTable_result { + public: + + MegasearchService_DescribeTable_result(const MegasearchService_DescribeTable_result&); + MegasearchService_DescribeTable_result& operator=(const MegasearchService_DescribeTable_result&); + MegasearchService_DescribeTable_result() { + } + + virtual ~MegasearchService_DescribeTable_result() throw(); + TableSchema success; + Exception e; + + _MegasearchService_DescribeTable_result__isset __isset; + + void __set_success(const TableSchema& val); + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_DescribeTable_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_DescribeTable_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_DescribeTable_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_DescribeTable_presult__isset { + _MegasearchService_DescribeTable_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_DescribeTable_presult__isset; + +class MegasearchService_DescribeTable_presult { + public: + + + virtual ~MegasearchService_DescribeTable_presult() throw(); + TableSchema* success; + Exception e; + + _MegasearchService_DescribeTable_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + + +class MegasearchService_ShowTables_args { + public: + + MegasearchService_ShowTables_args(const MegasearchService_ShowTables_args&); + MegasearchService_ShowTables_args& operator=(const MegasearchService_ShowTables_args&); + MegasearchService_ShowTables_args() { + } + + virtual ~MegasearchService_ShowTables_args() throw(); + + bool operator == (const MegasearchService_ShowTables_args & /* rhs */) const + { + return true; + } + bool operator != (const MegasearchService_ShowTables_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_ShowTables_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_ShowTables_pargs { + public: + + + virtual ~MegasearchService_ShowTables_pargs() throw(); + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_ShowTables_result__isset { + _MegasearchService_ShowTables_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_ShowTables_result__isset; + +class MegasearchService_ShowTables_result { + public: + + MegasearchService_ShowTables_result(const MegasearchService_ShowTables_result&); + MegasearchService_ShowTables_result& operator=(const MegasearchService_ShowTables_result&); + MegasearchService_ShowTables_result() { + } + + virtual ~MegasearchService_ShowTables_result() throw(); + std::vector success; + Exception e; + + _MegasearchService_ShowTables_result__isset __isset; + + void __set_success(const std::vector & val); + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_ShowTables_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_ShowTables_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_ShowTables_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_ShowTables_presult__isset { + _MegasearchService_ShowTables_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_ShowTables_presult__isset; + +class MegasearchService_ShowTables_presult { + public: + + + virtual ~MegasearchService_ShowTables_presult() throw(); + std::vector * success; + Exception e; + + _MegasearchService_ShowTables_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +typedef struct _MegasearchService_Ping_args__isset { + _MegasearchService_Ping_args__isset() : cmd(false) {} + bool cmd :1; +} _MegasearchService_Ping_args__isset; + +class MegasearchService_Ping_args { + public: + + MegasearchService_Ping_args(const MegasearchService_Ping_args&); + MegasearchService_Ping_args& operator=(const MegasearchService_Ping_args&); + MegasearchService_Ping_args() : cmd() { + } + + virtual ~MegasearchService_Ping_args() throw(); + std::string cmd; + + _MegasearchService_Ping_args__isset __isset; + + void __set_cmd(const std::string& val); + + bool operator == (const MegasearchService_Ping_args & rhs) const + { + if (!(cmd == rhs.cmd)) + return false; + return true; + } + bool operator != (const MegasearchService_Ping_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_Ping_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MegasearchService_Ping_pargs { + public: + + + virtual ~MegasearchService_Ping_pargs() throw(); + const std::string* cmd; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_Ping_result__isset { + _MegasearchService_Ping_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_Ping_result__isset; + +class MegasearchService_Ping_result { + public: + + MegasearchService_Ping_result(const MegasearchService_Ping_result&); + MegasearchService_Ping_result& operator=(const MegasearchService_Ping_result&); + MegasearchService_Ping_result() : success() { + } + + virtual ~MegasearchService_Ping_result() throw(); + std::string success; + Exception e; + + _MegasearchService_Ping_result__isset __isset; + + void __set_success(const std::string& val); + + void __set_e(const Exception& val); + + bool operator == (const MegasearchService_Ping_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MegasearchService_Ping_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MegasearchService_Ping_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MegasearchService_Ping_presult__isset { + _MegasearchService_Ping_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MegasearchService_Ping_presult__isset; + +class MegasearchService_Ping_presult { + public: + + + virtual ~MegasearchService_Ping_presult() throw(); + std::string* success; + Exception e; + + _MegasearchService_Ping_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +class MegasearchServiceClient : virtual public MegasearchServiceIf { + public: + MegasearchServiceClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot); + } + MegasearchServiceClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + setProtocol(iprot,oprot); + } + private: + void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void CreateTable(const TableSchema& param); + void send_CreateTable(const TableSchema& param); + void recv_CreateTable(); + void DeleteTable(const std::string& table_name); + void send_DeleteTable(const std::string& table_name); + void recv_DeleteTable(); + void CreateTablePartition(const CreateTablePartitionParam& param); + void send_CreateTablePartition(const CreateTablePartitionParam& param); + void recv_CreateTablePartition(); + void DeleteTablePartition(const DeleteTablePartitionParam& param); + void send_DeleteTablePartition(const DeleteTablePartitionParam& param); + void recv_DeleteTablePartition(); + void AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array); + void send_AddVector(const std::string& table_name, const std::vector & record_array); + void recv_AddVector(std::vector & _return); + void SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk); + void send_SearchVector(const std::string& table_name, const std::vector & query_record_array, const int64_t topk); + void recv_SearchVector(std::vector & _return); + void DescribeTable(TableSchema& _return, const std::string& table_name); + void send_DescribeTable(const std::string& table_name); + void recv_DescribeTable(TableSchema& _return); + void ShowTables(std::vector & _return); + void send_ShowTables(); + void recv_ShowTables(std::vector & _return); + void Ping(std::string& _return, const std::string& cmd); + void send_Ping(const std::string& cmd); + void recv_Ping(std::string& _return); + protected: + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; +}; + +class MegasearchServiceProcessor : public ::apache::thrift::TDispatchProcessor { + protected: + ::apache::thrift::stdcxx::shared_ptr iface_; + virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); + private: + typedef void (MegasearchServiceProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); + typedef std::map ProcessMap; + ProcessMap processMap_; + void process_CreateTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_DeleteTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_CreateTablePartition(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_DeleteTablePartition(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_AddVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_SearchVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_DescribeTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_ShowTables(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_Ping(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + public: + MegasearchServiceProcessor(::apache::thrift::stdcxx::shared_ptr iface) : + iface_(iface) { + processMap_["CreateTable"] = &MegasearchServiceProcessor::process_CreateTable; + processMap_["DeleteTable"] = &MegasearchServiceProcessor::process_DeleteTable; + processMap_["CreateTablePartition"] = &MegasearchServiceProcessor::process_CreateTablePartition; + processMap_["DeleteTablePartition"] = &MegasearchServiceProcessor::process_DeleteTablePartition; + processMap_["AddVector"] = &MegasearchServiceProcessor::process_AddVector; + processMap_["SearchVector"] = &MegasearchServiceProcessor::process_SearchVector; + processMap_["DescribeTable"] = &MegasearchServiceProcessor::process_DescribeTable; + processMap_["ShowTables"] = &MegasearchServiceProcessor::process_ShowTables; + processMap_["Ping"] = &MegasearchServiceProcessor::process_Ping; + } + + virtual ~MegasearchServiceProcessor() {} +}; + +class MegasearchServiceProcessorFactory : public ::apache::thrift::TProcessorFactory { + public: + MegasearchServiceProcessorFactory(const ::apache::thrift::stdcxx::shared_ptr< MegasearchServiceIfFactory >& handlerFactory) : + handlerFactory_(handlerFactory) {} + + ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + + protected: + ::apache::thrift::stdcxx::shared_ptr< MegasearchServiceIfFactory > handlerFactory_; +}; + +class MegasearchServiceMultiface : virtual public MegasearchServiceIf { + public: + MegasearchServiceMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + } + virtual ~MegasearchServiceMultiface() {} + protected: + std::vector > ifaces_; + MegasearchServiceMultiface() {} + void add(::apache::thrift::stdcxx::shared_ptr iface) { + ifaces_.push_back(iface); + } + public: + void CreateTable(const TableSchema& param) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->CreateTable(param); + } + ifaces_[i]->CreateTable(param); + } + + void DeleteTable(const std::string& table_name) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->DeleteTable(table_name); + } + ifaces_[i]->DeleteTable(table_name); + } + + void CreateTablePartition(const CreateTablePartitionParam& param) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->CreateTablePartition(param); + } + ifaces_[i]->CreateTablePartition(param); + } + + void DeleteTablePartition(const DeleteTablePartitionParam& param) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->DeleteTablePartition(param); + } + ifaces_[i]->DeleteTablePartition(param); + } + + void AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->AddVector(_return, table_name, record_array); + } + ifaces_[i]->AddVector(_return, table_name, record_array); + return; + } + + void SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->SearchVector(_return, table_name, query_record_array, topk); + } + ifaces_[i]->SearchVector(_return, table_name, query_record_array, topk); + return; + } + + void DescribeTable(TableSchema& _return, const std::string& table_name) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->DescribeTable(_return, table_name); + } + ifaces_[i]->DescribeTable(_return, table_name); + return; + } + + void ShowTables(std::vector & _return) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->ShowTables(_return); + } + ifaces_[i]->ShowTables(_return); + return; + } + + void Ping(std::string& _return, const std::string& cmd) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->Ping(_return, cmd); + } + ifaces_[i]->Ping(_return, cmd); + return; + } + +}; + +// The 'concurrent' client is a thread safe client that correctly handles +// out of order responses. It is slower than the regular client, so should +// only be used when you need to share a connection among multiple threads +class MegasearchServiceConcurrentClient : virtual public MegasearchServiceIf { + public: + MegasearchServiceConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot); + } + MegasearchServiceConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + setProtocol(iprot,oprot); + } + private: + void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void CreateTable(const TableSchema& param); + int32_t send_CreateTable(const TableSchema& param); + void recv_CreateTable(const int32_t seqid); + void DeleteTable(const std::string& table_name); + int32_t send_DeleteTable(const std::string& table_name); + void recv_DeleteTable(const int32_t seqid); + void CreateTablePartition(const CreateTablePartitionParam& param); + int32_t send_CreateTablePartition(const CreateTablePartitionParam& param); + void recv_CreateTablePartition(const int32_t seqid); + void DeleteTablePartition(const DeleteTablePartitionParam& param); + int32_t send_DeleteTablePartition(const DeleteTablePartitionParam& param); + void recv_DeleteTablePartition(const int32_t seqid); + void AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array); + int32_t send_AddVector(const std::string& table_name, const std::vector & record_array); + void recv_AddVector(std::vector & _return, const int32_t seqid); + void SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk); + int32_t send_SearchVector(const std::string& table_name, const std::vector & query_record_array, const int64_t topk); + void recv_SearchVector(std::vector & _return, const int32_t seqid); + void DescribeTable(TableSchema& _return, const std::string& table_name); + int32_t send_DescribeTable(const std::string& table_name); + void recv_DescribeTable(TableSchema& _return, const int32_t seqid); + void ShowTables(std::vector & _return); + int32_t send_ShowTables(); + void recv_ShowTables(std::vector & _return, const int32_t seqid); + void Ping(std::string& _return, const std::string& cmd); + int32_t send_Ping(const std::string& cmd); + void recv_Ping(std::string& _return, const int32_t seqid); + protected: + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; + ::apache::thrift::async::TConcurrentClientSyncInfo sync_; +}; + +#ifdef _MSC_VER + #pragma warning( pop ) +#endif + +}} // namespace + +#endif diff --git a/cpp/src/thrift/gen-cpp/MegasearchService_server.skeleton.cpp b/cpp/src/thrift/gen-cpp/MegasearchService_server.skeleton.cpp new file mode 100644 index 0000000000..f58e5556e7 --- /dev/null +++ b/cpp/src/thrift/gen-cpp/MegasearchService_server.skeleton.cpp @@ -0,0 +1,178 @@ +// This autogenerated skeleton file illustrates how to build a server. +// You should copy it to another filename to avoid overwriting it. + +#include "MegasearchService.h" +#include +#include +#include +#include + +using namespace ::apache::thrift; +using namespace ::apache::thrift::protocol; +using namespace ::apache::thrift::transport; +using namespace ::apache::thrift::server; + +using namespace ::megasearch::thrift; + +class MegasearchServiceHandler : virtual public MegasearchServiceIf { + public: + MegasearchServiceHandler() { + // Your initialization goes here + } + + /** + * @brief Create table method + * + * This method is used to create table + * + * @param param, use to provide table information to be created. + * + * + * @param param + */ + void CreateTable(const TableSchema& param) { + // Your implementation goes here + printf("CreateTable\n"); + } + + /** + * @brief Delete table method + * + * This method is used to delete table. + * + * @param table_name, table name is going to be deleted. + * + * + * @param table_name + */ + void DeleteTable(const std::string& table_name) { + // Your implementation goes here + printf("DeleteTable\n"); + } + + /** + * @brief Create table partition + * + * This method is used to create table partition. + * + * @param param, use to provide partition information to be created. + * + * + * @param param + */ + void CreateTablePartition(const CreateTablePartitionParam& param) { + // Your implementation goes here + printf("CreateTablePartition\n"); + } + + /** + * @brief Delete table partition + * + * This method is used to delete table partition. + * + * @param param, use to provide partition information to be deleted. + * + * + * @param param + */ + void DeleteTablePartition(const DeleteTablePartitionParam& param) { + // Your implementation goes here + printf("DeleteTablePartition\n"); + } + + /** + * @brief Add vector array to table + * + * This method is used to add vector array to table. + * + * @param table_name, table_name is inserted. + * @param record_array, vector array is inserted. + * + * @return vector id array + * + * @param table_name + * @param record_array + */ + void AddVector(std::vector & _return, const std::string& table_name, const std::vector & record_array) { + // Your implementation goes here + printf("AddVector\n"); + } + + /** + * @brief Query vector + * + * This method is used to query vector in table. + * + * @param table_name, table_name is queried. + * @param query_record_array, all vector are going to be queried. + * @param topk, how many similarity vectors will be searched. + * + * @return query result array. + * + * @param table_name + * @param query_record_array + * @param topk + */ + void SearchVector(std::vector & _return, const std::string& table_name, const std::vector & query_record_array, const int64_t topk) { + // Your implementation goes here + printf("SearchVector\n"); + } + + /** + * @brief Show table information + * + * This method is used to show table information. + * + * @param table_name, which table is show. + * + * @return table schema + * + * @param table_name + */ + void DescribeTable(TableSchema& _return, const std::string& table_name) { + // Your implementation goes here + printf("DescribeTable\n"); + } + + /** + * @brief List all tables in database + * + * This method is used to list all tables. + * + * + * @return table names. + */ + void ShowTables(std::vector & _return) { + // Your implementation goes here + printf("ShowTables\n"); + } + + /** + * @brief Give the server status + * + * This method is used to give the server status. + * + * @return Server status. + * + * @param cmd + */ + void Ping(std::string& _return, const std::string& cmd) { + // Your implementation goes here + printf("Ping\n"); + } + +}; + +int main(int argc, char **argv) { + int port = 9090; + ::apache::thrift::stdcxx::shared_ptr handler(new MegasearchServiceHandler()); + ::apache::thrift::stdcxx::shared_ptr processor(new MegasearchServiceProcessor(handler)); + ::apache::thrift::stdcxx::shared_ptr serverTransport(new TServerSocket(port)); + ::apache::thrift::stdcxx::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::apache::thrift::stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + + TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); + server.serve(); + return 0; +} + diff --git a/cpp/src/thrift/gen-cpp/VecService.cpp b/cpp/src/thrift/gen-cpp/VecService.cpp deleted file mode 100644 index c794959057..0000000000 --- a/cpp/src/thrift/gen-cpp/VecService.cpp +++ /dev/null @@ -1,4869 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.11.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#include "VecService.h" - -namespace megasearch { - - -VecService_add_group_args::~VecService_add_group_args() throw() { -} - - -uint32_t VecService_add_group_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->group.read(iprot); - this->__isset.group = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_group_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_group_args"); - - xfer += oprot->writeFieldBegin("group", ::apache::thrift::protocol::T_STRUCT, 2); - xfer += this->group.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_group_pargs::~VecService_add_group_pargs() throw() { -} - - -uint32_t VecService_add_group_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_group_pargs"); - - xfer += oprot->writeFieldBegin("group", ::apache::thrift::protocol::T_STRUCT, 2); - xfer += (*(this->group)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_group_result::~VecService_add_group_result() throw() { -} - - -uint32_t VecService_add_group_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_group_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_add_group_result"); - - if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_group_presult::~VecService_add_group_presult() throw() { -} - - -uint32_t VecService_add_group_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_get_group_args::~VecService_get_group_args() throw() { -} - - -uint32_t VecService_get_group_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_get_group_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_get_group_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_get_group_pargs::~VecService_get_group_pargs() throw() { -} - - -uint32_t VecService_get_group_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_get_group_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_get_group_result::~VecService_get_group_result() throw() { -} - - -uint32_t VecService_get_group_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->success.read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_get_group_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_get_group_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); - xfer += this->success.write(oprot); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_get_group_presult::~VecService_get_group_presult() throw() { -} - - -uint32_t VecService_get_group_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += (*(this->success)).read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_del_group_args::~VecService_del_group_args() throw() { -} - - -uint32_t VecService_del_group_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_del_group_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_del_group_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_del_group_pargs::~VecService_del_group_pargs() throw() { -} - - -uint32_t VecService_del_group_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_del_group_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_del_group_result::~VecService_del_group_result() throw() { -} - - -uint32_t VecService_del_group_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_del_group_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_del_group_result"); - - if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_del_group_presult::~VecService_del_group_presult() throw() { -} - - -uint32_t VecService_del_group_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_add_vector_args::~VecService_add_vector_args() throw() { -} - - -uint32_t VecService_add_vector_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor.read(iprot); - this->__isset.tensor = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_vector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_vector_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->tensor.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_pargs::~VecService_add_vector_pargs() throw() { -} - - -uint32_t VecService_add_vector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_vector_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += (*(this->tensor)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_result::~VecService_add_vector_result() throw() { -} - - -uint32_t VecService_add_vector_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->success); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_vector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_add_vector_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRING, 0); - xfer += oprot->writeString(this->success); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_presult::~VecService_add_vector_presult() throw() { -} - - -uint32_t VecService_add_vector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString((*(this->success))); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_add_vector_batch_args::~VecService_add_vector_batch_args() throw() { -} - - -uint32_t VecService_add_vector_batch_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor_list.read(iprot); - this->__isset.tensor_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_vector_batch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_vector_batch_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->tensor_list.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_batch_pargs::~VecService_add_vector_batch_pargs() throw() { -} - - -uint32_t VecService_add_vector_batch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_vector_batch_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += (*(this->tensor_list)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_batch_result::~VecService_add_vector_batch_result() throw() { -} - - -uint32_t VecService_add_vector_batch_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->success.clear(); - uint32_t _size99; - ::apache::thrift::protocol::TType _etype102; - xfer += iprot->readListBegin(_etype102, _size99); - this->success.resize(_size99); - uint32_t _i103; - for (_i103 = 0; _i103 < _size99; ++_i103) - { - xfer += iprot->readString(this->success[_i103]); - } - xfer += iprot->readListEnd(); - } - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_vector_batch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_add_vector_batch_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->success.size())); - std::vector ::const_iterator _iter104; - for (_iter104 = this->success.begin(); _iter104 != this->success.end(); ++_iter104) - { - xfer += oprot->writeString((*_iter104)); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_vector_batch_presult::~VecService_add_vector_batch_presult() throw() { -} - - -uint32_t VecService_add_vector_batch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - (*(this->success)).clear(); - uint32_t _size105; - ::apache::thrift::protocol::TType _etype108; - xfer += iprot->readListBegin(_etype108, _size105); - (*(this->success)).resize(_size105); - uint32_t _i109; - for (_i109 = 0; _i109 < _size105; ++_i109) - { - xfer += iprot->readString((*(this->success))[_i109]); - } - xfer += iprot->readListEnd(); - } - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_add_binary_vector_args::~VecService_add_binary_vector_args() throw() { -} - - -uint32_t VecService_add_binary_vector_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor.read(iprot); - this->__isset.tensor = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_binary_vector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_binary_vector_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->tensor.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_pargs::~VecService_add_binary_vector_pargs() throw() { -} - - -uint32_t VecService_add_binary_vector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_binary_vector_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += (*(this->tensor)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_result::~VecService_add_binary_vector_result() throw() { -} - - -uint32_t VecService_add_binary_vector_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->success); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_binary_vector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_add_binary_vector_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRING, 0); - xfer += oprot->writeString(this->success); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_presult::~VecService_add_binary_vector_presult() throw() { -} - - -uint32_t VecService_add_binary_vector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString((*(this->success))); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_add_binary_vector_batch_args::~VecService_add_binary_vector_batch_args() throw() { -} - - -uint32_t VecService_add_binary_vector_batch_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor_list.read(iprot); - this->__isset.tensor_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_binary_vector_batch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_binary_vector_batch_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->tensor_list.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_batch_pargs::~VecService_add_binary_vector_batch_pargs() throw() { -} - - -uint32_t VecService_add_binary_vector_batch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_add_binary_vector_batch_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += (*(this->tensor_list)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_batch_result::~VecService_add_binary_vector_batch_result() throw() { -} - - -uint32_t VecService_add_binary_vector_batch_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->success.clear(); - uint32_t _size110; - ::apache::thrift::protocol::TType _etype113; - xfer += iprot->readListBegin(_etype113, _size110); - this->success.resize(_size110); - uint32_t _i114; - for (_i114 = 0; _i114 < _size110; ++_i114) - { - xfer += iprot->readString(this->success[_i114]); - } - xfer += iprot->readListEnd(); - } - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_add_binary_vector_batch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_add_binary_vector_batch_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->success.size())); - std::vector ::const_iterator _iter115; - for (_iter115 = this->success.begin(); _iter115 != this->success.end(); ++_iter115) - { - xfer += oprot->writeString((*_iter115)); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_add_binary_vector_batch_presult::~VecService_add_binary_vector_batch_presult() throw() { -} - - -uint32_t VecService_add_binary_vector_batch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - (*(this->success)).clear(); - uint32_t _size116; - ::apache::thrift::protocol::TType _etype119; - xfer += iprot->readListBegin(_etype119, _size116); - (*(this->success)).resize(_size116); - uint32_t _i120; - for (_i120 = 0; _i120 < _size116; ++_i120) - { - xfer += iprot->readString((*(this->success))[_i120]); - } - xfer += iprot->readListEnd(); - } - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_search_vector_args::~VecService_search_vector_args() throw() { -} - - -uint32_t VecService_search_vector_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->top_k); - this->__isset.top_k = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor.read(iprot); - this->__isset.tensor = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->filter.read(iprot); - this->__isset.filter = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_vector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_vector_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64(this->top_k); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += this->tensor.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += this->filter.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_pargs::~VecService_search_vector_pargs() throw() { -} - - -uint32_t VecService_search_vector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_vector_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64((*(this->top_k))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += (*(this->tensor)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += (*(this->filter)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_result::~VecService_search_vector_result() throw() { -} - - -uint32_t VecService_search_vector_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->success.read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_vector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_search_vector_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); - xfer += this->success.write(oprot); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_presult::~VecService_search_vector_presult() throw() { -} - - -uint32_t VecService_search_vector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += (*(this->success)).read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_search_vector_batch_args::~VecService_search_vector_batch_args() throw() { -} - - -uint32_t VecService_search_vector_batch_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->top_k); - this->__isset.top_k = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor_list.read(iprot); - this->__isset.tensor_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->filter.read(iprot); - this->__isset.filter = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_vector_batch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_vector_batch_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64(this->top_k); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += this->tensor_list.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += this->filter.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_batch_pargs::~VecService_search_vector_batch_pargs() throw() { -} - - -uint32_t VecService_search_vector_batch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_vector_batch_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64((*(this->top_k))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += (*(this->tensor_list)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += (*(this->filter)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_batch_result::~VecService_search_vector_batch_result() throw() { -} - - -uint32_t VecService_search_vector_batch_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->success.read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_vector_batch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_search_vector_batch_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); - xfer += this->success.write(oprot); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_vector_batch_presult::~VecService_search_vector_batch_presult() throw() { -} - - -uint32_t VecService_search_vector_batch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += (*(this->success)).read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_search_binary_vector_args::~VecService_search_binary_vector_args() throw() { -} - - -uint32_t VecService_search_binary_vector_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->top_k); - this->__isset.top_k = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor.read(iprot); - this->__isset.tensor = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->filter.read(iprot); - this->__isset.filter = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_binary_vector_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_binary_vector_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64(this->top_k); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += this->tensor.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += this->filter.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_pargs::~VecService_search_binary_vector_pargs() throw() { -} - - -uint32_t VecService_search_binary_vector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_binary_vector_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64((*(this->top_k))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += (*(this->tensor)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += (*(this->filter)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_result::~VecService_search_binary_vector_result() throw() { -} - - -uint32_t VecService_search_binary_vector_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->success.read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_binary_vector_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_search_binary_vector_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); - xfer += this->success.write(oprot); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_presult::~VecService_search_binary_vector_presult() throw() { -} - - -uint32_t VecService_search_binary_vector_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += (*(this->success)).read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - - -VecService_search_binary_vector_batch_args::~VecService_search_binary_vector_batch_args() throw() { -} - - -uint32_t VecService_search_binary_vector_batch_args::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->group_id); - this->__isset.group_id = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->top_k); - this->__isset.top_k = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->tensor_list.read(iprot); - this->__isset.tensor_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->filter.read(iprot); - this->__isset.filter = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_binary_vector_batch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_binary_vector_batch_args"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->group_id); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64(this->top_k); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += this->tensor_list.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += this->filter.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_batch_pargs::~VecService_search_binary_vector_batch_pargs() throw() { -} - - -uint32_t VecService_search_binary_vector_batch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecService_search_binary_vector_batch_pargs"); - - xfer += oprot->writeFieldBegin("group_id", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString((*(this->group_id))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("top_k", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64((*(this->top_k))); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_STRUCT, 4); - xfer += (*(this->tensor_list)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5); - xfer += (*(this->filter)).write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_batch_result::~VecService_search_binary_vector_batch_result() throw() { -} - - -uint32_t VecService_search_binary_vector_batch_result::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->success.read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecService_search_binary_vector_batch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { - - uint32_t xfer = 0; - - xfer += oprot->writeStructBegin("VecService_search_binary_vector_batch_result"); - - if (this->__isset.success) { - xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0); - xfer += this->success.write(oprot); - xfer += oprot->writeFieldEnd(); - } else if (this->__isset.e) { - xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->e.write(oprot); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - - -VecService_search_binary_vector_batch_presult::~VecService_search_binary_vector_batch_presult() throw() { -} - - -uint32_t VecService_search_binary_vector_batch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 0: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += (*(this->success)).read(iprot); - this->__isset.success = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->e.read(iprot); - this->__isset.e = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -void VecServiceClient::add_group(const VecGroup& group) -{ - send_add_group(group); - recv_add_group(); -} - -void VecServiceClient::send_add_group(const VecGroup& group) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("add_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_group_pargs args; - args.group = &group; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_add_group() -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_add_group_presult result; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.e) { - throw result.e; - } - return; -} - -void VecServiceClient::get_group(VecGroup& _return, const std::string& group_id) -{ - send_get_group(group_id); - recv_get_group(_return); -} - -void VecServiceClient::send_get_group(const std::string& group_id) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("get_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_get_group_pargs args; - args.group_id = &group_id; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_get_group(VecGroup& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("get_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_get_group_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_group failed: unknown result"); -} - -void VecServiceClient::del_group(const std::string& group_id) -{ - send_del_group(group_id); - recv_del_group(); -} - -void VecServiceClient::send_del_group(const std::string& group_id) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("del_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_del_group_pargs args; - args.group_id = &group_id; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_del_group() -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("del_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_del_group_presult result; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.e) { - throw result.e; - } - return; -} - -void VecServiceClient::add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor) -{ - send_add_vector(group_id, tensor); - recv_add_vector(_return); -} - -void VecServiceClient::send_add_vector(const std::string& group_id, const VecTensor& tensor) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("add_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_vector_pargs args; - args.group_id = &group_id; - args.tensor = &tensor; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_add_vector(std::string& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_add_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_vector failed: unknown result"); -} - -void VecServiceClient::add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list) -{ - send_add_vector_batch(group_id, tensor_list); - recv_add_vector_batch(_return); -} - -void VecServiceClient::send_add_vector_batch(const std::string& group_id, const VecTensorList& tensor_list) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("add_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_vector_batch_pargs args; - args.group_id = &group_id; - args.tensor_list = &tensor_list; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_add_vector_batch(std::vector & _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_add_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_vector_batch failed: unknown result"); -} - -void VecServiceClient::add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor) -{ - send_add_binary_vector(group_id, tensor); - recv_add_binary_vector(_return); -} - -void VecServiceClient::send_add_binary_vector(const std::string& group_id, const VecBinaryTensor& tensor) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("add_binary_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_binary_vector_pargs args; - args.group_id = &group_id; - args.tensor = &tensor; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_add_binary_vector(std::string& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_binary_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_add_binary_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_binary_vector failed: unknown result"); -} - -void VecServiceClient::add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list) -{ - send_add_binary_vector_batch(group_id, tensor_list); - recv_add_binary_vector_batch(_return); -} - -void VecServiceClient::send_add_binary_vector_batch(const std::string& group_id, const VecBinaryTensorList& tensor_list) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("add_binary_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_binary_vector_batch_pargs args; - args.group_id = &group_id; - args.tensor_list = &tensor_list; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_add_binary_vector_batch(std::vector & _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_binary_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_add_binary_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_binary_vector_batch failed: unknown result"); -} - -void VecServiceClient::search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) -{ - send_search_vector(group_id, top_k, tensor, filter); - recv_search_vector(_return); -} - -void VecServiceClient::send_search_vector(const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("search_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_vector_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor = &tensor; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_search_vector(VecSearchResult& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_search_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_vector failed: unknown result"); -} - -void VecServiceClient::search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) -{ - send_search_vector_batch(group_id, top_k, tensor_list, filter); - recv_search_vector_batch(_return); -} - -void VecServiceClient::send_search_vector_batch(const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("search_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_vector_batch_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor_list = &tensor_list; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_search_vector_batch(VecSearchResultList& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_search_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_vector_batch failed: unknown result"); -} - -void VecServiceClient::search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) -{ - send_search_binary_vector(group_id, top_k, tensor, filter); - recv_search_binary_vector(_return); -} - -void VecServiceClient::send_search_binary_vector(const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("search_binary_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_binary_vector_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor = &tensor; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_search_binary_vector(VecSearchResult& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_binary_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_search_binary_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_binary_vector failed: unknown result"); -} - -void VecServiceClient::search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) -{ - send_search_binary_vector_batch(group_id, top_k, tensor_list, filter); - recv_search_binary_vector_batch(_return); -} - -void VecServiceClient::send_search_binary_vector_batch(const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t cseqid = 0; - oprot_->writeMessageBegin("search_binary_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_binary_vector_batch_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor_list = &tensor_list; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); -} - -void VecServiceClient::recv_search_binary_vector_batch(VecSearchResultList& _return) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - iprot_->readMessageBegin(fname, mtype, rseqid); - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_binary_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - VecService_search_binary_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - return; - } - if (result.__isset.e) { - throw result.e; - } - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_binary_vector_batch failed: unknown result"); -} - -bool VecServiceProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { - ProcessMap::iterator pfn; - pfn = processMap_.find(fname); - if (pfn == processMap_.end()) { - iprot->skip(::apache::thrift::protocol::T_STRUCT); - iprot->readMessageEnd(); - iprot->getTransport()->readEnd(); - ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); - oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return true; - } - (this->*(pfn->second))(seqid, iprot, oprot, callContext); - return true; -} - -void VecServiceProcessor::process_add_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.add_group", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.add_group"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.add_group"); - } - - VecService_add_group_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.add_group", bytes); - } - - VecService_add_group_result result; - try { - iface_->add_group(args.group); - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.add_group"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("add_group", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.add_group"); - } - - oprot->writeMessageBegin("add_group", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.add_group", bytes); - } -} - -void VecServiceProcessor::process_get_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.get_group", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.get_group"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.get_group"); - } - - VecService_get_group_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.get_group", bytes); - } - - VecService_get_group_result result; - try { - iface_->get_group(result.success, args.group_id); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.get_group"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("get_group", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.get_group"); - } - - oprot->writeMessageBegin("get_group", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.get_group", bytes); - } -} - -void VecServiceProcessor::process_del_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.del_group", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.del_group"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.del_group"); - } - - VecService_del_group_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.del_group", bytes); - } - - VecService_del_group_result result; - try { - iface_->del_group(args.group_id); - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.del_group"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("del_group", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.del_group"); - } - - oprot->writeMessageBegin("del_group", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.del_group", bytes); - } -} - -void VecServiceProcessor::process_add_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.add_vector", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.add_vector"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.add_vector"); - } - - VecService_add_vector_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.add_vector", bytes); - } - - VecService_add_vector_result result; - try { - iface_->add_vector(result.success, args.group_id, args.tensor); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.add_vector"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("add_vector", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.add_vector"); - } - - oprot->writeMessageBegin("add_vector", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.add_vector", bytes); - } -} - -void VecServiceProcessor::process_add_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.add_vector_batch", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.add_vector_batch"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.add_vector_batch"); - } - - VecService_add_vector_batch_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.add_vector_batch", bytes); - } - - VecService_add_vector_batch_result result; - try { - iface_->add_vector_batch(result.success, args.group_id, args.tensor_list); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.add_vector_batch"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("add_vector_batch", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.add_vector_batch"); - } - - oprot->writeMessageBegin("add_vector_batch", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.add_vector_batch", bytes); - } -} - -void VecServiceProcessor::process_add_binary_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.add_binary_vector", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.add_binary_vector"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.add_binary_vector"); - } - - VecService_add_binary_vector_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.add_binary_vector", bytes); - } - - VecService_add_binary_vector_result result; - try { - iface_->add_binary_vector(result.success, args.group_id, args.tensor); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.add_binary_vector"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("add_binary_vector", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.add_binary_vector"); - } - - oprot->writeMessageBegin("add_binary_vector", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.add_binary_vector", bytes); - } -} - -void VecServiceProcessor::process_add_binary_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.add_binary_vector_batch", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.add_binary_vector_batch"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.add_binary_vector_batch"); - } - - VecService_add_binary_vector_batch_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.add_binary_vector_batch", bytes); - } - - VecService_add_binary_vector_batch_result result; - try { - iface_->add_binary_vector_batch(result.success, args.group_id, args.tensor_list); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.add_binary_vector_batch"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("add_binary_vector_batch", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.add_binary_vector_batch"); - } - - oprot->writeMessageBegin("add_binary_vector_batch", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.add_binary_vector_batch", bytes); - } -} - -void VecServiceProcessor::process_search_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.search_vector", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.search_vector"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.search_vector"); - } - - VecService_search_vector_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.search_vector", bytes); - } - - VecService_search_vector_result result; - try { - iface_->search_vector(result.success, args.group_id, args.top_k, args.tensor, args.filter); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.search_vector"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("search_vector", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.search_vector"); - } - - oprot->writeMessageBegin("search_vector", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.search_vector", bytes); - } -} - -void VecServiceProcessor::process_search_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.search_vector_batch", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.search_vector_batch"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.search_vector_batch"); - } - - VecService_search_vector_batch_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.search_vector_batch", bytes); - } - - VecService_search_vector_batch_result result; - try { - iface_->search_vector_batch(result.success, args.group_id, args.top_k, args.tensor_list, args.filter); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.search_vector_batch"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("search_vector_batch", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.search_vector_batch"); - } - - oprot->writeMessageBegin("search_vector_batch", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.search_vector_batch", bytes); - } -} - -void VecServiceProcessor::process_search_binary_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.search_binary_vector", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.search_binary_vector"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.search_binary_vector"); - } - - VecService_search_binary_vector_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.search_binary_vector", bytes); - } - - VecService_search_binary_vector_result result; - try { - iface_->search_binary_vector(result.success, args.group_id, args.top_k, args.tensor, args.filter); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.search_binary_vector"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("search_binary_vector", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.search_binary_vector"); - } - - oprot->writeMessageBegin("search_binary_vector", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.search_binary_vector", bytes); - } -} - -void VecServiceProcessor::process_search_binary_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) -{ - void* ctx = NULL; - if (this->eventHandler_.get() != NULL) { - ctx = this->eventHandler_->getContext("VecService.search_binary_vector_batch", callContext); - } - ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "VecService.search_binary_vector_batch"); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preRead(ctx, "VecService.search_binary_vector_batch"); - } - - VecService_search_binary_vector_batch_args args; - args.read(iprot); - iprot->readMessageEnd(); - uint32_t bytes = iprot->getTransport()->readEnd(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postRead(ctx, "VecService.search_binary_vector_batch", bytes); - } - - VecService_search_binary_vector_batch_result result; - try { - iface_->search_binary_vector_batch(result.success, args.group_id, args.top_k, args.tensor_list, args.filter); - result.__isset.success = true; - } catch (VecException &e) { - result.e = e; - result.__isset.e = true; - } catch (const std::exception& e) { - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->handlerError(ctx, "VecService.search_binary_vector_batch"); - } - - ::apache::thrift::TApplicationException x(e.what()); - oprot->writeMessageBegin("search_binary_vector_batch", ::apache::thrift::protocol::T_EXCEPTION, seqid); - x.write(oprot); - oprot->writeMessageEnd(); - oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - return; - } - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->preWrite(ctx, "VecService.search_binary_vector_batch"); - } - - oprot->writeMessageBegin("search_binary_vector_batch", ::apache::thrift::protocol::T_REPLY, seqid); - result.write(oprot); - oprot->writeMessageEnd(); - bytes = oprot->getTransport()->writeEnd(); - oprot->getTransport()->flush(); - - if (this->eventHandler_.get() != NULL) { - this->eventHandler_->postWrite(ctx, "VecService.search_binary_vector_batch", bytes); - } -} - -::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > VecServiceProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { - ::apache::thrift::ReleaseHandler< VecServiceIfFactory > cleanup(handlerFactory_); - ::apache::thrift::stdcxx::shared_ptr< VecServiceIf > handler(handlerFactory_->getHandler(connInfo), cleanup); - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > processor(new VecServiceProcessor(handler)); - return processor; -} - -void VecServiceConcurrentClient::add_group(const VecGroup& group) -{ - int32_t seqid = send_add_group(group); - recv_add_group(seqid); -} - -int32_t VecServiceConcurrentClient::send_add_group(const VecGroup& group) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("add_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_group_pargs args; - args.group = &group; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_add_group(const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_add_group_presult result; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - sentry.commit(); - return; - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::get_group(VecGroup& _return, const std::string& group_id) -{ - int32_t seqid = send_get_group(group_id); - recv_get_group(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_get_group(const std::string& group_id) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("get_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_get_group_pargs args; - args.group_id = &group_id; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_get_group(VecGroup& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("get_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_get_group_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_group failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::del_group(const std::string& group_id) -{ - int32_t seqid = send_del_group(group_id); - recv_del_group(seqid); -} - -int32_t VecServiceConcurrentClient::send_del_group(const std::string& group_id) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("del_group", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_del_group_pargs args; - args.group_id = &group_id; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_del_group(const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("del_group") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_del_group_presult result; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - sentry.commit(); - return; - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor) -{ - int32_t seqid = send_add_vector(group_id, tensor); - recv_add_vector(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_add_vector(const std::string& group_id, const VecTensor& tensor) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("add_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_vector_pargs args; - args.group_id = &group_id; - args.tensor = &tensor; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_add_vector(std::string& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_add_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_vector failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list) -{ - int32_t seqid = send_add_vector_batch(group_id, tensor_list); - recv_add_vector_batch(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_add_vector_batch(const std::string& group_id, const VecTensorList& tensor_list) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("add_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_vector_batch_pargs args; - args.group_id = &group_id; - args.tensor_list = &tensor_list; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_add_vector_batch(std::vector & _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_add_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_vector_batch failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor) -{ - int32_t seqid = send_add_binary_vector(group_id, tensor); - recv_add_binary_vector(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_add_binary_vector(const std::string& group_id, const VecBinaryTensor& tensor) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("add_binary_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_binary_vector_pargs args; - args.group_id = &group_id; - args.tensor = &tensor; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_add_binary_vector(std::string& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_binary_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_add_binary_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_binary_vector failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list) -{ - int32_t seqid = send_add_binary_vector_batch(group_id, tensor_list); - recv_add_binary_vector_batch(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_add_binary_vector_batch(const std::string& group_id, const VecBinaryTensorList& tensor_list) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("add_binary_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_add_binary_vector_batch_pargs args; - args.group_id = &group_id; - args.tensor_list = &tensor_list; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_add_binary_vector_batch(std::vector & _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("add_binary_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_add_binary_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "add_binary_vector_batch failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) -{ - int32_t seqid = send_search_vector(group_id, top_k, tensor, filter); - recv_search_vector(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_search_vector(const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("search_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_vector_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor = &tensor; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_search_vector(VecSearchResult& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_search_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_vector failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t seqid = send_search_vector_batch(group_id, top_k, tensor_list, filter); - recv_search_vector_batch(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_search_vector_batch(const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("search_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_vector_batch_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor_list = &tensor_list; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_search_vector_batch(VecSearchResultList& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_search_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_vector_batch failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) -{ - int32_t seqid = send_search_binary_vector(group_id, top_k, tensor, filter); - recv_search_binary_vector(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_search_binary_vector(const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("search_binary_vector", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_binary_vector_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor = &tensor; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_search_binary_vector(VecSearchResult& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_binary_vector") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_search_binary_vector_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_binary_vector failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -void VecServiceConcurrentClient::search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t seqid = send_search_binary_vector_batch(group_id, top_k, tensor_list, filter); - recv_search_binary_vector_batch(_return, seqid); -} - -int32_t VecServiceConcurrentClient::send_search_binary_vector_batch(const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) -{ - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); - oprot_->writeMessageBegin("search_binary_vector_batch", ::apache::thrift::protocol::T_CALL, cseqid); - - VecService_search_binary_vector_batch_pargs args; - args.group_id = &group_id; - args.top_k = &top_k; - args.tensor_list = &tensor_list; - args.filter = &filter; - args.write(oprot_); - - oprot_->writeMessageEnd(); - oprot_->getTransport()->writeEnd(); - oprot_->getTransport()->flush(); - - sentry.commit(); - return cseqid; -} - -void VecServiceConcurrentClient::recv_search_binary_vector_batch(VecSearchResultList& _return, const int32_t seqid) -{ - - int32_t rseqid = 0; - std::string fname; - ::apache::thrift::protocol::TMessageType mtype; - - // the read mutex gets dropped and reacquired as part of waitForWork() - // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); - - while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { - iprot_->readMessageBegin(fname, mtype, rseqid); - } - if(seqid == rseqid) { - if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { - ::apache::thrift::TApplicationException x; - x.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - sentry.commit(); - throw x; - } - if (mtype != ::apache::thrift::protocol::T_REPLY) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - } - if (fname.compare("search_binary_vector_batch") != 0) { - iprot_->skip(::apache::thrift::protocol::T_STRUCT); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - // in a bad state, don't commit - using ::apache::thrift::protocol::TProtocolException; - throw TProtocolException(TProtocolException::INVALID_DATA); - } - VecService_search_binary_vector_batch_presult result; - result.success = &_return; - result.read(iprot_); - iprot_->readMessageEnd(); - iprot_->getTransport()->readEnd(); - - if (result.__isset.success) { - // _return pointer has now been filled - sentry.commit(); - return; - } - if (result.__isset.e) { - sentry.commit(); - throw result.e; - } - // in a bad state, don't commit - throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "search_binary_vector_batch failed: unknown result"); - } - // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); - - // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); - } // end while(true) -} - -} // namespace - diff --git a/cpp/src/thrift/gen-cpp/VecService.h b/cpp/src/thrift/gen-cpp/VecService.h deleted file mode 100644 index a3fdba2472..0000000000 --- a/cpp/src/thrift/gen-cpp/VecService.h +++ /dev/null @@ -1,1766 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.11.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#ifndef VecService_H -#define VecService_H - -#include -#include -#include "megasearch_types.h" - -namespace megasearch { - -#ifdef _MSC_VER - #pragma warning( push ) - #pragma warning (disable : 4250 ) //inheriting methods via dominance -#endif - -class VecServiceIf { - public: - virtual ~VecServiceIf() {} - - /** - * group interfaces - * - * @param group - */ - virtual void add_group(const VecGroup& group) = 0; - virtual void get_group(VecGroup& _return, const std::string& group_id) = 0; - virtual void del_group(const std::string& group_id) = 0; - - /** - * insert vector interfaces - * - * - * @param group_id - * @param tensor - */ - virtual void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor) = 0; - virtual void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list) = 0; - virtual void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor) = 0; - virtual void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list) = 0; - - /** - * search interfaces - * you can use filter to reduce search result - * filter.attrib_filter can specify which attribute you need, for example: - * set attrib_filter = {"color":""} means you want to get "color" attribute for result vector - * set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" - * if filter.time_range is empty, engine will search without time limit - * - * @param group_id - * @param top_k - * @param tensor - * @param filter - */ - virtual void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) = 0; - virtual void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) = 0; - virtual void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) = 0; - virtual void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) = 0; -}; - -class VecServiceIfFactory { - public: - typedef VecServiceIf Handler; - - virtual ~VecServiceIfFactory() {} - - virtual VecServiceIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0; - virtual void releaseHandler(VecServiceIf* /* handler */) = 0; -}; - -class VecServiceIfSingletonFactory : virtual public VecServiceIfFactory { - public: - VecServiceIfSingletonFactory(const ::apache::thrift::stdcxx::shared_ptr& iface) : iface_(iface) {} - virtual ~VecServiceIfSingletonFactory() {} - - virtual VecServiceIf* getHandler(const ::apache::thrift::TConnectionInfo&) { - return iface_.get(); - } - virtual void releaseHandler(VecServiceIf* /* handler */) {} - - protected: - ::apache::thrift::stdcxx::shared_ptr iface_; -}; - -class VecServiceNull : virtual public VecServiceIf { - public: - virtual ~VecServiceNull() {} - void add_group(const VecGroup& /* group */) { - return; - } - void get_group(VecGroup& /* _return */, const std::string& /* group_id */) { - return; - } - void del_group(const std::string& /* group_id */) { - return; - } - void add_vector(std::string& /* _return */, const std::string& /* group_id */, const VecTensor& /* tensor */) { - return; - } - void add_vector_batch(std::vector & /* _return */, const std::string& /* group_id */, const VecTensorList& /* tensor_list */) { - return; - } - void add_binary_vector(std::string& /* _return */, const std::string& /* group_id */, const VecBinaryTensor& /* tensor */) { - return; - } - void add_binary_vector_batch(std::vector & /* _return */, const std::string& /* group_id */, const VecBinaryTensorList& /* tensor_list */) { - return; - } - void search_vector(VecSearchResult& /* _return */, const std::string& /* group_id */, const int64_t /* top_k */, const VecTensor& /* tensor */, const VecSearchFilter& /* filter */) { - return; - } - void search_vector_batch(VecSearchResultList& /* _return */, const std::string& /* group_id */, const int64_t /* top_k */, const VecTensorList& /* tensor_list */, const VecSearchFilter& /* filter */) { - return; - } - void search_binary_vector(VecSearchResult& /* _return */, const std::string& /* group_id */, const int64_t /* top_k */, const VecBinaryTensor& /* tensor */, const VecSearchFilter& /* filter */) { - return; - } - void search_binary_vector_batch(VecSearchResultList& /* _return */, const std::string& /* group_id */, const int64_t /* top_k */, const VecBinaryTensorList& /* tensor_list */, const VecSearchFilter& /* filter */) { - return; - } -}; - -typedef struct _VecService_add_group_args__isset { - _VecService_add_group_args__isset() : group(false) {} - bool group :1; -} _VecService_add_group_args__isset; - -class VecService_add_group_args { - public: - - VecService_add_group_args(const VecService_add_group_args&); - VecService_add_group_args& operator=(const VecService_add_group_args&); - VecService_add_group_args() { - } - - virtual ~VecService_add_group_args() throw(); - VecGroup group; - - _VecService_add_group_args__isset __isset; - - void __set_group(const VecGroup& val); - - bool operator == (const VecService_add_group_args & rhs) const - { - if (!(group == rhs.group)) - return false; - return true; - } - bool operator != (const VecService_add_group_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_group_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_add_group_pargs { - public: - - - virtual ~VecService_add_group_pargs() throw(); - const VecGroup* group; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_group_result__isset { - _VecService_add_group_result__isset() : e(false) {} - bool e :1; -} _VecService_add_group_result__isset; - -class VecService_add_group_result { - public: - - VecService_add_group_result(const VecService_add_group_result&); - VecService_add_group_result& operator=(const VecService_add_group_result&); - VecService_add_group_result() { - } - - virtual ~VecService_add_group_result() throw(); - VecException e; - - _VecService_add_group_result__isset __isset; - - void __set_e(const VecException& val); - - bool operator == (const VecService_add_group_result & rhs) const - { - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_add_group_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_group_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_group_presult__isset { - _VecService_add_group_presult__isset() : e(false) {} - bool e :1; -} _VecService_add_group_presult__isset; - -class VecService_add_group_presult { - public: - - - virtual ~VecService_add_group_presult() throw(); - VecException e; - - _VecService_add_group_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_get_group_args__isset { - _VecService_get_group_args__isset() : group_id(false) {} - bool group_id :1; -} _VecService_get_group_args__isset; - -class VecService_get_group_args { - public: - - VecService_get_group_args(const VecService_get_group_args&); - VecService_get_group_args& operator=(const VecService_get_group_args&); - VecService_get_group_args() : group_id() { - } - - virtual ~VecService_get_group_args() throw(); - std::string group_id; - - _VecService_get_group_args__isset __isset; - - void __set_group_id(const std::string& val); - - bool operator == (const VecService_get_group_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - return true; - } - bool operator != (const VecService_get_group_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_get_group_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_get_group_pargs { - public: - - - virtual ~VecService_get_group_pargs() throw(); - const std::string* group_id; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_get_group_result__isset { - _VecService_get_group_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_get_group_result__isset; - -class VecService_get_group_result { - public: - - VecService_get_group_result(const VecService_get_group_result&); - VecService_get_group_result& operator=(const VecService_get_group_result&); - VecService_get_group_result() { - } - - virtual ~VecService_get_group_result() throw(); - VecGroup success; - VecException e; - - _VecService_get_group_result__isset __isset; - - void __set_success(const VecGroup& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_get_group_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_get_group_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_get_group_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_get_group_presult__isset { - _VecService_get_group_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_get_group_presult__isset; - -class VecService_get_group_presult { - public: - - - virtual ~VecService_get_group_presult() throw(); - VecGroup* success; - VecException e; - - _VecService_get_group_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_del_group_args__isset { - _VecService_del_group_args__isset() : group_id(false) {} - bool group_id :1; -} _VecService_del_group_args__isset; - -class VecService_del_group_args { - public: - - VecService_del_group_args(const VecService_del_group_args&); - VecService_del_group_args& operator=(const VecService_del_group_args&); - VecService_del_group_args() : group_id() { - } - - virtual ~VecService_del_group_args() throw(); - std::string group_id; - - _VecService_del_group_args__isset __isset; - - void __set_group_id(const std::string& val); - - bool operator == (const VecService_del_group_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - return true; - } - bool operator != (const VecService_del_group_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_del_group_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_del_group_pargs { - public: - - - virtual ~VecService_del_group_pargs() throw(); - const std::string* group_id; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_del_group_result__isset { - _VecService_del_group_result__isset() : e(false) {} - bool e :1; -} _VecService_del_group_result__isset; - -class VecService_del_group_result { - public: - - VecService_del_group_result(const VecService_del_group_result&); - VecService_del_group_result& operator=(const VecService_del_group_result&); - VecService_del_group_result() { - } - - virtual ~VecService_del_group_result() throw(); - VecException e; - - _VecService_del_group_result__isset __isset; - - void __set_e(const VecException& val); - - bool operator == (const VecService_del_group_result & rhs) const - { - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_del_group_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_del_group_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_del_group_presult__isset { - _VecService_del_group_presult__isset() : e(false) {} - bool e :1; -} _VecService_del_group_presult__isset; - -class VecService_del_group_presult { - public: - - - virtual ~VecService_del_group_presult() throw(); - VecException e; - - _VecService_del_group_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_add_vector_args__isset { - _VecService_add_vector_args__isset() : group_id(false), tensor(false) {} - bool group_id :1; - bool tensor :1; -} _VecService_add_vector_args__isset; - -class VecService_add_vector_args { - public: - - VecService_add_vector_args(const VecService_add_vector_args&); - VecService_add_vector_args& operator=(const VecService_add_vector_args&); - VecService_add_vector_args() : group_id() { - } - - virtual ~VecService_add_vector_args() throw(); - std::string group_id; - VecTensor tensor; - - _VecService_add_vector_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_tensor(const VecTensor& val); - - bool operator == (const VecService_add_vector_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(tensor == rhs.tensor)) - return false; - return true; - } - bool operator != (const VecService_add_vector_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_vector_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_add_vector_pargs { - public: - - - virtual ~VecService_add_vector_pargs() throw(); - const std::string* group_id; - const VecTensor* tensor; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_vector_result__isset { - _VecService_add_vector_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_vector_result__isset; - -class VecService_add_vector_result { - public: - - VecService_add_vector_result(const VecService_add_vector_result&); - VecService_add_vector_result& operator=(const VecService_add_vector_result&); - VecService_add_vector_result() : success() { - } - - virtual ~VecService_add_vector_result() throw(); - std::string success; - VecException e; - - _VecService_add_vector_result__isset __isset; - - void __set_success(const std::string& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_add_vector_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_add_vector_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_vector_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_vector_presult__isset { - _VecService_add_vector_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_vector_presult__isset; - -class VecService_add_vector_presult { - public: - - - virtual ~VecService_add_vector_presult() throw(); - std::string* success; - VecException e; - - _VecService_add_vector_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_add_vector_batch_args__isset { - _VecService_add_vector_batch_args__isset() : group_id(false), tensor_list(false) {} - bool group_id :1; - bool tensor_list :1; -} _VecService_add_vector_batch_args__isset; - -class VecService_add_vector_batch_args { - public: - - VecService_add_vector_batch_args(const VecService_add_vector_batch_args&); - VecService_add_vector_batch_args& operator=(const VecService_add_vector_batch_args&); - VecService_add_vector_batch_args() : group_id() { - } - - virtual ~VecService_add_vector_batch_args() throw(); - std::string group_id; - VecTensorList tensor_list; - - _VecService_add_vector_batch_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_tensor_list(const VecTensorList& val); - - bool operator == (const VecService_add_vector_batch_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(tensor_list == rhs.tensor_list)) - return false; - return true; - } - bool operator != (const VecService_add_vector_batch_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_vector_batch_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_add_vector_batch_pargs { - public: - - - virtual ~VecService_add_vector_batch_pargs() throw(); - const std::string* group_id; - const VecTensorList* tensor_list; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_vector_batch_result__isset { - _VecService_add_vector_batch_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_vector_batch_result__isset; - -class VecService_add_vector_batch_result { - public: - - VecService_add_vector_batch_result(const VecService_add_vector_batch_result&); - VecService_add_vector_batch_result& operator=(const VecService_add_vector_batch_result&); - VecService_add_vector_batch_result() { - } - - virtual ~VecService_add_vector_batch_result() throw(); - std::vector success; - VecException e; - - _VecService_add_vector_batch_result__isset __isset; - - void __set_success(const std::vector & val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_add_vector_batch_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_add_vector_batch_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_vector_batch_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_vector_batch_presult__isset { - _VecService_add_vector_batch_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_vector_batch_presult__isset; - -class VecService_add_vector_batch_presult { - public: - - - virtual ~VecService_add_vector_batch_presult() throw(); - std::vector * success; - VecException e; - - _VecService_add_vector_batch_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_add_binary_vector_args__isset { - _VecService_add_binary_vector_args__isset() : group_id(false), tensor(false) {} - bool group_id :1; - bool tensor :1; -} _VecService_add_binary_vector_args__isset; - -class VecService_add_binary_vector_args { - public: - - VecService_add_binary_vector_args(const VecService_add_binary_vector_args&); - VecService_add_binary_vector_args& operator=(const VecService_add_binary_vector_args&); - VecService_add_binary_vector_args() : group_id() { - } - - virtual ~VecService_add_binary_vector_args() throw(); - std::string group_id; - VecBinaryTensor tensor; - - _VecService_add_binary_vector_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_tensor(const VecBinaryTensor& val); - - bool operator == (const VecService_add_binary_vector_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(tensor == rhs.tensor)) - return false; - return true; - } - bool operator != (const VecService_add_binary_vector_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_binary_vector_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_add_binary_vector_pargs { - public: - - - virtual ~VecService_add_binary_vector_pargs() throw(); - const std::string* group_id; - const VecBinaryTensor* tensor; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_binary_vector_result__isset { - _VecService_add_binary_vector_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_binary_vector_result__isset; - -class VecService_add_binary_vector_result { - public: - - VecService_add_binary_vector_result(const VecService_add_binary_vector_result&); - VecService_add_binary_vector_result& operator=(const VecService_add_binary_vector_result&); - VecService_add_binary_vector_result() : success() { - } - - virtual ~VecService_add_binary_vector_result() throw(); - std::string success; - VecException e; - - _VecService_add_binary_vector_result__isset __isset; - - void __set_success(const std::string& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_add_binary_vector_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_add_binary_vector_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_binary_vector_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_binary_vector_presult__isset { - _VecService_add_binary_vector_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_binary_vector_presult__isset; - -class VecService_add_binary_vector_presult { - public: - - - virtual ~VecService_add_binary_vector_presult() throw(); - std::string* success; - VecException e; - - _VecService_add_binary_vector_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_add_binary_vector_batch_args__isset { - _VecService_add_binary_vector_batch_args__isset() : group_id(false), tensor_list(false) {} - bool group_id :1; - bool tensor_list :1; -} _VecService_add_binary_vector_batch_args__isset; - -class VecService_add_binary_vector_batch_args { - public: - - VecService_add_binary_vector_batch_args(const VecService_add_binary_vector_batch_args&); - VecService_add_binary_vector_batch_args& operator=(const VecService_add_binary_vector_batch_args&); - VecService_add_binary_vector_batch_args() : group_id() { - } - - virtual ~VecService_add_binary_vector_batch_args() throw(); - std::string group_id; - VecBinaryTensorList tensor_list; - - _VecService_add_binary_vector_batch_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_tensor_list(const VecBinaryTensorList& val); - - bool operator == (const VecService_add_binary_vector_batch_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(tensor_list == rhs.tensor_list)) - return false; - return true; - } - bool operator != (const VecService_add_binary_vector_batch_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_binary_vector_batch_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_add_binary_vector_batch_pargs { - public: - - - virtual ~VecService_add_binary_vector_batch_pargs() throw(); - const std::string* group_id; - const VecBinaryTensorList* tensor_list; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_binary_vector_batch_result__isset { - _VecService_add_binary_vector_batch_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_binary_vector_batch_result__isset; - -class VecService_add_binary_vector_batch_result { - public: - - VecService_add_binary_vector_batch_result(const VecService_add_binary_vector_batch_result&); - VecService_add_binary_vector_batch_result& operator=(const VecService_add_binary_vector_batch_result&); - VecService_add_binary_vector_batch_result() { - } - - virtual ~VecService_add_binary_vector_batch_result() throw(); - std::vector success; - VecException e; - - _VecService_add_binary_vector_batch_result__isset __isset; - - void __set_success(const std::vector & val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_add_binary_vector_batch_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_add_binary_vector_batch_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_add_binary_vector_batch_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_add_binary_vector_batch_presult__isset { - _VecService_add_binary_vector_batch_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_add_binary_vector_batch_presult__isset; - -class VecService_add_binary_vector_batch_presult { - public: - - - virtual ~VecService_add_binary_vector_batch_presult() throw(); - std::vector * success; - VecException e; - - _VecService_add_binary_vector_batch_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_search_vector_args__isset { - _VecService_search_vector_args__isset() : group_id(false), top_k(false), tensor(false), filter(false) {} - bool group_id :1; - bool top_k :1; - bool tensor :1; - bool filter :1; -} _VecService_search_vector_args__isset; - -class VecService_search_vector_args { - public: - - VecService_search_vector_args(const VecService_search_vector_args&); - VecService_search_vector_args& operator=(const VecService_search_vector_args&); - VecService_search_vector_args() : group_id(), top_k(0) { - } - - virtual ~VecService_search_vector_args() throw(); - std::string group_id; - int64_t top_k; - VecTensor tensor; - VecSearchFilter filter; - - _VecService_search_vector_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_top_k(const int64_t val); - - void __set_tensor(const VecTensor& val); - - void __set_filter(const VecSearchFilter& val); - - bool operator == (const VecService_search_vector_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(top_k == rhs.top_k)) - return false; - if (!(tensor == rhs.tensor)) - return false; - if (!(filter == rhs.filter)) - return false; - return true; - } - bool operator != (const VecService_search_vector_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_vector_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_search_vector_pargs { - public: - - - virtual ~VecService_search_vector_pargs() throw(); - const std::string* group_id; - const int64_t* top_k; - const VecTensor* tensor; - const VecSearchFilter* filter; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_vector_result__isset { - _VecService_search_vector_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_vector_result__isset; - -class VecService_search_vector_result { - public: - - VecService_search_vector_result(const VecService_search_vector_result&); - VecService_search_vector_result& operator=(const VecService_search_vector_result&); - VecService_search_vector_result() { - } - - virtual ~VecService_search_vector_result() throw(); - VecSearchResult success; - VecException e; - - _VecService_search_vector_result__isset __isset; - - void __set_success(const VecSearchResult& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_search_vector_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_search_vector_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_vector_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_vector_presult__isset { - _VecService_search_vector_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_vector_presult__isset; - -class VecService_search_vector_presult { - public: - - - virtual ~VecService_search_vector_presult() throw(); - VecSearchResult* success; - VecException e; - - _VecService_search_vector_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_search_vector_batch_args__isset { - _VecService_search_vector_batch_args__isset() : group_id(false), top_k(false), tensor_list(false), filter(false) {} - bool group_id :1; - bool top_k :1; - bool tensor_list :1; - bool filter :1; -} _VecService_search_vector_batch_args__isset; - -class VecService_search_vector_batch_args { - public: - - VecService_search_vector_batch_args(const VecService_search_vector_batch_args&); - VecService_search_vector_batch_args& operator=(const VecService_search_vector_batch_args&); - VecService_search_vector_batch_args() : group_id(), top_k(0) { - } - - virtual ~VecService_search_vector_batch_args() throw(); - std::string group_id; - int64_t top_k; - VecTensorList tensor_list; - VecSearchFilter filter; - - _VecService_search_vector_batch_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_top_k(const int64_t val); - - void __set_tensor_list(const VecTensorList& val); - - void __set_filter(const VecSearchFilter& val); - - bool operator == (const VecService_search_vector_batch_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(top_k == rhs.top_k)) - return false; - if (!(tensor_list == rhs.tensor_list)) - return false; - if (!(filter == rhs.filter)) - return false; - return true; - } - bool operator != (const VecService_search_vector_batch_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_vector_batch_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_search_vector_batch_pargs { - public: - - - virtual ~VecService_search_vector_batch_pargs() throw(); - const std::string* group_id; - const int64_t* top_k; - const VecTensorList* tensor_list; - const VecSearchFilter* filter; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_vector_batch_result__isset { - _VecService_search_vector_batch_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_vector_batch_result__isset; - -class VecService_search_vector_batch_result { - public: - - VecService_search_vector_batch_result(const VecService_search_vector_batch_result&); - VecService_search_vector_batch_result& operator=(const VecService_search_vector_batch_result&); - VecService_search_vector_batch_result() { - } - - virtual ~VecService_search_vector_batch_result() throw(); - VecSearchResultList success; - VecException e; - - _VecService_search_vector_batch_result__isset __isset; - - void __set_success(const VecSearchResultList& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_search_vector_batch_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_search_vector_batch_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_vector_batch_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_vector_batch_presult__isset { - _VecService_search_vector_batch_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_vector_batch_presult__isset; - -class VecService_search_vector_batch_presult { - public: - - - virtual ~VecService_search_vector_batch_presult() throw(); - VecSearchResultList* success; - VecException e; - - _VecService_search_vector_batch_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_search_binary_vector_args__isset { - _VecService_search_binary_vector_args__isset() : group_id(false), top_k(false), tensor(false), filter(false) {} - bool group_id :1; - bool top_k :1; - bool tensor :1; - bool filter :1; -} _VecService_search_binary_vector_args__isset; - -class VecService_search_binary_vector_args { - public: - - VecService_search_binary_vector_args(const VecService_search_binary_vector_args&); - VecService_search_binary_vector_args& operator=(const VecService_search_binary_vector_args&); - VecService_search_binary_vector_args() : group_id(), top_k(0) { - } - - virtual ~VecService_search_binary_vector_args() throw(); - std::string group_id; - int64_t top_k; - VecBinaryTensor tensor; - VecSearchFilter filter; - - _VecService_search_binary_vector_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_top_k(const int64_t val); - - void __set_tensor(const VecBinaryTensor& val); - - void __set_filter(const VecSearchFilter& val); - - bool operator == (const VecService_search_binary_vector_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(top_k == rhs.top_k)) - return false; - if (!(tensor == rhs.tensor)) - return false; - if (!(filter == rhs.filter)) - return false; - return true; - } - bool operator != (const VecService_search_binary_vector_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_binary_vector_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_search_binary_vector_pargs { - public: - - - virtual ~VecService_search_binary_vector_pargs() throw(); - const std::string* group_id; - const int64_t* top_k; - const VecBinaryTensor* tensor; - const VecSearchFilter* filter; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_binary_vector_result__isset { - _VecService_search_binary_vector_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_binary_vector_result__isset; - -class VecService_search_binary_vector_result { - public: - - VecService_search_binary_vector_result(const VecService_search_binary_vector_result&); - VecService_search_binary_vector_result& operator=(const VecService_search_binary_vector_result&); - VecService_search_binary_vector_result() { - } - - virtual ~VecService_search_binary_vector_result() throw(); - VecSearchResult success; - VecException e; - - _VecService_search_binary_vector_result__isset __isset; - - void __set_success(const VecSearchResult& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_search_binary_vector_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_search_binary_vector_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_binary_vector_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_binary_vector_presult__isset { - _VecService_search_binary_vector_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_binary_vector_presult__isset; - -class VecService_search_binary_vector_presult { - public: - - - virtual ~VecService_search_binary_vector_presult() throw(); - VecSearchResult* success; - VecException e; - - _VecService_search_binary_vector_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -typedef struct _VecService_search_binary_vector_batch_args__isset { - _VecService_search_binary_vector_batch_args__isset() : group_id(false), top_k(false), tensor_list(false), filter(false) {} - bool group_id :1; - bool top_k :1; - bool tensor_list :1; - bool filter :1; -} _VecService_search_binary_vector_batch_args__isset; - -class VecService_search_binary_vector_batch_args { - public: - - VecService_search_binary_vector_batch_args(const VecService_search_binary_vector_batch_args&); - VecService_search_binary_vector_batch_args& operator=(const VecService_search_binary_vector_batch_args&); - VecService_search_binary_vector_batch_args() : group_id(), top_k(0) { - } - - virtual ~VecService_search_binary_vector_batch_args() throw(); - std::string group_id; - int64_t top_k; - VecBinaryTensorList tensor_list; - VecSearchFilter filter; - - _VecService_search_binary_vector_batch_args__isset __isset; - - void __set_group_id(const std::string& val); - - void __set_top_k(const int64_t val); - - void __set_tensor_list(const VecBinaryTensorList& val); - - void __set_filter(const VecSearchFilter& val); - - bool operator == (const VecService_search_binary_vector_batch_args & rhs) const - { - if (!(group_id == rhs.group_id)) - return false; - if (!(top_k == rhs.top_k)) - return false; - if (!(tensor_list == rhs.tensor_list)) - return false; - if (!(filter == rhs.filter)) - return false; - return true; - } - bool operator != (const VecService_search_binary_vector_batch_args &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_binary_vector_batch_args & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - - -class VecService_search_binary_vector_batch_pargs { - public: - - - virtual ~VecService_search_binary_vector_batch_pargs() throw(); - const std::string* group_id; - const int64_t* top_k; - const VecBinaryTensorList* tensor_list; - const VecSearchFilter* filter; - - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_binary_vector_batch_result__isset { - _VecService_search_binary_vector_batch_result__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_binary_vector_batch_result__isset; - -class VecService_search_binary_vector_batch_result { - public: - - VecService_search_binary_vector_batch_result(const VecService_search_binary_vector_batch_result&); - VecService_search_binary_vector_batch_result& operator=(const VecService_search_binary_vector_batch_result&); - VecService_search_binary_vector_batch_result() { - } - - virtual ~VecService_search_binary_vector_batch_result() throw(); - VecSearchResultList success; - VecException e; - - _VecService_search_binary_vector_batch_result__isset __isset; - - void __set_success(const VecSearchResultList& val); - - void __set_e(const VecException& val); - - bool operator == (const VecService_search_binary_vector_batch_result & rhs) const - { - if (!(success == rhs.success)) - return false; - if (!(e == rhs.e)) - return false; - return true; - } - bool operator != (const VecService_search_binary_vector_batch_result &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecService_search_binary_vector_batch_result & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - -}; - -typedef struct _VecService_search_binary_vector_batch_presult__isset { - _VecService_search_binary_vector_batch_presult__isset() : success(false), e(false) {} - bool success :1; - bool e :1; -} _VecService_search_binary_vector_batch_presult__isset; - -class VecService_search_binary_vector_batch_presult { - public: - - - virtual ~VecService_search_binary_vector_batch_presult() throw(); - VecSearchResultList* success; - VecException e; - - _VecService_search_binary_vector_batch_presult__isset __isset; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - -}; - -class VecServiceClient : virtual public VecServiceIf { - public: - VecServiceClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { - setProtocol(prot); - } - VecServiceClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { - setProtocol(iprot,oprot); - } - private: - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { - setProtocol(prot,prot); - } - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { - piprot_=iprot; - poprot_=oprot; - iprot_ = iprot.get(); - oprot_ = oprot.get(); - } - public: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { - return piprot_; - } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { - return poprot_; - } - void add_group(const VecGroup& group); - void send_add_group(const VecGroup& group); - void recv_add_group(); - void get_group(VecGroup& _return, const std::string& group_id); - void send_get_group(const std::string& group_id); - void recv_get_group(VecGroup& _return); - void del_group(const std::string& group_id); - void send_del_group(const std::string& group_id); - void recv_del_group(); - void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor); - void send_add_vector(const std::string& group_id, const VecTensor& tensor); - void recv_add_vector(std::string& _return); - void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list); - void send_add_vector_batch(const std::string& group_id, const VecTensorList& tensor_list); - void recv_add_vector_batch(std::vector & _return); - void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor); - void send_add_binary_vector(const std::string& group_id, const VecBinaryTensor& tensor); - void recv_add_binary_vector(std::string& _return); - void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list); - void send_add_binary_vector_batch(const std::string& group_id, const VecBinaryTensorList& tensor_list); - void recv_add_binary_vector_batch(std::vector & _return); - void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter); - void send_search_vector(const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter); - void recv_search_vector(VecSearchResult& _return); - void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter); - void send_search_vector_batch(const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter); - void recv_search_vector_batch(VecSearchResultList& _return); - void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter); - void send_search_binary_vector(const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter); - void recv_search_binary_vector(VecSearchResult& _return); - void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter); - void send_search_binary_vector_batch(const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter); - void recv_search_binary_vector_batch(VecSearchResultList& _return); - protected: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; - ::apache::thrift::protocol::TProtocol* iprot_; - ::apache::thrift::protocol::TProtocol* oprot_; -}; - -class VecServiceProcessor : public ::apache::thrift::TDispatchProcessor { - protected: - ::apache::thrift::stdcxx::shared_ptr iface_; - virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); - private: - typedef void (VecServiceProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); - typedef std::map ProcessMap; - ProcessMap processMap_; - void process_add_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_get_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_del_group(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_add_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_add_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_add_binary_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_add_binary_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_search_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_search_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_search_binary_vector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - void process_search_binary_vector_batch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); - public: - VecServiceProcessor(::apache::thrift::stdcxx::shared_ptr iface) : - iface_(iface) { - processMap_["add_group"] = &VecServiceProcessor::process_add_group; - processMap_["get_group"] = &VecServiceProcessor::process_get_group; - processMap_["del_group"] = &VecServiceProcessor::process_del_group; - processMap_["add_vector"] = &VecServiceProcessor::process_add_vector; - processMap_["add_vector_batch"] = &VecServiceProcessor::process_add_vector_batch; - processMap_["add_binary_vector"] = &VecServiceProcessor::process_add_binary_vector; - processMap_["add_binary_vector_batch"] = &VecServiceProcessor::process_add_binary_vector_batch; - processMap_["search_vector"] = &VecServiceProcessor::process_search_vector; - processMap_["search_vector_batch"] = &VecServiceProcessor::process_search_vector_batch; - processMap_["search_binary_vector"] = &VecServiceProcessor::process_search_binary_vector; - processMap_["search_binary_vector_batch"] = &VecServiceProcessor::process_search_binary_vector_batch; - } - - virtual ~VecServiceProcessor() {} -}; - -class VecServiceProcessorFactory : public ::apache::thrift::TProcessorFactory { - public: - VecServiceProcessorFactory(const ::apache::thrift::stdcxx::shared_ptr< VecServiceIfFactory >& handlerFactory) : - handlerFactory_(handlerFactory) {} - - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); - - protected: - ::apache::thrift::stdcxx::shared_ptr< VecServiceIfFactory > handlerFactory_; -}; - -class VecServiceMultiface : virtual public VecServiceIf { - public: - VecServiceMultiface(std::vector >& ifaces) : ifaces_(ifaces) { - } - virtual ~VecServiceMultiface() {} - protected: - std::vector > ifaces_; - VecServiceMultiface() {} - void add(::apache::thrift::stdcxx::shared_ptr iface) { - ifaces_.push_back(iface); - } - public: - void add_group(const VecGroup& group) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->add_group(group); - } - ifaces_[i]->add_group(group); - } - - void get_group(VecGroup& _return, const std::string& group_id) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->get_group(_return, group_id); - } - ifaces_[i]->get_group(_return, group_id); - return; - } - - void del_group(const std::string& group_id) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->del_group(group_id); - } - ifaces_[i]->del_group(group_id); - } - - void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->add_vector(_return, group_id, tensor); - } - ifaces_[i]->add_vector(_return, group_id, tensor); - return; - } - - void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->add_vector_batch(_return, group_id, tensor_list); - } - ifaces_[i]->add_vector_batch(_return, group_id, tensor_list); - return; - } - - void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->add_binary_vector(_return, group_id, tensor); - } - ifaces_[i]->add_binary_vector(_return, group_id, tensor); - return; - } - - void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->add_binary_vector_batch(_return, group_id, tensor_list); - } - ifaces_[i]->add_binary_vector_batch(_return, group_id, tensor_list); - return; - } - - void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->search_vector(_return, group_id, top_k, tensor, filter); - } - ifaces_[i]->search_vector(_return, group_id, top_k, tensor, filter); - return; - } - - void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->search_vector_batch(_return, group_id, top_k, tensor_list, filter); - } - ifaces_[i]->search_vector_batch(_return, group_id, top_k, tensor_list, filter); - return; - } - - void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->search_binary_vector(_return, group_id, top_k, tensor, filter); - } - ifaces_[i]->search_binary_vector(_return, group_id, top_k, tensor, filter); - return; - } - - void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) { - size_t sz = ifaces_.size(); - size_t i = 0; - for (; i < (sz - 1); ++i) { - ifaces_[i]->search_binary_vector_batch(_return, group_id, top_k, tensor_list, filter); - } - ifaces_[i]->search_binary_vector_batch(_return, group_id, top_k, tensor_list, filter); - return; - } - -}; - -// The 'concurrent' client is a thread safe client that correctly handles -// out of order responses. It is slower than the regular client, so should -// only be used when you need to share a connection among multiple threads -class VecServiceConcurrentClient : virtual public VecServiceIf { - public: - VecServiceConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { - setProtocol(prot); - } - VecServiceConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { - setProtocol(iprot,oprot); - } - private: - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { - setProtocol(prot,prot); - } - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { - piprot_=iprot; - poprot_=oprot; - iprot_ = iprot.get(); - oprot_ = oprot.get(); - } - public: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { - return piprot_; - } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { - return poprot_; - } - void add_group(const VecGroup& group); - int32_t send_add_group(const VecGroup& group); - void recv_add_group(const int32_t seqid); - void get_group(VecGroup& _return, const std::string& group_id); - int32_t send_get_group(const std::string& group_id); - void recv_get_group(VecGroup& _return, const int32_t seqid); - void del_group(const std::string& group_id); - int32_t send_del_group(const std::string& group_id); - void recv_del_group(const int32_t seqid); - void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor); - int32_t send_add_vector(const std::string& group_id, const VecTensor& tensor); - void recv_add_vector(std::string& _return, const int32_t seqid); - void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list); - int32_t send_add_vector_batch(const std::string& group_id, const VecTensorList& tensor_list); - void recv_add_vector_batch(std::vector & _return, const int32_t seqid); - void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor); - int32_t send_add_binary_vector(const std::string& group_id, const VecBinaryTensor& tensor); - void recv_add_binary_vector(std::string& _return, const int32_t seqid); - void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list); - int32_t send_add_binary_vector_batch(const std::string& group_id, const VecBinaryTensorList& tensor_list); - void recv_add_binary_vector_batch(std::vector & _return, const int32_t seqid); - void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter); - int32_t send_search_vector(const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter); - void recv_search_vector(VecSearchResult& _return, const int32_t seqid); - void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter); - int32_t send_search_vector_batch(const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter); - void recv_search_vector_batch(VecSearchResultList& _return, const int32_t seqid); - void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter); - int32_t send_search_binary_vector(const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter); - void recv_search_binary_vector(VecSearchResult& _return, const int32_t seqid); - void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter); - int32_t send_search_binary_vector_batch(const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter); - void recv_search_binary_vector_batch(VecSearchResultList& _return, const int32_t seqid); - protected: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; - ::apache::thrift::protocol::TProtocol* iprot_; - ::apache::thrift::protocol::TProtocol* oprot_; - ::apache::thrift::async::TConcurrentClientSyncInfo sync_; -}; - -#ifdef _MSC_VER - #pragma warning( pop ) -#endif - -} // namespace - -#endif diff --git a/cpp/src/thrift/gen-cpp/VecService_server.skeleton.cpp b/cpp/src/thrift/gen-cpp/VecService_server.skeleton.cpp deleted file mode 100644 index 8727a0e500..0000000000 --- a/cpp/src/thrift/gen-cpp/VecService_server.skeleton.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// This autogenerated skeleton file illustrates how to build a server. -// You should copy it to another filename to avoid overwriting it. - -#include "VecService.h" -#include -#include -#include -#include - -using namespace ::apache::thrift; -using namespace ::apache::thrift::protocol; -using namespace ::apache::thrift::transport; -using namespace ::apache::thrift::server; - -using namespace ::megasearch; - -class VecServiceHandler : virtual public VecServiceIf { - public: - VecServiceHandler() { - // Your initialization goes here - } - - /** - * group interfaces - * - * @param group - */ - void add_group(const VecGroup& group) { - // Your implementation goes here - printf("add_group\n"); - } - - void get_group(VecGroup& _return, const std::string& group_id) { - // Your implementation goes here - printf("get_group\n"); - } - - void del_group(const std::string& group_id) { - // Your implementation goes here - printf("del_group\n"); - } - - /** - * insert vector interfaces - * - * - * @param group_id - * @param tensor - */ - void add_vector(std::string& _return, const std::string& group_id, const VecTensor& tensor) { - // Your implementation goes here - printf("add_vector\n"); - } - - void add_vector_batch(std::vector & _return, const std::string& group_id, const VecTensorList& tensor_list) { - // Your implementation goes here - printf("add_vector_batch\n"); - } - - void add_binary_vector(std::string& _return, const std::string& group_id, const VecBinaryTensor& tensor) { - // Your implementation goes here - printf("add_binary_vector\n"); - } - - void add_binary_vector_batch(std::vector & _return, const std::string& group_id, const VecBinaryTensorList& tensor_list) { - // Your implementation goes here - printf("add_binary_vector_batch\n"); - } - - /** - * search interfaces - * you can use filter to reduce search result - * filter.attrib_filter can specify which attribute you need, for example: - * set attrib_filter = {"color":""} means you want to get "color" attribute for result vector - * set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" - * if filter.time_range is empty, engine will search without time limit - * - * @param group_id - * @param top_k - * @param tensor - * @param filter - */ - void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecSearchFilter& filter) { - // Your implementation goes here - printf("search_vector\n"); - } - - void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecSearchFilter& filter) { - // Your implementation goes here - printf("search_vector_batch\n"); - } - - void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecSearchFilter& filter) { - // Your implementation goes here - printf("search_binary_vector\n"); - } - - void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecSearchFilter& filter) { - // Your implementation goes here - printf("search_binary_vector_batch\n"); - } - -}; - -int main(int argc, char **argv) { - int port = 9090; - ::apache::thrift::stdcxx::shared_ptr handler(new VecServiceHandler()); - ::apache::thrift::stdcxx::shared_ptr processor(new VecServiceProcessor(handler)); - ::apache::thrift::stdcxx::shared_ptr serverTransport(new TServerSocket(port)); - ::apache::thrift::stdcxx::shared_ptr transportFactory(new TBufferedTransportFactory()); - ::apache::thrift::stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); - - TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); - server.serve(); - return 0; -} - diff --git a/cpp/src/thrift/gen-cpp/megasearch_constants.cpp b/cpp/src/thrift/gen-cpp/megasearch_constants.cpp index 06adb7629f..4e22e9616c 100644 --- a/cpp/src/thrift/gen-cpp/megasearch_constants.cpp +++ b/cpp/src/thrift/gen-cpp/megasearch_constants.cpp @@ -1,17 +1,17 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.12.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "megasearch_constants.h" -namespace megasearch { +namespace megasearch { namespace thrift { const megasearchConstants g_megasearch_constants; megasearchConstants::megasearchConstants() { } -} // namespace +}} // namespace diff --git a/cpp/src/thrift/gen-cpp/megasearch_constants.h b/cpp/src/thrift/gen-cpp/megasearch_constants.h index 1f4b9553dd..7f31ad1a96 100644 --- a/cpp/src/thrift/gen-cpp/megasearch_constants.h +++ b/cpp/src/thrift/gen-cpp/megasearch_constants.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.12.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -9,7 +9,7 @@ #include "megasearch_types.h" -namespace megasearch { +namespace megasearch { namespace thrift { class megasearchConstants { public: @@ -19,6 +19,6 @@ class megasearchConstants { extern const megasearchConstants g_megasearch_constants; -} // namespace +}} // namespace #endif diff --git a/cpp/src/thrift/gen-cpp/megasearch_types.cpp b/cpp/src/thrift/gen-cpp/megasearch_types.cpp index bf4d316366..5731477b11 100644 --- a/cpp/src/thrift/gen-cpp/megasearch_types.cpp +++ b/cpp/src/thrift/gen-cpp/megasearch_types.cpp @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.12.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -11,29 +11,33 @@ #include -namespace megasearch { +namespace megasearch { namespace thrift { -int _kVecErrCodeValues[] = { - VecErrCode::SUCCESS, - VecErrCode::ILLEGAL_ARGUMENT, - VecErrCode::GROUP_NOT_EXISTS, - VecErrCode::ILLEGAL_TIME_RANGE, - VecErrCode::ILLEGAL_VECTOR_DIMENSION, - VecErrCode::OUT_OF_MEMORY +int _kErrorCodeValues[] = { + ErrorCode::SUCCESS, + ErrorCode::CONNECT_FAILED, + ErrorCode::PERMISSION_DENIED, + ErrorCode::TABLE_NOT_EXISTS, + ErrorCode::PARTITION_NOT_EXIST, + ErrorCode::ILLEGAL_ARGUMENT, + ErrorCode::ILLEGAL_RANGE, + ErrorCode::ILLEGAL_DIMENSION }; -const char* _kVecErrCodeNames[] = { +const char* _kErrorCodeNames[] = { "SUCCESS", + "CONNECT_FAILED", + "PERMISSION_DENIED", + "TABLE_NOT_EXISTS", + "PARTITION_NOT_EXIST", "ILLEGAL_ARGUMENT", - "GROUP_NOT_EXISTS", - "ILLEGAL_TIME_RANGE", - "ILLEGAL_VECTOR_DIMENSION", - "OUT_OF_MEMORY" + "ILLEGAL_RANGE", + "ILLEGAL_DIMENSION" }; -const std::map _VecErrCode_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(6, _kVecErrCodeValues, _kVecErrCodeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); +const std::map _ErrorCode_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(8, _kErrorCodeValues, _kErrorCodeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); -std::ostream& operator<<(std::ostream& out, const VecErrCode::type& val) { - std::map::const_iterator it = _VecErrCode_VALUES_TO_NAMES.find(val); - if (it != _VecErrCode_VALUES_TO_NAMES.end()) { +std::ostream& operator<<(std::ostream& out, const ErrorCode::type& val) { + std::map::const_iterator it = _ErrorCode_VALUES_TO_NAMES.find(val); + if (it != _ErrorCode_VALUES_TO_NAMES.end()) { out << it->second; } else { out << static_cast(val); @@ -42,25 +46,25 @@ std::ostream& operator<<(std::ostream& out, const VecErrCode::type& val) { } -VecException::~VecException() throw() { +Exception::~Exception() throw() { } -void VecException::__set_code(const VecErrCode::type val) { +void Exception::__set_code(const ErrorCode::type val) { this->code = val; } -void VecException::__set_reason(const std::string& val) { +void Exception::__set_reason(const std::string& val) { this->reason = val; } -std::ostream& operator<<(std::ostream& out, const VecException& obj) +std::ostream& operator<<(std::ostream& out, const Exception& obj) { obj.printTo(out); return out; } -uint32_t VecException::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t Exception::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -85,7 +89,7 @@ uint32_t VecException::read(::apache::thrift::protocol::TProtocol* iprot) { if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast0; xfer += iprot->readI32(ecast0); - this->code = (VecErrCode::type)ecast0; + this->code = (ErrorCode::type)ecast0; this->__isset.code = true; } else { xfer += iprot->skip(ftype); @@ -111,10 +115,10 @@ uint32_t VecException::read(::apache::thrift::protocol::TProtocol* iprot) { return xfer; } -uint32_t VecException::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t Exception::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecException"); + xfer += oprot->writeStructBegin("Exception"); xfer += oprot->writeFieldBegin("code", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->code); @@ -129,68 +133,63 @@ uint32_t VecException::write(::apache::thrift::protocol::TProtocol* oprot) const return xfer; } -void swap(VecException &a, VecException &b) { +void swap(Exception &a, Exception &b) { using ::std::swap; swap(a.code, b.code); swap(a.reason, b.reason); swap(a.__isset, b.__isset); } -VecException::VecException(const VecException& other1) : TException() { +Exception::Exception(const Exception& other1) : TException() { code = other1.code; reason = other1.reason; __isset = other1.__isset; } -VecException& VecException::operator=(const VecException& other2) { +Exception& Exception::operator=(const Exception& other2) { code = other2.code; reason = other2.reason; __isset = other2.__isset; return *this; } -void VecException::printTo(std::ostream& out) const { +void Exception::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecException("; + out << "Exception("; out << "code=" << to_string(code); out << ", " << "reason=" << to_string(reason); out << ")"; } -const char* VecException::what() const throw() { +const char* Exception::what() const throw() { try { std::stringstream ss; ss << "TException - service has thrown: " << *this; this->thriftTExceptionMessageHolder_ = ss.str(); return this->thriftTExceptionMessageHolder_.c_str(); } catch (const std::exception&) { - return "TException - service has thrown: VecException"; + return "TException - service has thrown: Exception"; } } -VecGroup::~VecGroup() throw() { +Column::~Column() throw() { } -void VecGroup::__set_id(const std::string& val) { - this->id = val; +void Column::__set_type(const int32_t val) { + this->type = val; } -void VecGroup::__set_dimension(const int32_t val) { - this->dimension = val; +void Column::__set_name(const std::string& val) { + this->name = val; } - -void VecGroup::__set_index_type(const int32_t val) { - this->index_type = val; -__isset.index_type = true; -} -std::ostream& operator<<(std::ostream& out, const VecGroup& obj) +std::ostream& operator<<(std::ostream& out, const Column& obj) { obj.printTo(out); return out; } -uint32_t VecGroup::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t Column::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -202,8 +201,8 @@ uint32_t VecGroup::read(::apache::thrift::protocol::TProtocol* iprot) { using ::apache::thrift::protocol::TProtocolException; - bool isset_id = false; - bool isset_dimension = false; + bool isset_type = false; + bool isset_name = false; while (true) { @@ -214,25 +213,157 @@ uint32_t VecGroup::read(::apache::thrift::protocol::TProtocol* iprot) { switch (fid) { case 1: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->id); - isset_id = true; + if (ftype == ::apache::thrift::protocol::T_I32) { + xfer += iprot->readI32(this->type); + isset_type = true; } else { xfer += iprot->skip(ftype); } break; case 2: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->dimension); + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->name); + isset_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_type) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_name) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Column::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Column"); + + xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_I32, 1); + xfer += oprot->writeI32(this->type); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Column &a, Column &b) { + using ::std::swap; + swap(a.type, b.type); + swap(a.name, b.name); +} + +Column::Column(const Column& other3) { + type = other3.type; + name = other3.name; +} +Column& Column::operator=(const Column& other4) { + type = other4.type; + name = other4.name; + return *this; +} +void Column::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Column("; + out << "type=" << to_string(type); + out << ", " << "name=" << to_string(name); + out << ")"; +} + + +VectorColumn::~VectorColumn() throw() { +} + + +void VectorColumn::__set_base(const Column& val) { + this->base = val; +} + +void VectorColumn::__set_dimension(const int64_t val) { + this->dimension = val; +} + +void VectorColumn::__set_index_type(const std::string& val) { + this->index_type = val; +} + +void VectorColumn::__set_store_raw_vector(const bool val) { + this->store_raw_vector = val; +} +std::ostream& operator<<(std::ostream& out, const VectorColumn& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t VectorColumn::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_base = false; + bool isset_dimension = false; + bool isset_index_type = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->base.read(iprot); + isset_base = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->dimension); isset_dimension = true; } else { xfer += iprot->skip(ftype); } break; case 3: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->index_type); - this->__isset.index_type = true; + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->index_type); + isset_index_type = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->store_raw_vector); + this->__isset.store_raw_vector = true; } else { xfer += iprot->skip(ftype); } @@ -246,91 +377,105 @@ uint32_t VecGroup::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->readStructEnd(); - if (!isset_id) + if (!isset_base) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_dimension) throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_index_type) + throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } -uint32_t VecGroup::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t VectorColumn::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecGroup"); + xfer += oprot->writeStructBegin("VectorColumn"); - xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->id); + xfer += oprot->writeFieldBegin("base", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->base.write(oprot); xfer += oprot->writeFieldEnd(); - xfer += oprot->writeFieldBegin("dimension", ::apache::thrift::protocol::T_I32, 2); - xfer += oprot->writeI32(this->dimension); + xfer += oprot->writeFieldBegin("dimension", ::apache::thrift::protocol::T_I64, 2); + xfer += oprot->writeI64(this->dimension); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("index_type", ::apache::thrift::protocol::T_STRING, 3); + xfer += oprot->writeString(this->index_type); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("store_raw_vector", ::apache::thrift::protocol::T_BOOL, 4); + xfer += oprot->writeBool(this->store_raw_vector); xfer += oprot->writeFieldEnd(); - if (this->__isset.index_type) { - xfer += oprot->writeFieldBegin("index_type", ::apache::thrift::protocol::T_I32, 3); - xfer += oprot->writeI32(this->index_type); - xfer += oprot->writeFieldEnd(); - } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } -void swap(VecGroup &a, VecGroup &b) { +void swap(VectorColumn &a, VectorColumn &b) { using ::std::swap; - swap(a.id, b.id); + swap(a.base, b.base); swap(a.dimension, b.dimension); swap(a.index_type, b.index_type); + swap(a.store_raw_vector, b.store_raw_vector); swap(a.__isset, b.__isset); } -VecGroup::VecGroup(const VecGroup& other3) { - id = other3.id; - dimension = other3.dimension; - index_type = other3.index_type; - __isset = other3.__isset; +VectorColumn::VectorColumn(const VectorColumn& other5) { + base = other5.base; + dimension = other5.dimension; + index_type = other5.index_type; + store_raw_vector = other5.store_raw_vector; + __isset = other5.__isset; } -VecGroup& VecGroup::operator=(const VecGroup& other4) { - id = other4.id; - dimension = other4.dimension; - index_type = other4.index_type; - __isset = other4.__isset; +VectorColumn& VectorColumn::operator=(const VectorColumn& other6) { + base = other6.base; + dimension = other6.dimension; + index_type = other6.index_type; + store_raw_vector = other6.store_raw_vector; + __isset = other6.__isset; return *this; } -void VecGroup::printTo(std::ostream& out) const { +void VectorColumn::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecGroup("; - out << "id=" << to_string(id); + out << "VectorColumn("; + out << "base=" << to_string(base); out << ", " << "dimension=" << to_string(dimension); - out << ", " << "index_type="; (__isset.index_type ? (out << to_string(index_type)) : (out << "")); + out << ", " << "index_type=" << to_string(index_type); + out << ", " << "store_raw_vector=" << to_string(store_raw_vector); out << ")"; } -VecTensor::~VecTensor() throw() { +TableSchema::~TableSchema() throw() { } -void VecTensor::__set_uid(const std::string& val) { - this->uid = val; +void TableSchema::__set_table_name(const std::string& val) { + this->table_name = val; } -void VecTensor::__set_tensor(const std::vector & val) { - this->tensor = val; +void TableSchema::__set_vector_column_array(const std::vector & val) { + this->vector_column_array = val; } -void VecTensor::__set_attrib(const std::map & val) { - this->attrib = val; -__isset.attrib = true; +void TableSchema::__set_attribute_column_array(const std::vector & val) { + this->attribute_column_array = val; +__isset.attribute_column_array = true; } -std::ostream& operator<<(std::ostream& out, const VecTensor& obj) + +void TableSchema::__set_partition_column_name_array(const std::vector & val) { + this->partition_column_name_array = val; +__isset.partition_column_name_array = true; +} +std::ostream& operator<<(std::ostream& out, const TableSchema& obj) { obj.printTo(out); return out; } -uint32_t VecTensor::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t TableSchema::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -342,8 +487,8 @@ uint32_t VecTensor::read(::apache::thrift::protocol::TProtocol* iprot) { using ::apache::thrift::protocol::TProtocolException; - bool isset_uid = false; - bool isset_tensor = false; + bool isset_table_name = false; + bool isset_vector_column_array = false; while (true) { @@ -355,8 +500,8 @@ uint32_t VecTensor::read(::apache::thrift::protocol::TProtocol* iprot) { { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->uid); - isset_uid = true; + xfer += iprot->readString(this->table_name); + isset_table_name = true; } else { xfer += iprot->skip(ftype); } @@ -364,42 +509,59 @@ uint32_t VecTensor::read(::apache::thrift::protocol::TProtocol* iprot) { case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { - this->tensor.clear(); - uint32_t _size5; - ::apache::thrift::protocol::TType _etype8; - xfer += iprot->readListBegin(_etype8, _size5); - this->tensor.resize(_size5); - uint32_t _i9; - for (_i9 = 0; _i9 < _size5; ++_i9) + this->vector_column_array.clear(); + uint32_t _size7; + ::apache::thrift::protocol::TType _etype10; + xfer += iprot->readListBegin(_etype10, _size7); + this->vector_column_array.resize(_size7); + uint32_t _i11; + for (_i11 = 0; _i11 < _size7; ++_i11) { - xfer += iprot->readDouble(this->tensor[_i9]); + xfer += this->vector_column_array[_i11].read(iprot); } xfer += iprot->readListEnd(); } - isset_tensor = true; + isset_vector_column_array = true; } else { xfer += iprot->skip(ftype); } break; case 3: - if (ftype == ::apache::thrift::protocol::T_MAP) { + if (ftype == ::apache::thrift::protocol::T_LIST) { { - this->attrib.clear(); - uint32_t _size10; - ::apache::thrift::protocol::TType _ktype11; - ::apache::thrift::protocol::TType _vtype12; - xfer += iprot->readMapBegin(_ktype11, _vtype12, _size10); - uint32_t _i14; - for (_i14 = 0; _i14 < _size10; ++_i14) + this->attribute_column_array.clear(); + uint32_t _size12; + ::apache::thrift::protocol::TType _etype15; + xfer += iprot->readListBegin(_etype15, _size12); + this->attribute_column_array.resize(_size12); + uint32_t _i16; + for (_i16 = 0; _i16 < _size12; ++_i16) { - std::string _key15; - xfer += iprot->readString(_key15); - std::string& _val16 = this->attrib[_key15]; - xfer += iprot->readString(_val16); + xfer += this->attribute_column_array[_i16].read(iprot); } - xfer += iprot->readMapEnd(); + xfer += iprot->readListEnd(); } - this->__isset.attrib = true; + this->__isset.attribute_column_array = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->partition_column_name_array.clear(); + uint32_t _size17; + ::apache::thrift::protocol::TType _etype20; + xfer += iprot->readListBegin(_etype20, _size17); + this->partition_column_name_array.resize(_size17); + uint32_t _i21; + for (_i21 = 0; _i21 < _size17; ++_i21) + { + xfer += iprot->readString(this->partition_column_name_array[_i21]); + } + xfer += iprot->readListEnd(); + } + this->__isset.partition_column_name_array = true; } else { xfer += iprot->skip(ftype); } @@ -413,45 +575,57 @@ uint32_t VecTensor::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->readStructEnd(); - if (!isset_uid) + if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_tensor) + if (!isset_vector_column_array) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } -uint32_t VecTensor::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t TableSchema::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecTensor"); + xfer += oprot->writeStructBegin("TableSchema"); - xfer += oprot->writeFieldBegin("uid", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->uid); + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->table_name); xfer += oprot->writeFieldEnd(); - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_LIST, 2); + xfer += oprot->writeFieldBegin("vector_column_array", ::apache::thrift::protocol::T_LIST, 2); { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_DOUBLE, static_cast(this->tensor.size())); - std::vector ::const_iterator _iter17; - for (_iter17 = this->tensor.begin(); _iter17 != this->tensor.end(); ++_iter17) + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->vector_column_array.size())); + std::vector ::const_iterator _iter22; + for (_iter22 = this->vector_column_array.begin(); _iter22 != this->vector_column_array.end(); ++_iter22) { - xfer += oprot->writeDouble((*_iter17)); + xfer += (*_iter22).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); - if (this->__isset.attrib) { - xfer += oprot->writeFieldBegin("attrib", ::apache::thrift::protocol::T_MAP, 3); + if (this->__isset.attribute_column_array) { + xfer += oprot->writeFieldBegin("attribute_column_array", ::apache::thrift::protocol::T_LIST, 3); { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->attrib.size())); - std::map ::const_iterator _iter18; - for (_iter18 = this->attrib.begin(); _iter18 != this->attrib.end(); ++_iter18) + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->attribute_column_array.size())); + std::vector ::const_iterator _iter23; + for (_iter23 = this->attribute_column_array.begin(); _iter23 != this->attribute_column_array.end(); ++_iter23) { - xfer += oprot->writeString(_iter18->first); - xfer += oprot->writeString(_iter18->second); + xfer += (*_iter23).write(oprot); } - xfer += oprot->writeMapEnd(); + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.partition_column_name_array) { + xfer += oprot->writeFieldBegin("partition_column_name_array", ::apache::thrift::protocol::T_LIST, 4); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->partition_column_name_array.size())); + std::vector ::const_iterator _iter24; + for (_iter24 = this->partition_column_name_array.begin(); _iter24 != this->partition_column_name_array.end(); ++_iter24) + { + xfer += oprot->writeString((*_iter24)); + } + xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); } @@ -460,52 +634,60 @@ uint32_t VecTensor::write(::apache::thrift::protocol::TProtocol* oprot) const { return xfer; } -void swap(VecTensor &a, VecTensor &b) { +void swap(TableSchema &a, TableSchema &b) { using ::std::swap; - swap(a.uid, b.uid); - swap(a.tensor, b.tensor); - swap(a.attrib, b.attrib); + swap(a.table_name, b.table_name); + swap(a.vector_column_array, b.vector_column_array); + swap(a.attribute_column_array, b.attribute_column_array); + swap(a.partition_column_name_array, b.partition_column_name_array); swap(a.__isset, b.__isset); } -VecTensor::VecTensor(const VecTensor& other19) { - uid = other19.uid; - tensor = other19.tensor; - attrib = other19.attrib; - __isset = other19.__isset; +TableSchema::TableSchema(const TableSchema& other25) { + table_name = other25.table_name; + vector_column_array = other25.vector_column_array; + attribute_column_array = other25.attribute_column_array; + partition_column_name_array = other25.partition_column_name_array; + __isset = other25.__isset; } -VecTensor& VecTensor::operator=(const VecTensor& other20) { - uid = other20.uid; - tensor = other20.tensor; - attrib = other20.attrib; - __isset = other20.__isset; +TableSchema& TableSchema::operator=(const TableSchema& other26) { + table_name = other26.table_name; + vector_column_array = other26.vector_column_array; + attribute_column_array = other26.attribute_column_array; + partition_column_name_array = other26.partition_column_name_array; + __isset = other26.__isset; return *this; } -void VecTensor::printTo(std::ostream& out) const { +void TableSchema::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecTensor("; - out << "uid=" << to_string(uid); - out << ", " << "tensor=" << to_string(tensor); - out << ", " << "attrib="; (__isset.attrib ? (out << to_string(attrib)) : (out << "")); + out << "TableSchema("; + out << "table_name=" << to_string(table_name); + out << ", " << "vector_column_array=" << to_string(vector_column_array); + out << ", " << "attribute_column_array="; (__isset.attribute_column_array ? (out << to_string(attribute_column_array)) : (out << "")); + out << ", " << "partition_column_name_array="; (__isset.partition_column_name_array ? (out << to_string(partition_column_name_array)) : (out << "")); out << ")"; } -VecTensorList::~VecTensorList() throw() { +Range::~Range() throw() { } -void VecTensorList::__set_tensor_list(const std::vector & val) { - this->tensor_list = val; +void Range::__set_start_value(const std::string& val) { + this->start_value = val; } -std::ostream& operator<<(std::ostream& out, const VecTensorList& obj) + +void Range::__set_end_value(const std::string& val) { + this->end_value = val; +} +std::ostream& operator<<(std::ostream& out, const Range& obj) { obj.printTo(out); return out; } -uint32_t VecTensorList::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t Range::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -517,7 +699,8 @@ uint32_t VecTensorList::read(::apache::thrift::protocol::TProtocol* iprot) { using ::apache::thrift::protocol::TProtocolException; - bool isset_tensor_list = false; + bool isset_start_value = false; + bool isset_end_value = false; while (true) { @@ -528,21 +711,17 @@ uint32_t VecTensorList::read(::apache::thrift::protocol::TProtocol* iprot) { switch (fid) { case 1: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->tensor_list.clear(); - uint32_t _size21; - ::apache::thrift::protocol::TType _etype24; - xfer += iprot->readListBegin(_etype24, _size21); - this->tensor_list.resize(_size21); - uint32_t _i25; - for (_i25 = 0; _i25 < _size21; ++_i25) - { - xfer += this->tensor_list[_i25].read(iprot); - } - xfer += iprot->readListEnd(); - } - isset_tensor_list = true; + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->start_value); + isset_start_value = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->end_value); + isset_end_value = true; } else { xfer += iprot->skip(ftype); } @@ -556,26 +735,24 @@ uint32_t VecTensorList::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->readStructEnd(); - if (!isset_tensor_list) + if (!isset_start_value) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_end_value) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } -uint32_t VecTensorList::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t Range::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecTensorList"); + xfer += oprot->writeStructBegin("Range"); - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_LIST, 1); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->tensor_list.size())); - std::vector ::const_iterator _iter26; - for (_iter26 = this->tensor_list.begin(); _iter26 != this->tensor_list.end(); ++_iter26) - { - xfer += (*_iter26).write(oprot); - } - xfer += oprot->writeListEnd(); - } + xfer += oprot->writeFieldBegin("start_value", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->start_value); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("end_value", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->end_value); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); @@ -583,50 +760,53 @@ uint32_t VecTensorList::write(::apache::thrift::protocol::TProtocol* oprot) cons return xfer; } -void swap(VecTensorList &a, VecTensorList &b) { +void swap(Range &a, Range &b) { using ::std::swap; - swap(a.tensor_list, b.tensor_list); + swap(a.start_value, b.start_value); + swap(a.end_value, b.end_value); } -VecTensorList::VecTensorList(const VecTensorList& other27) { - tensor_list = other27.tensor_list; +Range::Range(const Range& other27) { + start_value = other27.start_value; + end_value = other27.end_value; } -VecTensorList& VecTensorList::operator=(const VecTensorList& other28) { - tensor_list = other28.tensor_list; +Range& Range::operator=(const Range& other28) { + start_value = other28.start_value; + end_value = other28.end_value; return *this; } -void VecTensorList::printTo(std::ostream& out) const { +void Range::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecTensorList("; - out << "tensor_list=" << to_string(tensor_list); + out << "Range("; + out << "start_value=" << to_string(start_value); + out << ", " << "end_value=" << to_string(end_value); out << ")"; } -VecBinaryTensor::~VecBinaryTensor() throw() { +CreateTablePartitionParam::~CreateTablePartitionParam() throw() { } -void VecBinaryTensor::__set_uid(const std::string& val) { - this->uid = val; +void CreateTablePartitionParam::__set_table_name(const std::string& val) { + this->table_name = val; } -void VecBinaryTensor::__set_tensor(const std::string& val) { - this->tensor = val; +void CreateTablePartitionParam::__set_partition_name(const std::string& val) { + this->partition_name = val; } -void VecBinaryTensor::__set_attrib(const std::map & val) { - this->attrib = val; -__isset.attrib = true; +void CreateTablePartitionParam::__set_range_map(const std::map & val) { + this->range_map = val; } -std::ostream& operator<<(std::ostream& out, const VecBinaryTensor& obj) +std::ostream& operator<<(std::ostream& out, const CreateTablePartitionParam& obj) { obj.printTo(out); return out; } -uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t CreateTablePartitionParam::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -638,8 +818,9 @@ uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { using ::apache::thrift::protocol::TProtocolException; - bool isset_uid = false; - bool isset_tensor = false; + bool isset_table_name = false; + bool isset_partition_name = false; + bool isset_range_map = false; while (true) { @@ -651,16 +832,16 @@ uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->uid); - isset_uid = true; + xfer += iprot->readString(this->table_name); + isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readBinary(this->tensor); - isset_tensor = true; + xfer += iprot->readString(this->partition_name); + isset_partition_name = true; } else { xfer += iprot->skip(ftype); } @@ -668,7 +849,7 @@ uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { case 3: if (ftype == ::apache::thrift::protocol::T_MAP) { { - this->attrib.clear(); + this->range_map.clear(); uint32_t _size29; ::apache::thrift::protocol::TType _ktype30; ::apache::thrift::protocol::TType _vtype31; @@ -678,12 +859,12 @@ uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { { std::string _key34; xfer += iprot->readString(_key34); - std::string& _val35 = this->attrib[_key34]; - xfer += iprot->readString(_val35); + Range& _val35 = this->range_map[_key34]; + xfer += _val35.read(iprot); } xfer += iprot->readMapEnd(); } - this->__isset.attrib = true; + isset_range_map = true; } else { xfer += iprot->skip(ftype); } @@ -697,91 +878,93 @@ uint32_t VecBinaryTensor::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->readStructEnd(); - if (!isset_uid) + if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_tensor) + if (!isset_partition_name) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_range_map) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } -uint32_t VecBinaryTensor::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t CreateTablePartitionParam::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecBinaryTensor"); + xfer += oprot->writeStructBegin("CreateTablePartitionParam"); - xfer += oprot->writeFieldBegin("uid", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->uid); + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->table_name); xfer += oprot->writeFieldEnd(); - xfer += oprot->writeFieldBegin("tensor", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeBinary(this->tensor); + xfer += oprot->writeFieldBegin("partition_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->partition_name); xfer += oprot->writeFieldEnd(); - if (this->__isset.attrib) { - xfer += oprot->writeFieldBegin("attrib", ::apache::thrift::protocol::T_MAP, 3); + xfer += oprot->writeFieldBegin("range_map", ::apache::thrift::protocol::T_MAP, 3); + { + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast(this->range_map.size())); + std::map ::const_iterator _iter36; + for (_iter36 = this->range_map.begin(); _iter36 != this->range_map.end(); ++_iter36) { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->attrib.size())); - std::map ::const_iterator _iter36; - for (_iter36 = this->attrib.begin(); _iter36 != this->attrib.end(); ++_iter36) - { - xfer += oprot->writeString(_iter36->first); - xfer += oprot->writeString(_iter36->second); - } - xfer += oprot->writeMapEnd(); + xfer += oprot->writeString(_iter36->first); + xfer += _iter36->second.write(oprot); } - xfer += oprot->writeFieldEnd(); + xfer += oprot->writeMapEnd(); } + xfer += oprot->writeFieldEnd(); + xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } -void swap(VecBinaryTensor &a, VecBinaryTensor &b) { +void swap(CreateTablePartitionParam &a, CreateTablePartitionParam &b) { using ::std::swap; - swap(a.uid, b.uid); - swap(a.tensor, b.tensor); - swap(a.attrib, b.attrib); - swap(a.__isset, b.__isset); + swap(a.table_name, b.table_name); + swap(a.partition_name, b.partition_name); + swap(a.range_map, b.range_map); } -VecBinaryTensor::VecBinaryTensor(const VecBinaryTensor& other37) { - uid = other37.uid; - tensor = other37.tensor; - attrib = other37.attrib; - __isset = other37.__isset; +CreateTablePartitionParam::CreateTablePartitionParam(const CreateTablePartitionParam& other37) { + table_name = other37.table_name; + partition_name = other37.partition_name; + range_map = other37.range_map; } -VecBinaryTensor& VecBinaryTensor::operator=(const VecBinaryTensor& other38) { - uid = other38.uid; - tensor = other38.tensor; - attrib = other38.attrib; - __isset = other38.__isset; +CreateTablePartitionParam& CreateTablePartitionParam::operator=(const CreateTablePartitionParam& other38) { + table_name = other38.table_name; + partition_name = other38.partition_name; + range_map = other38.range_map; return *this; } -void VecBinaryTensor::printTo(std::ostream& out) const { +void CreateTablePartitionParam::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecBinaryTensor("; - out << "uid=" << to_string(uid); - out << ", " << "tensor=" << to_string(tensor); - out << ", " << "attrib="; (__isset.attrib ? (out << to_string(attrib)) : (out << "")); + out << "CreateTablePartitionParam("; + out << "table_name=" << to_string(table_name); + out << ", " << "partition_name=" << to_string(partition_name); + out << ", " << "range_map=" << to_string(range_map); out << ")"; } -VecBinaryTensorList::~VecBinaryTensorList() throw() { +DeleteTablePartitionParam::~DeleteTablePartitionParam() throw() { } -void VecBinaryTensorList::__set_tensor_list(const std::vector & val) { - this->tensor_list = val; +void DeleteTablePartitionParam::__set_table_name(const std::string& val) { + this->table_name = val; } -std::ostream& operator<<(std::ostream& out, const VecBinaryTensorList& obj) + +void DeleteTablePartitionParam::__set_partition_name_array(const std::vector & val) { + this->partition_name_array = val; +} +std::ostream& operator<<(std::ostream& out, const DeleteTablePartitionParam& obj) { obj.printTo(out); return out; } -uint32_t VecBinaryTensorList::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t DeleteTablePartitionParam::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -793,129 +976,8 @@ uint32_t VecBinaryTensorList::read(::apache::thrift::protocol::TProtocol* iprot) using ::apache::thrift::protocol::TProtocolException; - bool isset_tensor_list = false; - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->tensor_list.clear(); - uint32_t _size39; - ::apache::thrift::protocol::TType _etype42; - xfer += iprot->readListBegin(_etype42, _size39); - this->tensor_list.resize(_size39); - uint32_t _i43; - for (_i43 = 0; _i43 < _size39; ++_i43) - { - xfer += this->tensor_list[_i43].read(iprot); - } - xfer += iprot->readListEnd(); - } - isset_tensor_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - if (!isset_tensor_list) - throw TProtocolException(TProtocolException::INVALID_DATA); - return xfer; -} - -uint32_t VecBinaryTensorList::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecBinaryTensorList"); - - xfer += oprot->writeFieldBegin("tensor_list", ::apache::thrift::protocol::T_LIST, 1); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->tensor_list.size())); - std::vector ::const_iterator _iter44; - for (_iter44 = this->tensor_list.begin(); _iter44 != this->tensor_list.end(); ++_iter44) - { - xfer += (*_iter44).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(VecBinaryTensorList &a, VecBinaryTensorList &b) { - using ::std::swap; - swap(a.tensor_list, b.tensor_list); -} - -VecBinaryTensorList::VecBinaryTensorList(const VecBinaryTensorList& other45) { - tensor_list = other45.tensor_list; -} -VecBinaryTensorList& VecBinaryTensorList::operator=(const VecBinaryTensorList& other46) { - tensor_list = other46.tensor_list; - return *this; -} -void VecBinaryTensorList::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "VecBinaryTensorList("; - out << "tensor_list=" << to_string(tensor_list); - out << ")"; -} - - -VecSearchResultItem::~VecSearchResultItem() throw() { -} - - -void VecSearchResultItem::__set_uid(const std::string& val) { - this->uid = val; -} - -void VecSearchResultItem::__set_distance(const double val) { - this->distance = val; -__isset.distance = true; -} - -void VecSearchResultItem::__set_attrib(const std::map & val) { - this->attrib = val; -__isset.attrib = true; -} -std::ostream& operator<<(std::ostream& out, const VecSearchResultItem& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t VecSearchResultItem::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - bool isset_uid = false; + bool isset_table_name = false; + bool isset_partition_name_array = false; while (true) { @@ -927,24 +989,142 @@ uint32_t VecSearchResultItem::read(::apache::thrift::protocol::TProtocol* iprot) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->uid); - isset_uid = true; + xfer += iprot->readString(this->table_name); + isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: - if (ftype == ::apache::thrift::protocol::T_DOUBLE) { - xfer += iprot->readDouble(this->distance); - this->__isset.distance = true; + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->partition_name_array.clear(); + uint32_t _size39; + ::apache::thrift::protocol::TType _etype42; + xfer += iprot->readListBegin(_etype42, _size39); + this->partition_name_array.resize(_size39); + uint32_t _i43; + for (_i43 = 0; _i43 < _size39; ++_i43) + { + xfer += iprot->readString(this->partition_name_array[_i43]); + } + xfer += iprot->readListEnd(); + } + isset_partition_name_array = true; } else { xfer += iprot->skip(ftype); } break; - case 3: + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_table_name) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_partition_name_array) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t DeleteTablePartitionParam::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("DeleteTablePartitionParam"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("partition_name_array", ::apache::thrift::protocol::T_LIST, 2); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->partition_name_array.size())); + std::vector ::const_iterator _iter44; + for (_iter44 = this->partition_name_array.begin(); _iter44 != this->partition_name_array.end(); ++_iter44) + { + xfer += oprot->writeString((*_iter44)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(DeleteTablePartitionParam &a, DeleteTablePartitionParam &b) { + using ::std::swap; + swap(a.table_name, b.table_name); + swap(a.partition_name_array, b.partition_name_array); +} + +DeleteTablePartitionParam::DeleteTablePartitionParam(const DeleteTablePartitionParam& other45) { + table_name = other45.table_name; + partition_name_array = other45.partition_name_array; +} +DeleteTablePartitionParam& DeleteTablePartitionParam::operator=(const DeleteTablePartitionParam& other46) { + table_name = other46.table_name; + partition_name_array = other46.partition_name_array; + return *this; +} +void DeleteTablePartitionParam::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "DeleteTablePartitionParam("; + out << "table_name=" << to_string(table_name); + out << ", " << "partition_name_array=" << to_string(partition_name_array); + out << ")"; +} + + +RowRecord::~RowRecord() throw() { +} + + +void RowRecord::__set_vector_map(const std::map & val) { + this->vector_map = val; +} + +void RowRecord::__set_attribute_map(const std::map & val) { + this->attribute_map = val; +} +std::ostream& operator<<(std::ostream& out, const RowRecord& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t RowRecord::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_vector_map = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: if (ftype == ::apache::thrift::protocol::T_MAP) { { - this->attrib.clear(); + this->vector_map.clear(); uint32_t _size47; ::apache::thrift::protocol::TType _ktype48; ::apache::thrift::protocol::TType _vtype49; @@ -954,12 +1134,35 @@ uint32_t VecSearchResultItem::read(::apache::thrift::protocol::TProtocol* iprot) { std::string _key52; xfer += iprot->readString(_key52); - std::string& _val53 = this->attrib[_key52]; - xfer += iprot->readString(_val53); + std::string& _val53 = this->vector_map[_key52]; + xfer += iprot->readBinary(_val53); } xfer += iprot->readMapEnd(); } - this->__isset.attrib = true; + isset_vector_map = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_MAP) { + { + this->attribute_map.clear(); + uint32_t _size54; + ::apache::thrift::protocol::TType _ktype55; + ::apache::thrift::protocol::TType _vtype56; + xfer += iprot->readMapBegin(_ktype55, _vtype56, _size54); + uint32_t _i58; + for (_i58 = 0; _i58 < _size54; ++_i58) + { + std::string _key59; + xfer += iprot->readString(_key59); + std::string& _val60 = this->attribute_map[_key59]; + xfer += iprot->readString(_val60); + } + xfer += iprot->readMapEnd(); + } + this->__isset.attribute_map = true; } else { xfer += iprot->skip(ftype); } @@ -973,156 +1176,39 @@ uint32_t VecSearchResultItem::read(::apache::thrift::protocol::TProtocol* iprot) xfer += iprot->readStructEnd(); - if (!isset_uid) + if (!isset_vector_map) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } -uint32_t VecSearchResultItem::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t RowRecord::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecSearchResultItem"); + xfer += oprot->writeStructBegin("RowRecord"); - xfer += oprot->writeFieldBegin("uid", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->uid); + xfer += oprot->writeFieldBegin("vector_map", ::apache::thrift::protocol::T_MAP, 1); + { + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->vector_map.size())); + std::map ::const_iterator _iter61; + for (_iter61 = this->vector_map.begin(); _iter61 != this->vector_map.end(); ++_iter61) + { + xfer += oprot->writeString(_iter61->first); + xfer += oprot->writeBinary(_iter61->second); + } + xfer += oprot->writeMapEnd(); + } xfer += oprot->writeFieldEnd(); - if (this->__isset.distance) { - xfer += oprot->writeFieldBegin("distance", ::apache::thrift::protocol::T_DOUBLE, 2); - xfer += oprot->writeDouble(this->distance); - xfer += oprot->writeFieldEnd(); - } - if (this->__isset.attrib) { - xfer += oprot->writeFieldBegin("attrib", ::apache::thrift::protocol::T_MAP, 3); - { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->attrib.size())); - std::map ::const_iterator _iter54; - for (_iter54 = this->attrib.begin(); _iter54 != this->attrib.end(); ++_iter54) - { - xfer += oprot->writeString(_iter54->first); - xfer += oprot->writeString(_iter54->second); - } - xfer += oprot->writeMapEnd(); - } - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(VecSearchResultItem &a, VecSearchResultItem &b) { - using ::std::swap; - swap(a.uid, b.uid); - swap(a.distance, b.distance); - swap(a.attrib, b.attrib); - swap(a.__isset, b.__isset); -} - -VecSearchResultItem::VecSearchResultItem(const VecSearchResultItem& other55) { - uid = other55.uid; - distance = other55.distance; - attrib = other55.attrib; - __isset = other55.__isset; -} -VecSearchResultItem& VecSearchResultItem::operator=(const VecSearchResultItem& other56) { - uid = other56.uid; - distance = other56.distance; - attrib = other56.attrib; - __isset = other56.__isset; - return *this; -} -void VecSearchResultItem::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "VecSearchResultItem("; - out << "uid=" << to_string(uid); - out << ", " << "distance="; (__isset.distance ? (out << to_string(distance)) : (out << "")); - out << ", " << "attrib="; (__isset.attrib ? (out << to_string(attrib)) : (out << "")); - out << ")"; -} - - -VecSearchResult::~VecSearchResult() throw() { -} - - -void VecSearchResult::__set_result_list(const std::vector & val) { - this->result_list = val; -} -std::ostream& operator<<(std::ostream& out, const VecSearchResult& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t VecSearchResult::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) + xfer += oprot->writeFieldBegin("attribute_map", ::apache::thrift::protocol::T_MAP, 2); { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->attribute_map.size())); + std::map ::const_iterator _iter62; + for (_iter62 = this->attribute_map.begin(); _iter62 != this->attribute_map.end(); ++_iter62) { - case 1: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->result_list.clear(); - uint32_t _size57; - ::apache::thrift::protocol::TType _etype60; - xfer += iprot->readListBegin(_etype60, _size57); - this->result_list.resize(_size57); - uint32_t _i61; - for (_i61 = 0; _i61 < _size57; ++_i61) - { - xfer += this->result_list[_i61].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.result_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; + xfer += oprot->writeString(_iter62->first); + xfer += oprot->writeString(_iter62->second); } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecSearchResult::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecSearchResult"); - - xfer += oprot->writeFieldBegin("result_list", ::apache::thrift::protocol::T_LIST, 1); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->result_list.size())); - std::vector ::const_iterator _iter62; - for (_iter62 = this->result_list.begin(); _iter62 != this->result_list.end(); ++_iter62) - { - xfer += (*_iter62).write(oprot); - } - xfer += oprot->writeListEnd(); + xfer += oprot->writeMapEnd(); } xfer += oprot->writeFieldEnd(); @@ -1131,535 +1217,58 @@ uint32_t VecSearchResult::write(::apache::thrift::protocol::TProtocol* oprot) co return xfer; } -void swap(VecSearchResult &a, VecSearchResult &b) { +void swap(RowRecord &a, RowRecord &b) { using ::std::swap; - swap(a.result_list, b.result_list); + swap(a.vector_map, b.vector_map); + swap(a.attribute_map, b.attribute_map); swap(a.__isset, b.__isset); } -VecSearchResult::VecSearchResult(const VecSearchResult& other63) { - result_list = other63.result_list; +RowRecord::RowRecord(const RowRecord& other63) { + vector_map = other63.vector_map; + attribute_map = other63.attribute_map; __isset = other63.__isset; } -VecSearchResult& VecSearchResult::operator=(const VecSearchResult& other64) { - result_list = other64.result_list; +RowRecord& RowRecord::operator=(const RowRecord& other64) { + vector_map = other64.vector_map; + attribute_map = other64.attribute_map; __isset = other64.__isset; return *this; } -void VecSearchResult::printTo(std::ostream& out) const { +void RowRecord::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecSearchResult("; - out << "result_list=" << to_string(result_list); + out << "RowRecord("; + out << "vector_map=" << to_string(vector_map); + out << ", " << "attribute_map=" << to_string(attribute_map); out << ")"; } -VecSearchResultList::~VecSearchResultList() throw() { +QueryRecord::~QueryRecord() throw() { } -void VecSearchResultList::__set_result_list(const std::vector & val) { - this->result_list = val; +void QueryRecord::__set_vector_map(const std::map & val) { + this->vector_map = val; } -std::ostream& operator<<(std::ostream& out, const VecSearchResultList& obj) + +void QueryRecord::__set_selected_column_array(const std::vector & val) { + this->selected_column_array = val; +__isset.selected_column_array = true; +} + +void QueryRecord::__set_partition_filter_column_map(const std::map > & val) { + this->partition_filter_column_map = val; +__isset.partition_filter_column_map = true; +} +std::ostream& operator<<(std::ostream& out, const QueryRecord& obj) { obj.printTo(out); return out; } -uint32_t VecSearchResultList::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->result_list.clear(); - uint32_t _size65; - ::apache::thrift::protocol::TType _etype68; - xfer += iprot->readListBegin(_etype68, _size65); - this->result_list.resize(_size65); - uint32_t _i69; - for (_i69 = 0; _i69 < _size65; ++_i69) - { - xfer += this->result_list[_i69].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.result_list = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t VecSearchResultList::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecSearchResultList"); - - xfer += oprot->writeFieldBegin("result_list", ::apache::thrift::protocol::T_LIST, 1); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->result_list.size())); - std::vector ::const_iterator _iter70; - for (_iter70 = this->result_list.begin(); _iter70 != this->result_list.end(); ++_iter70) - { - xfer += (*_iter70).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(VecSearchResultList &a, VecSearchResultList &b) { - using ::std::swap; - swap(a.result_list, b.result_list); - swap(a.__isset, b.__isset); -} - -VecSearchResultList::VecSearchResultList(const VecSearchResultList& other71) { - result_list = other71.result_list; - __isset = other71.__isset; -} -VecSearchResultList& VecSearchResultList::operator=(const VecSearchResultList& other72) { - result_list = other72.result_list; - __isset = other72.__isset; - return *this; -} -void VecSearchResultList::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "VecSearchResultList("; - out << "result_list=" << to_string(result_list); - out << ")"; -} - - -VecDateTime::~VecDateTime() throw() { -} - - -void VecDateTime::__set_year(const int32_t val) { - this->year = val; -} - -void VecDateTime::__set_month(const int32_t val) { - this->month = val; -} - -void VecDateTime::__set_day(const int32_t val) { - this->day = val; -} - -void VecDateTime::__set_hour(const int32_t val) { - this->hour = val; -} - -void VecDateTime::__set_minute(const int32_t val) { - this->minute = val; -} - -void VecDateTime::__set_second(const int32_t val) { - this->second = val; -} -std::ostream& operator<<(std::ostream& out, const VecDateTime& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t VecDateTime::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - bool isset_year = false; - bool isset_month = false; - bool isset_day = false; - bool isset_hour = false; - bool isset_minute = false; - bool isset_second = false; - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->year); - isset_year = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->month); - isset_month = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->day); - isset_day = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->hour); - isset_hour = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->minute); - isset_minute = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 6: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->second); - isset_second = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - if (!isset_year) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_month) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_day) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_hour) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_minute) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_second) - throw TProtocolException(TProtocolException::INVALID_DATA); - return xfer; -} - -uint32_t VecDateTime::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecDateTime"); - - xfer += oprot->writeFieldBegin("year", ::apache::thrift::protocol::T_I32, 1); - xfer += oprot->writeI32(this->year); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("month", ::apache::thrift::protocol::T_I32, 2); - xfer += oprot->writeI32(this->month); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("day", ::apache::thrift::protocol::T_I32, 3); - xfer += oprot->writeI32(this->day); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("hour", ::apache::thrift::protocol::T_I32, 4); - xfer += oprot->writeI32(this->hour); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("minute", ::apache::thrift::protocol::T_I32, 5); - xfer += oprot->writeI32(this->minute); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("second", ::apache::thrift::protocol::T_I32, 6); - xfer += oprot->writeI32(this->second); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(VecDateTime &a, VecDateTime &b) { - using ::std::swap; - swap(a.year, b.year); - swap(a.month, b.month); - swap(a.day, b.day); - swap(a.hour, b.hour); - swap(a.minute, b.minute); - swap(a.second, b.second); -} - -VecDateTime::VecDateTime(const VecDateTime& other73) { - year = other73.year; - month = other73.month; - day = other73.day; - hour = other73.hour; - minute = other73.minute; - second = other73.second; -} -VecDateTime& VecDateTime::operator=(const VecDateTime& other74) { - year = other74.year; - month = other74.month; - day = other74.day; - hour = other74.hour; - minute = other74.minute; - second = other74.second; - return *this; -} -void VecDateTime::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "VecDateTime("; - out << "year=" << to_string(year); - out << ", " << "month=" << to_string(month); - out << ", " << "day=" << to_string(day); - out << ", " << "hour=" << to_string(hour); - out << ", " << "minute=" << to_string(minute); - out << ", " << "second=" << to_string(second); - out << ")"; -} - - -VecTimeRange::~VecTimeRange() throw() { -} - - -void VecTimeRange::__set_time_begin(const VecDateTime& val) { - this->time_begin = val; -} - -void VecTimeRange::__set_begine_closed(const bool val) { - this->begine_closed = val; -} - -void VecTimeRange::__set_time_end(const VecDateTime& val) { - this->time_end = val; -} - -void VecTimeRange::__set_end_closed(const bool val) { - this->end_closed = val; -} -std::ostream& operator<<(std::ostream& out, const VecTimeRange& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t VecTimeRange::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - bool isset_time_begin = false; - bool isset_begine_closed = false; - bool isset_time_end = false; - bool isset_end_closed = false; - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->time_begin.read(iprot); - isset_time_begin = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_BOOL) { - xfer += iprot->readBool(this->begine_closed); - isset_begine_closed = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->time_end.read(iprot); - isset_time_end = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_BOOL) { - xfer += iprot->readBool(this->end_closed); - isset_end_closed = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - if (!isset_time_begin) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_begine_closed) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_time_end) - throw TProtocolException(TProtocolException::INVALID_DATA); - if (!isset_end_closed) - throw TProtocolException(TProtocolException::INVALID_DATA); - return xfer; -} - -uint32_t VecTimeRange::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecTimeRange"); - - xfer += oprot->writeFieldBegin("time_begin", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->time_begin.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("begine_closed", ::apache::thrift::protocol::T_BOOL, 2); - xfer += oprot->writeBool(this->begine_closed); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("time_end", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->time_end.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("end_closed", ::apache::thrift::protocol::T_BOOL, 4); - xfer += oprot->writeBool(this->end_closed); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(VecTimeRange &a, VecTimeRange &b) { - using ::std::swap; - swap(a.time_begin, b.time_begin); - swap(a.begine_closed, b.begine_closed); - swap(a.time_end, b.time_end); - swap(a.end_closed, b.end_closed); -} - -VecTimeRange::VecTimeRange(const VecTimeRange& other75) { - time_begin = other75.time_begin; - begine_closed = other75.begine_closed; - time_end = other75.time_end; - end_closed = other75.end_closed; -} -VecTimeRange& VecTimeRange::operator=(const VecTimeRange& other76) { - time_begin = other76.time_begin; - begine_closed = other76.begine_closed; - time_end = other76.time_end; - end_closed = other76.end_closed; - return *this; -} -void VecTimeRange::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "VecTimeRange("; - out << "time_begin=" << to_string(time_begin); - out << ", " << "begine_closed=" << to_string(begine_closed); - out << ", " << "time_end=" << to_string(time_end); - out << ", " << "end_closed=" << to_string(end_closed); - out << ")"; -} - - -VecSearchFilter::~VecSearchFilter() throw() { -} - - -void VecSearchFilter::__set_attrib_filter(const std::map & val) { - this->attrib_filter = val; -__isset.attrib_filter = true; -} - -void VecSearchFilter::__set_time_ranges(const std::vector & val) { - this->time_ranges = val; -__isset.time_ranges = true; -} - -void VecSearchFilter::__set_return_attribs(const std::vector & val) { - this->return_attribs = val; -__isset.return_attribs = true; -} -std::ostream& operator<<(std::ostream& out, const VecSearchFilter& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t VecSearchFilter::read(::apache::thrift::protocol::TProtocol* iprot) { +uint32_t QueryRecord::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; @@ -1671,6 +1280,7 @@ uint32_t VecSearchFilter::read(::apache::thrift::protocol::TProtocol* iprot) { using ::apache::thrift::protocol::TProtocolException; + bool isset_vector_map = false; while (true) { @@ -1683,7 +1293,50 @@ uint32_t VecSearchFilter::read(::apache::thrift::protocol::TProtocol* iprot) { case 1: if (ftype == ::apache::thrift::protocol::T_MAP) { { - this->attrib_filter.clear(); + this->vector_map.clear(); + uint32_t _size65; + ::apache::thrift::protocol::TType _ktype66; + ::apache::thrift::protocol::TType _vtype67; + xfer += iprot->readMapBegin(_ktype66, _vtype67, _size65); + uint32_t _i69; + for (_i69 = 0; _i69 < _size65; ++_i69) + { + std::string _key70; + xfer += iprot->readString(_key70); + std::string& _val71 = this->vector_map[_key70]; + xfer += iprot->readBinary(_val71); + } + xfer += iprot->readMapEnd(); + } + isset_vector_map = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->selected_column_array.clear(); + uint32_t _size72; + ::apache::thrift::protocol::TType _etype75; + xfer += iprot->readListBegin(_etype75, _size72); + this->selected_column_array.resize(_size72); + uint32_t _i76; + for (_i76 = 0; _i76 < _size72; ++_i76) + { + xfer += iprot->readString(this->selected_column_array[_i76]); + } + xfer += iprot->readListEnd(); + } + this->__isset.selected_column_array = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_MAP) { + { + this->partition_filter_column_map.clear(); uint32_t _size77; ::apache::thrift::protocol::TType _ktype78; ::apache::thrift::protocol::TType _vtype79; @@ -1693,52 +1346,209 @@ uint32_t VecSearchFilter::read(::apache::thrift::protocol::TProtocol* iprot) { { std::string _key82; xfer += iprot->readString(_key82); - std::string& _val83 = this->attrib_filter[_key82]; - xfer += iprot->readString(_val83); + std::vector & _val83 = this->partition_filter_column_map[_key82]; + { + _val83.clear(); + uint32_t _size84; + ::apache::thrift::protocol::TType _etype87; + xfer += iprot->readListBegin(_etype87, _size84); + _val83.resize(_size84); + uint32_t _i88; + for (_i88 = 0; _i88 < _size84; ++_i88) + { + xfer += _val83[_i88].read(iprot); + } + xfer += iprot->readListEnd(); + } } xfer += iprot->readMapEnd(); } - this->__isset.attrib_filter = true; + this->__isset.partition_filter_column_map = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_vector_map) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t QueryRecord::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("QueryRecord"); + + xfer += oprot->writeFieldBegin("vector_map", ::apache::thrift::protocol::T_MAP, 1); + { + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->vector_map.size())); + std::map ::const_iterator _iter89; + for (_iter89 = this->vector_map.begin(); _iter89 != this->vector_map.end(); ++_iter89) + { + xfer += oprot->writeString(_iter89->first); + xfer += oprot->writeBinary(_iter89->second); + } + xfer += oprot->writeMapEnd(); + } + xfer += oprot->writeFieldEnd(); + + if (this->__isset.selected_column_array) { + xfer += oprot->writeFieldBegin("selected_column_array", ::apache::thrift::protocol::T_LIST, 2); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->selected_column_array.size())); + std::vector ::const_iterator _iter90; + for (_iter90 = this->selected_column_array.begin(); _iter90 != this->selected_column_array.end(); ++_iter90) + { + xfer += oprot->writeString((*_iter90)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.partition_filter_column_map) { + xfer += oprot->writeFieldBegin("partition_filter_column_map", ::apache::thrift::protocol::T_MAP, 3); + { + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_LIST, static_cast(this->partition_filter_column_map.size())); + std::map > ::const_iterator _iter91; + for (_iter91 = this->partition_filter_column_map.begin(); _iter91 != this->partition_filter_column_map.end(); ++_iter91) + { + xfer += oprot->writeString(_iter91->first); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(_iter91->second.size())); + std::vector ::const_iterator _iter92; + for (_iter92 = _iter91->second.begin(); _iter92 != _iter91->second.end(); ++_iter92) + { + xfer += (*_iter92).write(oprot); + } + xfer += oprot->writeListEnd(); + } + } + xfer += oprot->writeMapEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(QueryRecord &a, QueryRecord &b) { + using ::std::swap; + swap(a.vector_map, b.vector_map); + swap(a.selected_column_array, b.selected_column_array); + swap(a.partition_filter_column_map, b.partition_filter_column_map); + swap(a.__isset, b.__isset); +} + +QueryRecord::QueryRecord(const QueryRecord& other93) { + vector_map = other93.vector_map; + selected_column_array = other93.selected_column_array; + partition_filter_column_map = other93.partition_filter_column_map; + __isset = other93.__isset; +} +QueryRecord& QueryRecord::operator=(const QueryRecord& other94) { + vector_map = other94.vector_map; + selected_column_array = other94.selected_column_array; + partition_filter_column_map = other94.partition_filter_column_map; + __isset = other94.__isset; + return *this; +} +void QueryRecord::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "QueryRecord("; + out << "vector_map=" << to_string(vector_map); + out << ", " << "selected_column_array="; (__isset.selected_column_array ? (out << to_string(selected_column_array)) : (out << "")); + out << ", " << "partition_filter_column_map="; (__isset.partition_filter_column_map ? (out << to_string(partition_filter_column_map)) : (out << "")); + out << ")"; +} + + +QueryResult::~QueryResult() throw() { +} + + +void QueryResult::__set_id(const int64_t val) { + this->id = val; +} + +void QueryResult::__set_score(const double val) { + this->score = val; +} + +void QueryResult::__set_column_map(const std::map & val) { + this->column_map = val; +} +std::ostream& operator<<(std::ostream& out, const QueryResult& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t QueryResult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->id); + this->__isset.id = true; } else { xfer += iprot->skip(ftype); } break; case 2: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->time_ranges.clear(); - uint32_t _size84; - ::apache::thrift::protocol::TType _etype87; - xfer += iprot->readListBegin(_etype87, _size84); - this->time_ranges.resize(_size84); - uint32_t _i88; - for (_i88 = 0; _i88 < _size84; ++_i88) - { - xfer += this->time_ranges[_i88].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.time_ranges = true; + if (ftype == ::apache::thrift::protocol::T_DOUBLE) { + xfer += iprot->readDouble(this->score); + this->__isset.score = true; } else { xfer += iprot->skip(ftype); } break; case 3: - if (ftype == ::apache::thrift::protocol::T_LIST) { + if (ftype == ::apache::thrift::protocol::T_MAP) { { - this->return_attribs.clear(); - uint32_t _size89; - ::apache::thrift::protocol::TType _etype92; - xfer += iprot->readListBegin(_etype92, _size89); - this->return_attribs.resize(_size89); - uint32_t _i93; - for (_i93 = 0; _i93 < _size89; ++_i93) + this->column_map.clear(); + uint32_t _size95; + ::apache::thrift::protocol::TType _ktype96; + ::apache::thrift::protocol::TType _vtype97; + xfer += iprot->readMapBegin(_ktype96, _vtype97, _size95); + uint32_t _i99; + for (_i99 = 0; _i99 < _size95; ++_i99) { - xfer += iprot->readString(this->return_attribs[_i93]); + std::string _key100; + xfer += iprot->readString(_key100); + std::string& _val101 = this->column_map[_key100]; + xfer += iprot->readString(_val101); } - xfer += iprot->readListEnd(); + xfer += iprot->readMapEnd(); } - this->__isset.return_attribs = true; + this->__isset.column_map = true; } else { xfer += iprot->skip(ftype); } @@ -1755,84 +1565,177 @@ uint32_t VecSearchFilter::read(::apache::thrift::protocol::TProtocol* iprot) { return xfer; } -uint32_t VecSearchFilter::write(::apache::thrift::protocol::TProtocol* oprot) const { +uint32_t QueryResult::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("VecSearchFilter"); + xfer += oprot->writeStructBegin("QueryResult"); - if (this->__isset.attrib_filter) { - xfer += oprot->writeFieldBegin("attrib_filter", ::apache::thrift::protocol::T_MAP, 1); + xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_I64, 1); + xfer += oprot->writeI64(this->id); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("score", ::apache::thrift::protocol::T_DOUBLE, 2); + xfer += oprot->writeDouble(this->score); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("column_map", ::apache::thrift::protocol::T_MAP, 3); + { + xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->column_map.size())); + std::map ::const_iterator _iter102; + for (_iter102 = this->column_map.begin(); _iter102 != this->column_map.end(); ++_iter102) { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast(this->attrib_filter.size())); - std::map ::const_iterator _iter94; - for (_iter94 = this->attrib_filter.begin(); _iter94 != this->attrib_filter.end(); ++_iter94) - { - xfer += oprot->writeString(_iter94->first); - xfer += oprot->writeString(_iter94->second); - } - xfer += oprot->writeMapEnd(); + xfer += oprot->writeString(_iter102->first); + xfer += oprot->writeString(_iter102->second); } - xfer += oprot->writeFieldEnd(); - } - if (this->__isset.time_ranges) { - xfer += oprot->writeFieldBegin("time_ranges", ::apache::thrift::protocol::T_LIST, 2); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->time_ranges.size())); - std::vector ::const_iterator _iter95; - for (_iter95 = this->time_ranges.begin(); _iter95 != this->time_ranges.end(); ++_iter95) - { - xfer += (*_iter95).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - } - if (this->__isset.return_attribs) { - xfer += oprot->writeFieldBegin("return_attribs", ::apache::thrift::protocol::T_LIST, 3); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->return_attribs.size())); - std::vector ::const_iterator _iter96; - for (_iter96 = this->return_attribs.begin(); _iter96 != this->return_attribs.end(); ++_iter96) - { - xfer += oprot->writeString((*_iter96)); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); + xfer += oprot->writeMapEnd(); } + xfer += oprot->writeFieldEnd(); + xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } -void swap(VecSearchFilter &a, VecSearchFilter &b) { +void swap(QueryResult &a, QueryResult &b) { using ::std::swap; - swap(a.attrib_filter, b.attrib_filter); - swap(a.time_ranges, b.time_ranges); - swap(a.return_attribs, b.return_attribs); + swap(a.id, b.id); + swap(a.score, b.score); + swap(a.column_map, b.column_map); swap(a.__isset, b.__isset); } -VecSearchFilter::VecSearchFilter(const VecSearchFilter& other97) { - attrib_filter = other97.attrib_filter; - time_ranges = other97.time_ranges; - return_attribs = other97.return_attribs; - __isset = other97.__isset; +QueryResult::QueryResult(const QueryResult& other103) { + id = other103.id; + score = other103.score; + column_map = other103.column_map; + __isset = other103.__isset; } -VecSearchFilter& VecSearchFilter::operator=(const VecSearchFilter& other98) { - attrib_filter = other98.attrib_filter; - time_ranges = other98.time_ranges; - return_attribs = other98.return_attribs; - __isset = other98.__isset; +QueryResult& QueryResult::operator=(const QueryResult& other104) { + id = other104.id; + score = other104.score; + column_map = other104.column_map; + __isset = other104.__isset; return *this; } -void VecSearchFilter::printTo(std::ostream& out) const { +void QueryResult::printTo(std::ostream& out) const { using ::apache::thrift::to_string; - out << "VecSearchFilter("; - out << "attrib_filter="; (__isset.attrib_filter ? (out << to_string(attrib_filter)) : (out << "")); - out << ", " << "time_ranges="; (__isset.time_ranges ? (out << to_string(time_ranges)) : (out << "")); - out << ", " << "return_attribs="; (__isset.return_attribs ? (out << to_string(return_attribs)) : (out << "")); + out << "QueryResult("; + out << "id=" << to_string(id); + out << ", " << "score=" << to_string(score); + out << ", " << "column_map=" << to_string(column_map); out << ")"; } -} // namespace + +TopKQueryResult::~TopKQueryResult() throw() { +} + + +void TopKQueryResult::__set_query_result_arrays(const std::vector & val) { + this->query_result_arrays = val; +} +std::ostream& operator<<(std::ostream& out, const TopKQueryResult& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t TopKQueryResult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->query_result_arrays.clear(); + uint32_t _size105; + ::apache::thrift::protocol::TType _etype108; + xfer += iprot->readListBegin(_etype108, _size105); + this->query_result_arrays.resize(_size105); + uint32_t _i109; + for (_i109 = 0; _i109 < _size105; ++_i109) + { + xfer += this->query_result_arrays[_i109].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.query_result_arrays = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t TopKQueryResult::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("TopKQueryResult"); + + xfer += oprot->writeFieldBegin("query_result_arrays", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->query_result_arrays.size())); + std::vector ::const_iterator _iter110; + for (_iter110 = this->query_result_arrays.begin(); _iter110 != this->query_result_arrays.end(); ++_iter110) + { + xfer += (*_iter110).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(TopKQueryResult &a, TopKQueryResult &b) { + using ::std::swap; + swap(a.query_result_arrays, b.query_result_arrays); + swap(a.__isset, b.__isset); +} + +TopKQueryResult::TopKQueryResult(const TopKQueryResult& other111) { + query_result_arrays = other111.query_result_arrays; + __isset = other111.__isset; +} +TopKQueryResult& TopKQueryResult::operator=(const TopKQueryResult& other112) { + query_result_arrays = other112.query_result_arrays; + __isset = other112.__isset; + return *this; +} +void TopKQueryResult::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "TopKQueryResult("; + out << "query_result_arrays=" << to_string(query_result_arrays); + out << ")"; +} + +}} // namespace diff --git a/cpp/src/thrift/gen-cpp/megasearch_types.h b/cpp/src/thrift/gen-cpp/megasearch_types.h index e7e424b2db..8f8f03b47d 100644 --- a/cpp/src/thrift/gen-cpp/megasearch_types.h +++ b/cpp/src/thrift/gen-cpp/megasearch_types.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.12.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -18,72 +18,72 @@ #include -namespace megasearch { +namespace megasearch { namespace thrift { -struct VecErrCode { +struct ErrorCode { enum type { SUCCESS = 0, - ILLEGAL_ARGUMENT = 1, - GROUP_NOT_EXISTS = 2, - ILLEGAL_TIME_RANGE = 3, - ILLEGAL_VECTOR_DIMENSION = 4, - OUT_OF_MEMORY = 5 + CONNECT_FAILED = 1, + PERMISSION_DENIED = 2, + TABLE_NOT_EXISTS = 3, + PARTITION_NOT_EXIST = 4, + ILLEGAL_ARGUMENT = 5, + ILLEGAL_RANGE = 6, + ILLEGAL_DIMENSION = 7 }; }; -extern const std::map _VecErrCode_VALUES_TO_NAMES; +extern const std::map _ErrorCode_VALUES_TO_NAMES; -std::ostream& operator<<(std::ostream& out, const VecErrCode::type& val); +std::ostream& operator<<(std::ostream& out, const ErrorCode::type& val); -class VecException; +class Exception; -class VecGroup; +class Column; -class VecTensor; +class VectorColumn; -class VecTensorList; +class TableSchema; -class VecBinaryTensor; +class Range; -class VecBinaryTensorList; +class CreateTablePartitionParam; -class VecSearchResultItem; +class DeleteTablePartitionParam; -class VecSearchResult; +class RowRecord; -class VecSearchResultList; +class QueryRecord; -class VecDateTime; +class QueryResult; -class VecTimeRange; +class TopKQueryResult; -class VecSearchFilter; - -typedef struct _VecException__isset { - _VecException__isset() : code(false), reason(false) {} +typedef struct _Exception__isset { + _Exception__isset() : code(false), reason(false) {} bool code :1; bool reason :1; -} _VecException__isset; +} _Exception__isset; -class VecException : public ::apache::thrift::TException { +class Exception : public ::apache::thrift::TException { public: - VecException(const VecException&); - VecException& operator=(const VecException&); - VecException() : code((VecErrCode::type)0), reason() { + Exception(const Exception&); + Exception& operator=(const Exception&); + Exception() : code((ErrorCode::type)0), reason() { } - virtual ~VecException() throw(); - VecErrCode::type code; + virtual ~Exception() throw(); + ErrorCode::type code; std::string reason; - _VecException__isset __isset; + _Exception__isset __isset; - void __set_code(const VecErrCode::type val); + void __set_code(const ErrorCode::type val); void __set_reason(const std::string& val); - bool operator == (const VecException & rhs) const + bool operator == (const Exception & rhs) const { if (!(code == rhs.code)) return false; @@ -91,11 +91,11 @@ class VecException : public ::apache::thrift::TException { return false; return true; } - bool operator != (const VecException &rhs) const { + bool operator != (const Exception &rhs) const { return !(*this == rhs); } - bool operator < (const VecException & ) const; + bool operator < (const Exception & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -105,53 +105,97 @@ class VecException : public ::apache::thrift::TException { const char* what() const throw(); }; -void swap(VecException &a, VecException &b); +void swap(Exception &a, Exception &b); -std::ostream& operator<<(std::ostream& out, const VecException& obj); +std::ostream& operator<<(std::ostream& out, const Exception& obj); -typedef struct _VecGroup__isset { - _VecGroup__isset() : index_type(false) {} - bool index_type :1; -} _VecGroup__isset; -class VecGroup : public virtual ::apache::thrift::TBase { +class Column : public virtual ::apache::thrift::TBase { public: - VecGroup(const VecGroup&); - VecGroup& operator=(const VecGroup&); - VecGroup() : id(), dimension(0), index_type(0) { + Column(const Column&); + Column& operator=(const Column&); + Column() : type(0), name() { } - virtual ~VecGroup() throw(); - std::string id; - int32_t dimension; - int32_t index_type; + virtual ~Column() throw(); + int32_t type; + std::string name; - _VecGroup__isset __isset; + void __set_type(const int32_t val); - void __set_id(const std::string& val); + void __set_name(const std::string& val); - void __set_dimension(const int32_t val); - - void __set_index_type(const int32_t val); - - bool operator == (const VecGroup & rhs) const + bool operator == (const Column & rhs) const { - if (!(id == rhs.id)) + if (!(type == rhs.type)) + return false; + if (!(name == rhs.name)) + return false; + return true; + } + bool operator != (const Column &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Column & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Column &a, Column &b); + +std::ostream& operator<<(std::ostream& out, const Column& obj); + +typedef struct _VectorColumn__isset { + _VectorColumn__isset() : store_raw_vector(true) {} + bool store_raw_vector :1; +} _VectorColumn__isset; + +class VectorColumn : public virtual ::apache::thrift::TBase { + public: + + VectorColumn(const VectorColumn&); + VectorColumn& operator=(const VectorColumn&); + VectorColumn() : dimension(0), index_type(), store_raw_vector(false) { + } + + virtual ~VectorColumn() throw(); + Column base; + int64_t dimension; + std::string index_type; + bool store_raw_vector; + + _VectorColumn__isset __isset; + + void __set_base(const Column& val); + + void __set_dimension(const int64_t val); + + void __set_index_type(const std::string& val); + + void __set_store_raw_vector(const bool val); + + bool operator == (const VectorColumn & rhs) const + { + if (!(base == rhs.base)) return false; if (!(dimension == rhs.dimension)) return false; - if (__isset.index_type != rhs.__isset.index_type) + if (!(index_type == rhs.index_type)) return false; - else if (__isset.index_type && !(index_type == rhs.index_type)) + if (!(store_raw_vector == rhs.store_raw_vector)) return false; return true; } - bool operator != (const VecGroup &rhs) const { + bool operator != (const VectorColumn &rhs) const { return !(*this == rhs); } - bool operator < (const VecGroup & ) const; + bool operator < (const VectorColumn & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -159,53 +203,61 @@ class VecGroup : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecGroup &a, VecGroup &b); +void swap(VectorColumn &a, VectorColumn &b); -std::ostream& operator<<(std::ostream& out, const VecGroup& obj); +std::ostream& operator<<(std::ostream& out, const VectorColumn& obj); -typedef struct _VecTensor__isset { - _VecTensor__isset() : attrib(false) {} - bool attrib :1; -} _VecTensor__isset; +typedef struct _TableSchema__isset { + _TableSchema__isset() : attribute_column_array(false), partition_column_name_array(false) {} + bool attribute_column_array :1; + bool partition_column_name_array :1; +} _TableSchema__isset; -class VecTensor : public virtual ::apache::thrift::TBase { +class TableSchema : public virtual ::apache::thrift::TBase { public: - VecTensor(const VecTensor&); - VecTensor& operator=(const VecTensor&); - VecTensor() : uid() { + TableSchema(const TableSchema&); + TableSchema& operator=(const TableSchema&); + TableSchema() : table_name() { } - virtual ~VecTensor() throw(); - std::string uid; - std::vector tensor; - std::map attrib; + virtual ~TableSchema() throw(); + std::string table_name; + std::vector vector_column_array; + std::vector attribute_column_array; + std::vector partition_column_name_array; - _VecTensor__isset __isset; + _TableSchema__isset __isset; - void __set_uid(const std::string& val); + void __set_table_name(const std::string& val); - void __set_tensor(const std::vector & val); + void __set_vector_column_array(const std::vector & val); - void __set_attrib(const std::map & val); + void __set_attribute_column_array(const std::vector & val); - bool operator == (const VecTensor & rhs) const + void __set_partition_column_name_array(const std::vector & val); + + bool operator == (const TableSchema & rhs) const { - if (!(uid == rhs.uid)) + if (!(table_name == rhs.table_name)) return false; - if (!(tensor == rhs.tensor)) + if (!(vector_column_array == rhs.vector_column_array)) return false; - if (__isset.attrib != rhs.__isset.attrib) + if (__isset.attribute_column_array != rhs.__isset.attribute_column_array) return false; - else if (__isset.attrib && !(attrib == rhs.attrib)) + else if (__isset.attribute_column_array && !(attribute_column_array == rhs.attribute_column_array)) + return false; + if (__isset.partition_column_name_array != rhs.__isset.partition_column_name_array) + return false; + else if (__isset.partition_column_name_array && !(partition_column_name_array == rhs.partition_column_name_array)) return false; return true; } - bool operator != (const VecTensor &rhs) const { + bool operator != (const TableSchema &rhs) const { return !(*this == rhs); } - bool operator < (const VecTensor & ) const; + bool operator < (const TableSchema & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -213,35 +265,40 @@ class VecTensor : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecTensor &a, VecTensor &b); +void swap(TableSchema &a, TableSchema &b); -std::ostream& operator<<(std::ostream& out, const VecTensor& obj); +std::ostream& operator<<(std::ostream& out, const TableSchema& obj); -class VecTensorList : public virtual ::apache::thrift::TBase { +class Range : public virtual ::apache::thrift::TBase { public: - VecTensorList(const VecTensorList&); - VecTensorList& operator=(const VecTensorList&); - VecTensorList() { + Range(const Range&); + Range& operator=(const Range&); + Range() : start_value(), end_value() { } - virtual ~VecTensorList() throw(); - std::vector tensor_list; + virtual ~Range() throw(); + std::string start_value; + std::string end_value; - void __set_tensor_list(const std::vector & val); + void __set_start_value(const std::string& val); - bool operator == (const VecTensorList & rhs) const + void __set_end_value(const std::string& val); + + bool operator == (const Range & rhs) const { - if (!(tensor_list == rhs.tensor_list)) + if (!(start_value == rhs.start_value)) + return false; + if (!(end_value == rhs.end_value)) return false; return true; } - bool operator != (const VecTensorList &rhs) const { + bool operator != (const Range &rhs) const { return !(*this == rhs); } - bool operator < (const VecTensorList & ) const; + bool operator < (const Range & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -249,53 +306,45 @@ class VecTensorList : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecTensorList &a, VecTensorList &b); +void swap(Range &a, Range &b); -std::ostream& operator<<(std::ostream& out, const VecTensorList& obj); +std::ostream& operator<<(std::ostream& out, const Range& obj); -typedef struct _VecBinaryTensor__isset { - _VecBinaryTensor__isset() : attrib(false) {} - bool attrib :1; -} _VecBinaryTensor__isset; -class VecBinaryTensor : public virtual ::apache::thrift::TBase { +class CreateTablePartitionParam : public virtual ::apache::thrift::TBase { public: - VecBinaryTensor(const VecBinaryTensor&); - VecBinaryTensor& operator=(const VecBinaryTensor&); - VecBinaryTensor() : uid(), tensor() { + CreateTablePartitionParam(const CreateTablePartitionParam&); + CreateTablePartitionParam& operator=(const CreateTablePartitionParam&); + CreateTablePartitionParam() : table_name(), partition_name() { } - virtual ~VecBinaryTensor() throw(); - std::string uid; - std::string tensor; - std::map attrib; + virtual ~CreateTablePartitionParam() throw(); + std::string table_name; + std::string partition_name; + std::map range_map; - _VecBinaryTensor__isset __isset; + void __set_table_name(const std::string& val); - void __set_uid(const std::string& val); + void __set_partition_name(const std::string& val); - void __set_tensor(const std::string& val); + void __set_range_map(const std::map & val); - void __set_attrib(const std::map & val); - - bool operator == (const VecBinaryTensor & rhs) const + bool operator == (const CreateTablePartitionParam & rhs) const { - if (!(uid == rhs.uid)) + if (!(table_name == rhs.table_name)) return false; - if (!(tensor == rhs.tensor)) + if (!(partition_name == rhs.partition_name)) return false; - if (__isset.attrib != rhs.__isset.attrib) - return false; - else if (__isset.attrib && !(attrib == rhs.attrib)) + if (!(range_map == rhs.range_map)) return false; return true; } - bool operator != (const VecBinaryTensor &rhs) const { + bool operator != (const CreateTablePartitionParam &rhs) const { return !(*this == rhs); } - bool operator < (const VecBinaryTensor & ) const; + bool operator < (const CreateTablePartitionParam & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -303,35 +352,40 @@ class VecBinaryTensor : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecBinaryTensor &a, VecBinaryTensor &b); +void swap(CreateTablePartitionParam &a, CreateTablePartitionParam &b); -std::ostream& operator<<(std::ostream& out, const VecBinaryTensor& obj); +std::ostream& operator<<(std::ostream& out, const CreateTablePartitionParam& obj); -class VecBinaryTensorList : public virtual ::apache::thrift::TBase { +class DeleteTablePartitionParam : public virtual ::apache::thrift::TBase { public: - VecBinaryTensorList(const VecBinaryTensorList&); - VecBinaryTensorList& operator=(const VecBinaryTensorList&); - VecBinaryTensorList() { + DeleteTablePartitionParam(const DeleteTablePartitionParam&); + DeleteTablePartitionParam& operator=(const DeleteTablePartitionParam&); + DeleteTablePartitionParam() : table_name() { } - virtual ~VecBinaryTensorList() throw(); - std::vector tensor_list; + virtual ~DeleteTablePartitionParam() throw(); + std::string table_name; + std::vector partition_name_array; - void __set_tensor_list(const std::vector & val); + void __set_table_name(const std::string& val); - bool operator == (const VecBinaryTensorList & rhs) const + void __set_partition_name_array(const std::vector & val); + + bool operator == (const DeleteTablePartitionParam & rhs) const { - if (!(tensor_list == rhs.tensor_list)) + if (!(table_name == rhs.table_name)) + return false; + if (!(partition_name_array == rhs.partition_name_array)) return false; return true; } - bool operator != (const VecBinaryTensorList &rhs) const { + bool operator != (const DeleteTablePartitionParam &rhs) const { return !(*this == rhs); } - bool operator < (const VecBinaryTensorList & ) const; + bool operator < (const DeleteTablePartitionParam & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -339,56 +393,46 @@ class VecBinaryTensorList : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecBinaryTensorList &a, VecBinaryTensorList &b); +void swap(DeleteTablePartitionParam &a, DeleteTablePartitionParam &b); -std::ostream& operator<<(std::ostream& out, const VecBinaryTensorList& obj); +std::ostream& operator<<(std::ostream& out, const DeleteTablePartitionParam& obj); -typedef struct _VecSearchResultItem__isset { - _VecSearchResultItem__isset() : distance(false), attrib(false) {} - bool distance :1; - bool attrib :1; -} _VecSearchResultItem__isset; +typedef struct _RowRecord__isset { + _RowRecord__isset() : attribute_map(false) {} + bool attribute_map :1; +} _RowRecord__isset; -class VecSearchResultItem : public virtual ::apache::thrift::TBase { +class RowRecord : public virtual ::apache::thrift::TBase { public: - VecSearchResultItem(const VecSearchResultItem&); - VecSearchResultItem& operator=(const VecSearchResultItem&); - VecSearchResultItem() : uid(), distance(0) { + RowRecord(const RowRecord&); + RowRecord& operator=(const RowRecord&); + RowRecord() { } - virtual ~VecSearchResultItem() throw(); - std::string uid; - double distance; - std::map attrib; + virtual ~RowRecord() throw(); + std::map vector_map; + std::map attribute_map; - _VecSearchResultItem__isset __isset; + _RowRecord__isset __isset; - void __set_uid(const std::string& val); + void __set_vector_map(const std::map & val); - void __set_distance(const double val); + void __set_attribute_map(const std::map & val); - void __set_attrib(const std::map & val); - - bool operator == (const VecSearchResultItem & rhs) const + bool operator == (const RowRecord & rhs) const { - if (!(uid == rhs.uid)) + if (!(vector_map == rhs.vector_map)) return false; - if (__isset.distance != rhs.__isset.distance) - return false; - else if (__isset.distance && !(distance == rhs.distance)) - return false; - if (__isset.attrib != rhs.__isset.attrib) - return false; - else if (__isset.attrib && !(attrib == rhs.attrib)) + if (!(attribute_map == rhs.attribute_map)) return false; return true; } - bool operator != (const VecSearchResultItem &rhs) const { + bool operator != (const RowRecord &rhs) const { return !(*this == rhs); } - bool operator < (const VecSearchResultItem & ) const; + bool operator < (const RowRecord & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -396,41 +440,56 @@ class VecSearchResultItem : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecSearchResultItem &a, VecSearchResultItem &b); +void swap(RowRecord &a, RowRecord &b); -std::ostream& operator<<(std::ostream& out, const VecSearchResultItem& obj); +std::ostream& operator<<(std::ostream& out, const RowRecord& obj); -typedef struct _VecSearchResult__isset { - _VecSearchResult__isset() : result_list(false) {} - bool result_list :1; -} _VecSearchResult__isset; +typedef struct _QueryRecord__isset { + _QueryRecord__isset() : selected_column_array(false), partition_filter_column_map(false) {} + bool selected_column_array :1; + bool partition_filter_column_map :1; +} _QueryRecord__isset; -class VecSearchResult : public virtual ::apache::thrift::TBase { +class QueryRecord : public virtual ::apache::thrift::TBase { public: - VecSearchResult(const VecSearchResult&); - VecSearchResult& operator=(const VecSearchResult&); - VecSearchResult() { + QueryRecord(const QueryRecord&); + QueryRecord& operator=(const QueryRecord&); + QueryRecord() { } - virtual ~VecSearchResult() throw(); - std::vector result_list; + virtual ~QueryRecord() throw(); + std::map vector_map; + std::vector selected_column_array; + std::map > partition_filter_column_map; - _VecSearchResult__isset __isset; + _QueryRecord__isset __isset; - void __set_result_list(const std::vector & val); + void __set_vector_map(const std::map & val); - bool operator == (const VecSearchResult & rhs) const + void __set_selected_column_array(const std::vector & val); + + void __set_partition_filter_column_map(const std::map > & val); + + bool operator == (const QueryRecord & rhs) const { - if (!(result_list == rhs.result_list)) + if (!(vector_map == rhs.vector_map)) + return false; + if (__isset.selected_column_array != rhs.__isset.selected_column_array) + return false; + else if (__isset.selected_column_array && !(selected_column_array == rhs.selected_column_array)) + return false; + if (__isset.partition_filter_column_map != rhs.__isset.partition_filter_column_map) + return false; + else if (__isset.partition_filter_column_map && !(partition_filter_column_map == rhs.partition_filter_column_map)) return false; return true; } - bool operator != (const VecSearchResult &rhs) const { + bool operator != (const QueryRecord &rhs) const { return !(*this == rhs); } - bool operator < (const VecSearchResult & ) const; + bool operator < (const QueryRecord & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -438,41 +497,53 @@ class VecSearchResult : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecSearchResult &a, VecSearchResult &b); +void swap(QueryRecord &a, QueryRecord &b); -std::ostream& operator<<(std::ostream& out, const VecSearchResult& obj); +std::ostream& operator<<(std::ostream& out, const QueryRecord& obj); -typedef struct _VecSearchResultList__isset { - _VecSearchResultList__isset() : result_list(false) {} - bool result_list :1; -} _VecSearchResultList__isset; +typedef struct _QueryResult__isset { + _QueryResult__isset() : id(false), score(false), column_map(false) {} + bool id :1; + bool score :1; + bool column_map :1; +} _QueryResult__isset; -class VecSearchResultList : public virtual ::apache::thrift::TBase { +class QueryResult : public virtual ::apache::thrift::TBase { public: - VecSearchResultList(const VecSearchResultList&); - VecSearchResultList& operator=(const VecSearchResultList&); - VecSearchResultList() { + QueryResult(const QueryResult&); + QueryResult& operator=(const QueryResult&); + QueryResult() : id(0), score(0) { } - virtual ~VecSearchResultList() throw(); - std::vector result_list; + virtual ~QueryResult() throw(); + int64_t id; + double score; + std::map column_map; - _VecSearchResultList__isset __isset; + _QueryResult__isset __isset; - void __set_result_list(const std::vector & val); + void __set_id(const int64_t val); - bool operator == (const VecSearchResultList & rhs) const + void __set_score(const double val); + + void __set_column_map(const std::map & val); + + bool operator == (const QueryResult & rhs) const { - if (!(result_list == rhs.result_list)) + if (!(id == rhs.id)) + return false; + if (!(score == rhs.score)) + return false; + if (!(column_map == rhs.column_map)) return false; return true; } - bool operator != (const VecSearchResultList &rhs) const { + bool operator != (const QueryResult &rhs) const { return !(*this == rhs); } - bool operator < (const VecSearchResultList & ) const; + bool operator < (const QueryResult & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -480,60 +551,41 @@ class VecSearchResultList : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecSearchResultList &a, VecSearchResultList &b); +void swap(QueryResult &a, QueryResult &b); -std::ostream& operator<<(std::ostream& out, const VecSearchResultList& obj); +std::ostream& operator<<(std::ostream& out, const QueryResult& obj); +typedef struct _TopKQueryResult__isset { + _TopKQueryResult__isset() : query_result_arrays(false) {} + bool query_result_arrays :1; +} _TopKQueryResult__isset; -class VecDateTime : public virtual ::apache::thrift::TBase { +class TopKQueryResult : public virtual ::apache::thrift::TBase { public: - VecDateTime(const VecDateTime&); - VecDateTime& operator=(const VecDateTime&); - VecDateTime() : year(0), month(0), day(0), hour(0), minute(0), second(0) { + TopKQueryResult(const TopKQueryResult&); + TopKQueryResult& operator=(const TopKQueryResult&); + TopKQueryResult() { } - virtual ~VecDateTime() throw(); - int32_t year; - int32_t month; - int32_t day; - int32_t hour; - int32_t minute; - int32_t second; + virtual ~TopKQueryResult() throw(); + std::vector query_result_arrays; - void __set_year(const int32_t val); + _TopKQueryResult__isset __isset; - void __set_month(const int32_t val); + void __set_query_result_arrays(const std::vector & val); - void __set_day(const int32_t val); - - void __set_hour(const int32_t val); - - void __set_minute(const int32_t val); - - void __set_second(const int32_t val); - - bool operator == (const VecDateTime & rhs) const + bool operator == (const TopKQueryResult & rhs) const { - if (!(year == rhs.year)) - return false; - if (!(month == rhs.month)) - return false; - if (!(day == rhs.day)) - return false; - if (!(hour == rhs.hour)) - return false; - if (!(minute == rhs.minute)) - return false; - if (!(second == rhs.second)) + if (!(query_result_arrays == rhs.query_result_arrays)) return false; return true; } - bool operator != (const VecDateTime &rhs) const { + bool operator != (const TopKQueryResult &rhs) const { return !(*this == rhs); } - bool operator < (const VecDateTime & ) const; + bool operator < (const TopKQueryResult & ) const; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -541,121 +593,10 @@ class VecDateTime : public virtual ::apache::thrift::TBase { virtual void printTo(std::ostream& out) const; }; -void swap(VecDateTime &a, VecDateTime &b); +void swap(TopKQueryResult &a, TopKQueryResult &b); -std::ostream& operator<<(std::ostream& out, const VecDateTime& obj); +std::ostream& operator<<(std::ostream& out, const TopKQueryResult& obj); - -class VecTimeRange : public virtual ::apache::thrift::TBase { - public: - - VecTimeRange(const VecTimeRange&); - VecTimeRange& operator=(const VecTimeRange&); - VecTimeRange() : begine_closed(0), end_closed(0) { - } - - virtual ~VecTimeRange() throw(); - VecDateTime time_begin; - bool begine_closed; - VecDateTime time_end; - bool end_closed; - - void __set_time_begin(const VecDateTime& val); - - void __set_begine_closed(const bool val); - - void __set_time_end(const VecDateTime& val); - - void __set_end_closed(const bool val); - - bool operator == (const VecTimeRange & rhs) const - { - if (!(time_begin == rhs.time_begin)) - return false; - if (!(begine_closed == rhs.begine_closed)) - return false; - if (!(time_end == rhs.time_end)) - return false; - if (!(end_closed == rhs.end_closed)) - return false; - return true; - } - bool operator != (const VecTimeRange &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecTimeRange & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(VecTimeRange &a, VecTimeRange &b); - -std::ostream& operator<<(std::ostream& out, const VecTimeRange& obj); - -typedef struct _VecSearchFilter__isset { - _VecSearchFilter__isset() : attrib_filter(false), time_ranges(false), return_attribs(false) {} - bool attrib_filter :1; - bool time_ranges :1; - bool return_attribs :1; -} _VecSearchFilter__isset; - -class VecSearchFilter : public virtual ::apache::thrift::TBase { - public: - - VecSearchFilter(const VecSearchFilter&); - VecSearchFilter& operator=(const VecSearchFilter&); - VecSearchFilter() { - } - - virtual ~VecSearchFilter() throw(); - std::map attrib_filter; - std::vector time_ranges; - std::vector return_attribs; - - _VecSearchFilter__isset __isset; - - void __set_attrib_filter(const std::map & val); - - void __set_time_ranges(const std::vector & val); - - void __set_return_attribs(const std::vector & val); - - bool operator == (const VecSearchFilter & rhs) const - { - if (__isset.attrib_filter != rhs.__isset.attrib_filter) - return false; - else if (__isset.attrib_filter && !(attrib_filter == rhs.attrib_filter)) - return false; - if (__isset.time_ranges != rhs.__isset.time_ranges) - return false; - else if (__isset.time_ranges && !(time_ranges == rhs.time_ranges)) - return false; - if (__isset.return_attribs != rhs.__isset.return_attribs) - return false; - else if (__isset.return_attribs && !(return_attribs == rhs.return_attribs)) - return false; - return true; - } - bool operator != (const VecSearchFilter &rhs) const { - return !(*this == rhs); - } - - bool operator < (const VecSearchFilter & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(VecSearchFilter &a, VecSearchFilter &b); - -std::ostream& operator<<(std::ostream& out, const VecSearchFilter& obj); - -} // namespace +}} // namespace #endif diff --git a/cpp/src/thrift/gen-py/py_sample.py b/cpp/src/thrift/gen-py/py_sample.py deleted file mode 100644 index 0a4690c1eb..0000000000 --- a/cpp/src/thrift/gen-py/py_sample.py +++ /dev/null @@ -1,68 +0,0 @@ -import time -import struct - -from megasearch import VecService - -#Note: pip install thrift -from thrift.transport import TSocket -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TCompactProtocol, TJSONProtocol - -def test_megasearch(): - try: - #connect - transport = TSocket.TSocket('localhost', 33001) - transport = TTransport.TBufferedTransport(transport) - protocol = TJSONProtocol.TJSONProtocol(transport) - client = VecService.Client(protocol) - transport.open() - - print("connected"); - - #add group - group = VecService.VecGroup("test_" + time.strftime('%H%M%S'), 256) - client.add_group(group) - - print("group added"); - - # build binary vectors - bin_vec_list = VecService.VecBinaryTensorList([]) - for i in range(10000): - a=[] - for k in range(group.dimension): - a.append(i + k) - bin_vec = VecService.VecBinaryTensor("binary_" + str(i), bytes()) - bin_vec.tensor = struct.pack(str(group.dimension)+"d", *a) - bin_vec_list.tensor_list.append(bin_vec) - - # add vectors - client.add_binary_vector_batch(group.id, bin_vec_list) - - wait_storage = 5 - print("wait {} seconds for persisting data".format(wait_storage)) - time.sleep(wait_storage) - - # search vector - a = [] - for k in range(group.dimension): - a.append(300 + k) - bin_vec = VecService.VecBinaryTensor("binary_search", bytes()) - bin_vec.tensor = struct.pack(str(group.dimension) + "d", *a) - filter = VecService.VecSearchFilter() - res = VecService.VecSearchResult() - - print("begin search ..."); - res = client.search_binary_vector(group.id, 5, bin_vec, filter) - - print('result count: ' + str(len(res.result_list))) - for item in res.result_list: - print(item.uid) - - transport.close() - print("disconnected"); - - except VecService.VecException as ex: - print(ex.reason) - - -test_megasearch() \ No newline at end of file diff --git a/cpp/src/thrift/megasearch.thrift b/cpp/src/thrift/megasearch.thrift index 3565f3c5df..e85b77dc3d 100644 --- a/cpp/src/thrift/megasearch.thrift +++ b/cpp/src/thrift/megasearch.thrift @@ -3,140 +3,222 @@ * Unauthorized copying of this file, via any medium is strictly prohibited. * Proprietary and confidential. ******************************************************************************/ -namespace cl megasearch -namespace cpp megasearch -namespace py megasearch -namespace d megasearch -namespace dart megasearch -namespace java megasearch -namespace perl megasearch -namespace php megasearch -namespace haxe megasearch -namespace netcore megasearch +namespace cl megasearch.thrift +namespace cpp megasearch.thrift +namespace py megasearch.thrift +namespace d megasearch.thrift +namespace dart megasearch.thrift +namespace java megasearch.thrift +namespace perl megasearch.thrift +namespace php megasearch.thrift +namespace haxe megasearch.thrift +namespace netcore megasearch.thrift -enum VecErrCode { +enum ErrorCode { SUCCESS = 0, + CONNECT_FAILED, + PERMISSION_DENIED, + TABLE_NOT_EXISTS, + PARTITION_NOT_EXIST, ILLEGAL_ARGUMENT, - GROUP_NOT_EXISTS, - ILLEGAL_TIME_RANGE, - ILLEGAL_VECTOR_DIMENSION, - OUT_OF_MEMORY, + ILLEGAL_RANGE, + ILLEGAL_DIMENSION, } -exception VecException { - 1: VecErrCode code; +exception Exception { + 1: ErrorCode code; 2: string reason; } -struct VecGroup { - 1: required string id; - 2: required i32 dimension; - 3: optional i32 index_type; -} -struct VecTensor { - 1: required string uid; - 2: required list tensor; - 3: optional map attrib; -} - -struct VecTensorList { - 1: required list tensor_list; -} - -struct VecBinaryTensor { - 1: required string uid; - 2: required binary tensor; - 3: optional map attrib; -} - -struct VecBinaryTensorList { - 1: required list tensor_list; -} - -struct VecSearchResultItem { - 1: required string uid; - 2: optional double distance; - 3: optional map attrib; -} - -struct VecSearchResult { - 1: list result_list; -} - -struct VecSearchResultList { - 1: list result_list; +/** + * @brief Table column description + */ +struct Column { + 1: required i32 type; ///< Column Type: 0:invealid/1:int8/2:int16/3:int32/4:int64/5:float32/6:float64/7:date/8:vector + 2: required string name; ///< Column name } /** - * second; Seconds. [0-59] reserved - * minute; Minutes. [0-59] reserved - * hour; Hours. [0-23] reserved - * day; Day. [1-31] - * month; Month. [0-11] - * year; Year - 1900. + * @brief Table vector column description */ -struct VecDateTime { - 1: required i32 year; - 2: required i32 month; - 3: required i32 day; - 4: required i32 hour; - 5: required i32 minute; - 6: required i32 second; +struct VectorColumn { + 1: required Column base; ///< Base column schema + 2: required i64 dimension; ///< Vector dimension + 3: required string index_type; ///< Index type, optional: raw, ivf + 4: bool store_raw_vector = false; ///< Is vector self stored in the table } /** - * time_begin; time range begin - * begine_closed; true means '[', false means '(' reserved - * time_end; set to true to return tensor double array - * end_closed; time range end reserved + * @brief Table Schema */ -struct VecTimeRange { - 1: required VecDateTime time_begin; - 2: required bool begine_closed; - 3: required VecDateTime time_end; - 4: required bool end_closed; +struct TableSchema { + 1: required string table_name; ///< Table name + 2: required list vector_column_array; ///< Vector column description + 3: optional list attribute_column_array; ///< Columns description + 4: optional list partition_column_name_array; ///< Partition column name } /** - * attrib_filter; reserved - * time_ranges; search condition, for example: "date between 1999-02-12 and 2008-10-14" - * return_attribs; specify required attribute names + * @brief Range Schema */ -struct VecSearchFilter { - 1: optional map attrib_filter; - 2: optional list time_ranges; - 3: optional list return_attribs; +struct Range { + 1: required string start_value; ///< Range start + 2: required string end_value; ///< Range stop } -service VecService { +/** + * @brief Create table partition parameters + */ +struct CreateTablePartitionParam { + 1: required string table_name; ///< Table name, vector/float32/float64 type column is not allowed for partition + 2: required string partition_name; ///< Partition name, created partition name + 3: required map range_map; ///< Column name to Range map +} + + +/** + * @brief Delete table partition parameters + */ +struct DeleteTablePartitionParam { + 1: required string table_name; ///< Table name + 2: required list partition_name_array; ///< Partition name array +} + +/** + * @brief Record inserted + */ +struct RowRecord { + 1: required map vector_map; ///< Vector columns + 2: map attribute_map; ///< Other attribute columns +} + +/** + * @brief Query record + */ +struct QueryRecord { + 1: required map vector_map; ///< Query vectors + 2: optional list selected_column_array; ///< Output column array + 3: optional map> partition_filter_column_map; ///< Range used to select partitions +} + +/** + * @brief Query result + */ +struct QueryResult { + 1: i64 id; ///< Output result + 2: double score; ///< Vector similarity score: 0 ~ 100 + 3: map column_map; ///< Other column +} + +/** + * @brief TopK query result + */ +struct TopKQueryResult { + 1: list query_result_arrays; ///< TopK query result +} + +service MegasearchService { /** - * group interfaces - */ - void add_group(2: VecGroup group) throws(1: VecException e); - VecGroup get_group(2: string group_id) throws(1: VecException e); - void del_group(2: string group_id) throws(1: VecException e); - - - /** - * insert vector interfaces + * @brief Create table method + * + * This method is used to create table + * + * @param param, use to provide table information to be created. * */ - string add_vector(2: string group_id, 3: VecTensor tensor) throws(1: VecException e); - list add_vector_batch(2: string group_id, 3: VecTensorList tensor_list) throws(1: VecException e); - string add_binary_vector(2: string group_id, 3: VecBinaryTensor tensor) throws(1: VecException e); - list add_binary_vector_batch(2: string group_id, 3: VecBinaryTensorList tensor_list) throws(1: VecException e); + void CreateTable(2: TableSchema param) throws(1: Exception e); + /** - * search interfaces - * you can use filter to reduce search result - * filter.attrib_filter can specify which attribute you need, for example: - * set attrib_filter = {"color":""} means you want to get "color" attribute for result vector - * set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" - * if filter.time_range is empty, engine will search without time limit + * @brief Delete table method + * + * This method is used to delete table. + * + * @param table_name, table name is going to be deleted. + * */ - VecSearchResult search_vector(2: string group_id, 3: i64 top_k, 4: VecTensor tensor, 5: VecSearchFilter filter) throws(1: VecException e); - VecSearchResultList search_vector_batch(2: string group_id, 3: i64 top_k, 4: VecTensorList tensor_list, 5: VecSearchFilter filter) throws(1: VecException e); - VecSearchResult search_binary_vector(2: string group_id, 3: i64 top_k, 4: VecBinaryTensor tensor, 5: VecSearchFilter filter) throws(1: VecException e); - VecSearchResultList search_binary_vector_batch(2: string group_id, 3: i64 top_k, 4: VecBinaryTensorList tensor_list, 5: VecSearchFilter filter) throws(1: VecException e); + void DeleteTable(2: string table_name) throws(1: Exception e); + + + /** + * @brief Create table partition + * + * This method is used to create table partition. + * + * @param param, use to provide partition information to be created. + * + */ + void CreateTablePartition(2: CreateTablePartitionParam param) throws(1: Exception e); + + + /** + * @brief Delete table partition + * + * This method is used to delete table partition. + * + * @param param, use to provide partition information to be deleted. + * + */ + void DeleteTablePartition(2: DeleteTablePartitionParam param) throws(1: Exception e); + + + /** + * @brief Add vector array to table + * + * This method is used to add vector array to table. + * + * @param table_name, table_name is inserted. + * @param record_array, vector array is inserted. + * + * @return vector id array + */ + list AddVector(2: string table_name, + 3: list record_array) throws(1: Exception e); + + + /** + * @brief Query vector + * + * This method is used to query vector in table. + * + * @param table_name, table_name is queried. + * @param query_record_array, all vector are going to be queried. + * @param topk, how many similarity vectors will be searched. + * + * @return query result array. + */ + list SearchVector(2: string table_name, + 3: list query_record_array, + 4: i64 topk) throws(1: Exception e); + + /** + * @brief Show table information + * + * This method is used to show table information. + * + * @param table_name, which table is show. + * + * @return table schema + */ + TableSchema DescribeTable(2: string table_name) throws(1: Exception e); + + /** + * @brief List all tables in database + * + * This method is used to list all tables. + * + * + * @return table names. + */ + list ShowTables() throws(1: Exception e); + + /** + * @brief Give the server status + * + * This method is used to give the server status. + * + * @return Server status. + */ + string Ping(2: string cmd) throws(1: Exception e); } \ No newline at end of file diff --git a/cpp/test_client/CMakeLists.txt b/cpp/test_client/CMakeLists.txt deleted file mode 100644 index df918d734e..0000000000 --- a/cpp/test_client/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -# Unauthorized copying of this file, via any medium is strictly prohibited. -# Proprietary and confidential. -#------------------------------------------------------------------------------- - -include_directories(../src) - -aux_source_directory(./src client_src) -aux_source_directory(../src/config config_files) - -set(util_files - ../src/utils/CommonUtil.cpp - ../src/utils/LogUtil.cpp - ../src/utils/TimeRecorder.cpp) - -set(service_files - ../src/thrift/gen-cpp/VecService.cpp - ../src/thrift/gen-cpp/megasearch_constants.cpp - ../src/thrift/gen-cpp/megasearch_types.cpp) - - - -link_directories( - "${CMAKE_BINARY_DIR}/lib" - "${VECWISE_THIRD_PARTY_BUILD}/lib" -) - -set(unittest_libs - gtest_main - gmock_main - pthread) - -set(client_libs - yaml-cpp - boost_system - boost_filesystem - thrift - faiss - pthread) - -include_directories(/usr/local/cuda/include) -find_library(cuda_library cudart cublas HINTS /usr/local/cuda/lib64) - -add_executable(test_client - ./main.cpp - ../src/server/ServerConfig.cpp - ${client_src} - ${service_files} - ${config_files} - ${util_files} - ${VECWISE_THIRD_PARTY_BUILD}/include/easylogging++.cc) - -target_link_libraries(test_client ${unittest_libs} ${client_libs} ${cuda_library}) - -#add_executable(skeleton_server -# ../src/thrift/gen-cpp/VecService_server.skeleton.cpp -# ../src/thrift/gen-cpp/VecService.cpp -# ../src/thrift/gen-cpp/VectorService_constants.cpp -# ../src/thrift/gen-cpp/VectorService_types.cpp) -# -#target_link_libraries(skeleton_server thrift) diff --git a/cpp/test_client/src/ClientSession.h b/cpp/test_client/src/ClientSession.h deleted file mode 100644 index 44cf54adb2..0000000000 --- a/cpp/test_client/src/ClientSession.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#pragma once - -#include "thrift/gen-cpp/VecService.h" - -#include - -namespace zilliz { -namespace vecwise { -namespace client { - -using VecServiceClientPtr = std::shared_ptr; - -class ClientSession { -public: - ClientSession(const std::string& address, int32_t port, const std::string& protocol); - ~ClientSession(); - - VecServiceClientPtr interface(); - - VecServiceClientPtr client_; -}; - -} -} -} diff --git a/cpp/test_client/src/ClientTest.cpp b/cpp/test_client/src/ClientTest.cpp deleted file mode 100644 index 188f30a02e..0000000000 --- a/cpp/test_client/src/ClientTest.cpp +++ /dev/null @@ -1,361 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#include "ClientTest.h" - -#include -#include "utils/TimeRecorder.h" -#include "utils/AttributeSerializer.h" -#include "ClientSession.h" -#include "server/ServerConfig.h" -#include "Log.h" - -#include - -using namespace megasearch; -using namespace zilliz; -using namespace zilliz::vecwise; -using namespace zilliz::vecwise::client; - -namespace { - static const int32_t VEC_DIMENSION = 256; - static const int64_t BATCH_COUNT = 10000; - static const int64_t REPEAT_COUNT = 1; - static const int64_t TOP_K = 10; - - static const std::string TEST_ATTRIB_NUM = "number"; - static const std::string TEST_ATTRIB_COMMENT = "comment"; - - std::string CurrentTime() { - time_t tt; - time( &tt ); - tt = tt + 8*3600; - tm* t= gmtime( &tt ); - - std::string str = std::to_string(t->tm_year + 1900) + "_" + std::to_string(t->tm_mon + 1) - + "_" + std::to_string(t->tm_mday) + "_" + std::to_string(t->tm_hour) - + "_" + std::to_string(t->tm_min) + "_" + std::to_string(t->tm_sec); - - return str; - } - - void GetDate(int& year, int& month, int& day) { - time_t tt; - time( &tt ); - tm* t= gmtime( &tt ); - year = t->tm_year; - month = t->tm_mon; - day = t->tm_mday; - } - - void GetServerAddress(std::string& address, int32_t& port, std::string& protocol) { - server::ServerConfig& config = server::ServerConfig::GetInstance(); - server::ConfigNode server_config = config.GetConfig(server::CONFIG_SERVER); - address = server_config.GetValue(server::CONFIG_SERVER_ADDRESS, "127.0.0.1"); - port = server_config.GetInt32Value(server::CONFIG_SERVER_PORT, 33001); - protocol = server_config.GetValue(server::CONFIG_SERVER_PROTOCOL, "binary"); - //std::string mode = server_config.GetValue(server::CONFIG_SERVER_MODE, "thread_pool"); - } - - int32_t GetFlushInterval() { - server::ServerConfig& config = server::ServerConfig::GetInstance(); - server::ConfigNode db_config = config.GetConfig(server::CONFIG_DB); - return db_config.GetInt32Value(server::CONFIG_DB_FLUSH_INTERVAL); - } - - std::string GetGroupID() { - static std::string s_id(CurrentTime()); - return s_id; - } - - void BuildVectors(int64_t from, int64_t to, - VecTensorList* tensor_list, - VecBinaryTensorList* bin_tensor_list) { - if(to <= from) { - return; - } - - static int64_t total_build = 0; - int64_t count = to - from; - server::TimeRecorder rc(std::to_string(count) + " vectors built"); - for (int64_t k = from; k < to; k++) { - VecTensor tensor; - tensor.tensor.reserve(VEC_DIMENSION); - VecBinaryTensor bin_tensor; - bin_tensor.tensor.resize(VEC_DIMENSION * sizeof(double)); - double *d_p = (double *) (const_cast(bin_tensor.tensor.data())); - for (int32_t i = 0; i < VEC_DIMENSION; i++) { - double val = (double) (i + k); - tensor.tensor.push_back(val); - d_p[i] = val; - } - - server::AttribMap attrib_map; - attrib_map[TEST_ATTRIB_NUM] = "No." + std::to_string(k); - - if(tensor_list) { - tensor.uid = "normal_vec_" + std::to_string(k); - attrib_map[TEST_ATTRIB_COMMENT] = "this is vector " + tensor.uid; - tensor.__set_attrib(attrib_map); - tensor_list->tensor_list.emplace_back(tensor); - } - - if(bin_tensor_list) { - bin_tensor.uid = "binary_vec_" + std::to_string(k); - attrib_map[TEST_ATTRIB_COMMENT] = "this is binary vector " + bin_tensor.uid; - bin_tensor.__set_attrib(attrib_map); - bin_tensor_list->tensor_list.emplace_back(bin_tensor); - } - - total_build++; - if (total_build % 10000 == 0) { - CLIENT_LOG_INFO << total_build << " vectors built"; - } - } - - rc.Elapse("done"); - } -} - -TEST(AddVector, CLIENT_TEST) { - try { - std::string address, protocol; - int32_t port = 0; - GetServerAddress(address, port, protocol); - client::ClientSession session(address, port, protocol); - - //verify get invalid group - try { - std::string id; - VecTensor tensor; - for(int32_t i = 0; i < VEC_DIMENSION; i++) { - tensor.tensor.push_back(0.5); - } - session.interface()->add_vector(id, GetGroupID(), tensor); - } catch (VecException& ex) { - CLIENT_LOG_ERROR << "request encounter exception: " << ex.what(); - ASSERT_EQ(ex.code, VecErrCode::ILLEGAL_ARGUMENT); - } - - try { - VecGroup temp_group; - session.interface()->get_group(temp_group, GetGroupID()); - //ASSERT_TRUE(temp_group.id.empty()); - } catch (VecException& ex) { - CLIENT_LOG_ERROR << "request encounter exception: " << ex.what(); - ASSERT_EQ(ex.code, VecErrCode::GROUP_NOT_EXISTS); - } - - //add group - VecGroup group; - group.id = GetGroupID(); - group.dimension = VEC_DIMENSION; - group.index_type = 0; - session.interface()->add_group(group); - - for(int64_t r = 0; r < REPEAT_COUNT; r++) { - //prepare data - CLIENT_LOG_INFO << "Preparing vectors..."; - const int64_t count = BATCH_COUNT; - int64_t offset = r*count*2; - VecTensorList tensor_list_1, tensor_list_2; - VecBinaryTensorList bin_tensor_list_1, bin_tensor_list_2; - BuildVectors(0 + offset, count + offset, &tensor_list_1, &bin_tensor_list_1); - BuildVectors(count + offset, count * 2 + offset, &tensor_list_2, &bin_tensor_list_2); - -#if 0 - //add vectors one by one - { - server::TimeRecorder rc("Add " + std::to_string(count) + " vectors one by one"); - for (int64_t k = 0; k < count; k++) { - std::string id; - tensor_list_1.tensor_list[k].uid = ""; - session.interface()->add_vector(id, group.id, tensor_list_1.tensor_list[k]); - if (k % 1000 == 0) { - CLIENT_LOG_INFO << "add normal vector no." << k; - } - ASSERT_TRUE(!id.empty()); - } - rc.Elapse("done!"); - } - - //add vectors in one batch - { - server::TimeRecorder rc("Add " + std::to_string(count) + " vectors in one batch"); - std::vector ids; - session.interface()->add_vector_batch(ids, group.id, tensor_list_2); - rc.Elapse("done!"); - } - -#else - //add binary vectors one by one - { - server::TimeRecorder rc("Add " + std::to_string(count) + " binary vectors one by one"); - for (int64_t k = 0; k < count; k++) { - std::string id; - bin_tensor_list_1.tensor_list[k].uid = ""; - session.interface()->add_binary_vector(id, group.id, bin_tensor_list_1.tensor_list[k]); - if (k % 1000 == 0) { - CLIENT_LOG_INFO << "add binary vector no." << k; - } - ASSERT_TRUE(!id.empty()); - } - rc.Elapse("done!"); - } - - //add binary vectors in one batch - { - server::TimeRecorder rc("Add " + std::to_string(count) + " binary vectors in one batch"); - std::vector ids; - session.interface()->add_binary_vector_batch(ids, group.id, bin_tensor_list_2); - ASSERT_EQ(ids.size(), bin_tensor_list_2.tensor_list.size()); - for(size_t i = 0; i < ids.size(); i++) { - ASSERT_TRUE(!ids[i].empty()); - } - rc.Elapse("done!"); - } -#endif - } - - } catch (std::exception &ex) { - CLIENT_LOG_ERROR << "request encounter exception: " << ex.what(); - ASSERT_TRUE(false); - } -} - -TEST(SearchVector, CLIENT_TEST) { - uint32_t sleep_seconds = GetFlushInterval(); - std::cout << "Sleep " << sleep_seconds << " seconds..." << std::endl; - sleep(sleep_seconds); - - try { - std::string address, protocol; - int32_t port = 0; - GetServerAddress(address, port, protocol); - client::ClientSession session(address, port, protocol); - - //search vector - { - const int32_t anchor_index = 100; - VecTensor tensor; - for (int32_t i = 0; i < VEC_DIMENSION; i++) { - tensor.tensor.push_back((double) (i + anchor_index)); - } - - //build time range - VecSearchResult res; - VecSearchFilter filter; - VecTimeRange range; - VecDateTime date; - GetDate(date.year, date.month, date.day); - range.time_begin = date; - range.time_end = date; - std::vector time_ranges; - time_ranges.emplace_back(range); - filter.__set_time_ranges(time_ranges); - - //normal search - { - server::TimeRecorder rc("Search top_k"); - session.interface()->search_vector(res, GetGroupID(), TOP_K, tensor, filter); - rc.Elapse("done!"); - - //build result - std::cout << "Search result: " << std::endl; - for (VecSearchResultItem &item : res.result_list) { - std::cout << "\t" << item.uid << std::endl; - - ASSERT_TRUE(item.attrib.count(TEST_ATTRIB_NUM) != 0); - ASSERT_TRUE(item.attrib.count(TEST_ATTRIB_COMMENT) != 0); - ASSERT_TRUE(!item.attrib[TEST_ATTRIB_COMMENT].empty()); - } - - ASSERT_EQ(res.result_list.size(), (uint64_t) TOP_K); - if (!res.result_list.empty()) { - ASSERT_TRUE(!res.result_list[0].uid.empty()); - } - } - - //filter attribute search - { - std::vector require_attributes = {TEST_ATTRIB_COMMENT}; - filter.__set_return_attribs(require_attributes); - server::TimeRecorder rc("Search top_k with attribute filter"); - session.interface()->search_vector(res, GetGroupID(), TOP_K, tensor, filter); - rc.Elapse("done!"); - - //build result - std::cout << "Search result attributes: " << std::endl; - for (VecSearchResultItem &item : res.result_list) { - ASSERT_EQ(item.attrib.size(), 1UL); - ASSERT_TRUE(item.attrib.count(TEST_ATTRIB_COMMENT) != 0); - ASSERT_TRUE(!item.attrib[TEST_ATTRIB_COMMENT].empty()); - std::cout << "\t" << item.uid << ":" << item.attrib[TEST_ATTRIB_COMMENT] << std::endl; - } - - ASSERT_EQ(res.result_list.size(), (uint64_t) TOP_K); - } - - //empty search - { - date.day > 0 ? date.day -= 1 : date.day += 1; - range.time_begin = date; - range.time_end = date; - time_ranges.clear(); - time_ranges.emplace_back(range); - filter.__set_time_ranges(time_ranges); - session.interface()->search_vector(res, GetGroupID(), TOP_K, tensor, filter); - - ASSERT_EQ(res.result_list.size(), 0); - } - } - - //search binary vector - { - const int32_t anchor_index = BATCH_COUNT + 200; - const int32_t search_count = 10; - server::TimeRecorder rc("Search binary batch top_k"); - VecBinaryTensorList tensor_list; - for(int32_t k = anchor_index; k < anchor_index + search_count; k++) { - VecBinaryTensor bin_tensor; - bin_tensor.tensor.resize(VEC_DIMENSION * sizeof(double)); - double* d_p = new double[VEC_DIMENSION]; - for (int32_t i = 0; i < VEC_DIMENSION; i++) { - d_p[i] = (double)(i + k); - } - memcpy(const_cast(bin_tensor.tensor.data()), d_p, VEC_DIMENSION * sizeof(double)); - tensor_list.tensor_list.emplace_back(bin_tensor); - } - - VecSearchResultList res; - VecSearchFilter filter; - session.interface()->search_binary_vector_batch(res, GetGroupID(), TOP_K, tensor_list, filter); - - std::cout << "Search binary batch result: " << std::endl; - for(size_t i = 0 ; i < res.result_list.size(); i++) { - std::cout << "No " << i << ":" << std::endl; - for(VecSearchResultItem& item : res.result_list[i].result_list) { - std::cout << "\t" << item.uid << std::endl; - ASSERT_TRUE(item.attrib.count(TEST_ATTRIB_NUM) != 0); - ASSERT_TRUE(item.attrib.count(TEST_ATTRIB_COMMENT) != 0); - ASSERT_TRUE(!item.attrib[TEST_ATTRIB_COMMENT].empty()); - } - } - - rc.Elapse("done!"); - - ASSERT_EQ(res.result_list.size(), search_count); - for(size_t i = 0 ; i < res.result_list.size(); i++) { - ASSERT_EQ(res.result_list[i].result_list.size(), (uint64_t) TOP_K); - ASSERT_TRUE(!res.result_list[i].result_list.empty()); - } - } - - } catch (std::exception& ex) { - CLIENT_LOG_ERROR << "request encounter exception: " << ex.what(); - ASSERT_TRUE(false); - } -} diff --git a/cpp/test_client/src/FaissTest.cpp b/cpp/test_client/src/FaissTest.cpp deleted file mode 100644 index a775c66099..0000000000 --- a/cpp/test_client/src/FaissTest.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#include "FaissTest.h" - -#include "utils/TimeRecorder.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace zilliz { -namespace vecwise { -namespace client { -namespace { - void test_flat() { - zilliz::vecwise::server::TimeRecorder recorder("test_flat"); - - int d = 64; // dimension - int nb = 100000; // database size - int nq = 10000; // nb of queries - - float *xb = new float[d * nb]; - float *xq = new float[d * nq]; - - for (int i = 0; i < nb; i++) { - for (int j = 0; j < d; j++) - xb[d * i + j] = drand48(); - xb[d * i] += i / 1000.; - } - - for (int i = 0; i < nq; i++) { - for (int j = 0; j < d; j++) - xq[d * i + j] = drand48(); - xq[d * i] += i / 1000.; - } - - recorder.Record("prepare data"); - - faiss::IndexFlatL2 index(d); // call constructor - - recorder.Record("declare index"); - - printf("is_trained = %s\n", index.is_trained ? "true" : "false"); - index.add(nb, xb); // add vectors to the index - printf("ntotal = %ld\n", index.ntotal); - - recorder.Record("add index"); - - int k = 4; - - { // sanity check: search 5 first vectors of xb - long *I = new long[k * 5]; - float *D = new float[k * 5]; - - index.search(5, xb, k, D, I); - - // print results - printf("I=\n"); - for (int i = 0; i < 5; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - printf("D=\n"); - for (int i = 0; i < 5; i++) { - for (int j = 0; j < k; j++) - printf("%7g ", D[i * k + j]); - printf("\n"); - } - - delete[] I; - delete[] D; - } - - recorder.Record("search top 4"); - - { // search xq - long *I = new long[k * nq]; - float *D = new float[k * nq]; - - index.search(nq, xq, k, D, I); - - // print results - printf("I (5 first results)=\n"); - for (int i = 0; i < 5; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - printf("I (5 last results)=\n"); - for (int i = nq - 5; i < nq; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - delete[] I; - delete[] D; - } - - recorder.Record("search xq"); - - delete[] xb; - delete[] xq; - - recorder.Record("delete data"); - } - - void test_gpu() { - zilliz::vecwise::server::TimeRecorder recorder("test_gpu"); - - int d = 64; // dimension - int nb = 100000; // database size - int nq = 10000; // nb of queries - - float *xb = new float[d * nb]; - float *xq = new float[d * nq]; - - for (int i = 0; i < nb; i++) { - for (int j = 0; j < d; j++) - xb[d * i + j] = drand48(); - xb[d * i] += i / 1000.; - } - - for (int i = 0; i < nq; i++) { - for (int j = 0; j < d; j++) - xq[d * i + j] = drand48(); - xq[d * i] += i / 1000.; - } - - recorder.Record("prepare data"); - - faiss::gpu::StandardGpuResources res; - - // Using a flat index - - faiss::gpu::GpuIndexFlatL2 index_flat(&res, d); - - recorder.Record("declare index"); - - printf("is_trained = %s\n", index_flat.is_trained ? "true" : "false"); - index_flat.add(nb, xb); // add vectors to the index - printf("ntotal = %ld\n", index_flat.ntotal); - - recorder.Record("add index"); - - int k = 4; - - { // search xq - long *I = new long[k * nq]; - float *D = new float[k * nq]; - - index_flat.search(nq, xq, k, D, I); - - // print results - printf("I (5 first results)=\n"); - for (int i = 0; i < 5; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - printf("I (5 last results)=\n"); - for (int i = nq - 5; i < nq; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - delete[] I; - delete[] D; - } - - recorder.Record("search top 4"); - - // Using an IVF index - - int nlist = 100; - faiss::gpu::GpuIndexIVFFlat index_ivf(&res, d, nlist, faiss::METRIC_L2); - // here we specify METRIC_L2, by default it performs inner-product search - - recorder.Record("declare index"); - - assert(!index_ivf.is_trained); - index_ivf.train(nb, xb); - assert(index_ivf.is_trained); - - recorder.Record("train index"); - - index_ivf.add(nb, xb); // add vectors to the index - - recorder.Record("add index"); - - printf("is_trained = %s\n", index_ivf.is_trained ? "true" : "false"); - printf("ntotal = %ld\n", index_ivf.ntotal); - - { // search xq - long *I = new long[k * nq]; - float *D = new float[k * nq]; - - index_ivf.search(nq, xq, k, D, I); - - // print results - printf("I (5 first results)=\n"); - for (int i = 0; i < 5; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - printf("I (5 last results)=\n"); - for (int i = nq - 5; i < nq; i++) { - for (int j = 0; j < k; j++) - printf("%5ld ", I[i * k + j]); - printf("\n"); - } - - delete[] I; - delete[] D; - } - - recorder.Record("search xq"); - - delete[] xb; - delete[] xq; - - recorder.Record("delete data"); - } -} - -void FaissTest::test() { - - int ngpus = faiss::gpu::getNumDevices(); - - printf("Number of GPUs: %d\n", ngpus); - - test_flat(); - test_gpu(); -} - -} -} -} \ No newline at end of file diff --git a/cpp/test_client/src/Log.h b/cpp/test_client/src/Log.h deleted file mode 100644 index 34af7319b4..0000000000 --- a/cpp/test_client/src/Log.h +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#pragma once - -#include - -namespace zilliz { -namespace vecwise { -namespace client { - -#define CLIENT_DOMAIN_NAME "[CLIENT] " -#define CLIENT_ERROR_TEXT "CLIENT Error:" - -#define CLIENT_LOG_TRACE LOG(TRACE) << CLIENT_DOMAIN_NAME -#define CLIENT_LOG_DEBUG LOG(DEBUG) << CLIENT_DOMAIN_NAME -#define CLIENT_LOG_INFO LOG(INFO) << CLIENT_DOMAIN_NAME -#define CLIENT_LOG_WARNING LOG(WARNING) << CLIENT_DOMAIN_NAME -#define CLIENT_LOG_ERROR LOG(ERROR) << CLIENT_DOMAIN_NAME -#define CLIENT_LOG_FATAL LOG(FATAL) << CLIENT_DOMAIN_NAME - -} // namespace sql -} // namespace zilliz -} // namespace server From fe5b511596df803ca473a5283e33f1c864151ede Mon Sep 17 00:00:00 2001 From: groot Date: Mon, 27 May 2019 20:34:20 +0800 Subject: [PATCH 2/3] add search example Former-commit-id: f38cc87551001449c5930fb719ba038b45af47df --- .../sdk/examples/simple/src/ClientTest.cpp | 109 +++++++++++++++--- cpp/src/server/MegasearchTask.cpp | 4 +- 2 files changed, 93 insertions(+), 20 deletions(-) diff --git a/cpp/src/sdk/examples/simple/src/ClientTest.cpp b/cpp/src/sdk/examples/simple/src/ClientTest.cpp index d6547079c3..01669680fc 100644 --- a/cpp/src/sdk/examples/simple/src/ClientTest.cpp +++ b/cpp/src/sdk/examples/simple/src/ClientTest.cpp @@ -7,11 +7,12 @@ #include "MegaSearch.h" #include +#include +#include + +using namespace megasearch; namespace { - static const std::string TABLE_NAME = "human face"; - static const int64_t TABLE_DIMENSION = 512; - void PrintTableSchema(const megasearch::TableSchema& tb_schema) { std::cout << "===========================================" << std::endl; std::cout << "Table name: " << tb_schema.table_name << std::endl; @@ -20,52 +21,124 @@ namespace { std::cout << "Table partitions: " << tb_schema.partition_column_name_array.size() << std::endl; std::cout << "===========================================" << std::endl; } + + std::string CurrentTime() { + time_t tt; + time( &tt ); + tt = tt + 8*3600; + tm* t= gmtime( &tt ); + + std::string str = std::to_string(t->tm_year + 1900) + "_" + std::to_string(t->tm_mon + 1) + + "_" + std::to_string(t->tm_mday) + "_" + std::to_string(t->tm_hour) + + "_" + std::to_string(t->tm_min) + "_" + std::to_string(t->tm_sec); + + return str; + } + + std::string GetTableName() { + static std::string s_id(CurrentTime()); + return s_id; + } + + static const std::string TABLE_NAME = GetTableName(); + static const std::string VECTOR_COLUMN_NAME = "face_vector"; + static const int64_t TABLE_DIMENSION = 512; + + void BuildVectors(int64_t from, int64_t to, + std::vector* vector_record_array, + std::vector* query_record_array) { + if(to <= from){ + return; + } + + if(vector_record_array) { + vector_record_array->clear(); + } + if(query_record_array) { + query_record_array->clear(); + } + + for (int64_t k = from; k < to; k++) { + + std::vector f_p; + f_p.resize(TABLE_DIMENSION); + for(int64_t i = 0; i < TABLE_DIMENSION; i++) { + f_p[i] = (float)(i + k); + } + + if(vector_record_array) { + RowRecord record; + record.vector_map.insert(std::make_pair(VECTOR_COLUMN_NAME, f_p)); + vector_record_array->emplace_back(record); + } + + if(query_record_array) { + QueryRecord record; + record.vector_map.insert(std::make_pair(VECTOR_COLUMN_NAME, f_p)); + query_record_array->emplace_back(record); + } + } + } } void ClientTest::Test(const std::string& address, const std::string& port) { - std::shared_ptr conn = megasearch::Connection::Create(); - megasearch::ConnectParam param = { address, port }; + std::shared_ptr conn = Connection::Create(); + ConnectParam param = { address, port }; conn->Connect(param); {//create table - megasearch::TableSchema tb_schema; - megasearch::VectorColumn col1; - col1.name = "face"; + TableSchema tb_schema; + VectorColumn col1; + col1.name = VECTOR_COLUMN_NAME; col1.dimension = TABLE_DIMENSION; col1.store_raw_vector = true; tb_schema.vector_column_array.emplace_back(col1); - megasearch::Column col2; + Column col2; col2.name = "age"; tb_schema.attribute_column_array.emplace_back(col2); tb_schema.table_name = TABLE_NAME; PrintTableSchema(tb_schema); - megasearch::Status stat = conn->CreateTable(tb_schema); + Status stat = conn->CreateTable(tb_schema); std::cout << "Create table result: " << stat.ToString() << std::endl; } {//describe table - megasearch::TableSchema tb_schema; - megasearch::Status stat = conn->DescribeTable(TABLE_NAME, tb_schema); + TableSchema tb_schema; + Status stat = conn->DescribeTable(TABLE_NAME, tb_schema); std::cout << "Describe table result: " << stat.ToString() << std::endl; PrintTableSchema(tb_schema); } {//add vectors - + std::vector record_array; + BuildVectors(0, 10000, &record_array, nullptr); + std::vector record_ids; + std::cout << "Begin add vectors" << std::endl; + Status stat = conn->AddVector(TABLE_NAME, record_array, record_ids); + std::cout << "Add vector result: " << stat.ToString() << std::endl; + std::cout << "Returned vector ids: " << record_ids.size() << std::endl; } {//search vectors + sleep(10); + std::vector record_array; + BuildVectors(500, 510, nullptr, &record_array); + std::vector topk_query_result_array; + std::cout << "Begin search vectors" << std::endl; + Status stat = conn->SearchVector(TABLE_NAME, record_array, topk_query_result_array, 10); + std::cout << "Search vector result: " << stat.ToString() << std::endl; + std::cout << "Returned result count: " << topk_query_result_array.size() << std::endl; } - {//delete table - megasearch::Status stat = conn->DeleteTable(TABLE_NAME); - std::cout << "Delete table result: " << stat.ToString() << std::endl; - } +// {//delete table +// Status stat = conn->DeleteTable(TABLE_NAME); +// std::cout << "Delete table result: " << stat.ToString() << std::endl; +// } - megasearch::Connection::Destroy(conn); + Connection::Destroy(conn); } \ No newline at end of file diff --git a/cpp/src/server/MegasearchTask.cpp b/cpp/src/server/MegasearchTask.cpp index 077f217d68..884557ffa4 100644 --- a/cpp/src/server/MegasearchTask.cpp +++ b/cpp/src/server/MegasearchTask.cpp @@ -163,7 +163,7 @@ ServerError DeleteTableTask::OnExecute() { error_msg_ = "delete table not implemented"; SERVER_LOG_ERROR << error_msg_; - //IVecIdMapper::GetInstance()->DeleteGroup(table_name_); + IVecIdMapper::GetInstance()->DeleteGroup(table_name_); return SERVER_NOT_IMPLEMENT; } @@ -349,7 +349,7 @@ ServerError SearchVectorTask::OnExecute() { thrift_topk_result.query_result_arrays.emplace_back(thrift_result); } - result_array_.push_back(thrift_topk_result); + result_array_.emplace_back(thrift_topk_result); } rc.Record("construct result"); } From 22e2a2bc3fa9a104d87954d3eb8eeebf3691055d Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 28 May 2019 09:59:06 +0800 Subject: [PATCH 3/3] throw exception for invalid index type Former-commit-id: b028167c2460be4738af5f092a443749dba89bc0 --- cpp/CHANGELOG.md | 1 + cpp/src/sdk/src/interface/ConnectionImpl.cpp | 32 ++++++++++---------- cpp/src/sdk/src/interface/ConnectionImpl.h | 2 +- cpp/src/sdk/src/util/ConvertUtil.cpp | 5 +-- cpp/src/sdk/src/util/Exception.h | 32 ++++++++++++++++++++ 5 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 cpp/src/sdk/src/util/Exception.h diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 263f4a787a..489228eca8 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -16,3 +16,4 @@ Please mark all change in change log and use the ticket from JIRA. - MS-1 - Add CHANGELOG.md - MS-4 - Refactor the vecwise_engine code structure +- MS-6 - Implement SDK interface part 1 diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.cpp b/cpp/src/sdk/src/interface/ConnectionImpl.cpp index 26fb5ff209..69612ad8b4 100644 --- a/cpp/src/sdk/src/interface/ConnectionImpl.cpp +++ b/cpp/src/sdk/src/interface/ConnectionImpl.cpp @@ -22,59 +22,59 @@ Connection::Destroy(std::shared_ptr connection_ptr) { ////////////////////////////////////////////////////////////////////////////////////////////// ConnectionImpl::ConnectionImpl() { - client_proxy = std::make_shared(); + client_proxy_ = std::make_shared(); } Status ConnectionImpl::Connect(const ConnectParam ¶m) { - return client_proxy->Connect(param); + return client_proxy_->Connect(param); } Status ConnectionImpl::Connect(const std::string &uri) { - return client_proxy->Connect(uri); + return client_proxy_->Connect(uri); } Status ConnectionImpl::Connected() const { - return client_proxy->Connected(); + return client_proxy_->Connected(); } Status ConnectionImpl::Disconnect() { - return client_proxy->Disconnect(); + return client_proxy_->Disconnect(); } std::string ConnectionImpl::ClientVersion() const { - return client_proxy->ClientVersion(); + return client_proxy_->ClientVersion(); } Status ConnectionImpl::CreateTable(const TableSchema ¶m) { - return client_proxy->CreateTable(param); + return client_proxy_->CreateTable(param); } Status ConnectionImpl::CreateTablePartition(const CreateTablePartitionParam ¶m) { - return client_proxy->CreateTablePartition(param); + return client_proxy_->CreateTablePartition(param); } Status ConnectionImpl::DeleteTablePartition(const DeleteTablePartitionParam ¶m) { - return client_proxy->DeleteTablePartition(param); + return client_proxy_->DeleteTablePartition(param); } Status ConnectionImpl::DeleteTable(const std::string &table_name) { - return client_proxy->DeleteTable(table_name); + return client_proxy_->DeleteTable(table_name); } Status ConnectionImpl::AddVector(const std::string &table_name, const std::vector &record_array, std::vector &id_array) { - return client_proxy->AddVector(table_name, record_array, id_array); + return client_proxy_->AddVector(table_name, record_array, id_array); } Status @@ -82,27 +82,27 @@ ConnectionImpl::SearchVector(const std::string &table_name, const std::vector &query_record_array, std::vector &topk_query_result_array, int64_t topk) { - return client_proxy->SearchVector(table_name, query_record_array, topk_query_result_array, topk); + return client_proxy_->SearchVector(table_name, query_record_array, topk_query_result_array, topk); } Status ConnectionImpl::DescribeTable(const std::string &table_name, TableSchema &table_schema) { - return client_proxy->DescribeTable(table_name, table_schema); + return client_proxy_->DescribeTable(table_name, table_schema); } Status ConnectionImpl::ShowTables(std::vector &table_array) { - return client_proxy->ShowTables(table_array); + return client_proxy_->ShowTables(table_array); } std::string ConnectionImpl::ServerVersion() const { - return client_proxy->ServerVersion(); + return client_proxy_->ServerVersion(); } std::string ConnectionImpl::ServerStatus() const { - return client_proxy->ServerStatus(); + return client_proxy_->ServerStatus(); } } diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.h b/cpp/src/sdk/src/interface/ConnectionImpl.h index 624bbebde5..0c67ea3f42 100644 --- a/cpp/src/sdk/src/interface/ConnectionImpl.h +++ b/cpp/src/sdk/src/interface/ConnectionImpl.h @@ -51,7 +51,7 @@ public: virtual std::string ServerStatus() const override; private: - std::shared_ptr client_proxy; + std::shared_ptr client_proxy_; }; } diff --git a/cpp/src/sdk/src/util/ConvertUtil.cpp b/cpp/src/sdk/src/util/ConvertUtil.cpp index 90cab3fdb4..577f5de446 100644 --- a/cpp/src/sdk/src/util/ConvertUtil.cpp +++ b/cpp/src/sdk/src/util/ConvertUtil.cpp @@ -4,6 +4,7 @@ * Proprietary and confidential. ******************************************************************************/ #include "ConvertUtil.h" +#include "Exception.h" #include @@ -20,7 +21,7 @@ std::string ConvertUtil::IndexType2Str(megasearch::IndexType index) { const auto& iter = s_index2str.find(index); if(iter == s_index2str.end()) { - return INDEX_RAW; + throw Exception(StatusCode::Invalid, "Invalid index type"); } return iter->second; @@ -34,7 +35,7 @@ megasearch::IndexType ConvertUtil::Str2IndexType(const std::string& type) { const auto& iter = s_str2index.find(type); if(iter == s_str2index.end()) { - return megasearch::IndexType::raw; + throw Exception(StatusCode::Invalid, "Invalid index type"); } return iter->second; diff --git a/cpp/src/sdk/src/util/Exception.h b/cpp/src/sdk/src/util/Exception.h new file mode 100644 index 0000000000..7e31b182a6 --- /dev/null +++ b/cpp/src/sdk/src/util/Exception.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited. + * Proprietary and confidential. + ******************************************************************************/ +#pragma once + +#include "Status.h" + +#include + +namespace megasearch { +class Exception : public std::exception { +public: + Exception(StatusCode error_code, + const std::string &message = std::string()) + : error_code_(error_code), message_(message) {} + +public: + StatusCode error_code() const { + return error_code_; + } + + virtual const char *what() const noexcept { + return message_.c_str(); + } + +private: + StatusCode error_code_; + std::string message_; +}; +} \ No newline at end of file