@lancedb/lancedb 0.21.2-beta.1 → 0.21.2

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/CLAUDE.md ADDED
@@ -0,0 +1,13 @@
1
+ These are the typescript bindings of LanceDB.
2
+ The core Rust library is in the `../rust/lancedb` directory, the rust binding
3
+ code is in the `src/` directory and the typescript bindings are in
4
+ the `lancedb/` directory.
5
+
6
+ Whenever you change the Rust code, you will need to recompile: `npm run build`.
7
+
8
+ Common commands:
9
+ * Build: `npm run build`
10
+ * Lint: `npm run lint`
11
+ * Fix lints: `npm run lint-fix`
12
+ * Test: `npm test`
13
+ * Run single test file: `npm test __test__/arrow.test.ts`
@@ -62,6 +62,9 @@ export interface OpenTableOptions {
62
62
  /**
63
63
  * Set the size of the index cache, specified as a number of entries
64
64
  *
65
+ * @deprecated Use session-level cache configuration instead.
66
+ * Create a Session with custom cache sizes and pass it to the connect() function.
67
+ *
65
68
  * The exact meaning of an "entry" will depend on the type of index:
66
69
  * - IVF: there is one entry for each IVF partition
67
70
  * - BTREE: there is one entry for the entire index
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Connection } from "./connection";
2
- import { ConnectionOptions } from "./native.js";
2
+ import { ConnectionOptions, Session } from "./native.js";
3
3
  export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, MergeResult, AddResult, AddColumnsResult, AlterColumnsResult, DeleteResult, DropColumnsResult, UpdateResult, } from "./native.js";
4
4
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
5
5
  export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
6
+ export { Session } from "./native.js";
6
7
  export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
7
8
  export { Index, IndexOptions, IvfPqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
8
9
  export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, ColumnAlteration, } from "./table";
@@ -35,7 +36,7 @@ export { IntoSql, packBits } from "./util";
35
36
  * });
36
37
  * ```
37
38
  */
38
- export declare function connect(uri: string, options?: Partial<ConnectionOptions>): Promise<Connection>;
39
+ export declare function connect(uri: string, options?: Partial<ConnectionOptions>, session?: Session): Promise<Connection>;
39
40
  /**
40
41
  * Connect to a LanceDB instance at the given URI.
41
42
  *
@@ -53,6 +54,15 @@ export declare function connect(uri: string, options?: Partial<ConnectionOptions
53
54
  * storageOptions: {timeout: "60s"}
54
55
  * });
55
56
  * ```
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const session = Session.default();
61
+ * const conn = await connect({
62
+ * uri: "/path/to/database",
63
+ * session: session
64
+ * });
65
+ * ```
56
66
  */
57
67
  export declare function connect(options: Partial<ConnectionOptions> & {
58
68
  uri: string;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: Copyright The LanceDB Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.packBits = exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = void 0;
5
+ exports.packBits = exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Session = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = void 0;
6
6
  exports.connect = connect;
7
7
  const connection_1 = require("./connection");
8
8
  const native_js_1 = require("./native.js");
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get:
15
15
  Object.defineProperty(exports, "VectorColumnOptions", { enumerable: true, get: function () { return arrow_1.VectorColumnOptions; } });
16
16
  var connection_2 = require("./connection");
17
17
  Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_2.Connection; } });
18
+ var native_js_3 = require("./native.js");
19
+ Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return native_js_3.Session; } });
18
20
  var query_1 = require("./query");
19
21
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
20
22
  Object.defineProperty(exports, "QueryBase", { enumerable: true, get: function () { return query_1.QueryBase; } });
@@ -38,21 +40,23 @@ exports.embedding = require("./embedding");
38
40
  exports.rerankers = require("./rerankers");
39
41
  var util_1 = require("./util");
40
42
  Object.defineProperty(exports, "packBits", { enumerable: true, get: function () { return util_1.packBits; } });
