Commit f50dca75 authored by groot's avatar groot
Browse files

format wrapper code


Former-commit-id: 743ea20fd6a827c949296b16cf026e09e89f112a
parent 8e941b81
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -27,15 +27,13 @@
#include "utils/CommonUtil.h"
#include "metrics/Metrics.h"
#include "server/Server.h"
#include "version.h"
#include "../version.h"


INITIALIZE_EASYLOGGINGPP

void print_help(const std::string &app_name);

using namespace zilliz::milvus;

int
main(int argc, char *argv[]) {
    std::cout << std::endl << "Welcome to use Milvus by Zilliz!" << std::endl;
@@ -103,6 +101,7 @@ main(int argc, char *argv[]) {
    }

    /* Handle Signal */
    using ::zilliz::milvus;
    signal(SIGHUP, server::SignalUtil::HandleSignal);
    signal(SIGINT, server::SignalUtil::HandleSignal);
    signal(SIGUSR1, server::SignalUtil::HandleSignal);
+24 −23
Original line number Diff line number Diff line
@@ -16,45 +16,46 @@
// under the License.


#include "DataTransfer.h"
#include "wrapper/DataTransfer.h"

#include <vector>
#include <memory>
#include <utility>

namespace zilliz {
namespace milvus {
namespace engine {

using namespace zilliz::knowhere;

DatasetPtr
GenDatasetWithIds(const int64_t &nb, const int64_t &dim, const float *xb, const long *ids) {
knowhere::DatasetPtr
GenDatasetWithIds(const int64_t &nb, const int64_t &dim, const float *xb, const int64_t *ids) {
    std::vector<int64_t> shape{nb, dim};
    auto tensor = ConstructFloatTensor((uint8_t *) xb, nb * dim * sizeof(float), shape);
    std::vector<TensorPtr> tensors{tensor};
    std::vector<FieldPtr> tensor_fields{ConstructFloatField("data")};
    auto tensor_schema = std::make_shared<Schema>(tensor_fields);
    auto tensor = knowhere::ConstructFloatTensor((uint8_t *) xb, nb * dim * sizeof(float), shape);
    std::vector<knowhere::TensorPtr> tensors{tensor};
    std::vector<knowhere::FieldPtr> tensor_fields{knowhere::ConstructFloatField("data")};
    auto tensor_schema = std::make_shared<knowhere::Schema>(tensor_fields);

    auto id_array = ConstructInt64Array((uint8_t *) ids, nb * sizeof(int64_t));
    std::vector<ArrayPtr> arrays{id_array};
    std::vector<FieldPtr> array_fields{ConstructInt64Field("id")};
    auto array_schema = std::make_shared<Schema>(tensor_fields);
    auto id_array = knowhere::ConstructInt64Array((uint8_t *) ids, nb * sizeof(int64_t));
    std::vector<knowhere::ArrayPtr> arrays{id_array};
    std::vector<knowhere::FieldPtr> array_fields{knowhere::ConstructInt64Field("id")};
    auto array_schema = std::make_shared<knowhere::Schema>(tensor_fields);

    auto dataset = std::make_shared<Dataset>(std::move(arrays), array_schema,
    auto dataset = std::make_shared<knowhere::Dataset>(std::move(arrays), array_schema,
                                             std::move(tensors), tensor_schema);
    return dataset;
}

DatasetPtr
knowhere::DatasetPtr
GenDataset(const int64_t &nb, const int64_t &dim, const float *xb) {
    std::vector<int64_t> shape{nb, dim};
    auto tensor = ConstructFloatTensor((uint8_t *) xb, nb * dim * sizeof(float), shape);
    std::vector<TensorPtr> tensors{tensor};
    std::vector<FieldPtr> tensor_fields{ConstructFloatField("data")};
    auto tensor_schema = std::make_shared<Schema>(tensor_fields);
    auto tensor = knowhere::ConstructFloatTensor((uint8_t *) xb, nb * dim * sizeof(float), shape);
    std::vector<knowhere::TensorPtr> tensors{tensor};
    std::vector<knowhere::FieldPtr> tensor_fields{knowhere::ConstructFloatField("data")};
    auto tensor_schema = std::make_shared<knowhere::Schema>(tensor_fields);

    auto dataset = std::make_shared<Dataset>(std::move(tensors), tensor_schema);
    auto dataset = std::make_shared<knowhere::Dataset>(std::move(tensors), tensor_schema);
    return dataset;
}

}
}
}
} // namespace engine
} // namespace milvus
} // namespace zilliz
+4 −5
Original line number Diff line number Diff line
@@ -20,17 +20,16 @@

#include "knowhere/adapter/Structure.h"


namespace zilliz {
namespace milvus {
namespace engine {

extern zilliz::knowhere::DatasetPtr
GenDatasetWithIds(const int64_t &nb, const int64_t &dim, const float *xb, const long *ids);
GenDatasetWithIds(const int64_t &nb, const int64_t &dim, const float *xb, const int64_t *ids);

extern zilliz::knowhere::DatasetPtr
GenDataset(const int64_t &nb, const int64_t &dim, const float *xb);

}
}
}
} // namespace engine
} // namespace milvus
} // namespace zilliz
+14 −10
Original line number Diff line number Diff line
@@ -16,11 +16,15 @@
// under the License.


#include "KnowhereResource.h"
#include "wrapper/KnowhereResource.h"
#include "knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h"
#include "server/Config.h"

#include <map>
#include <set>
#include <vector>
#include <string>
#include <utility>

namespace zilliz {
namespace milvus {
@@ -80,6 +84,6 @@ KnowhereResource::Finalize() {
    return Status::OK();
}

}
}
}
 No newline at end of file
} // namespace engine
} // namespace milvus
} // namespace zilliz
+4 −5
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ public:
    Finalize();
};


}
}
}
} // namespace engine
} // namespace milvus
} // namespace zilliz
Loading