LocalClient API¶
LocalClient
¶
A singleton class for the local LynseDB client. Using the LocalClient class, users can create and access database instances, as well as operate on the collections within them (Low-Level API). This class is thread-safe only. Using it in multiple processes will result in a race condition.
Source code in lynse/api/native_api/high_level.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
root_path
property
¶
Get the root path of the database.
Returns:
Type | Description |
---|---|
str
|
The root path of the database. |
__new__(root_path)
¶
Create a new instance or return the existing instance of the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_path |
Path or str
|
The root path of the database. |
required |
Returns:
Name | Type | Description |
---|---|---|
LocalClient |
LocalClient
|
The instance of the class. |
Source code in lynse/api/native_api/high_level.py
copy_collection(deep=False)
¶
Copy the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deep |
bool
|
Whether to make a deep copy. Default is False. Which means share the data with the original collection. |
False
|
Returns:
Type | Description |
---|---|
ExclusiveDB
|
The copied collection. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
This method is not implemented yet. |
Source code in lynse/api/native_api/high_level.py
database_exists()
¶
Check if the database exists.
Returns:
Type | Description |
---|---|
Bool
|
Whether the database exists. |
drop_collection(collection)
¶
Delete a collection from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection |
str
|
The name of the collection to delete. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in lynse/api/native_api/high_level.py
drop_database()
¶
Delete the database.
Returns:
Type | Description |
---|---|
None |
Source code in lynse/api/native_api/high_level.py
get_collection(collection, cache_chunks=20, warm_up=True)
¶
Get a collection from the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection |
str
|
The name of the collection to get. |
required |
cache_chunks |
int
|
The number of chunks to cache. Default is 20. |
20
|
warm_up |
bool
|
Whether to warm up the database. Default is True. |
True
|
Returns:
Type | Description |
---|---|
ExclusiveDB
|
The collection. |
Source code in lynse/api/native_api/high_level.py
require_collection(collection, dim=None, chunk_size=100000, dtypes='float32', use_cache=True, n_threads=10, warm_up=False, drop_if_exists=False, description=None, cache_chunks=20)
¶
Create or load a collection in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection |
str
|
The name of the collection. |
required |
dim |
int
|
Dimension of the vectors. Default is None. When creating a new collection, the dimension of the vectors must be specified. When loading an existing collection, the dimension of the vectors is automatically loaded. |
None
|
chunk_size |
int
|
The size of each data chunk. Default is 100_000. |
100000
|
dtypes |
str
|
The data type of the vectors. Default is 'float32'. Options are 'float16', 'float32' or 'float64'. |
'float32'
|
use_cache |
bool
|
Whether to use cache for search. Default is True. |
True
|
n_threads |
int
|
The number of threads to use for parallel processing. Default is 10. |
10
|
warm_up |
bool
|
Whether to warm up the database. Default is False. |
False
|
drop_if_exists |
bool
|
Whether to drop the collection if it already exists. Default is False. |
False
|
description |
str
|
A description of the collection. Default is None. The description is limited to 500 characters. |
None
|
cache_chunks |
int
|
The number of chunks to cache. Default is 20. |
20
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in lynse/api/native_api/high_level.py
show_collections()
¶
Show the collections in the database.
Returns:
Name | Type | Description |
---|---|---|
List |
The list of collections in the database. |
show_collections_details()
¶
Show the collections in the database.
Returns:
Type | Description |
---|---|
Dict or DataFrame
|
The details of the collections in the database. |
update_collection_description(collection, description)
¶
Update the description of the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection |
str
|
The name of the collection. |
required |
description |
None or str or int or float or bool
|
The description of the collection. |
required |
Returns:
Type | Description |
---|---|
None |