@zilliz/milvus2-sdk-node 2.3.5 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -35
- package/dist/milvus/HttpClient.d.ts +165 -2
- package/dist/milvus/HttpClient.js +17 -3
- package/dist/milvus/HttpClient.js.map +1 -1
- package/dist/milvus/MilvusClient.d.ts +3 -3
- package/dist/milvus/MilvusClient.js +42 -8
- package/dist/milvus/MilvusClient.js.map +1 -1
- package/dist/milvus/const/client.d.ts +4 -3
- package/dist/milvus/const/client.js +4 -3
- package/dist/milvus/const/client.js.map +1 -1
- package/dist/milvus/const/defaults.d.ts +5 -4
- package/dist/milvus/const/defaults.js +14 -13
- package/dist/milvus/const/defaults.js.map +1 -1
- package/dist/milvus/const/error.js +1 -1
- package/dist/milvus/const/error.js.map +1 -1
- package/dist/milvus/const/milvus.d.ts +47 -8
- package/dist/milvus/const/milvus.js +42 -3
- package/dist/milvus/const/milvus.js.map +1 -1
- package/dist/milvus/grpc/BaseClient.d.ts +11 -9
- package/dist/milvus/grpc/BaseClient.js +59 -21
- package/dist/milvus/grpc/BaseClient.js.map +1 -1
- package/dist/milvus/grpc/Collection.d.ts +311 -366
- package/dist/milvus/grpc/Collection.js +355 -387
- package/dist/milvus/grpc/Collection.js.map +1 -1
- package/dist/milvus/grpc/Data.d.ts +244 -291
- package/dist/milvus/grpc/Data.js +402 -539
- package/dist/milvus/grpc/Data.js.map +1 -1
- package/dist/milvus/grpc/Database.d.ts +29 -41
- package/dist/milvus/grpc/Database.js +32 -44
- package/dist/milvus/grpc/Database.js.map +1 -1
- package/dist/milvus/grpc/GrpcClient.d.ts +34 -13
- package/dist/milvus/grpc/GrpcClient.js +80 -70
- package/dist/milvus/grpc/GrpcClient.js.map +1 -1
- package/dist/milvus/grpc/MilvusIndex.d.ts +127 -67
- package/dist/milvus/grpc/MilvusIndex.js +166 -70
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
- package/dist/milvus/grpc/Partition.d.ts +78 -113
- package/dist/milvus/grpc/Partition.js +109 -119
- package/dist/milvus/grpc/Partition.js.map +1 -1
- package/dist/milvus/grpc/Resource.d.ts +63 -92
- package/dist/milvus/grpc/Resource.js +69 -98
- package/dist/milvus/grpc/Resource.js.map +1 -1
- package/dist/milvus/grpc/User.d.ts +263 -295
- package/dist/milvus/grpc/User.js +287 -310
- package/dist/milvus/grpc/User.js.map +1 -1
- package/dist/milvus/http/Alias.d.ts +37 -0
- package/dist/milvus/http/Alias.js +62 -0
- package/dist/milvus/http/Alias.js.map +1 -0
- package/dist/milvus/http/Collection.d.ts +15 -1
- package/dist/milvus/http/Collection.js +55 -9
- package/dist/milvus/http/Collection.js.map +1 -1
- package/dist/milvus/http/Import.d.ts +33 -0
- package/dist/milvus/http/Import.js +48 -0
- package/dist/milvus/http/Import.js.map +1 -0
- package/dist/milvus/http/MilvusIndex.d.ts +35 -0
- package/dist/milvus/http/MilvusIndex.js +55 -0
- package/dist/milvus/http/MilvusIndex.js.map +1 -0
- package/dist/milvus/http/Partition.d.ts +41 -0
- package/dist/milvus/http/Partition.js +76 -0
- package/dist/milvus/http/Partition.js.map +1 -0
- package/dist/milvus/http/Role.d.ts +39 -0
- package/dist/milvus/http/Role.js +69 -0
- package/dist/milvus/http/Role.js.map +1 -0
- package/dist/milvus/http/User.d.ts +41 -0
- package/dist/milvus/http/User.js +76 -0
- package/dist/milvus/http/User.js.map +1 -0
- package/dist/milvus/http/Vector.d.ts +5 -3
- package/dist/milvus/http/Vector.js +10 -7
- package/dist/milvus/http/Vector.js.map +1 -1
- package/dist/milvus/http/index.d.ts +6 -0
- package/dist/milvus/http/index.js +6 -0
- package/dist/milvus/http/index.js.map +1 -1
- package/dist/milvus/index.d.ts +0 -1
- package/dist/milvus/index.js +0 -1
- package/dist/milvus/index.js.map +1 -1
- package/dist/milvus/types/Client.d.ts +5 -0
- package/dist/milvus/types/Collection.d.ts +34 -9
- package/dist/milvus/types/Common.d.ts +1 -3
- package/dist/milvus/types/Data.d.ts +79 -23
- package/dist/milvus/types/Data.js +1 -0
- package/dist/milvus/types/Data.js.map +1 -1
- package/dist/milvus/types/HighLevel.d.ts +6 -3
- package/dist/milvus/types/Http.d.ts +191 -9
- package/dist/milvus/types/MilvusIndex.d.ts +17 -3
- package/dist/milvus/utils/Bytes.d.ts +84 -0
- package/dist/milvus/utils/Bytes.js +261 -0
- package/dist/milvus/utils/Bytes.js.map +1 -0
- package/dist/milvus/utils/Format.d.ts +126 -68
- package/dist/milvus/utils/Format.js +375 -94
- package/dist/milvus/utils/Format.js.map +1 -1
- package/dist/milvus/utils/Function.d.ts +4 -2
- package/dist/milvus/utils/Function.js +58 -25
- package/dist/milvus/utils/Function.js.map +1 -1
- package/dist/milvus/utils/Grpc.d.ts +3 -2
- package/dist/milvus/utils/Grpc.js +65 -98
- package/dist/milvus/utils/Grpc.js.map +1 -1
- package/dist/milvus/utils/Validate.d.ts +18 -3
- package/dist/milvus/utils/Validate.js +38 -12
- package/dist/milvus/utils/Validate.js.map +1 -1
- package/dist/milvus/utils/index.d.ts +1 -1
- package/dist/milvus/utils/index.js +1 -1
- package/dist/milvus/utils/index.js.map +1 -1
- package/dist/proto/proto/common.proto +26 -1
- package/dist/proto/proto/google/protobuf/descriptor.proto +90 -28
- package/dist/proto/proto/milvus.proto +168 -2
- package/dist/proto/proto/rg.proto +28 -0
- package/dist/proto/proto/schema.proto +34 -0
- package/dist/sdk.json +1 -1
- package/package.json +8 -5
- package/dist/milvus/OrmClient.d.ts +0 -19
- package/dist/milvus/OrmClient.js +0 -51
- package/dist/milvus/OrmClient.js.map +0 -1
- package/dist/milvus/orm/Collection.d.ts +0 -43
- package/dist/milvus/orm/Collection.js +0 -165
- package/dist/milvus/orm/Collection.js.map +0 -1
- package/dist/milvus/orm/index.d.ts +0 -1
- package/dist/milvus/orm/index.js +0 -18
- package/dist/milvus/orm/index.js.map +0 -1
- package/dist/milvus/utils/Blob.d.ts +0 -4
- package/dist/milvus/utils/Blob.js +0 -18
- package/dist/milvus/utils/Blob.js.map +0 -1
|
@@ -36,6 +36,7 @@ enum DataType {
|
|
|
36
36
|
FloatVector = 101;
|
|
37
37
|
Float16Vector = 102;
|
|
38
38
|
BFloat16Vector = 103;
|
|
39
|
+
SparseFloatVector = 104;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
enum FieldState {
|
|
@@ -63,6 +64,7 @@ message FieldSchema {
|
|
|
63
64
|
ValueField default_value = 11; // default_value only support scalars except array and json for now
|
|
64
65
|
bool is_dynamic = 12; // mark whether this field is the dynamic field
|
|
65
66
|
bool is_partition_key = 13; // enable logic partitions
|
|
67
|
+
bool is_clustering_key = 14;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/**
|
|
@@ -74,6 +76,7 @@ message CollectionSchema {
|
|
|
74
76
|
bool autoID = 3 [deprecated=true]; // deprecated later, keep compatible with c++ part now
|
|
75
77
|
repeated FieldSchema fields = 4;
|
|
76
78
|
bool enable_dynamic_field = 5; // mark whether this table has the dynamic field function enabled.
|
|
79
|
+
repeated common.KeyValuePair properties = 6;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
message BoolArray { repeated bool data = 1; }
|
|
@@ -124,13 +127,22 @@ message ScalarField {
|
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
|
|
130
|
+
// beta, api may change
|
|
131
|
+
message SparseFloatArray {
|
|
132
|
+
repeated bytes contents = 1;
|
|
133
|
+
// dim is the max dimension of the current batch of vectors
|
|
134
|
+
int64 dim = 2;
|
|
135
|
+
}
|
|
136
|
+
|
|
127
137
|
message VectorField {
|
|
138
|
+
// For sparse vector, dim is the max dimension of the current batch of vectors
|
|
128
139
|
int64 dim = 1;
|
|
129
140
|
oneof data {
|
|
130
141
|
FloatArray float_vector = 2;
|
|
131
142
|
bytes binary_vector = 3;
|
|
132
143
|
bytes float16_vector = 4;
|
|
133
144
|
bytes bfloat16_vector = 5;
|
|
145
|
+
SparseFloatArray sparse_float_vector = 6;
|
|
134
146
|
}
|
|
135
147
|
}
|
|
136
148
|
|
|
@@ -160,4 +172,26 @@ message SearchResultData {
|
|
|
160
172
|
IDs ids = 5;
|
|
161
173
|
repeated int64 topks = 6;
|
|
162
174
|
repeated string output_fields = 7;
|
|
175
|
+
FieldData group_by_field_value = 8;
|
|
176
|
+
int64 all_search_count = 9;
|
|
177
|
+
repeated float distances = 10;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// vector field clustering info
|
|
181
|
+
message VectorClusteringInfo {
|
|
182
|
+
// for multi vectors
|
|
183
|
+
string field = 1;
|
|
184
|
+
schema.VectorField centroid = 2;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Scalar field clustering info
|
|
188
|
+
// todo more definitions: min/max, etc
|
|
189
|
+
message ScalarClusteringInfo {
|
|
190
|
+
string field = 1;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// clustering distribution info of a certain data unit, it can be segment, partition, etc.
|
|
194
|
+
message ClusteringInfo {
|
|
195
|
+
repeated VectorClusteringInfo vector_clustering_infos = 1;
|
|
196
|
+
repeated ScalarClusteringInfo scalar_clustering_infos = 2;
|
|
163
197
|
}
|
package/dist/sdk.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.
|
|
1
|
+
{"version":"2.4.1","milvusVersion":"v2.4.0"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zilliz/milvus2-sdk-node",
|
|
3
3
|
"author": "ued@zilliz.com",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"milvusVersion": "v2.
|
|
4
|
+
"version": "2.4.1",
|
|
5
|
+
"milvusVersion": "v2.4.0",
|
|
6
6
|
"main": "dist/milvus",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
"doc-json": "npx typedoc milvus --json"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grpc/grpc-js": "1.
|
|
24
|
-
"@grpc/proto-loader": "0.7.
|
|
23
|
+
"@grpc/grpc-js": "^1.10.1",
|
|
24
|
+
"@grpc/proto-loader": "^0.7.10",
|
|
25
|
+
"@petamoriken/float16": "^3.8.6",
|
|
25
26
|
"dayjs": "^1.11.7",
|
|
27
|
+
"generic-pool": "^3.9.0",
|
|
26
28
|
"lru-cache": "^9.1.2",
|
|
27
|
-
"protobufjs": "7.2.
|
|
29
|
+
"protobufjs": "^7.2.6",
|
|
28
30
|
"winston": "^3.9.0"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
"@types/jest": "^29.5.1",
|
|
33
35
|
"@types/node-fetch": "^2.6.8",
|
|
34
36
|
"jest": "^29.5.0",
|
|
37
|
+
"long": "^5.2.3",
|
|
35
38
|
"node-fetch": "2",
|
|
36
39
|
"ts-jest": "^29.1.0",
|
|
37
40
|
"ts-node": "^10.9.1",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ShowCollectionsReq, CreateColReq, MilvusClient } from './';
|
|
2
|
-
import { Collection } from './orm';
|
|
3
|
-
/**
|
|
4
|
-
* ORM client that extends Milvus client
|
|
5
|
-
*/
|
|
6
|
-
export declare class OrmClient extends MilvusClient {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new collection with the given name and schema, or returns an existing one with the same name.
|
|
9
|
-
* @param data An object containing the collection name, dimension, schema (optional), enable_dynamic_field (optional), and description (optional).
|
|
10
|
-
* @returns A Collection object representing the newly created or existing collection, and it is indexed and loaded
|
|
11
|
-
*/
|
|
12
|
-
collection(data: CreateColReq): Promise<Collection>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves a list of collections from the Milvus server.
|
|
15
|
-
* @param data An optional object containing parameters for filtering the list of collections.
|
|
16
|
-
* @returns An array of Collection objects representing the collections returned by the server.
|
|
17
|
-
*/
|
|
18
|
-
collections(data?: ShowCollectionsReq): Promise<Collection[]>;
|
|
19
|
-
}
|
package/dist/milvus/OrmClient.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OrmClient = void 0;
|
|
13
|
-
const _1 = require("./");
|
|
14
|
-
const orm_1 = require("./orm");
|
|
15
|
-
/**
|
|
16
|
-
* ORM client that extends Milvus client
|
|
17
|
-
*/
|
|
18
|
-
class OrmClient extends _1.MilvusClient {
|
|
19
|
-
// ORM-like APIs
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new collection with the given name and schema, or returns an existing one with the same name.
|
|
22
|
-
* @param data An object containing the collection name, dimension, schema (optional), enable_dynamic_field (optional), and description (optional).
|
|
23
|
-
* @returns A Collection object representing the newly created or existing collection, and it is indexed and loaded
|
|
24
|
-
*/
|
|
25
|
-
collection(data) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
// create collection using high-level API
|
|
28
|
-
yield this.createCollection(data);
|
|
29
|
-
// return collection object
|
|
30
|
-
const col = new orm_1.Collection({ name: data.collection_name, client: this });
|
|
31
|
-
// init
|
|
32
|
-
yield col.init();
|
|
33
|
-
return col;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves a list of collections from the Milvus server.
|
|
38
|
-
* @param data An optional object containing parameters for filtering the list of collections.
|
|
39
|
-
* @returns An array of Collection objects representing the collections returned by the server.
|
|
40
|
-
*/
|
|
41
|
-
collections(data) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const cols = yield this.showCollections(data);
|
|
44
|
-
return cols.data.map(col => {
|
|
45
|
-
return new orm_1.Collection({ name: col.name, client: this });
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.OrmClient = OrmClient;
|
|
51
|
-
//# sourceMappingURL=OrmClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrmClient.js","sourceRoot":"","sources":["../../milvus/OrmClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAoE;AACpE,+BAAmC;AAEnC;;GAEG;AACH,MAAa,SAAU,SAAQ,eAAY;IACzC,gBAAgB;IAChB;;;;OAIG;IACG,UAAU,CAAC,IAAkB;;YACjC,yCAAyC;YACzC,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAClC,2BAA2B;YAC3B,MAAM,GAAG,GAAG,IAAI,gBAAU,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YACzE,QAAQ;YACR,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,GAAG,CAAC;QACb,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW,CAAC,IAAyB;;YACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAE9C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACzB,OAAO,IAAI,gBAAU,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AA7BD,8BA6BC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { MilvusClient, InsertReq, SearchSimpleReq, GetReq, DeleteReq, QueryReq, DataType } from '..';
|
|
2
|
-
interface collectionProps {
|
|
3
|
-
name: string;
|
|
4
|
-
client: MilvusClient;
|
|
5
|
-
}
|
|
6
|
-
export declare class Collection {
|
|
7
|
-
#private;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
private get param();
|
|
10
|
-
pkFieldName: string;
|
|
11
|
-
vectorFieldName: string;
|
|
12
|
-
vectorType: DataType;
|
|
13
|
-
dim: number;
|
|
14
|
-
constructor({ name, client }: collectionProps);
|
|
15
|
-
init(): Promise<void>;
|
|
16
|
-
count(): Promise<number>;
|
|
17
|
-
info(): Promise<{
|
|
18
|
-
index_descriptions: import("..").IndexDescription[];
|
|
19
|
-
status: import("..").ResStatus;
|
|
20
|
-
schema: import("..").CollectionSchema;
|
|
21
|
-
collectionID: string;
|
|
22
|
-
consistency_level: string;
|
|
23
|
-
aliases: string[];
|
|
24
|
-
virtual_channel_names: string[];
|
|
25
|
-
physical_channel_names: string[];
|
|
26
|
-
start_positions: string[];
|
|
27
|
-
properties: import("..").KeyValuePair[];
|
|
28
|
-
created_timestamp: string;
|
|
29
|
-
created_utc_timestamp: string;
|
|
30
|
-
shards_num: number;
|
|
31
|
-
num_partitions?: string | undefined;
|
|
32
|
-
db_name: string;
|
|
33
|
-
}>;
|
|
34
|
-
load(): Promise<import("..").ResStatus>;
|
|
35
|
-
release(): Promise<import("..").ResStatus>;
|
|
36
|
-
index(): Promise<import("..").ResStatus>;
|
|
37
|
-
search(data: Omit<SearchSimpleReq, 'collection_name'>): Promise<import("..").SearchResults>;
|
|
38
|
-
query(data: Omit<QueryReq, 'collection_name'>): Promise<import("..").QueryResults>;
|
|
39
|
-
insert(data: Omit<InsertReq, 'collection_name'>): Promise<import("..").MutationResult>;
|
|
40
|
-
delete(data: Omit<DeleteReq, 'collection_name'>): Promise<import("..").MutationResult>;
|
|
41
|
-
get(data: Omit<GetReq, 'collection_name'>): Promise<import("..").QueryResults>;
|
|
42
|
-
}
|
|
43
|
-
export {};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var _Collection_client;
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.Collection = void 0;
|
|
25
|
-
const __1 = require("..");
|
|
26
|
-
// This class represents a collection in Milvus.
|
|
27
|
-
class Collection {
|
|
28
|
-
// param
|
|
29
|
-
get param() {
|
|
30
|
-
return { collection_name: this.name };
|
|
31
|
-
}
|
|
32
|
-
// Creates a new `Collection` instance.
|
|
33
|
-
constructor({ name, client }) {
|
|
34
|
-
// The private client that is used to communicate with Milvus.
|
|
35
|
-
_Collection_client.set(this, void 0);
|
|
36
|
-
// pk field name
|
|
37
|
-
this.pkFieldName = '';
|
|
38
|
-
// vector filed name
|
|
39
|
-
this.vectorFieldName = '';
|
|
40
|
-
// vector type
|
|
41
|
-
this.vectorType = __1.DataType.FloatVector;
|
|
42
|
-
// vector dimension
|
|
43
|
-
this.dim = 0;
|
|
44
|
-
// Set the name of the collection.
|
|
45
|
-
this.name = name;
|
|
46
|
-
// Assign the private client.
|
|
47
|
-
__classPrivateFieldSet(this, _Collection_client, client, "f");
|
|
48
|
-
}
|
|
49
|
-
// update key information
|
|
50
|
-
init() {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
// Get collection info
|
|
53
|
-
const collectionInfo = yield __classPrivateFieldGet(this, _Collection_client, "f").describeCollection(this.param);
|
|
54
|
-
// extract key information
|
|
55
|
-
for (let i = 0; i < collectionInfo.schema.fields.length; i++) {
|
|
56
|
-
const f = collectionInfo.schema.fields[i];
|
|
57
|
-
const type = __1.DataTypeMap[f.data_type];
|
|
58
|
-
// get pk field info
|
|
59
|
-
if (f.is_primary_key) {
|
|
60
|
-
this.pkFieldName = f.name;
|
|
61
|
-
}
|
|
62
|
-
// get vector field info
|
|
63
|
-
if (type === __1.DataType.FloatVector || type === __1.DataType.BinaryVector) {
|
|
64
|
-
// vector field
|
|
65
|
-
this.vectorFieldName = f.name;
|
|
66
|
-
// vector type
|
|
67
|
-
this.vectorType = type;
|
|
68
|
-
// get dimension
|
|
69
|
-
this.dim = Number((0, __1.findKeyValue)(f.type_params, 'dim'));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Returns the number of entities in the collection.
|
|
75
|
-
count() {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
// Get the collection statistics from Milvus.
|
|
78
|
-
const stats = yield __classPrivateFieldGet(this, _Collection_client, "f").getCollectionStatistics(this.param);
|
|
79
|
-
// Return the number of entities in the collection.
|
|
80
|
-
return Number(stats.data.row_count);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
// Returns information about the collection, such as its schema.
|
|
84
|
-
info() {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
// Get collection info
|
|
87
|
-
const collectionInfo = yield __classPrivateFieldGet(this, _Collection_client, "f").describeCollection(this.param);
|
|
88
|
-
// get Index info
|
|
89
|
-
const indexInfo = yield __classPrivateFieldGet(this, _Collection_client, "f").describeIndex(this.param);
|
|
90
|
-
// combine information and return
|
|
91
|
-
return Object.assign(Object.assign({}, collectionInfo), indexInfo);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// Loads the collection from disk.
|
|
95
|
-
load() {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").loadCollectionSync(this.param);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// release the collection from memory.
|
|
101
|
-
release() {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").releaseCollection(this.param);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
// Creates an index for the collection.
|
|
107
|
-
index() {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
// build index req parameters
|
|
110
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").createIndex({
|
|
111
|
-
collection_name: this.name,
|
|
112
|
-
field_name: this.vectorFieldName,
|
|
113
|
-
params: {},
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
// Searches the collection for entities that match a given query.
|
|
118
|
-
search(data) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
// Create a request object to search the collection.
|
|
121
|
-
const searchSimpleReq = (0, __1.cloneObj)(data);
|
|
122
|
-
searchSimpleReq.collection_name = this.name;
|
|
123
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").search(searchSimpleReq);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
// Queries the collection for entities that match a given query.
|
|
127
|
-
query(data) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
// Create a request object to query the collection.
|
|
130
|
-
const queryReq = (0, __1.cloneObj)(data);
|
|
131
|
-
queryReq.collection_name = this.name;
|
|
132
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").query(queryReq);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// Inserts an entity into the collection.
|
|
136
|
-
insert(data) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
// Create a request object to insert the entity.
|
|
139
|
-
const insertReq = (0, __1.cloneObj)(data);
|
|
140
|
-
insertReq.collection_name = this.name;
|
|
141
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").insert(insertReq);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// Deletes an entity from the collection.
|
|
145
|
-
delete(data) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
// Create a request object to delete the entity.
|
|
148
|
-
const deleteReq = (0, __1.cloneObj)(data);
|
|
149
|
-
deleteReq.collection_name = this.name;
|
|
150
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").delete(deleteReq);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
// get
|
|
154
|
-
get(data) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
// Create a request object to query the collection.
|
|
157
|
-
const getReq = (0, __1.cloneObj)(data);
|
|
158
|
-
getReq.collection_name = this.name;
|
|
159
|
-
return yield __classPrivateFieldGet(this, _Collection_client, "f").get(getReq);
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.Collection = Collection;
|
|
164
|
-
_Collection_client = new WeakMap();
|
|
165
|
-
//# sourceMappingURL=Collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../../../milvus/orm/Collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAWY;AAOZ,gDAAgD;AAChD,MAAa,UAAU;IAOrB,QAAQ;IACR,IAAY,KAAK;QACf,OAAO,EAAE,eAAe,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;IAWD,uCAAuC;IACvC,YAAY,EAAE,IAAI,EAAE,MAAM,EAAmB;QArB7C,8DAA8D;QAC9D,qCAAsB;QAUtB,gBAAgB;QAChB,gBAAW,GAAW,EAAE,CAAC;QACzB,oBAAoB;QACpB,oBAAe,GAAW,EAAE,CAAC;QAC7B,cAAc;QACd,eAAU,GAAa,YAAQ,CAAC,WAAW,CAAC;QAC5C,mBAAmB;QACnB,QAAG,GAAW,CAAC,CAAC;QAId,kCAAkC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,6BAA6B;QAC7B,uBAAA,IAAI,sBAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED,yBAAyB;IACnB,IAAI;;YACR,sBAAsB;YACtB,MAAM,cAAc,GAAG,MAAM,uBAAA,IAAI,0BAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEzE,0BAA0B;YAC1B,KAAK,IAAI,CAAC,GAAG,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CAAC;YAE9C,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC;YAEtC,OAAO,MAAM,uBAAA,IAAI,0BAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;KAAA;IAED,yCAAyC;IACnC,MAAM,CAAC,IAAwC;;YACnD,gDAAgD;YAChD,MAAM,SAAS,GAAG,IAAA,YAAQ,EAAC,IAAI,CAAc,CAAC;YAE9C,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC;YAEtC,OAAO,MAAM,uBAAA,IAAI,0BAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;KAAA;IAED,MAAM;IACA,GAAG,CAAC,IAAqC;;YAC7C,mDAAmD;YACnD,MAAM,MAAM,GAAG,IAAA,YAAQ,EAAC,IAAI,CAAW,CAAC;YAExC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC;YAEnC,OAAO,MAAM,uBAAA,IAAI,0BAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;KAAA;CACF;AAjJD,gCAiJC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Collection';
|
package/dist/milvus/orm/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Collection"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/orm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBinaryVectorToBytes = exports.parseFloatVectorToBytes = void 0;
|
|
4
|
-
const parseFloatVectorToBytes = (array) => {
|
|
5
|
-
// create array buffer
|
|
6
|
-
const a = new Float32Array(array);
|
|
7
|
-
// need return bytes to milvus proto
|
|
8
|
-
return Buffer.from(a.buffer);
|
|
9
|
-
};
|
|
10
|
-
exports.parseFloatVectorToBytes = parseFloatVectorToBytes;
|
|
11
|
-
const parseBinaryVectorToBytes = (array) => {
|
|
12
|
-
// create array buffer
|
|
13
|
-
const a = new Uint8Array(array);
|
|
14
|
-
// need return bytes to milvus proto
|
|
15
|
-
return Buffer.from(a.buffer);
|
|
16
|
-
};
|
|
17
|
-
exports.parseBinaryVectorToBytes = parseBinaryVectorToBytes;
|
|
18
|
-
//# sourceMappingURL=Blob.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Blob.js","sourceRoot":"","sources":["../../../milvus/utils/Blob.ts"],"names":[],"mappings":";;;AAEO,MAAM,uBAAuB,GAAG,CAAC,KAAmB,EAAE,EAAE;IAC7D,sBAAsB;IACtB,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,oCAAoC;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC;AAEK,MAAM,wBAAwB,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC/D,sBAAsB;IACtB,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,oCAAoC;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,wBAAwB,4BAKnC"}
|