mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-30 23:45:28 +08:00
190 lines
5.4 KiB
C++
190 lines
5.4 KiB
C++
// This autogenerated skeleton file illustrates how to build a server.
|
|
// You should copy it to another filename to avoid overwriting it.
|
|
|
|
#include "MilvusService.h"
|
|
#include <thrift/protocol/TBinaryProtocol.h>
|
|
#include <thrift/server/TSimpleServer.h>
|
|
#include <thrift/transport/TServerSocket.h>
|
|
#include <thrift/transport/TBufferTransports.h>
|
|
|
|
using namespace ::apache::thrift;
|
|
using namespace ::apache::thrift::protocol;
|
|
using namespace ::apache::thrift::transport;
|
|
using namespace ::apache::thrift::server;
|
|
|
|
using namespace ::milvus::thrift;
|
|
|
|
class MilvusServiceHandler : virtual public MilvusServiceIf {
|
|
public:
|
|
MilvusServiceHandler() {
|
|
// 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 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<int64_t> & _return, const std::string& table_name, const std::vector<RowRecord> & 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 query_range_array, optional ranges for conditional search. If not specified, search whole table
|
|
* @param topk, how many similarity vectors will be searched.
|
|
*
|
|
* @return query result array.
|
|
*
|
|
* @param table_name
|
|
* @param query_record_array
|
|
* @param query_range_array
|
|
* @param topk
|
|
*/
|
|
void SearchVector(std::vector<TopKQueryResult> & _return, const std::string& table_name, const std::vector<RowRecord> & query_record_array, const std::vector<Range> & query_range_array, const int64_t topk) {
|
|
// Your implementation goes here
|
|
printf("SearchVector\n");
|
|
}
|
|
|
|
/**
|
|
* @brief Internal use query interface
|
|
*
|
|
* This method is used to query vector in specified files.
|
|
*
|
|
* @param file_id_array, specified files id array, queried.
|
|
* @param query_record_array, all vector are going to be queried.
|
|
* @param query_range_array, optional ranges for conditional search. If not specified, search whole table
|
|
* @param topk, how many similarity vectors will be searched.
|
|
*
|
|
* @return query result array.
|
|
*
|
|
* @param table_name
|
|
* @param file_id_array
|
|
* @param query_record_array
|
|
* @param query_range_array
|
|
* @param topk
|
|
*/
|
|
void SearchVectorInFiles(std::vector<TopKQueryResult> & _return, const std::string& table_name, const std::vector<std::string> & file_id_array, const std::vector<RowRecord> & query_record_array, const std::vector<Range> & query_range_array, const int64_t topk) {
|
|
// Your implementation goes here
|
|
printf("SearchVectorInFiles\n");
|
|
}
|
|
|
|
/**
|
|
* @brief Get table schema
|
|
*
|
|
* This method is used to get table schema.
|
|
*
|
|
* @param table_name, target table name.
|
|
*
|
|
* @return table schema
|
|
*
|
|
* @param table_name
|
|
*/
|
|
void DescribeTable(TableSchema& _return, const std::string& table_name) {
|
|
// Your implementation goes here
|
|
printf("DescribeTable\n");
|
|
}
|
|
|
|
/**
|
|
* @brief Get table row count
|
|
*
|
|
* This method is used to get table row count.
|
|
*
|
|
* @param table_name, target table name.
|
|
*
|
|
* @return table row count
|
|
*
|
|
* @param table_name
|
|
*/
|
|
int64_t GetTableRowCount(const std::string& table_name) {
|
|
// Your implementation goes here
|
|
printf("GetTableRowCount\n");
|
|
}
|
|
|
|
/**
|
|
* @brief List all tables in database
|
|
*
|
|
* This method is used to list all tables.
|
|
*
|
|
*
|
|
* @return table names.
|
|
*/
|
|
void ShowTables(std::vector<std::string> & _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<MilvusServiceHandler> handler(new MilvusServiceHandler());
|
|
::apache::thrift::stdcxx::shared_ptr<TProcessor> processor(new MilvusServiceProcessor(handler));
|
|
::apache::thrift::stdcxx::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
|
|
::apache::thrift::stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
|
|
::apache::thrift::stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
|
|
|
TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
|
|
server.serve();
|
|
return 0;
|
|
}
|
|
|