2020-11-03 03:45:48 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "query/Parser.h"
|
2020-11-05 06:30:52 +00:00
|
|
|
#include "query/Expr.h"
|
|
|
|
#include "query/PlanNode.h"
|
|
|
|
#include "query/generated/ExprVisitor.h"
|
|
|
|
#include "query/generated/PlanNodeVisitor.h"
|
2020-11-06 07:34:39 +00:00
|
|
|
#include "test_utils/DataGen.h"
|
|
|
|
#include "query/generated/ShowPlanNodeVisitor.h"
|
2020-11-03 03:45:48 +00:00
|
|
|
|
|
|
|
TEST(Query, Naive) {
|
|
|
|
SUCCEED();
|
|
|
|
using namespace milvus::wtf;
|
|
|
|
std::string dsl_string = R"(
|
|
|
|
{
|
|
|
|
"bool": {
|
|
|
|
"must": [
|
|
|
|
{
|
|
|
|
"term": {
|
|
|
|
"A": [
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
5
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"range": {
|
|
|
|
"B": {
|
|
|
|
"GT": 1,
|
|
|
|
"LT": 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"vector": {
|
|
|
|
"Vec": {
|
|
|
|
"metric_type": "L2",
|
|
|
|
"params": {
|
|
|
|
"nprobe": 10
|
|
|
|
},
|
|
|
|
"query": "$0",
|
|
|
|
"topk": 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
})";
|
2020-11-06 07:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Query, ShowExecutor) {
|
|
|
|
using namespace milvus::query;
|
|
|
|
using namespace milvus::segcore;
|
|
|
|
auto node = std::make_unique<FloatVectorANNS>();
|
|
|
|
auto schema = std::make_shared<Schema>();
|
|
|
|
int64_t num_queries = 100L;
|
|
|
|
schema->AddField("fakevec", DataType::VECTOR_FLOAT, 16);
|
|
|
|
auto raw_data = DataGen(schema, num_queries);
|
2020-11-10 05:17:31 +00:00
|
|
|
auto& info = node->query_info_;
|
|
|
|
info.metric_type_ = "L2";
|
2020-11-14 03:24:49 +00:00
|
|
|
info.num_queries_ = 10;
|
2020-11-10 05:17:31 +00:00
|
|
|
info.topK_ = 20;
|
|
|
|
info.field_id_ = "fakevec";
|
2020-11-06 07:34:39 +00:00
|
|
|
node->predicate_ = std::nullopt;
|
|
|
|
ShowPlanNodeVisitor show_visitor;
|
|
|
|
PlanNodePtr base(node.release());
|
|
|
|
auto res = show_visitor.call_child(*base);
|
2020-11-10 05:17:31 +00:00
|
|
|
auto dup = res;
|
2020-11-14 03:24:49 +00:00
|
|
|
dup["data"] = "...collased...";
|
2020-11-10 05:17:31 +00:00
|
|
|
std::cout << dup.dump(4);
|
2020-11-14 03:24:49 +00:00
|
|
|
}
|