presubmit 0.1.0
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/LICENSE +202 -0
- package/README.md +51 -0
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/apps/web/dist/assets/FileCode-CZZH52o7.js +5 -0
- package/apps/web/dist/assets/FileCode-DovDO7Jh.css +1 -0
- package/apps/web/dist/assets/SettingsPage-CRvOwdjt.js +4 -0
- package/apps/web/dist/assets/SettingsPage-UbYSCwJj.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-0sw-J6YS.css +1 -0
- package/apps/web/dist/assets/TerminalPanel-BqUjPWav.js +16 -0
- package/apps/web/dist/assets/index-BhqNNFja.js +54 -0
- package/apps/web/dist/assets/index-DD8VXy8H.css +1 -0
- package/apps/web/dist/assets/presubmit-mark-BBQ19Fmr.svg +7 -0
- package/apps/web/dist/assets/presubmit-mark-busy-CwBC-7on.svg +8 -0
- package/apps/web/dist/assets/react-vendor-wiHys0m2.js +9 -0
- package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/apps/web/dist/index.html +6 -0
- package/apps/web/dist/service-worker.js +11 -0
- package/dist/apps/server/src/agent-builder.js +204 -0
- package/dist/apps/server/src/attach.js +163 -0
- package/dist/apps/server/src/attachments.js +86 -0
- package/dist/apps/server/src/browser-access.js +131 -0
- package/dist/apps/server/src/check-provenance.js +95 -0
- package/dist/apps/server/src/check-supervisor.js +112 -0
- package/dist/apps/server/src/checks.js +402 -0
- package/dist/apps/server/src/child-collaboration-guidance.js +2 -0
- package/dist/apps/server/src/child-sessions.js +191 -0
- package/dist/apps/server/src/cli.js +162 -0
- package/dist/apps/server/src/conversation-search.js +12 -0
- package/dist/apps/server/src/coordinator-messages.js +72 -0
- package/dist/apps/server/src/dev-auth.js +54 -0
- package/dist/apps/server/src/dev-server.js +201 -0
- package/dist/apps/server/src/dev-worker.js +48 -0
- package/dist/apps/server/src/diagnostics.js +105 -0
- package/dist/apps/server/src/fast-mode.js +8 -0
- package/dist/apps/server/src/folder-picker.js +54 -0
- package/dist/apps/server/src/git-blobs.js +62 -0
- package/dist/apps/server/src/git-handoff.js +127 -0
- package/dist/apps/server/src/history-sources.js +59 -0
- package/dist/apps/server/src/hub.js +159 -0
- package/dist/apps/server/src/internal-transport.js +38 -0
- package/dist/apps/server/src/local-embeddings.js +70 -0
- package/dist/apps/server/src/ollama-setup.js +56 -0
- package/dist/apps/server/src/planning.js +30 -0
- package/dist/apps/server/src/project-agents.js +276 -0
- package/dist/apps/server/src/project-memory.js +94 -0
- package/dist/apps/server/src/projects.js +106 -0
- package/dist/apps/server/src/queued-launch.js +13 -0
- package/dist/apps/server/src/reply-search.js +172 -0
- package/dist/apps/server/src/review-context.js +60 -0
- package/dist/apps/server/src/review-refresh.js +14 -0
- package/dist/apps/server/src/reviewers.js +75 -0
- package/dist/apps/server/src/search-settings.js +22 -0
- package/dist/apps/server/src/semantic-history.js +186 -0
- package/dist/apps/server/src/server.js +4338 -0
- package/dist/apps/server/src/session-changes.js +181 -0
- package/dist/apps/server/src/session-router-settings.js +198 -0
- package/dist/apps/server/src/session-workspaces.js +135 -0
- package/dist/apps/server/src/sessions.js +579 -0
- package/dist/apps/server/src/shared-auth.js +70 -0
- package/dist/apps/server/src/shell-evaluator-settings.js +53 -0
- package/dist/apps/server/src/store.js +203 -0
- package/dist/apps/server/src/tailscale-process.js +115 -0
- package/dist/apps/server/src/tailscale-serve-worker.js +33 -0
- package/dist/apps/server/src/tailscale-serve.js +276 -0
- package/dist/apps/server/src/task-capacity.js +92 -0
- package/dist/apps/server/src/task-graph.js +190 -0
- package/dist/apps/server/src/task-logs.js +74 -0
- package/dist/apps/server/src/task-numbers.js +25 -0
- package/dist/apps/server/src/task-orchestrator.js +1088 -0
- package/dist/apps/server/src/terminal.js +182 -0
- package/dist/apps/server/src/terminals.js +80 -0
- package/dist/apps/server/src/tool-safety.js +2 -0
- package/dist/apps/server/src/workspace-lock.js +140 -0
- package/dist/apps/server/src/workspace-watcher.js +65 -0
- package/dist/apps/server/src/workspace.js +517 -0
- package/dist/packages/agent-pi/src/agent-builder-tool.js +32 -0
- package/dist/packages/agent-pi/src/agent-capabilities.js +44 -0
- package/dist/packages/agent-pi/src/ask-user.js +86 -0
- package/dist/packages/agent-pi/src/auth.js +510 -0
- package/dist/packages/agent-pi/src/check-tools.js +72 -0
- package/dist/packages/agent-pi/src/command-policy.js +246 -0
- package/dist/packages/agent-pi/src/coordinator-tools.js +122 -0
- package/dist/packages/agent-pi/src/fast-mode.js +67 -0
- package/dist/packages/agent-pi/src/file-tools.js +163 -0
- package/dist/packages/agent-pi/src/history-tool.js +40 -0
- package/dist/packages/agent-pi/src/history.js +34 -0
- package/dist/packages/agent-pi/src/index.js +177 -0
- package/dist/packages/agent-pi/src/ipc.js +314 -0
- package/dist/packages/agent-pi/src/jev-session-router.js +408 -0
- package/dist/packages/agent-pi/src/jev-tools.js +71 -0
- package/dist/packages/agent-pi/src/local-model.js +277 -0
- package/dist/packages/agent-pi/src/memory-tools.js +119 -0
- package/dist/packages/agent-pi/src/model.js +25 -0
- package/dist/packages/agent-pi/src/planning.js +206 -0
- package/dist/packages/agent-pi/src/resource-loader.js +23 -0
- package/dist/packages/agent-pi/src/review-tools.js +158 -0
- package/dist/packages/agent-pi/src/review-transition.js +73 -0
- package/dist/packages/agent-pi/src/review.js +40 -0
- package/dist/packages/agent-pi/src/routing.js +27 -0
- package/dist/packages/agent-pi/src/session-setup.js +118 -0
- package/dist/packages/agent-pi/src/shell-context.js +51 -0
- package/dist/packages/agent-pi/src/shell-policy.js +281 -0
- package/dist/packages/agent-pi/src/shell-safety.js +205 -0
- package/dist/packages/agent-pi/src/shell.js +121 -0
- package/dist/packages/agent-pi/src/snapshot-permissions.js +12 -0
- package/dist/packages/agent-pi/src/spike.js +41 -0
- package/dist/packages/agent-pi/src/task-tools.js +53 -0
- package/dist/packages/agent-pi/src/types.js +1 -0
- package/dist/packages/agent-pi/src/usage.js +30 -0
- package/dist/packages/agent-pi/src/worker.js +602 -0
- package/dist/packages/protocol/src/activity-summary.js +77 -0
- package/dist/packages/protocol/src/agents.js +301 -0
- package/dist/packages/protocol/src/browser-access.js +1 -0
- package/dist/packages/protocol/src/checks.js +40 -0
- package/dist/packages/protocol/src/child-sessions.js +28 -0
- package/dist/packages/protocol/src/command-policy.js +3 -0
- package/dist/packages/protocol/src/coordinator.js +135 -0
- package/dist/packages/protocol/src/delegation.js +40 -0
- package/dist/packages/protocol/src/git-diff.js +71 -0
- package/dist/packages/protocol/src/git-handoff.js +1 -0
- package/dist/packages/protocol/src/index.js +1 -0
- package/dist/packages/protocol/src/memory.js +46 -0
- package/dist/packages/protocol/src/metrics.js +70 -0
- package/dist/packages/protocol/src/planning.js +138 -0
- package/dist/packages/protocol/src/retrieval.js +36 -0
- package/dist/packages/protocol/src/reviewers.js +17 -0
- package/dist/packages/protocol/src/search.js +16 -0
- package/dist/packages/protocol/src/session-changes.js +29 -0
- package/dist/packages/protocol/src/session-router.js +123 -0
- package/dist/packages/protocol/src/shell-evaluator.js +43 -0
- package/dist/packages/protocol/src/task-graph.js +1 -0
- package/dist/packages/protocol/src/token-usage.js +17 -0
- package/dist/packages/protocol/src/user-questions.js +106 -0
- package/package.json +71 -0
- package/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
- package/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
- package/vendor/lancedb/dist/arrow.d.ts +296 -0
- package/vendor/lancedb/dist/arrow.js +1145 -0
- package/vendor/lancedb/dist/arrow_type.d.ts +9 -0
- package/vendor/lancedb/dist/arrow_type.js +29 -0
- package/vendor/lancedb/dist/connection.d.ts +508 -0
- package/vendor/lancedb/dist/connection.js +298 -0
- package/vendor/lancedb/dist/embedding/embedding_function.d.ts +103 -0
- package/vendor/lancedb/dist/embedding/embedding_function.js +192 -0
- package/vendor/lancedb/dist/embedding/index.d.ts +37 -0
- package/vendor/lancedb/dist/embedding/index.js +108 -0
- package/vendor/lancedb/dist/embedding/openai.d.ts +16 -0
- package/vendor/lancedb/dist/embedding/openai.js +81 -0
- package/vendor/lancedb/dist/embedding/registry.d.ts +94 -0
- package/vendor/lancedb/dist/embedding/registry.js +221 -0
- package/vendor/lancedb/dist/embedding/transformers.d.ts +36 -0
- package/vendor/lancedb/dist/embedding/transformers.js +110 -0
- package/vendor/lancedb/dist/header.d.ts +162 -0
- package/vendor/lancedb/dist/header.js +217 -0
- package/vendor/lancedb/dist/index.d.ts +246 -0
- package/vendor/lancedb/dist/index.js +176 -0
- package/vendor/lancedb/dist/indices.d.ts +721 -0
- package/vendor/lancedb/dist/indices.js +166 -0
- package/vendor/lancedb/dist/materialized_view.d.ts +69 -0
- package/vendor/lancedb/dist/materialized_view.js +112 -0
- package/vendor/lancedb/dist/merge.d.ts +104 -0
- package/vendor/lancedb/dist/merge.js +120 -0
- package/vendor/lancedb/dist/native.d.ts +1193 -0
- package/vendor/lancedb/dist/native.js +688 -0
- package/vendor/lancedb/dist/oauth.d.ts +66 -0
- package/vendor/lancedb/dist/oauth.js +15 -0
- package/vendor/lancedb/dist/otel.d.ts +26 -0
- package/vendor/lancedb/dist/otel.js +114 -0
- package/vendor/lancedb/dist/permutation.d.ts +143 -0
- package/vendor/lancedb/dist/permutation.js +184 -0
- package/vendor/lancedb/dist/query.d.ts +663 -0
- package/vendor/lancedb/dist/query.js +966 -0
- package/vendor/lancedb/dist/rerankers/index.d.ts +5 -0
- package/vendor/lancedb/dist/rerankers/index.js +19 -0
- package/vendor/lancedb/dist/rerankers/rrf.d.ts +14 -0
- package/vendor/lancedb/dist/rerankers/rrf.js +28 -0
- package/vendor/lancedb/dist/sanitize.d.ts +32 -0
- package/vendor/lancedb/dist/sanitize.js +544 -0
- package/vendor/lancedb/dist/scannable.d.ts +92 -0
- package/vendor/lancedb/dist/scannable.js +200 -0
- package/vendor/lancedb/dist/schema.d.ts +16 -0
- package/vendor/lancedb/dist/schema.js +387 -0
- package/vendor/lancedb/dist/table.d.ts +1069 -0
- package/vendor/lancedb/dist/table.js +498 -0
- package/vendor/lancedb/dist/util.d.ts +14 -0
- package/vendor/lancedb/dist/util.js +77 -0
- package/vendor/lancedb/license_header.txt +2 -0
- package/vendor/lancedb/package.json +56 -0
- package/vendor/transformers/LICENSE +202 -0
- package/vendor/transformers/dist/transformers.cjs +30844 -0
- package/vendor/transformers/dist/transformers.mjs +31404 -0
- package/vendor/transformers/package.json +55 -0
- package/vendor/transformers/types/backends/onnx.d.ts +30 -0
- package/vendor/transformers/types/configs.d.ts +85 -0
- package/vendor/transformers/types/env.d.ts +110 -0
- package/vendor/transformers/types/generation/configuration_utils.d.ts +320 -0
- package/vendor/transformers/types/generation/logits_process.d.ts +354 -0
- package/vendor/transformers/types/generation/logits_sampler.d.ts +51 -0
- package/vendor/transformers/types/generation/parameters.d.ts +47 -0
- package/vendor/transformers/types/generation/stopping_criteria.d.ts +81 -0
- package/vendor/transformers/types/generation/streamers.d.ts +81 -0
- package/vendor/transformers/types/models/whisper/common_whisper.d.ts +8 -0
- package/vendor/transformers/types/models/whisper/generation_whisper.d.ts +76 -0
- package/vendor/transformers/types/models.d.ts +3684 -0
- package/vendor/transformers/types/ops/registry.d.ts +11 -0
- package/vendor/transformers/types/pipelines.d.ts +2402 -0
- package/vendor/transformers/types/processors.d.ts +924 -0
- package/vendor/transformers/types/tokenizers.d.ts +990 -0
- package/vendor/transformers/types/transformers.d.ts +13 -0
- package/vendor/transformers/types/utils/audio.d.ts +130 -0
- package/vendor/transformers/types/utils/constants.d.ts +2 -0
- package/vendor/transformers/types/utils/core.d.ts +98 -0
- package/vendor/transformers/types/utils/data-structures.d.ts +236 -0
- package/vendor/transformers/types/utils/devices.d.ts +18 -0
- package/vendor/transformers/types/utils/dtypes.d.ts +19 -0
- package/vendor/transformers/types/utils/generic.d.ts +11 -0
- package/vendor/transformers/types/utils/hub.d.ts +152 -0
- package/vendor/transformers/types/utils/image.d.ts +119 -0
- package/vendor/transformers/types/utils/maths.d.ts +280 -0
- package/vendor/transformers/types/utils/tensor.d.ts +418 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Index = void 0;
|
|
6
|
+
const native_1 = require("./native");
|
|
7
|
+
class Index {
|
|
8
|
+
inner;
|
|
9
|
+
constructor(inner) {
|
|
10
|
+
this.inner = inner;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create an IvfPq index
|
|
14
|
+
*
|
|
15
|
+
* This index stores a compressed (quantized) copy of every vector. These vectors
|
|
16
|
+
* are grouped into partitions of similar vectors. Each partition keeps track of
|
|
17
|
+
* a centroid which is the average value of all vectors in the group.
|
|
18
|
+
*
|
|
19
|
+
* During a query the centroids are compared with the query vector to find the closest
|
|
20
|
+
* partitions. The compressed vectors in these partitions are then searched to find
|
|
21
|
+
* the closest vectors.
|
|
22
|
+
*
|
|
23
|
+
* The compression scheme is called product quantization. Each vector is divided into
|
|
24
|
+
* subvectors and then each subvector is quantized into a small number of bits. the
|
|
25
|
+
* parameters `num_bits` and `num_subvectors` control this process, providing a tradeoff
|
|
26
|
+
* between index size (and thus search speed) and index accuracy.
|
|
27
|
+
*
|
|
28
|
+
* The partitioning process is called IVF and the `num_partitions` parameter controls how
|
|
29
|
+
* many groups to create.
|
|
30
|
+
*
|
|
31
|
+
* Note that training an IVF PQ index on a large dataset is a slow operation and
|
|
32
|
+
* currently is also a memory intensive operation.
|
|
33
|
+
*/
|
|
34
|
+
static ivfPq(options) {
|
|
35
|
+
return new Index(native_1.Index.ivfPq(options?.distanceType, options?.numPartitions, options?.numSubVectors, options?.numBits, options?.maxIterations, options?.sampleRate));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create an IvfRq index
|
|
39
|
+
*
|
|
40
|
+
* IVF-RQ (RabitQ Quantization) compresses vectors using RabitQ quantization
|
|
41
|
+
* and organizes them into IVF partitions.
|
|
42
|
+
*
|
|
43
|
+
* The compression scheme is called RabitQ quantization. Each dimension is quantized into a small number of bits.
|
|
44
|
+
* The parameters `num_bits` and `num_partitions` control this process, providing a tradeoff
|
|
45
|
+
* between index size (and thus search speed) and index accuracy.
|
|
46
|
+
*
|
|
47
|
+
* The partitioning process is called IVF and the `num_partitions` parameter controls how
|
|
48
|
+
* many groups to create.
|
|
49
|
+
*
|
|
50
|
+
* Note that training an IVF RQ index on a large dataset is a slow operation and
|
|
51
|
+
* currently is also a memory intensive operation.
|
|
52
|
+
*/
|
|
53
|
+
static ivfRq(options) {
|
|
54
|
+
return new Index(native_1.Index.ivfRq(options?.distanceType, options?.numPartitions, options?.numBits, options?.maxIterations, options?.sampleRate));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create an IvfFlat index
|
|
58
|
+
*
|
|
59
|
+
* This index groups vectors into partitions of similar vectors. Each partition keeps track of
|
|
60
|
+
* a centroid which is the average value of all vectors in the group.
|
|
61
|
+
*
|
|
62
|
+
* During a query the centroids are compared with the query vector to find the closest
|
|
63
|
+
* partitions. The vectors in these partitions are then searched to find
|
|
64
|
+
* the closest vectors.
|
|
65
|
+
*
|
|
66
|
+
* The partitioning process is called IVF and the `num_partitions` parameter controls how
|
|
67
|
+
* many groups to create.
|
|
68
|
+
*
|
|
69
|
+
* Note that training an IVF FLAT index on a large dataset is a slow operation and
|
|
70
|
+
* currently is also a memory intensive operation.
|
|
71
|
+
*/
|
|
72
|
+
static ivfFlat(options) {
|
|
73
|
+
return new Index(native_1.Index.ivfFlat(options?.distanceType, options?.numPartitions, options?.maxIterations, options?.sampleRate));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a btree index
|
|
77
|
+
*
|
|
78
|
+
* A btree index is an index on a scalar columns. The index stores a copy of the column
|
|
79
|
+
* in sorted order. A header entry is created for each block of rows (currently the
|
|
80
|
+
* block size is fixed at 4096). These header entries are stored in a separate
|
|
81
|
+
* cacheable structure (a btree). To search for data the header is used to determine
|
|
82
|
+
* which blocks need to be read from disk.
|
|
83
|
+
*
|
|
84
|
+
* For example, a btree index in a table with 1Bi rows requires sizeof(Scalar) * 256Ki
|
|
85
|
+
* bytes of memory and will generally need to read sizeof(Scalar) * 4096 bytes to find
|
|
86
|
+
* the correct row ids.
|
|
87
|
+
*
|
|
88
|
+
* This index is good for scalar columns with mostly distinct values and does best when
|
|
89
|
+
* the query is highly selective.
|
|
90
|
+
*
|
|
91
|
+
* The btree index does not currently have any parameters though parameters such as the
|
|
92
|
+
* block size may be added in the future.
|
|
93
|
+
*/
|
|
94
|
+
static btree() {
|
|
95
|
+
return new Index(native_1.Index.btree());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create a bitmap index.
|
|
99
|
+
*
|
|
100
|
+
* A `Bitmap` index stores a bitmap for each distinct value in the column for every row.
|
|
101
|
+
*
|
|
102
|
+
* This index works best for low-cardinality columns, where the number of unique values
|
|
103
|
+
* is small (i.e., less than a few hundreds).
|
|
104
|
+
*/
|
|
105
|
+
static bitmap() {
|
|
106
|
+
return new Index(native_1.Index.bitmap());
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create a label list index.
|
|
110
|
+
*
|
|
111
|
+
* LabelList index is a scalar index that can be used on `List<T>` columns to
|
|
112
|
+
* support queries with `array_contains_all` and `array_contains_any`
|
|
113
|
+
* using an underlying bitmap index.
|
|
114
|
+
*/
|
|
115
|
+
static labelList() {
|
|
116
|
+
return new Index(native_1.Index.labelList());
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create an FM-Index.
|
|
120
|
+
*
|
|
121
|
+
* An FM-Index is a scalar index on string or binary columns that accelerates
|
|
122
|
+
* substring search, i.e. `contains(col, 'needle')`. Unlike the tokenized
|
|
123
|
+
* full-text-search index, it matches arbitrary substrings of the raw bytes.
|
|
124
|
+
*/
|
|
125
|
+
static fm() {
|
|
126
|
+
return new Index(native_1.Index.fm());
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a full text search index
|
|
130
|
+
*
|
|
131
|
+
* A full text search index is an index on a string column, so that you can conduct full
|
|
132
|
+
* text searches on the column.
|
|
133
|
+
*
|
|
134
|
+
* The results of a full text search are ordered by relevance measured by BM25.
|
|
135
|
+
*
|
|
136
|
+
* You can combine filters with full text search.
|
|
137
|
+
*/
|
|
138
|
+
static fts(options) {
|
|
139
|
+
return new Index(native_1.Index.fts(options?.withPosition, options?.baseTokenizer, options?.language, options?.maxTokenLength, options?.lowercase, options?.stem, options?.removeStopWords, options?.customStopWords, options?.asciiFolding, options?.ngramMinLength, options?.ngramMaxLength, options?.prefixOnly, options?.blockSize));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* Create a hnswPq index
|
|
144
|
+
*
|
|
145
|
+
* HNSW-PQ stands for Hierarchical Navigable Small World - Product Quantization.
|
|
146
|
+
* It is a variant of the HNSW algorithm that uses product quantization to compress
|
|
147
|
+
* the vectors.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
static hnswPq(options) {
|
|
151
|
+
return new Index(native_1.Index.hnswPq(options?.distanceType, options?.numPartitions, options?.numSubVectors, options?.maxIterations, options?.sampleRate, options?.m, options?.efConstruction));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* Create a hnswSq index
|
|
156
|
+
*
|
|
157
|
+
* HNSW-SQ stands for Hierarchical Navigable Small World - Scalar Quantization.
|
|
158
|
+
* It is a variant of the HNSW algorithm that uses scalar quantization to compress
|
|
159
|
+
* the vectors.
|
|
160
|
+
*
|
|
161
|
+
*/
|
|
162
|
+
static hnswSq(options) {
|
|
163
|
+
return new Index(native_1.Index.hnswSq(options?.distanceType, options?.numPartitions, options?.maxIterations, options?.sampleRate, options?.m, options?.efConstruction));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.Index = Index;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { RefreshMaterializedViewResult } from "./native";
|
|
2
|
+
import { Table } from "./table";
|
|
3
|
+
/** Schema metadata key holding a materialized view's definition. */
|
|
4
|
+
export declare const DEFINITION_META_KEY = "mv.definition";
|
|
5
|
+
/** The query that defines a materialized view. */
|
|
6
|
+
export interface MaterializedViewDefinition {
|
|
7
|
+
/** Name of the source table, in the same database as the view. */
|
|
8
|
+
sourceTable: string;
|
|
9
|
+
/** `[output column, SQL expression]` pairs, in view schema order. */
|
|
10
|
+
projections: [string, string][];
|
|
11
|
+
/** SQL predicate selecting the source rows the view holds. */
|
|
12
|
+
filter?: string;
|
|
13
|
+
/** Cap on the number of rows the view holds. */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Source columns the projections and filter read. */
|
|
16
|
+
inputs: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The view's columns: column names, `[alias, SQL expression]` pairs, or a
|
|
20
|
+
* record of the same. A bare name projects itself.
|
|
21
|
+
*/
|
|
22
|
+
export type MaterializedViewSelect = (string | [string, string])[] | Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* @internal Reject a numeric option N-API would otherwise silently coerce:
|
|
25
|
+
* `Infinity` reaches Rust as 0, `1.5` as 1.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateNonNegativeInteger(value: number | undefined, name: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* @internal Normalize a select argument into `[alias, expression]` pairs.
|
|
30
|
+
* A bare name projects itself and is quoted, so any valid column name works;
|
|
31
|
+
* pair and record entries are kept verbatim because their right side is an
|
|
32
|
+
* expression.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeSelect(select?: MaterializedViewSelect): [string, string][] | undefined;
|
|
35
|
+
/** @internal Parse a definition off a table's stored schema metadata. */
|
|
36
|
+
export declare function definitionFromMetadata(metadata: Map<string, string>, name: string): MaterializedViewDefinition;
|
|
37
|
+
/**
|
|
38
|
+
* A handle on a materialized view: its table plus its definition.
|
|
39
|
+
*
|
|
40
|
+
* Obtained from {@link Connection#createMaterializedView} or
|
|
41
|
+
* {@link Connection#openMaterializedView}. The view is a normal table --
|
|
42
|
+
* queries, indexes and search all apply through {@link MaterializedView#table}
|
|
43
|
+
* -- whose contents are maintained by {@link MaterializedView#refresh}.
|
|
44
|
+
*/
|
|
45
|
+
export declare class MaterializedView {
|
|
46
|
+
private readonly inner;
|
|
47
|
+
constructor(table: Table);
|
|
48
|
+
get name(): string;
|
|
49
|
+
/** The view, as the table it is. */
|
|
50
|
+
table(): Table;
|
|
51
|
+
/** The query that defines the view, read from its stored schema. */
|
|
52
|
+
definition(): Promise<MaterializedViewDefinition>;
|
|
53
|
+
/**
|
|
54
|
+
* Recompute the view from its source.
|
|
55
|
+
*
|
|
56
|
+
* The refresh is incremental when the source's changes can be reconciled
|
|
57
|
+
* into the view -- rows added, changed or removed since the last one --
|
|
58
|
+
* and otherwise rebuilds. `full` forces a rebuild; `sourceVersion`
|
|
59
|
+
* refreshes to that source version instead of the latest.
|
|
60
|
+
*
|
|
61
|
+
* Concurrent refreshes of one view do not duplicate its rows. Two that
|
|
62
|
+
* plan the same source rows conflict on commit, and the loser throws
|
|
63
|
+
* rather than writing them a second time.
|
|
64
|
+
*/
|
|
65
|
+
refresh(options?: {
|
|
66
|
+
full?: boolean;
|
|
67
|
+
sourceVersion?: number;
|
|
68
|
+
}): Promise<RefreshMaterializedViewResult>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.MaterializedView = exports.DEFINITION_META_KEY = void 0;
|
|
6
|
+
exports.validateNonNegativeInteger = validateNonNegativeInteger;
|
|
7
|
+
exports.normalizeSelect = normalizeSelect;
|
|
8
|
+
exports.definitionFromMetadata = definitionFromMetadata;
|
|
9
|
+
/** Schema metadata key holding a materialized view's definition. */
|
|
10
|
+
exports.DEFINITION_META_KEY = "mv.definition";
|
|
11
|
+
/**
|
|
12
|
+
* @internal Reject a numeric option N-API would otherwise silently coerce:
|
|
13
|
+
* `Infinity` reaches Rust as 0, `1.5` as 1.
|
|
14
|
+
*/
|
|
15
|
+
function validateNonNegativeInteger(value, name) {
|
|
16
|
+
if (value !== undefined && !(Number.isSafeInteger(value) && value >= 0)) {
|
|
17
|
+
throw new Error(`${name} must be a non-negative integer`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** @internal Quote a column name as a Lance SQL identifier (backticks). */
|
|
21
|
+
function quoteIdentifier(name) {
|
|
22
|
+
return "`" + name.replace(/`/g, "``") + "`";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal Normalize a select argument into `[alias, expression]` pairs.
|
|
26
|
+
* A bare name projects itself and is quoted, so any valid column name works;
|
|
27
|
+
* pair and record entries are kept verbatim because their right side is an
|
|
28
|
+
* expression.
|
|
29
|
+
*/
|
|
30
|
+
function normalizeSelect(select) {
|
|
31
|
+
if (select === undefined) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(select)) {
|
|
35
|
+
return select.map((item) => typeof item === "string" ? [item, quoteIdentifier(item)] : item);
|
|
36
|
+
}
|
|
37
|
+
return Object.entries(select);
|
|
38
|
+
}
|
|
39
|
+
/** @internal Parse a definition off a table's stored schema metadata. */
|
|
40
|
+
function definitionFromMetadata(metadata, name) {
|
|
41
|
+
const raw = metadata.get(exports.DEFINITION_META_KEY);
|
|
42
|
+
if (raw === undefined) {
|
|
43
|
+
throw new Error(`Table '${name}' is not a materialized view`);
|
|
44
|
+
}
|
|
45
|
+
// biome-ignore lint/suspicious/noExplicitAny: raw JSON
|
|
46
|
+
const value = JSON.parse(raw);
|
|
47
|
+
if (value.kind !== "select") {
|
|
48
|
+
throw new Error(`materialized view '${name}' is defined by '${value.kind}', which this ` +
|
|
49
|
+
"version of lancedb cannot refresh");
|
|
50
|
+
}
|
|
51
|
+
const limit = value.limit ?? undefined;
|
|
52
|
+
// JSON.parse rounds integers past 2^53; every exact u64 parses to a safe
|
|
53
|
+
// integer and every rounded one does not, so this rejects precisely the
|
|
54
|
+
// values a number cannot carry.
|
|
55
|
+
if (limit !== undefined && !Number.isSafeInteger(limit)) {
|
|
56
|
+
throw new Error(`materialized view '${name}' has a stored limit too large to represent exactly`);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
sourceTable: value.source_table,
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: raw JSON
|
|
61
|
+
projections: (value.projections ?? []).map((p) => [
|
|
62
|
+
p.output,
|
|
63
|
+
p.expression,
|
|
64
|
+
]),
|
|
65
|
+
filter: value.filter ?? undefined,
|
|
66
|
+
limit,
|
|
67
|
+
inputs: value.inputs ?? [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A handle on a materialized view: its table plus its definition.
|
|
72
|
+
*
|
|
73
|
+
* Obtained from {@link Connection#createMaterializedView} or
|
|
74
|
+
* {@link Connection#openMaterializedView}. The view is a normal table --
|
|
75
|
+
* queries, indexes and search all apply through {@link MaterializedView#table}
|
|
76
|
+
* -- whose contents are maintained by {@link MaterializedView#refresh}.
|
|
77
|
+
*/
|
|
78
|
+
class MaterializedView {
|
|
79
|
+
inner;
|
|
80
|
+
constructor(table) {
|
|
81
|
+
this.inner = table;
|
|
82
|
+
}
|
|
83
|
+
get name() {
|
|
84
|
+
return this.inner.name;
|
|
85
|
+
}
|
|
86
|
+
/** The view, as the table it is. */
|
|
87
|
+
table() {
|
|
88
|
+
return this.inner;
|
|
89
|
+
}
|
|
90
|
+
/** The query that defines the view, read from its stored schema. */
|
|
91
|
+
async definition() {
|
|
92
|
+
const schema = await this.inner.schema();
|
|
93
|
+
return definitionFromMetadata(schema.metadata, this.name);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Recompute the view from its source.
|
|
97
|
+
*
|
|
98
|
+
* The refresh is incremental when the source's changes can be reconciled
|
|
99
|
+
* into the view -- rows added, changed or removed since the last one --
|
|
100
|
+
* and otherwise rebuilds. `full` forces a rebuild; `sourceVersion`
|
|
101
|
+
* refreshes to that source version instead of the latest.
|
|
102
|
+
*
|
|
103
|
+
* Concurrent refreshes of one view do not duplicate its rows. Two that
|
|
104
|
+
* plan the same source rows conflict on commit, and the loser throws
|
|
105
|
+
* rather than writing them a second time.
|
|
106
|
+
*/
|
|
107
|
+
async refresh(options) {
|
|
108
|
+
validateNonNegativeInteger(options?.sourceVersion, "sourceVersion");
|
|
109
|
+
return await this.inner.refreshMaterializedView(options?.full, options?.sourceVersion);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.MaterializedView = MaterializedView;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Data, Schema } from "./arrow";
|
|
2
|
+
import { MergeResult, NativeMergeInsertBuilder } from "./native";
|
|
3
|
+
/** A builder used to create and run a merge insert operation */
|
|
4
|
+
export declare class MergeInsertBuilder {
|
|
5
|
+
#private;
|
|
6
|
+
/** Construct a MergeInsertBuilder. __Internal use only.__ */
|
|
7
|
+
constructor(native: NativeMergeInsertBuilder, schema: Schema | Promise<Schema>);
|
|
8
|
+
/**
|
|
9
|
+
* Rows that exist in both the source table (new data) and
|
|
10
|
+
* the target table (old data) will be updated, replacing
|
|
11
|
+
* the old row with the corresponding matching row.
|
|
12
|
+
*
|
|
13
|
+
* If there are multiple matches then the behavior is undefined.
|
|
14
|
+
* Currently this causes multiple copies of the row to be created
|
|
15
|
+
* but that behavior is subject to change.
|
|
16
|
+
*
|
|
17
|
+
* An optional condition may be specified. If it is, then only
|
|
18
|
+
* matched rows that satisfy the condtion will be updated. Any
|
|
19
|
+
* rows that do not satisfy the condition will be left as they
|
|
20
|
+
* are. Failing to satisfy the condition does not cause a
|
|
21
|
+
* "matched row" to become a "not matched" row.
|
|
22
|
+
*
|
|
23
|
+
* The condition should be an SQL string. Use the prefix
|
|
24
|
+
* target. to refer to rows in the target table (old data)
|
|
25
|
+
* and the prefix source. to refer to rows in the source
|
|
26
|
+
* table (new data).
|
|
27
|
+
*
|
|
28
|
+
* For example, "target.last_update < source.last_update"
|
|
29
|
+
*/
|
|
30
|
+
whenMatchedUpdateAll(options?: {
|
|
31
|
+
where: string;
|
|
32
|
+
}): MergeInsertBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Rows that exist only in the source table (new data) should
|
|
35
|
+
* be inserted into the target table.
|
|
36
|
+
*/
|
|
37
|
+
whenNotMatchedInsertAll(): MergeInsertBuilder;
|
|
38
|
+
/**
|
|
39
|
+
* Rows that exist only in the target table (old data) will be
|
|
40
|
+
* deleted. An optional condition can be provided to limit what
|
|
41
|
+
* data is deleted.
|
|
42
|
+
*
|
|
43
|
+
* @param options.where - An optional condition to limit what data is deleted
|
|
44
|
+
*/
|
|
45
|
+
whenNotMatchedBySourceDelete(options?: {
|
|
46
|
+
where: string;
|
|
47
|
+
}): MergeInsertBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Controls whether to use indexes for the merge operation.
|
|
50
|
+
*
|
|
51
|
+
* When set to `true` (the default), the operation will use an index if available
|
|
52
|
+
* on the join key for improved performance. When set to `false`, it forces a full
|
|
53
|
+
* table scan even if an index exists. This can be useful for benchmarking or when
|
|
54
|
+
* the query optimizer chooses a suboptimal path.
|
|
55
|
+
*
|
|
56
|
+
* @param useIndex - Whether to use indices for the merge operation. Defaults to `true`.
|
|
57
|
+
*/
|
|
58
|
+
useIndex(useIndex: boolean): MergeInsertBuilder;
|
|
59
|
+
/**
|
|
60
|
+
* Control MemWAL routing for this merge.
|
|
61
|
+
*
|
|
62
|
+
* By default (unset), a `mergeInsert` on a table with an LSM write spec is
|
|
63
|
+
* routed through Lance's MemWAL shard writer, and a table without one uses the
|
|
64
|
+
* standard path.
|
|
65
|
+
*
|
|
66
|
+
* @param enable - `true` forces MemWAL routing and errors if the table has no
|
|
67
|
+
* LSM write spec. `false` forces the standard write path even when a spec is set.
|
|
68
|
+
*/
|
|
69
|
+
useLsm(enable: boolean): MergeInsertBuilder;
|
|
70
|
+
/**
|
|
71
|
+
* Controls how an LSM merge checks that its input targets a single shard.
|
|
72
|
+
*
|
|
73
|
+
* When a table has an LSM write spec, every row in a `mergeInsert` call must
|
|
74
|
+
* route to the same shard. When `true` (the default), every row is inspected
|
|
75
|
+
* to verify this. When `false`, only the first row is inspected and the
|
|
76
|
+
* shard it routes to is used for the whole input — a faster path for callers
|
|
77
|
+
* that have already pre-sharded their input. Has no effect on tables without
|
|
78
|
+
* an LSM write spec.
|
|
79
|
+
*
|
|
80
|
+
* @param validateSingleShard - Whether to check every row routes to one shard. Defaults to `true`.
|
|
81
|
+
*/
|
|
82
|
+
validateSingleShard(validateSingleShard: boolean): MergeInsertBuilder;
|
|
83
|
+
/**
|
|
84
|
+
* Executes the merge insert operation
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<MergeResult>} the merge result
|
|
87
|
+
*/
|
|
88
|
+
execute(data: Data, execOptions?: Partial<WriteExecutionOptions>): Promise<MergeResult>;
|
|
89
|
+
}
|
|
90
|
+
export interface WriteExecutionOptions {
|
|
91
|
+
/**
|
|
92
|
+
* Maximum time to run the operation before cancelling it.
|
|
93
|
+
*
|
|
94
|
+
* By default, there is a 30-second timeout that is only enforced after the
|
|
95
|
+
* first attempt. This is to prevent spending too long retrying to resolve
|
|
96
|
+
* conflicts. For example, if a write attempt takes 20 seconds and fails,
|
|
97
|
+
* the second attempt will be cancelled after 10 seconds, hitting the
|
|
98
|
+
* 30-second timeout. However, a write that takes one hour and succeeds on the
|
|
99
|
+
* first attempt will not be cancelled.
|
|
100
|
+
*
|
|
101
|
+
* When this is set, the timeout is enforced on all attempts, including the first.
|
|
102
|
+
*/
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MergeInsertBuilder = void 0;
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
6
|
+
const arrow_1 = require("./arrow");
|
|
7
|
+
/** A builder used to create and run a merge insert operation */
|
|
8
|
+
class MergeInsertBuilder {
|
|
9
|
+
#native;
|
|
10
|
+
#schema;
|
|
11
|
+
/** Construct a MergeInsertBuilder. __Internal use only.__ */
|
|
12
|
+
constructor(native, schema) {
|
|
13
|
+
this.#native = native;
|
|
14
|
+
this.#schema = schema;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Rows that exist in both the source table (new data) and
|
|
18
|
+
* the target table (old data) will be updated, replacing
|
|
19
|
+
* the old row with the corresponding matching row.
|
|
20
|
+
*
|
|
21
|
+
* If there are multiple matches then the behavior is undefined.
|
|
22
|
+
* Currently this causes multiple copies of the row to be created
|
|
23
|
+
* but that behavior is subject to change.
|
|
24
|
+
*
|
|
25
|
+
* An optional condition may be specified. If it is, then only
|
|
26
|
+
* matched rows that satisfy the condtion will be updated. Any
|
|
27
|
+
* rows that do not satisfy the condition will be left as they
|
|
28
|
+
* are. Failing to satisfy the condition does not cause a
|
|
29
|
+
* "matched row" to become a "not matched" row.
|
|
30
|
+
*
|
|
31
|
+
* The condition should be an SQL string. Use the prefix
|
|
32
|
+
* target. to refer to rows in the target table (old data)
|
|
33
|
+
* and the prefix source. to refer to rows in the source
|
|
34
|
+
* table (new data).
|
|
35
|
+
*
|
|
36
|
+
* For example, "target.last_update < source.last_update"
|
|
37
|
+
*/
|
|
38
|
+
whenMatchedUpdateAll(options) {
|
|
39
|
+
return new MergeInsertBuilder(this.#native.whenMatchedUpdateAll(options?.where), this.#schema);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Rows that exist only in the source table (new data) should
|
|
43
|
+
* be inserted into the target table.
|
|
44
|
+
*/
|
|
45
|
+
whenNotMatchedInsertAll() {
|
|
46
|
+
return new MergeInsertBuilder(this.#native.whenNotMatchedInsertAll(), this.#schema);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Rows that exist only in the target table (old data) will be
|
|
50
|
+
* deleted. An optional condition can be provided to limit what
|
|
51
|
+
* data is deleted.
|
|
52
|
+
*
|
|
53
|
+
* @param options.where - An optional condition to limit what data is deleted
|
|
54
|
+
*/
|
|
55
|
+
whenNotMatchedBySourceDelete(options) {
|
|
56
|
+
return new MergeInsertBuilder(this.#native.whenNotMatchedBySourceDelete(options?.where), this.#schema);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Controls whether to use indexes for the merge operation.
|
|
60
|
+
*
|
|
61
|
+
* When set to `true` (the default), the operation will use an index if available
|
|
62
|
+
* on the join key for improved performance. When set to `false`, it forces a full
|
|
63
|
+
* table scan even if an index exists. This can be useful for benchmarking or when
|
|
64
|
+
* the query optimizer chooses a suboptimal path.
|
|
65
|
+
*
|
|
66
|
+
* @param useIndex - Whether to use indices for the merge operation. Defaults to `true`.
|
|
67
|
+
*/
|
|
68
|
+
useIndex(useIndex) {
|
|
69
|
+
return new MergeInsertBuilder(this.#native.useIndex(useIndex), this.#schema);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Control MemWAL routing for this merge.
|
|
73
|
+
*
|
|
74
|
+
* By default (unset), a `mergeInsert` on a table with an LSM write spec is
|
|
75
|
+
* routed through Lance's MemWAL shard writer, and a table without one uses the
|
|
76
|
+
* standard path.
|
|
77
|
+
*
|
|
78
|
+
* @param enable - `true` forces MemWAL routing and errors if the table has no
|
|
79
|
+
* LSM write spec. `false` forces the standard write path even when a spec is set.
|
|
80
|
+
*/
|
|
81
|
+
useLsm(enable) {
|
|
82
|
+
return new MergeInsertBuilder(this.#native.useLsm(enable), this.#schema);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Controls how an LSM merge checks that its input targets a single shard.
|
|
86
|
+
*
|
|
87
|
+
* When a table has an LSM write spec, every row in a `mergeInsert` call must
|
|
88
|
+
* route to the same shard. When `true` (the default), every row is inspected
|
|
89
|
+
* to verify this. When `false`, only the first row is inspected and the
|
|
90
|
+
* shard it routes to is used for the whole input — a faster path for callers
|
|
91
|
+
* that have already pre-sharded their input. Has no effect on tables without
|
|
92
|
+
* an LSM write spec.
|
|
93
|
+
*
|
|
94
|
+
* @param validateSingleShard - Whether to check every row routes to one shard. Defaults to `true`.
|
|
95
|
+
*/
|
|
96
|
+
validateSingleShard(validateSingleShard) {
|
|
97
|
+
return new MergeInsertBuilder(this.#native.validateSingleShard(validateSingleShard), this.#schema);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Executes the merge insert operation
|
|
101
|
+
*
|
|
102
|
+
* @returns {Promise<MergeResult>} the merge result
|
|
103
|
+
*/
|
|
104
|
+
async execute(data, execOptions) {
|
|
105
|
+
let schema;
|
|
106
|
+
if (this.#schema instanceof Promise) {
|
|
107
|
+
schema = await this.#schema;
|
|
108
|
+
this.#schema = schema; // In case of future calls
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
schema = this.#schema;
|
|
112
|
+
}
|
|
113
|
+
if (execOptions?.timeoutMs !== undefined) {
|
|
114
|
+
this.#native.setTimeout(execOptions.timeoutMs);
|
|
115
|
+
}
|
|
116
|
+
const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
|
|
117
|
+
return await this.#native.execute(buffer);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.MergeInsertBuilder = MergeInsertBuilder;
|