SearchTask.h 1.9 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

18 19 20
#pragma once

#include "Task.h"
W
wxyu 已提交
21
#include "scheduler/Definition.h"
S
starlord 已提交
22
#include "scheduler/job/SearchJob.h"
23

S
starlord 已提交
24
#include <vector>
25 26 27

namespace zilliz {
namespace milvus {
W
wxyu 已提交
28
namespace scheduler {
29

W
wxyu 已提交
30
// TODO: rewrite
31
class XSearchTask : public Task {
S
starlord 已提交
32 33
 public:
    explicit XSearchTask(TableFileSchemaPtr file);
W
wxyu 已提交
34

35 36 37 38 39 40
    void
    Load(LoadType type, uint8_t device_id) override;

    void
    Execute() override;

S
starlord 已提交
41
 public:
S
starlord 已提交
42 43 44
    static Status
    ClusterResult(const std::vector<int64_t>& output_ids, const std::vector<float>& output_distence, uint64_t nq,
                  uint64_t topk, scheduler::ResultSet& result_set);
45

S
starlord 已提交
46 47 48
    static Status
    MergeResult(scheduler::Id2DistanceMap& distance_src, scheduler::Id2DistanceMap& distance_target, uint64_t topk,
                bool ascending);
49

S
starlord 已提交
50 51
    static Status
    TopkResult(scheduler::ResultSet& result_src, uint64_t topk, bool ascending, scheduler::ResultSet& result_target);
52

S
starlord 已提交
53
 public:
W
wxyu 已提交
54
    TableFileSchemaPtr file_;
55 56 57 58 59

    size_t index_id_ = 0;
    int index_type_ = 0;
    ExecutionEnginePtr index_engine_ = nullptr;
    bool metric_l2 = true;
J
jinhai 已提交
60 61

    static std::mutex merge_mutex_;
62 63
};

S
starlord 已提交
64 65 66
}  // namespace scheduler
}  // namespace milvus
}  // namespace zilliz