提交 487ea034 编写于 作者: G groot

redefine thrift api


Former-commit-id: 0dc225d0372e6e2260126a301552a37d161ccec8
上级 2ff4cae2
......@@ -123,16 +123,15 @@ VecServiceHandler::search_vector(VecSearchResult &_return,
const std::string &group_id,
const int64_t top_k,
const VecTensor &tensor,
const VecTimeRangeList &time_range_list) {
const VecSearchFilter& filter) {
TimeRecordWrapper rc("search_vector()");
SERVER_LOG_TRACE << "group_id = " << group_id << ", top_k = " << top_k
<< ", vector dimension = " << tensor.tensor.size()
<< ", time range list size = " << time_range_list.range_list.size();
<< ", vector dimension = " << tensor.tensor.size();
VecTensorList tensor_list;
tensor_list.tensor_list.push_back(tensor);
VecSearchResultList result;
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, time_range_list, result);
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, result);
VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance();
scheduler.ExecuteTask(task_ptr);
......@@ -148,13 +147,12 @@ VecServiceHandler::search_vector_batch(VecSearchResultList &_return,
const std::string &group_id,
const int64_t top_k,
const VecTensorList &tensor_list,
const VecTimeRangeList &time_range_list) {
const VecSearchFilter& filter) {
TimeRecordWrapper rc("search_vector_batch()");
SERVER_LOG_TRACE << "group_id = " << group_id << ", top_k = " << top_k
<< ", vector list size = " << tensor_list.tensor_list.size()
<< ", time range list size = " << time_range_list.range_list.size();
<< ", vector list size = " << tensor_list.tensor_list.size();
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, time_range_list, _return);
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, _return);
VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance();
scheduler.ExecuteTask(task_ptr);
}
......@@ -164,16 +162,15 @@ VecServiceHandler::search_binary_vector(VecSearchResult& _return,
const std::string& group_id,
const int64_t top_k,
const VecBinaryTensor& tensor,
const VecTimeRangeList& time_range_list) {
const VecSearchFilter& filter) {
TimeRecordWrapper rc("search_binary_vector()");
SERVER_LOG_TRACE << "group_id = " << group_id << ", top_k = " << top_k
<< ", vector dimension = " << tensor.tensor.size()
<< ", time range list size = " << time_range_list.range_list.size();
<< ", vector dimension = " << tensor.tensor.size();
VecBinaryTensorList tensor_list;
tensor_list.tensor_list.push_back(tensor);
VecSearchResultList result;
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, time_range_list, result);
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, result);
VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance();
scheduler.ExecuteTask(task_ptr);
......@@ -189,13 +186,12 @@ VecServiceHandler::search_binary_vector_batch(VecSearchResultList& _return,
const std::string& group_id,
const int64_t top_k,
const VecBinaryTensorList& tensor_list,
const VecTimeRangeList& time_range_list) {
const VecSearchFilter& filter) {
TimeRecordWrapper rc("search_binary_vector_batch()");
SERVER_LOG_TRACE << "group_id = " << group_id << ", top_k = " << top_k
<< ", vector list size = " << tensor_list.tensor_list.size()
<< ", time range list size = " << time_range_list.range_list.size();
<< ", vector list size = " << tensor_list.tensor_list.size();
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, time_range_list, _return);
BaseTaskPtr task_ptr = SearchVectorTask::Create(group_id, top_k, &tensor_list, filter, _return);
VecServiceScheduler& scheduler = VecServiceScheduler::GetInstance();
scheduler.ExecuteTask(task_ptr);
}
......
......@@ -55,21 +55,23 @@ public:
void add_binary_vector_batch(const std::string& group_id, const VecBinaryTensorList& tensor_list);
/**
* search interfaces
* if time_range_list is empty, engine will search without time limit
*
* @param group_id
* @param top_k
* @param tensor
* @param time_range_list
*/
void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecTimeRangeList& time_range_list);
void search_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecTensorList& tensor_list, const VecTimeRangeList& time_range_list);
void search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecTimeRangeList& time_range_list);
void search_binary_vector_batch(VecSearchResultList& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensorList& tensor_list, const VecTimeRangeList& time_range_list);
* search interfaces
* if time_range_list 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);
};
......
......@@ -405,14 +405,14 @@ ServerError AddBatchVectorTask::OnExecute() {
SearchVectorTask::SearchVectorTask(const std::string& group_id,
const int64_t top_k,
const VecTensorList* tensor_list,
const VecTimeRangeList& time_range_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),
time_range_list_(time_range_list),
filter_(filter),
result_(result) {
}
......@@ -420,14 +420,14 @@ SearchVectorTask::SearchVectorTask(const std::string& group_id,
SearchVectorTask::SearchVectorTask(const std::string& group_id,
const int64_t top_k,
const VecBinaryTensorList* bin_tensor_list,
const VecTimeRangeList& time_range_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),
time_range_list_(time_range_list),
filter_(filter),
result_(result) {
}
......@@ -435,17 +435,17 @@ SearchVectorTask::SearchVectorTask(const std::string& group_id,
BaseTaskPtr SearchVectorTask::Create(const std::string& group_id,
const int64_t top_k,
const VecTensorList* tensor_list,
const VecTimeRangeList& time_range_list,
const VecSearchFilter& filter,
VecSearchResultList& result) {
return std::shared_ptr<BaseTask>(new SearchVectorTask(group_id, top_k, tensor_list, time_range_list, result));
return std::shared_ptr<BaseTask>(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 VecTimeRangeList& time_range_list,
const VecSearchFilter& filter,
VecSearchResultList& result) {
return std::shared_ptr<BaseTask>(new SearchVectorTask(group_id, top_k, bin_tensor_list, time_range_list, result));
return std::shared_ptr<BaseTask>(new SearchVectorTask(group_id, top_k, bin_tensor_list, filter, result));
}
......@@ -546,8 +546,10 @@ ServerError SearchVectorTask::OnExecute() {
std::string sid;
std::string nid = nid_prefix + std::to_string(id);
IVecIdMapper::GetInstance()->Get(nid, sid);
v_res.id_list.push_back(sid);
v_res.distance_list.push_back(0.0);//TODO: return distance
VecSearchResultItem item;
item.uid = sid;
item.distance = 0.0;////TODO: return distance
v_res.result_list.emplace_back(item);
SERVER_LOG_TRACE << "nid = " << nid << ", string id = " << sid;
......
......@@ -130,26 +130,26 @@ public:
static BaseTaskPtr Create(const std::string& group_id,
const int64_t top_k,
const VecTensorList* tensor_list,
const VecTimeRangeList& time_range_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 VecTimeRangeList& time_range_list,
const VecSearchFilter& filter,
VecSearchResultList& result);
protected:
SearchVectorTask(const std::string& group_id,
const int64_t top_k,
const VecTensorList* tensor_list,
const VecTimeRangeList& time_range_list,
const VecSearchFilter& filter,
VecSearchResultList& result);
SearchVectorTask(const std::string& group_id,
const int64_t top_k,
const VecBinaryTensorList* bin_tensor_list,
const VecTimeRangeList& time_range_list,
const VecSearchFilter& filter,
VecSearchResultList& result);
ServerError GetTargetData(std::vector<float>& data) const;
......@@ -163,7 +163,7 @@ private:
int64_t top_k_;
const VecTensorList* tensor_list_;
const VecBinaryTensorList* bin_tensor_list_;
const VecTimeRangeList& time_range_list_;
const VecSearchFilter& filter_;
VecSearchResultList& result_;
};
......
......@@ -19,32 +19,39 @@ exception VecException {
}
struct VecGroup {
1: string id;
2: i32 dimension;
3: i32 index_type;
1: required string id;
2: required i32 dimension;
3: optional i32 index_type;
}
struct VecTensor {
1: string uid;
2: list<double> tensor;
1: required string uid;
2: required list<double> tensor;
3: optional map<string, string> attrib;
}
struct VecTensorList {
1: list<VecTensor> tensor_list;
1: required list<VecTensor> tensor_list;
}
struct VecBinaryTensor {
1: string uid;
2: binary tensor;
1: required string uid;
2: required binary tensor;
3: optional map<string, string> attrib;
}
struct VecBinaryTensorList {
1: list<VecBinaryTensor> tensor_list;
1: required list<VecBinaryTensor> tensor_list;
}
struct VecSearchResultItem {
1: required string uid;
2: optional double distance;
3: optional map<string, string> attrib;
}
struct VecSearchResult {
1: list<string> id_list;
2: list<double> distance_list;
1: list<VecSearchResultItem> result_list;
}
struct VecSearchResultList {
......@@ -53,23 +60,24 @@ struct VecSearchResultList {
struct VecDateTime {
1: i32 year;
2: i32 month;
3: i32 day;
4: i32 hour;
5: i32 minute;
6: i32 second;
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 VecTimeRange {
1: VecDateTime time_begin;
2: bool begine_closed;
3: VecDateTime time_end;
4: bool end_closed;
1: required VecDateTime time_begin;
2: required bool begine_closed;
3: required VecDateTime time_end;
4: required bool end_closed;
}
struct VecTimeRangeList {
1: list<VecTimeRange> range_list;
struct VecSearchFilter {
1: optional map<string, string> attrib_filter;
2: optional list<VecTimeRange> time_ranges;
}
service VecService {
......@@ -93,9 +101,10 @@ service VecService {
/**
* search interfaces
* if time_range_list is empty, engine will search without time limit
*
*/
VecSearchResult search_vector(2: string group_id, 3: i64 top_k, 4: VecTensor tensor, 5: VecTimeRangeList time_range_list) throws(1: VecException e);
VecSearchResultList search_vector_batch(2: string group_id, 3: i64 top_k, 4: VecTensorList tensor_list, 5: VecTimeRangeList time_range_list) throws(1: VecException e);
VecSearchResult search_binary_vector(2: string group_id, 3: i64 top_k, 4: VecBinaryTensor tensor, 5: VecTimeRangeList time_range_list) throws(1: VecException e);
VecSearchResultList search_binary_vector_batch(2: string group_id, 3: i64 top_k, 4: VecBinaryTensorList tensor_list, 5: VecTimeRangeList time_range_list) throws(1: VecException e);
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);
}
\ No newline at end of file
......@@ -1453,8 +1453,8 @@ uint32_t VecService_search_vector_args::read(::apache::thrift::protocol::TProtoc
break;
case 5:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += this->time_range_list.read(iprot);
this->__isset.time_range_list = true;
xfer += this->filter.read(iprot);
this->__isset.filter = true;
} else {
xfer += iprot->skip(ftype);
}
......@@ -1488,8 +1488,8 @@ uint32_t VecService_search_vector_args::write(::apache::thrift::protocol::TProto
xfer += this->tensor.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->time_range_list.write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->filter.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -1519,8 +1519,8 @@ uint32_t VecService_search_vector_pargs::write(::apache::thrift::protocol::TProt
xfer += (*(this->tensor)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->time_range_list)).write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->filter)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -1708,8 +1708,8 @@ uint32_t VecService_search_vector_batch_args::read(::apache::thrift::protocol::T
break;
case 5:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += this->time_range_list.read(iprot);
this->__isset.time_range_list = true;
xfer += this->filter.read(iprot);
this->__isset.filter = true;
} else {
xfer += iprot->skip(ftype);
}
......@@ -1743,8 +1743,8 @@ uint32_t VecService_search_vector_batch_args::write(::apache::thrift::protocol::
xfer += this->tensor_list.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->time_range_list.write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->filter.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -1774,8 +1774,8 @@ uint32_t VecService_search_vector_batch_pargs::write(::apache::thrift::protocol:
xfer += (*(this->tensor_list)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->time_range_list)).write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->filter)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -1963,8 +1963,8 @@ uint32_t VecService_search_binary_vector_args::read(::apache::thrift::protocol::
break;
case 5:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += this->time_range_list.read(iprot);
this->__isset.time_range_list = true;
xfer += this->filter.read(iprot);
this->__isset.filter = true;
} else {
xfer += iprot->skip(ftype);
}
......@@ -1998,8 +1998,8 @@ uint32_t VecService_search_binary_vector_args::write(::apache::thrift::protocol:
xfer += this->tensor.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->time_range_list.write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->filter.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -2029,8 +2029,8 @@ uint32_t VecService_search_binary_vector_pargs::write(::apache::thrift::protocol
xfer += (*(this->tensor)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->time_range_list)).write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->filter)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -2218,8 +2218,8 @@ uint32_t VecService_search_binary_vector_batch_args::read(::apache::thrift::prot
break;
case 5:
if (ftype == ::apache::thrift::protocol::T_STRUCT) {
xfer += this->time_range_list.read(iprot);
this->__isset.time_range_list = true;
xfer += this->filter.read(iprot);
this->__isset.filter = true;
} else {
xfer += iprot->skip(ftype);
}
......@@ -2253,8 +2253,8 @@ uint32_t VecService_search_binary_vector_batch_args::write(::apache::thrift::pro
xfer += this->tensor_list.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->time_range_list.write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += this->filter.write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -2284,8 +2284,8 @@ uint32_t VecService_search_binary_vector_batch_pargs::write(::apache::thrift::pr
xfer += (*(this->tensor_list)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("time_range_list", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->time_range_list)).write(oprot);
xfer += oprot->writeFieldBegin("filter", ::apache::thrift::protocol::T_STRUCT, 5);
xfer += (*(this->filter)).write(oprot);
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
......@@ -2822,13 +2822,13 @@ void VecServiceClient::recv_add_binary_vector_batch()
return;
}
void VecServiceClient::search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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);
......@@ -2837,7 +2837,7 @@ void VecServiceClient::send_search_vector(const std::string& group_id, const int
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor = &tensor;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -2886,13 +2886,13 @@ void VecServiceClient::recv_search_vector(VecSearchResult& _return)
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 VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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);
......@@ -2901,7 +2901,7 @@ void VecServiceClient::send_search_vector_batch(const std::string& group_id, con
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor_list = &tensor_list;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -2950,13 +2950,13 @@ void VecServiceClient::recv_search_vector_batch(VecSearchResultList& _return)
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 VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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);
......@@ -2965,7 +2965,7 @@ void VecServiceClient::send_search_binary_vector(const std::string& group_id, co
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor = &tensor;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -3014,13 +3014,13 @@ void VecServiceClient::recv_search_binary_vector(VecSearchResult& _return)
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 VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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);
......@@ -3029,7 +3029,7 @@ void VecServiceClient::send_search_binary_vector_batch(const std::string& group_
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor_list = &tensor_list;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -3513,7 +3513,7 @@ void VecServiceProcessor::process_search_vector(int32_t seqid, ::apache::thrift:
VecService_search_vector_result result;
try {
iface_->search_vector(result.success, args.group_id, args.top_k, args.tensor, args.time_range_list);
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;
......@@ -3570,7 +3570,7 @@ void VecServiceProcessor::process_search_vector_batch(int32_t seqid, ::apache::t
VecService_search_vector_batch_result result;
try {
iface_->search_vector_batch(result.success, args.group_id, args.top_k, args.tensor_list, args.time_range_list);
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;
......@@ -3627,7 +3627,7 @@ void VecServiceProcessor::process_search_binary_vector(int32_t seqid, ::apache::
VecService_search_binary_vector_result result;
try {
iface_->search_binary_vector(result.success, args.group_id, args.top_k, args.tensor, args.time_range_list);
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;
......@@ -3684,7 +3684,7 @@ void VecServiceProcessor::process_search_binary_vector_batch(int32_t seqid, ::ap
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.time_range_list);
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;
......@@ -4309,13 +4309,13 @@ void VecServiceConcurrentClient::recv_add_binary_vector_batch(const int32_t seqi
} // end while(true)
}
void VecServiceConcurrentClient::search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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_);
......@@ -4325,7 +4325,7 @@ int32_t VecServiceConcurrentClient::send_search_vector(const std::string& group_
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor = &tensor;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -4400,13 +4400,13 @@ void VecServiceConcurrentClient::recv_search_vector(VecSearchResult& _return, co
} // 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 VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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_);
......@@ -4416,7 +4416,7 @@ int32_t VecServiceConcurrentClient::send_search_vector_batch(const std::string&
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor_list = &tensor_list;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -4491,13 +4491,13 @@ void VecServiceConcurrentClient::recv_search_vector_batch(VecSearchResultList& _
} // end while(true)
}
void VecServiceConcurrentClient::search_binary_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecBinaryTensor& tensor, const VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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_);
......@@ -4507,7 +4507,7 @@ int32_t VecServiceConcurrentClient::send_search_binary_vector(const std::string&
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor = &tensor;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......@@ -4582,13 +4582,13 @@ void VecServiceConcurrentClient::recv_search_binary_vector(VecSearchResult& _ret
} // 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 VecTimeRangeList& time_range_list)
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, time_range_list);
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 VecTimeRangeList& time_range_list)
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_);
......@@ -4598,7 +4598,7 @@ int32_t VecServiceConcurrentClient::send_search_binary_vector_batch(const std::s
args.group_id = &group_id;
args.top_k = &top_k;
args.tensor_list = &tensor_list;
args.time_range_list = &time_range_list;
args.filter = &filter;
args.write(oprot_);
oprot_->writeMessageEnd();
......
此差异已折叠。
......@@ -69,27 +69,28 @@ class VecServiceHandler : virtual public VecServiceIf {
* search interfaces
* if time_range_list is empty, engine will search without time limit
*
*
* @param group_id
* @param top_k
* @param tensor
* @param time_range_list
* @param filter
*/
void search_vector(VecSearchResult& _return, const std::string& group_id, const int64_t top_k, const VecTensor& tensor, const VecTimeRangeList& time_range_list) {
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 VecTimeRangeList& time_range_list) {
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 VecTimeRangeList& time_range_list) {
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 VecTimeRangeList& time_range_list) {
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");
}
......
......@@ -47,6 +47,8 @@ class VecBinaryTensor;
class VecBinaryTensorList;
class VecSearchResultItem;
class VecSearchResult;
class VecSearchResultList;
......@@ -55,7 +57,7 @@ class VecDateTime;
class VecTimeRange;
class VecTimeRangeList;
class VecSearchFilter;
typedef struct _VecException__isset {
_VecException__isset() : code(false), reason(false) {}
......@@ -108,9 +110,7 @@ void swap(VecException &a, VecException &b);
std::ostream& operator<<(std::ostream& out, const VecException& obj);
typedef struct _VecGroup__isset {
_VecGroup__isset() : id(false), dimension(false), index_type(false) {}
bool id :1;
bool dimension :1;
_VecGroup__isset() : index_type(false) {}
bool index_type :1;
} _VecGroup__isset;
......@@ -141,7 +141,9 @@ class VecGroup : public virtual ::apache::thrift::TBase {
return false;
if (!(dimension == rhs.dimension))
return false;
if (!(index_type == rhs.index_type))
if (__isset.index_type != rhs.__isset.index_type)
return false;
else if (__isset.index_type && !(index_type == rhs.index_type))
return false;
return true;
}
......@@ -162,9 +164,8 @@ void swap(VecGroup &a, VecGroup &b);
std::ostream& operator<<(std::ostream& out, const VecGroup& obj);
typedef struct _VecTensor__isset {
_VecTensor__isset() : uid(false), tensor(false) {}
bool uid :1;
bool tensor :1;
_VecTensor__isset() : attrib(false) {}
bool attrib :1;
} _VecTensor__isset;
class VecTensor : public virtual ::apache::thrift::TBase {
......@@ -178,6 +179,7 @@ class VecTensor : public virtual ::apache::thrift::TBase {
virtual ~VecTensor() throw();
std::string uid;
std::vector<double> tensor;
std::map<std::string, std::string> attrib;
_VecTensor__isset __isset;
......@@ -185,12 +187,18 @@ class VecTensor : public virtual ::apache::thrift::TBase {
void __set_tensor(const std::vector<double> & val);
void __set_attrib(const std::map<std::string, std::string> & val);
bool operator == (const VecTensor & rhs) const
{
if (!(uid == rhs.uid))
return false;
if (!(tensor == rhs.tensor))
return false;
if (__isset.attrib != rhs.__isset.attrib)
return false;
else if (__isset.attrib && !(attrib == rhs.attrib))
return false;
return true;
}
bool operator != (const VecTensor &rhs) const {
......@@ -209,10 +217,6 @@ void swap(VecTensor &a, VecTensor &b);
std::ostream& operator<<(std::ostream& out, const VecTensor& obj);
typedef struct _VecTensorList__isset {
_VecTensorList__isset() : tensor_list(false) {}
bool tensor_list :1;
} _VecTensorList__isset;
class VecTensorList : public virtual ::apache::thrift::TBase {
public:
......@@ -225,8 +229,6 @@ class VecTensorList : public virtual ::apache::thrift::TBase {
virtual ~VecTensorList() throw();
std::vector<VecTensor> tensor_list;
_VecTensorList__isset __isset;
void __set_tensor_list(const std::vector<VecTensor> & val);
bool operator == (const VecTensorList & rhs) const
......@@ -252,9 +254,8 @@ void swap(VecTensorList &a, VecTensorList &b);
std::ostream& operator<<(std::ostream& out, const VecTensorList& obj);
typedef struct _VecBinaryTensor__isset {
_VecBinaryTensor__isset() : uid(false), tensor(false) {}
bool uid :1;
bool tensor :1;
_VecBinaryTensor__isset() : attrib(false) {}
bool attrib :1;
} _VecBinaryTensor__isset;
class VecBinaryTensor : public virtual ::apache::thrift::TBase {
......@@ -268,6 +269,7 @@ class VecBinaryTensor : public virtual ::apache::thrift::TBase {
virtual ~VecBinaryTensor() throw();
std::string uid;
std::string tensor;
std::map<std::string, std::string> attrib;
_VecBinaryTensor__isset __isset;
......@@ -275,12 +277,18 @@ class VecBinaryTensor : public virtual ::apache::thrift::TBase {
void __set_tensor(const std::string& val);
void __set_attrib(const std::map<std::string, std::string> & val);
bool operator == (const VecBinaryTensor & rhs) const
{
if (!(uid == rhs.uid))
return false;
if (!(tensor == rhs.tensor))
return false;
if (__isset.attrib != rhs.__isset.attrib)
return false;
else if (__isset.attrib && !(attrib == rhs.attrib))
return false;
return true;
}
bool operator != (const VecBinaryTensor &rhs) const {
......@@ -299,10 +307,6 @@ void swap(VecBinaryTensor &a, VecBinaryTensor &b);
std::ostream& operator<<(std::ostream& out, const VecBinaryTensor& obj);
typedef struct _VecBinaryTensorList__isset {
_VecBinaryTensorList__isset() : tensor_list(false) {}
bool tensor_list :1;
} _VecBinaryTensorList__isset;
class VecBinaryTensorList : public virtual ::apache::thrift::TBase {
public:
......@@ -315,8 +319,6 @@ class VecBinaryTensorList : public virtual ::apache::thrift::TBase {
virtual ~VecBinaryTensorList() throw();
std::vector<VecBinaryTensor> tensor_list;
_VecBinaryTensorList__isset __isset;
void __set_tensor_list(const std::vector<VecBinaryTensor> & val);
bool operator == (const VecBinaryTensorList & rhs) const
......@@ -341,10 +343,66 @@ void swap(VecBinaryTensorList &a, VecBinaryTensorList &b);
std::ostream& operator<<(std::ostream& out, const VecBinaryTensorList& obj);
typedef struct _VecSearchResultItem__isset {
_VecSearchResultItem__isset() : distance(false), attrib(false) {}
bool distance :1;
bool attrib :1;
} _VecSearchResultItem__isset;
class VecSearchResultItem : public virtual ::apache::thrift::TBase {
public:
VecSearchResultItem(const VecSearchResultItem&);
VecSearchResultItem& operator=(const VecSearchResultItem&);
VecSearchResultItem() : uid(), distance(0) {
}
virtual ~VecSearchResultItem() throw();
std::string uid;
double distance;
std::map<std::string, std::string> attrib;
_VecSearchResultItem__isset __isset;
void __set_uid(const std::string& val);
void __set_distance(const double val);
void __set_attrib(const std::map<std::string, std::string> & val);
bool operator == (const VecSearchResultItem & rhs) const
{
if (!(uid == rhs.uid))
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))
return false;
return true;
}
bool operator != (const VecSearchResultItem &rhs) const {
return !(*this == rhs);
}
bool operator < (const VecSearchResultItem & ) 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(VecSearchResultItem &a, VecSearchResultItem &b);
std::ostream& operator<<(std::ostream& out, const VecSearchResultItem& obj);
typedef struct _VecSearchResult__isset {
_VecSearchResult__isset() : id_list(false), distance_list(false) {}
bool id_list :1;
bool distance_list :1;
_VecSearchResult__isset() : result_list(false) {}
bool result_list :1;
} _VecSearchResult__isset;
class VecSearchResult : public virtual ::apache::thrift::TBase {
......@@ -356,20 +414,15 @@ class VecSearchResult : public virtual ::apache::thrift::TBase {
}
virtual ~VecSearchResult() throw();
std::vector<std::string> id_list;
std::vector<double> distance_list;
std::vector<VecSearchResultItem> result_list;
_VecSearchResult__isset __isset;
void __set_id_list(const std::vector<std::string> & val);
void __set_distance_list(const std::vector<double> & val);
void __set_result_list(const std::vector<VecSearchResultItem> & val);
bool operator == (const VecSearchResult & rhs) const
{
if (!(id_list == rhs.id_list))
return false;
if (!(distance_list == rhs.distance_list))
if (!(result_list == rhs.result_list))
return false;
return true;
}
......@@ -431,15 +484,6 @@ void swap(VecSearchResultList &a, VecSearchResultList &b);
std::ostream& operator<<(std::ostream& out, const VecSearchResultList& obj);
typedef struct _VecDateTime__isset {
_VecDateTime__isset() : year(false), month(false), day(false), hour(false), minute(false), second(false) {}
bool year :1;
bool month :1;
bool day :1;
bool hour :1;
bool minute :1;
bool second :1;
} _VecDateTime__isset;
class VecDateTime : public virtual ::apache::thrift::TBase {
public:
......@@ -457,8 +501,6 @@ class VecDateTime : public virtual ::apache::thrift::TBase {
int32_t minute;
int32_t second;
_VecDateTime__isset __isset;
void __set_year(const int32_t val);
void __set_month(const int32_t val);
......@@ -503,13 +545,6 @@ void swap(VecDateTime &a, VecDateTime &b);
std::ostream& operator<<(std::ostream& out, const VecDateTime& obj);
typedef struct _VecTimeRange__isset {
_VecTimeRange__isset() : time_begin(false), begine_closed(false), time_end(false), end_closed(false) {}
bool time_begin :1;
bool begine_closed :1;
bool time_end :1;
bool end_closed :1;
} _VecTimeRange__isset;
class VecTimeRange : public virtual ::apache::thrift::TBase {
public:
......@@ -525,8 +560,6 @@ class VecTimeRange : public virtual ::apache::thrift::TBase {
VecDateTime time_end;
bool end_closed;
_VecTimeRange__isset __isset;
void __set_time_begin(const VecDateTime& val);
void __set_begine_closed(const bool val);
......@@ -563,37 +596,47 @@ void swap(VecTimeRange &a, VecTimeRange &b);
std::ostream& operator<<(std::ostream& out, const VecTimeRange& obj);
typedef struct _VecTimeRangeList__isset {
_VecTimeRangeList__isset() : range_list(false) {}
bool range_list :1;
} _VecTimeRangeList__isset;
typedef struct _VecSearchFilter__isset {
_VecSearchFilter__isset() : attrib_filter(false), time_ranges(false) {}
bool attrib_filter :1;
bool time_ranges :1;
} _VecSearchFilter__isset;
class VecTimeRangeList : public virtual ::apache::thrift::TBase {
class VecSearchFilter : public virtual ::apache::thrift::TBase {
public:
VecTimeRangeList(const VecTimeRangeList&);
VecTimeRangeList& operator=(const VecTimeRangeList&);
VecTimeRangeList() {
VecSearchFilter(const VecSearchFilter&);
VecSearchFilter& operator=(const VecSearchFilter&);
VecSearchFilter() {
}
virtual ~VecTimeRangeList() throw();
std::vector<VecTimeRange> range_list;
virtual ~VecSearchFilter() throw();
std::map<std::string, std::string> attrib_filter;
std::vector<VecTimeRange> time_ranges;
_VecSearchFilter__isset __isset;
_VecTimeRangeList__isset __isset;
void __set_attrib_filter(const std::map<std::string, std::string> & val);
void __set_range_list(const std::vector<VecTimeRange> & val);
void __set_time_ranges(const std::vector<VecTimeRange> & val);
bool operator == (const VecTimeRangeList & rhs) const
bool operator == (const VecSearchFilter & rhs) const
{
if (!(range_list == rhs.range_list))
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;
return true;
}
bool operator != (const VecTimeRangeList &rhs) const {
bool operator != (const VecSearchFilter &rhs) const {
return !(*this == rhs);
}
bool operator < (const VecTimeRangeList & ) const;
bool operator < (const VecSearchFilter & ) const;
uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
......@@ -601,9 +644,9 @@ class VecTimeRangeList : public virtual ::apache::thrift::TBase {
virtual void printTo(std::ostream& out) const;
};
void swap(VecTimeRangeList &a, VecTimeRangeList &b);
void swap(VecSearchFilter &a, VecSearchFilter &b);
std::ostream& operator<<(std::ostream& out, const VecTimeRangeList& obj);
std::ostream& operator<<(std::ostream& out, const VecSearchFilter& obj);
......
......@@ -158,18 +158,18 @@ TEST(SearchVector, CLIENT_TEST) {
}
VecSearchResult res;
VecTimeRangeList range;
session.interface()->search_vector(res, GetGroupID(), top_k, tensor, range);
VecSearchFilter filter;
session.interface()->search_vector(res, GetGroupID(), top_k, tensor, filter);
std::cout << "Search result: " << std::endl;
for(auto id : res.id_list) {
std::cout << "\t" << id << std::endl;
for(VecSearchResultItem& item : res.result_list) {
std::cout << "\t" << item.uid << std::endl;
}
rc.Elapse("done!");
ASSERT_EQ(res.id_list.size(), (uint64_t)top_k);
if(!res.id_list.empty()) {
ASSERT_TRUE(res.id_list[0].find(std::to_string(anchor_index)) != std::string::npos);
ASSERT_EQ(res.result_list.size(), (uint64_t)top_k);
if(!res.result_list.empty()) {
ASSERT_TRUE(res.result_list[0].uid.find(std::to_string(anchor_index)) != std::string::npos);
}
}
......@@ -192,14 +192,14 @@ TEST(SearchVector, CLIENT_TEST) {
}
VecSearchResultList res;
VecTimeRangeList range;
session.interface()->search_binary_vector_batch(res, GetGroupID(), top_k, tensor_list, range);
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(auto id : res.result_list[i].id_list) {
std::cout << "\t" << id << std::endl;
for(VecSearchResultItem& item : res.result_list[i].result_list) {
std::cout << "\t" << item.uid << std::endl;
}
}
......@@ -207,9 +207,9 @@ TEST(SearchVector, CLIENT_TEST) {
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].id_list.size(), (uint64_t) top_k);
if (!res.result_list[i].id_list.empty()) {
ASSERT_TRUE(res.result_list[i].id_list[0].find(std::to_string(anchor_index + i)) != std::string::npos);
ASSERT_EQ(res.result_list[i].result_list.size(), (uint64_t) top_k);
if (!res.result_list[i].result_list.empty()) {
ASSERT_TRUE(res.result_list[i].result_list[0].uid.find(std::to_string(anchor_index + i)) != std::string::npos);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册