RequestHandler.h 5.9 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6 7 8 9 10
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include <cstdint>
#include <string>

G
groot 已提交
11
#include "MilvusService.h"
G
groot 已提交
12 13

namespace zilliz {
J
jinhai 已提交
14
namespace milvus {
G
groot 已提交
15 16
namespace server {

G
groot 已提交
17
class RequestHandler : virtual public ::milvus::thrift::MilvusServiceIf {
G
groot 已提交
18
public:
G
groot 已提交
19
    RequestHandler();
G
groot 已提交
20 21

    /**
G
groot 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
     * @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 ::milvus::thrift::TableSchema &param);

    /**
     * @brief Test table existence method
     *
     * This method is used to test table existence.
     *
     * @param table_name, table name is going to be tested.
     *
     *
     * @param table_name
     */
    bool HasTable(const std::string &table_name);
G
groot 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56

    /**
     * @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);

P
peng.xu 已提交
57 58 59 60 61 62 63 64 65 66 67 68
    /**
     * @brief build index by table method
     *
     * This method is used to build index by table in sync.
     *
     * @param table_name, table name is going to be built index.
     *
     *
     * @param table_name
     */
    void BuildIndex(const std::string &table_name);

G
groot 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    /**
     * @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,
G
groot 已提交
84
            const std::vector<::milvus::thrift::RowRecord> & record_array);
G
groot 已提交
85 86 87 88 89 90 91 92

    /**
     * @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.
G
groot 已提交
93
     * @param query_range_array, optional ranges for conditional search. If not specified, search whole table
G
groot 已提交
94 95 96 97 98 99
     * @param topk, how many similarity vectors will be searched.
     *
     * @return query result array.
     *
     * @param table_name
     * @param query_record_array
G
groot 已提交
100
     * @param query_range_array
G
groot 已提交
101 102
     * @param topk
     */
G
groot 已提交
103
    void SearchVector(std::vector<::milvus::thrift::TopKQueryResult> & _return,
G
groot 已提交
104
            const std::string& table_name,
G
groot 已提交
105 106
            const std::vector<::milvus::thrift::RowRecord> & query_record_array,
            const std::vector<::milvus::thrift::Range> & query_range_array,
G
groot 已提交
107
            const int64_t topk);
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130

    /**
     * @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 binary result array.
     *
     * @param table_name
     * @param query_record_array
     * @param query_range_array
     * @param topk
     */
    void SearchVector2(std::vector<::milvus::thrift::TopKQueryBinResult> & _return,
            const std::string& table_name,
            const std::vector<::milvus::thrift::RowRecord> & query_record_array,
            const std::vector<::milvus::thrift::Range> & query_range_array,
            const int64_t topk);
G
groot 已提交
131

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
    /**
   * @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 file_id_array
   * @param query_record_array
   * @param query_range_array
   * @param topk
   */
    virtual void SearchVectorInFiles(std::vector<::milvus::thrift::TopKQueryResult> & _return,
            const std::string& table_name,
            const std::vector<std::string> & file_id_array,
            const std::vector<::milvus::thrift::RowRecord> & query_record_array,
            const std::vector<::milvus::thrift::Range> & query_range_array,
            const int64_t topk);

G
groot 已提交
156
    /**
G
groot 已提交
157
     * @brief Get table schema
G
groot 已提交
158
     *
G
groot 已提交
159
     * This method is used to get table schema.
G
groot 已提交
160
     *
G
groot 已提交
161
     * @param table_name, target table name.
G
groot 已提交
162 163 164 165 166
     *
     * @return table schema
     *
     * @param table_name
     */
G
groot 已提交
167
    void DescribeTable(::milvus::thrift::TableSchema& _return, const std::string& table_name);
G
groot 已提交
168

G
groot 已提交
169 170 171 172 173 174 175 176 177 178 179 180 181
    /**
     * @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);

G
groot 已提交
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
    /**
     * @brief List all tables in database
     *
     * This method is used to list all tables.
     *
     *
     * @return table names.
     */
    void ShowTables(std::vector<std::string> & _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);
};

}
}
}