index_c.h 3.0 KB
Newer Older
D
dragondriver 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed 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

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include "segcore/collection_c.h"
X
XuanYang-cn 已提交
20
#include "common/type_c.h"
21
#include "common/vector_index_c.h"
D
dragondriver 已提交
22 23

typedef void* CIndex;
24
typedef void* CIndexQueryResult;
D
dragondriver 已提交
25
typedef void* CBinary;
D
dragondriver 已提交
26 27

// TODO: how could we pass map between go and c++ more efficiently?
C
cxytz01 已提交
28
// Solution: using Protobuf instead of JSON, this way significantly increase programming efficiency
29

30 31
CStatus
CreateIndex(const char* serialized_type_params, const char* serialized_index_params, CIndex* res_index);
D
dragondriver 已提交
32 33 34 35

void
DeleteIndex(CIndex index);

36
CStatus
D
dragondriver 已提交
37 38
BuildFloatVecIndexWithoutIds(CIndex index, int64_t float_value_num, const float* vectors);

39
CStatus
D
dragondriver 已提交
40
BuildBinaryVecIndexWithoutIds(CIndex index, int64_t data_size, const uint8_t* vectors);
D
dragondriver 已提交
41

42
CStatus
D
dragondriver 已提交
43 44
SerializeToSlicedBuffer(CIndex index, CBinary* c_binary);

45 46 47
CStatus
SerializeToBinarySet(CIndex index, CBinarySet* c_binary_set);

D
dragondriver 已提交
48 49 50 51 52 53 54 55 56
int64_t
GetCBinarySize(CBinary c_binary);

// Note: the memory of data is allocated outside
void
GetCBinaryData(CBinary c_binary, void* data);

void
DeleteCBinary(CBinary c_binary);
D
dragondriver 已提交
57

B
bigsheeper 已提交
58
CStatus
D
dragondriver 已提交
59
LoadFromSlicedBuffer(CIndex index, const char* serialized_sliced_blob_buffer, int32_t size);
D
dragondriver 已提交
60

61 62 63
CStatus
LoadFromBinarySet(CIndex index, CBinarySet c_binary_set);

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
CStatus
QueryOnFloatVecIndex(CIndex index, int64_t float_value_num, const float* vectors, CIndexQueryResult* res);

CStatus
QueryOnFloatVecIndexWithParam(CIndex index,
                              int64_t float_value_num,
                              const float* vectors,
                              const char* serialized_search_params,
                              CIndexQueryResult* res);

CStatus
QueryOnBinaryVecIndex(CIndex index, int64_t data_size, const uint8_t* vectors, CIndexQueryResult* res);

CStatus
QueryOnBinaryVecIndexWithParam(CIndex index,
                               int64_t data_size,
                               const uint8_t* vectors,
                               const char* serialized_search_params,
                               CIndexQueryResult* res);

CStatus
CreateQueryResult(CIndexQueryResult* res);

int64_t
NqOfQueryResult(CIndexQueryResult res);

int64_t
TopkOfQueryResult(CIndexQueryResult res);

void
GetIdsOfQueryResult(CIndexQueryResult res, int64_t* ids);

void
GetDistancesOfQueryResult(CIndexQueryResult res, float* distances);

CStatus
X
xige-16 已提交
100
DeleteIndexQueryResult(CIndexQueryResult res);
101

D
dragondriver 已提交
102 103 104
void
DeleteByteArray(const char* array);

D
dragondriver 已提交
105 106 107
#ifdef __cplusplus
};
#endif