41
- async function connect(uriOrOptions, options = {}) {
43
+ async function connect(uriOrOptions, options) {
42
44
  let uri;
45
+ let finalOptions = {};
43
46
  if (typeof uriOrOptions !== "string") {
44
47
  const { uri: uri_, ...opts } = uriOrOptions;
45
48
  uri = uri_;
46
- options = opts;
49
+ finalOptions = opts;
47
50
  }
48
51
  else {
49
52
  uri = uriOrOptions;
53
+ finalOptions = options || {};
50
54
  }
51
55
  if (!uri) {
52
56
  throw new Error("uri is required");
53
57
  }
54
- options = options ?? {};
55
- options.storageOptions = (0, connection_1.cleanseStorageOptions)(options.storageOptions);
56
- const nativeConn = await native_js_1.Connection.new(uri, options);
58
+ finalOptions = finalOptions ?? {};
59
+ finalOptions.storageOptions = (0, connection_1.cleanseStorageOptions)(finalOptions.storageOptions);
60
+ const nativeConn = await native_js_1.Connection.new(uri, finalOptions);
57
61
  return new connection_1.LocalConnection(nativeConn);
58
62
  }
package/dist/native.d.ts CHANGED
@@ -274,6 +274,11 @@ export interface ConnectionOptions {
274
274
  * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
275
275
  */
276
276
  storageOptions?: Record<string, string>
277
+ /**
278
+ * (For LanceDB OSS only): the session to use for this connection. Holds
279
+ * shared caches and other session-specific state.
280
+ */
281
+ session?: Session
277
282
  /** (For LanceDB cloud only): configuration for the remote HTTP client. */
278
283
  clientConfig?: ClientConfig
279
284
  /**
@@ -403,6 +408,40 @@ export class RrfReranker {
403
408
  static tryNew(k: Float32Array): Promise<RrfReranker>
404
409
  rerankHybrid(query: string, vecResults: Buffer, ftsResults: Buffer): Promise<Buffer>
405
410
  }
411
+ /**
412
+ * A session for managing caches and object stores across LanceDB operations.
413
+ *
414
+ * Sessions allow you to configure cache sizes for index and metadata caches,
415
+ * which can significantly impact memory use and performance. They can
416
+ * also be re-used across multiple connections to share the same cache state.
417
+ */
418
+ export class Session {
419
+ /**
420
+ * Create a new session with custom cache sizes.
421
+ *
422
+ * # Parameters
423
+ *
424
+ * - `index_cache_size_bytes`: The size of the index cache in bytes.
425
+ * Index data is stored in memory in this cache to speed up queries.
426
+ * Defaults to 6GB if not specified.
427
+ * - `metadata_cache_size_bytes`: The size of the metadata cache in bytes.
428
+ * The metadata cache stores file metadata and schema information in memory.
429
+ * This cache improves scan and write performance.
430
+ * Defaults to 1GB if not specified.
431
+ */
432
+ constructor(indexCacheSizeBytes?: bigint | undefined | null, metadataCacheSizeBytes?: bigint | undefined | null)
433
+ /**
434
+ * Create a session with default cache sizes.
435
+ *
436
+ * This is equivalent to creating a session with 6GB index cache
437
+ * and 1GB metadata cache.
438
+ */
439
+ static default(): Session
440
+ /** Get the current size of the session caches in bytes. */
441
+ sizeBytes(): bigint
442
+ /** Get the approximate number of items cached in the session. */
443
+ approxNumItems(): number
444
+ }
406
445
  export class Table {
407
446
  name: string
408
447
  display(): string
package/dist/native.js CHANGED
@@ -319,7 +319,7 @@ if (!nativeBinding) {
319
319
  }
320
320
  throw new Error(`Failed to load native binding`);
321
321
  }
322
- const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, JsFullTextQuery, Reranker, RrfReranker, Table, TagContents, Tags } = nativeBinding;
322
+ const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, JsFullTextQuery, Reranker, RrfReranker, Session, Table, TagContents, Tags } = nativeBinding;
323
323
  module.exports.Connection = Connection;
324
324
  module.exports.Index = Index;
325
325
  module.exports.RecordBatchIterator = RecordBatchIterator;
@@ -329,6 +329,7 @@ module.exports.VectorQuery = VectorQuery;
329
329
  module.exports.JsFullTextQuery = JsFullTextQuery;
330
330
  module.exports.Reranker = Reranker;
331
331
  module.exports.RrfReranker = RrfReranker;
332
+ module.exports.Session = Session;
332
333
  module.exports.Table = Table;
333
334
  module.exports.TagContents = TagContents;
334
335
  module.exports.Tags = Tags;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.21.2-beta.1",
14
+ "version": "0.21.2",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -100,14 +100,14 @@
100
100
  "reflect-metadata": "^0.2.2"
101
101
  },
102
102
  "optionalDependencies": {
103
- "@lancedb/lancedb-darwin-x64": "0.21.2-beta.1",
104
- "@lancedb/lancedb-darwin-arm64": "0.21.2-beta.1",
105
- "@lancedb/lancedb-linux-x64-gnu": "0.21.2-beta.1",
106
- "@lancedb/lancedb-linux-arm64-gnu": "0.21.2-beta.1",
107
- "@lancedb/lancedb-linux-x64-musl": "0.21.2-beta.1",
108
- "@lancedb/lancedb-linux-arm64-musl": "0.21.2-beta.1",
109
- "@lancedb/lancedb-win32-x64-msvc": "0.21.2-beta.1",
110
- "@lancedb/lancedb-win32-arm64-msvc": "0.21.2-beta.1"
103
+ "@lancedb/lancedb-darwin-x64": "0.21.2",
104
+ "@lancedb/lancedb-darwin-arm64": "0.21.2",
105
+ "@lancedb/lancedb-linux-x64-gnu": "0.21.2",
106
+ "@lancedb/lancedb-linux-arm64-gnu": "0.21.2",
107
+ "@lancedb/lancedb-linux-x64-musl": "0.21.2",
108
+ "@lancedb/lancedb-linux-arm64-musl": "0.21.2",
109
+ "@lancedb/lancedb-win32-x64-msvc": "0.21.2",
110
+ "@lancedb/lancedb-win32-arm64-msvc": "0.21.2"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "apache-arrow": ">=15.0.0 <=18.1.0"