@lix-js/sdk 0.6.0-preview.3 → 0.6.0-preview.5
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 +1 -1
- package/SKILL.md +105 -65
- package/dist/engine-wasm/index.js +4 -4
- package/dist/engine-wasm/wasm/lix_engine.d.ts +30 -6
- package/dist/engine-wasm/wasm/lix_engine.js +187 -117
- package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
- package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +14 -8
- package/dist/generated/builtin-schemas.d.ts +69 -69
- package/dist/generated/builtin-schemas.js +94 -94
- package/dist/open-lix.d.ts +42 -28
- package/dist/open-lix.js +49 -10
- package/dist/sqlite/index.js +86 -30
- package/dist-engine-src/README.md +3 -3
- package/dist-engine-src/src/backend/capabilities.rs +67 -0
- package/dist-engine-src/src/backend/conformance/baseline.rs +1127 -0
- package/dist-engine-src/src/backend/conformance/factory.rs +93 -0
- package/dist-engine-src/src/backend/conformance/failure_tests.rs +608 -0
- package/dist-engine-src/src/backend/conformance/fixtures.rs +26 -0
- package/dist-engine-src/src/backend/conformance/mod.rs +75 -0
- package/dist-engine-src/src/backend/conformance/model.rs +28 -0
- package/dist-engine-src/src/backend/conformance/model_based.rs +257 -0
- package/dist-engine-src/src/backend/conformance/persistence.rs +204 -0
- package/dist-engine-src/src/backend/conformance/projection.rs +21 -0
- package/dist-engine-src/src/backend/conformance/pushdown.rs +24 -0
- package/dist-engine-src/src/backend/conformance/runner.rs +90 -0
- package/dist-engine-src/src/backend/conformance/scan.rs +24 -0
- package/dist-engine-src/src/backend/conformance/write.rs +16 -0
- package/dist-engine-src/src/backend/error.rs +94 -0
- package/dist-engine-src/src/backend/in_memory.rs +670 -0
- package/dist-engine-src/src/backend/mod.rs +36 -9
- package/dist-engine-src/src/backend/predicate.rs +80 -0
- package/dist-engine-src/src/backend/traits.rs +260 -0
- package/dist-engine-src/src/backend/types.rs +224 -81
- package/dist-engine-src/src/binary_cas/context.rs +8 -8
- package/dist-engine-src/src/binary_cas/kv.rs +234 -259
- package/dist-engine-src/src/{version → branch}/context.rs +12 -12
- package/dist-engine-src/src/branch/lifecycle.rs +221 -0
- package/dist-engine-src/src/branch/mod.rs +13 -0
- package/dist-engine-src/src/branch/refs.rs +321 -0
- package/dist-engine-src/src/branch/stage_rows.rs +67 -0
- package/dist-engine-src/src/branch/types.rs +21 -0
- package/dist-engine-src/src/catalog/context.rs +18 -18
- package/dist-engine-src/src/catalog/snapshot.rs +8 -8
- package/dist-engine-src/src/changelog/bench_support.rs +785 -0
- package/dist-engine-src/src/changelog/change.rs +1 -0
- package/dist-engine-src/src/changelog/codec.rs +497 -0
- package/dist-engine-src/src/changelog/commit.rs +1 -0
- package/dist-engine-src/src/changelog/context.rs +1614 -0
- package/dist-engine-src/src/changelog/mod.rs +29 -0
- package/dist-engine-src/src/changelog/store.rs +163 -0
- package/dist-engine-src/src/changelog/test_support.rs +54 -0
- package/dist-engine-src/src/changelog/types.rs +213 -0
- package/dist-engine-src/src/commit_graph/context.rs +317 -274
- package/dist-engine-src/src/commit_graph/mod.rs +2 -4
- package/dist-engine-src/src/commit_graph/types.rs +22 -42
- package/dist-engine-src/src/commit_graph/walker.rs +133 -103
- package/dist-engine-src/src/common/error.rs +52 -18
- package/dist-engine-src/src/common/identity.rs +2 -2
- package/dist-engine-src/src/common/mod.rs +1 -1
- package/dist-engine-src/src/domain.rs +42 -46
- package/dist-engine-src/src/engine.rs +74 -96
- package/dist-engine-src/src/{entity_identity.rs → entity_pk.rs} +89 -92
- package/dist-engine-src/src/functions/context.rs +56 -52
- package/dist-engine-src/src/functions/state.rs +51 -52
- package/dist-engine-src/src/init.rs +288 -154
- package/dist-engine-src/src/json_store/context.rs +15 -266
- package/dist-engine-src/src/json_store/mod.rs +26 -0
- package/dist-engine-src/src/json_store/store.rs +103 -718
- package/dist-engine-src/src/json_store/types.rs +4 -9
- package/dist-engine-src/src/lib.rs +49 -19
- package/dist-engine-src/src/live_state/context.rs +654 -790
- package/dist-engine-src/src/live_state/mod.rs +9 -3
- package/dist-engine-src/src/live_state/overlay.rs +4 -4
- package/dist-engine-src/src/live_state/types.rs +30 -21
- package/dist-engine-src/src/live_state/visibility.rs +514 -71
- package/dist-engine-src/src/plugin/install.rs +48 -48
- package/dist-engine-src/src/plugin/manifest.rs +7 -7
- package/dist-engine-src/src/plugin/materializer.rs +0 -275
- package/dist-engine-src/src/plugin/plugin_manifest.json +4 -3
- package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +2 -2
- package/dist-engine-src/src/schema/builtin/lix_branch_descriptor.json +34 -0
- package/dist-engine-src/src/schema/builtin/lix_branch_ref.json +48 -0
- package/dist-engine-src/src/schema/builtin/lix_change.json +3 -3
- package/dist-engine-src/src/schema/builtin/lix_commit.json +1 -1
- package/dist-engine-src/src/schema/builtin/lix_label_assignment.json +6 -6
- package/dist-engine-src/src/schema/builtin/mod.rs +18 -20
- package/dist-engine-src/src/schema/compatibility.rs +11 -11
- package/dist-engine-src/src/schema/definition.json +2 -2
- package/dist-engine-src/src/schema/definition.rs +5 -5
- package/dist-engine-src/src/schema/key.rs +3 -3
- package/dist-engine-src/src/schema/mod.rs +1 -1
- package/dist-engine-src/src/schema/tests.rs +18 -18
- package/dist-engine-src/src/session/context.rs +819 -124
- package/dist-engine-src/src/session/create_branch.rs +94 -0
- package/dist-engine-src/src/session/execute.rs +260 -57
- package/dist-engine-src/src/session/merge/analysis.rs +9 -3
- package/dist-engine-src/src/session/merge/{version.rs → branch.rs} +119 -129
- package/dist-engine-src/src/session/merge/conflicts.rs +2 -2
- package/dist-engine-src/src/session/merge/mod.rs +5 -6
- package/dist-engine-src/src/session/merge/stats.rs +7 -11
- package/dist-engine-src/src/session/mod.rs +19 -16
- package/dist-engine-src/src/session/switch_branch.rs +113 -0
- package/dist-engine-src/src/session/transaction.rs +557 -0
- package/dist-engine-src/src/sql2/bind/classify.rs +102 -0
- package/dist-engine-src/src/sql2/bind/error.rs +5 -0
- package/dist-engine-src/src/sql2/bind/expr.rs +29 -0
- package/dist-engine-src/src/sql2/bind/mod.rs +12 -0
- package/dist-engine-src/src/sql2/{udfs/public_call.rs → bind/public_udf.rs} +98 -3
- package/dist-engine-src/src/sql2/bind/read.rs +65 -0
- package/dist-engine-src/src/sql2/bind/statement.rs +2236 -0
- package/dist-engine-src/src/sql2/bind/table.rs +273 -0
- package/dist-engine-src/src/sql2/bind/write.rs +86 -0
- package/dist-engine-src/src/sql2/branch_scope.rs +436 -0
- package/dist-engine-src/src/sql2/catalog/capability.rs +20 -0
- package/dist-engine-src/src/sql2/catalog/entity_surface.rs +296 -0
- package/dist-engine-src/src/sql2/catalog/mod.rs +15 -0
- package/dist-engine-src/src/sql2/catalog/registry.rs +556 -0
- package/dist-engine-src/src/sql2/catalog/schema.rs +88 -0
- package/dist-engine-src/src/sql2/catalog/surface.rs +41 -0
- package/dist-engine-src/src/sql2/change_materialization.rs +122 -0
- package/dist-engine-src/src/sql2/context.rs +36 -30
- package/dist-engine-src/src/sql2/error.rs +4 -5
- package/dist-engine-src/src/sql2/exec/bound_public_write.rs +1593 -0
- package/dist-engine-src/src/sql2/exec/datafusion.rs +5266 -0
- package/dist-engine-src/src/sql2/exec/fast_write.rs +82 -0
- package/dist-engine-src/src/sql2/exec/mod.rs +24 -0
- package/dist-engine-src/src/sql2/exec/write.rs +661 -0
- package/dist-engine-src/src/sql2/filesystem_planner.rs +72 -77
- package/dist-engine-src/src/sql2/filesystem_visibility.rs +21 -21
- package/dist-engine-src/src/sql2/history_projection.rs +8 -8
- package/dist-engine-src/src/sql2/history_route.rs +35 -31
- package/dist-engine-src/src/sql2/mod.rs +30 -24
- package/dist-engine-src/src/sql2/optimize/datafusion.rs +1 -0
- package/dist-engine-src/src/sql2/optimize/mod.rs +2 -0
- package/dist-engine-src/src/sql2/optimize/simple_write.rs +116 -0
- package/dist-engine-src/src/sql2/parse/mod.rs +69 -0
- package/dist-engine-src/src/sql2/parse/normalize.rs +1 -0
- package/dist-engine-src/src/sql2/plan/branch_scope.rs +24 -0
- package/dist-engine-src/src/sql2/plan/mod.rs +5 -0
- package/dist-engine-src/src/sql2/plan/predicate.rs +22 -0
- package/dist-engine-src/src/sql2/plan/write.rs +147 -0
- package/dist-engine-src/src/sql2/predicate_typecheck.rs +258 -0
- package/dist-engine-src/src/sql2/{version_provider.rs → providers/branch.rs} +218 -214
- package/dist-engine-src/src/sql2/{change_provider.rs → providers/change.rs} +156 -42
- package/dist-engine-src/src/sql2/{directory_provider.rs → providers/directory.rs} +291 -322
- package/dist-engine-src/src/sql2/{directory_history_provider.rs → providers/directory_history.rs} +56 -42
- package/dist-engine-src/src/sql2/providers/entity.rs +1484 -0
- package/dist-engine-src/src/sql2/{entity_history_provider.rs → providers/entity_history.rs} +43 -31
- package/dist-engine-src/src/sql2/{file_provider.rs → providers/file.rs} +323 -316
- package/dist-engine-src/src/sql2/{file_history_provider.rs → providers/file_history.rs} +60 -46
- package/dist-engine-src/src/sql2/{history_provider.rs → providers/history.rs} +46 -32
- package/dist-engine-src/src/sql2/{lix_state_provider.rs → providers/lix_state.rs} +359 -329
- package/dist-engine-src/src/sql2/providers/mod.rs +508 -0
- package/dist-engine-src/src/sql2/read_only.rs +2 -2
- package/dist-engine-src/src/sql2/session.rs +47 -96
- package/dist-engine-src/src/sql2/storage/constraints.rs +1 -0
- package/dist-engine-src/src/sql2/storage/mod.rs +1 -0
- package/dist-engine-src/src/sql2/test_support/differential.rs +712 -0
- package/dist-engine-src/src/sql2/test_support/generators.rs +354 -0
- package/dist-engine-src/src/sql2/test_support/mod.rs +2 -0
- package/dist-engine-src/src/sql2/udfs/{lix_active_version_commit_id.rs → lix_active_branch_commit_id.rs} +7 -7
- package/dist-engine-src/src/sql2/udfs/mod.rs +3 -6
- package/dist-engine-src/src/sql2/write_normalization.rs +45 -22
- package/dist-engine-src/src/storage/conformance.rs +399 -0
- package/dist-engine-src/src/storage/context.rs +552 -288
- package/dist-engine-src/src/storage/mod.rs +48 -10
- package/dist-engine-src/src/storage/point.rs +440 -0
- package/dist-engine-src/src/storage/read_scope.rs +43 -64
- package/dist-engine-src/src/storage/reader.rs +867 -0
- package/dist-engine-src/src/storage/scan.rs +784 -0
- package/dist-engine-src/src/storage/spaces.rs +236 -0
- package/dist-engine-src/src/storage/stats.rs +80 -0
- package/dist-engine-src/src/storage/write_set.rs +962 -0
- package/dist-engine-src/src/storage_bench.rs +136 -4828
- package/dist-engine-src/src/test_support.rs +360 -138
- package/dist-engine-src/src/tracked_state/bench_support.rs +394 -0
- package/dist-engine-src/src/tracked_state/codec.rs +155 -1057
- package/dist-engine-src/src/tracked_state/commit_root_rebuild.rs +358 -0
- package/dist-engine-src/src/tracked_state/context.rs +1927 -993
- package/dist-engine-src/src/tracked_state/diff.rs +1715 -261
- package/dist-engine-src/src/tracked_state/merge.rs +74 -88
- package/dist-engine-src/src/tracked_state/mod.rs +19 -16
- package/dist-engine-src/src/tracked_state/{materialization.rs → row_materialization.rs} +50 -178
- package/dist-engine-src/src/tracked_state/storage.rs +243 -191
- package/dist-engine-src/src/tracked_state/tree.rs +247 -371
- package/dist-engine-src/src/tracked_state/types.rs +49 -42
- package/dist-engine-src/src/transaction/bench_support.rs +407 -0
- package/dist-engine-src/src/transaction/commit.rs +821 -713
- package/dist-engine-src/src/transaction/context.rs +705 -600
- package/dist-engine-src/src/transaction/mod.rs +13 -2
- package/dist-engine-src/src/transaction/normalization.rs +63 -76
- package/dist-engine-src/src/transaction/prep.rs +13 -13
- package/dist-engine-src/src/transaction/schema_resolver.rs +19 -5
- package/dist-engine-src/src/transaction/staging.rs +228 -434
- package/dist-engine-src/src/transaction/types.rs +41 -98
- package/dist-engine-src/src/transaction/validation.rs +382 -446
- package/dist-engine-src/src/untracked_state/codec.rs +337 -29
- package/dist-engine-src/src/untracked_state/context.rs +7 -7
- package/dist-engine-src/src/untracked_state/materialization.rs +2 -2
- package/dist-engine-src/src/untracked_state/mod.rs +1 -1
- package/dist-engine-src/src/untracked_state/storage.rs +659 -157
- package/dist-engine-src/src/untracked_state/types.rs +21 -21
- package/package.json +71 -68
- package/dist-engine-src/src/backend/kv.rs +0 -358
- package/dist-engine-src/src/backend/testing.rs +0 -658
- package/dist-engine-src/src/commit_store/codec.rs +0 -887
- package/dist-engine-src/src/commit_store/context.rs +0 -944
- package/dist-engine-src/src/commit_store/materialization.rs +0 -84
- package/dist-engine-src/src/commit_store/mod.rs +0 -16
- package/dist-engine-src/src/commit_store/storage.rs +0 -600
- package/dist-engine-src/src/commit_store/types.rs +0 -215
- package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +0 -34
- package/dist-engine-src/src/schema/builtin/lix_version_ref.json +0 -48
- package/dist-engine-src/src/session/create_version.rs +0 -88
- package/dist-engine-src/src/session/merge/apply.rs +0 -23
- package/dist-engine-src/src/session/optimization9_sql2_bench.rs +0 -100
- package/dist-engine-src/src/session/switch_version.rs +0 -109
- package/dist-engine-src/src/sql2/classify.rs +0 -182
- package/dist-engine-src/src/sql2/entity_provider.rs +0 -3211
- package/dist-engine-src/src/sql2/execute.rs +0 -3440
- package/dist-engine-src/src/sql2/public_bind/assignment.rs +0 -46
- package/dist-engine-src/src/sql2/public_bind/capability.rs +0 -41
- package/dist-engine-src/src/sql2/public_bind/dml.rs +0 -166
- package/dist-engine-src/src/sql2/public_bind/mod.rs +0 -25
- package/dist-engine-src/src/sql2/public_bind/table.rs +0 -168
- package/dist-engine-src/src/sql2/version_scope.rs +0 -394
- package/dist-engine-src/src/storage/types.rs +0 -501
- package/dist-engine-src/src/tracked_state/by_file_index.rs +0 -98
- package/dist-engine-src/src/tracked_state/materializer.rs +0 -488
- package/dist-engine-src/src/transaction/live_state_overlay.rs +0 -35
- package/dist-engine-src/src/version/lifecycle.rs +0 -221
- package/dist-engine-src/src/version/mod.rs +0 -13
- package/dist-engine-src/src/version/refs.rs +0 -330
- package/dist-engine-src/src/version/stage_rows.rs +0 -67
- package/dist-engine-src/src/version/types.rs +0 -21
|
@@ -26,31 +26,36 @@ use crate::commit_graph::CommitGraphReader;
|
|
|
26
26
|
use crate::serialize_row_metadata;
|
|
27
27
|
use crate::LixError;
|
|
28
28
|
|
|
29
|
-
use
|
|
30
|
-
use
|
|
29
|
+
use crate::sql2::change_materialization::MaterializedChange;
|
|
30
|
+
use crate::sql2::history_projection::{tombstone_identity_column_value, HistoryIdentityProjection};
|
|
31
|
+
use crate::sql2::history_route::{
|
|
31
32
|
history_descriptor_event_matches, load_history_entries, parse_history_filter,
|
|
32
33
|
HistoryColumnStyle, HistoryEntry, HistoryRoute, HistoryViewDescriptor, HISTORY_COL_CHANGE_ID,
|
|
33
|
-
HISTORY_COL_COMMIT_CREATED_AT, HISTORY_COL_DEPTH,
|
|
34
|
+
HISTORY_COL_COMMIT_CREATED_AT, HISTORY_COL_DEPTH, HISTORY_COL_ENTITY_PK, HISTORY_COL_FILE_ID,
|
|
34
35
|
HISTORY_COL_METADATA, HISTORY_COL_OBSERVED_COMMIT_ID, HISTORY_COL_SCHEMA_KEY,
|
|
35
36
|
HISTORY_COL_SNAPSHOT_CONTENT, HISTORY_COL_START_COMMIT_ID,
|
|
36
37
|
};
|
|
37
|
-
use
|
|
38
|
-
use
|
|
39
|
-
use crate::
|
|
38
|
+
use crate::sql2::result_metadata::json_field;
|
|
39
|
+
use crate::sql2::SqlHistoryQuerySource;
|
|
40
|
+
use crate::storage::StorageRead;
|
|
40
41
|
|
|
41
42
|
const FILE_DESCRIPTOR_SCHEMA_KEY: &str = "lix_file_descriptor";
|
|
42
43
|
const DIRECTORY_DESCRIPTOR_SCHEMA_KEY: &str = "lix_directory_descriptor";
|
|
43
44
|
const BLOB_REF_SCHEMA_KEY: &str = "lix_binary_blob_ref";
|
|
44
45
|
|
|
45
|
-
pub(
|
|
46
|
+
pub(super) async fn register_lix_file_history_surface<S>(
|
|
46
47
|
session: &datafusion::prelude::SessionContext,
|
|
48
|
+
surface_name: &str,
|
|
47
49
|
commit_graph: Box<dyn CommitGraphReader>,
|
|
48
|
-
query_source:
|
|
50
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
49
51
|
blob_reader: Arc<dyn BlobDataReader>,
|
|
50
|
-
) -> Result<(), LixError>
|
|
52
|
+
) -> Result<(), LixError>
|
|
53
|
+
where
|
|
54
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
55
|
+
{
|
|
51
56
|
session
|
|
52
57
|
.register_table(
|
|
53
|
-
|
|
58
|
+
surface_name,
|
|
54
59
|
Arc::new(LixFileHistoryProvider::new(
|
|
55
60
|
Arc::new(Mutex::new(commit_graph)),
|
|
56
61
|
query_source,
|
|
@@ -61,23 +66,23 @@ pub(crate) async fn register_lix_file_history_provider(
|
|
|
61
66
|
Ok(())
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
struct LixFileHistoryProvider {
|
|
69
|
+
struct LixFileHistoryProvider<S> {
|
|
65
70
|
schema: SchemaRef,
|
|
66
71
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
67
|
-
query_source:
|
|
72
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
68
73
|
blob_reader: Arc<dyn BlobDataReader>,
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
impl std::fmt::Debug for LixFileHistoryProvider {
|
|
76
|
+
impl<S> std::fmt::Debug for LixFileHistoryProvider<S> {
|
|
72
77
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
73
78
|
f.debug_struct("LixFileHistoryProvider").finish()
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
impl LixFileHistoryProvider {
|
|
82
|
+
impl<S> LixFileHistoryProvider<S> {
|
|
78
83
|
fn new(
|
|
79
84
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
80
|
-
query_source:
|
|
85
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
81
86
|
blob_reader: Arc<dyn BlobDataReader>,
|
|
82
87
|
) -> Self {
|
|
83
88
|
Self {
|
|
@@ -90,7 +95,10 @@ impl LixFileHistoryProvider {
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
#[async_trait]
|
|
93
|
-
impl TableProvider for LixFileHistoryProvider
|
|
98
|
+
impl<S> TableProvider for LixFileHistoryProvider<S>
|
|
99
|
+
where
|
|
100
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
101
|
+
{
|
|
94
102
|
fn as_any(&self) -> &dyn Any {
|
|
95
103
|
self
|
|
96
104
|
}
|
|
@@ -148,9 +156,9 @@ impl TableProvider for LixFileHistoryProvider {
|
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
struct LixFileHistoryScanExec {
|
|
159
|
+
struct LixFileHistoryScanExec<S> {
|
|
152
160
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
153
|
-
query_source:
|
|
161
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
154
162
|
blob_reader: Arc<dyn BlobDataReader>,
|
|
155
163
|
schema: SchemaRef,
|
|
156
164
|
needs_data: bool,
|
|
@@ -159,7 +167,7 @@ struct LixFileHistoryScanExec {
|
|
|
159
167
|
properties: Arc<PlanProperties>,
|
|
160
168
|
}
|
|
161
169
|
|
|
162
|
-
impl std::fmt::Debug for LixFileHistoryScanExec {
|
|
170
|
+
impl<S> std::fmt::Debug for LixFileHistoryScanExec<S> {
|
|
163
171
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
164
172
|
f.debug_struct("LixFileHistoryScanExec")
|
|
165
173
|
.field("route", &self.route)
|
|
@@ -168,10 +176,10 @@ impl std::fmt::Debug for LixFileHistoryScanExec {
|
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
impl LixFileHistoryScanExec {
|
|
179
|
+
impl<S> LixFileHistoryScanExec<S> {
|
|
172
180
|
fn new(
|
|
173
181
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
174
|
-
query_source:
|
|
182
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
175
183
|
blob_reader: Arc<dyn BlobDataReader>,
|
|
176
184
|
schema: SchemaRef,
|
|
177
185
|
needs_data: bool,
|
|
@@ -197,7 +205,7 @@ impl LixFileHistoryScanExec {
|
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
207
|
|
|
200
|
-
impl DisplayAs for LixFileHistoryScanExec {
|
|
208
|
+
impl<S> DisplayAs for LixFileHistoryScanExec<S> {
|
|
201
209
|
fn fmt_as(&self, t: DisplayFormatType, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
202
210
|
match t {
|
|
203
211
|
DisplayFormatType::Default | DisplayFormatType::Verbose => write!(
|
|
@@ -210,7 +218,10 @@ impl DisplayAs for LixFileHistoryScanExec {
|
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
|
|
213
|
-
impl ExecutionPlan for LixFileHistoryScanExec
|
|
221
|
+
impl<S> ExecutionPlan for LixFileHistoryScanExec<S>
|
|
222
|
+
where
|
|
223
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
224
|
+
{
|
|
214
225
|
fn name(&self) -> &str {
|
|
215
226
|
"LixFileHistoryScanExec"
|
|
216
227
|
}
|
|
@@ -319,7 +330,7 @@ struct FileHistoryEvent {
|
|
|
319
330
|
|
|
320
331
|
#[derive(Debug, Clone)]
|
|
321
332
|
struct FileHistoryOutputRow {
|
|
322
|
-
|
|
333
|
+
entity_pk: String,
|
|
323
334
|
id: String,
|
|
324
335
|
path: Option<String>,
|
|
325
336
|
directory_id: Option<String>,
|
|
@@ -351,13 +362,16 @@ struct BlobRefSnapshot {
|
|
|
351
362
|
blob_hash: String,
|
|
352
363
|
}
|
|
353
364
|
|
|
354
|
-
async fn load_file_history_rows(
|
|
365
|
+
async fn load_file_history_rows<S>(
|
|
355
366
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
356
|
-
query_source:
|
|
367
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
357
368
|
blob_reader: &Arc<dyn BlobDataReader>,
|
|
358
369
|
route: &HistoryRoute,
|
|
359
370
|
needs_data: bool,
|
|
360
|
-
) -> Result<Vec<FileHistoryOutputRow>, LixError>
|
|
371
|
+
) -> Result<Vec<FileHistoryOutputRow>, LixError>
|
|
372
|
+
where
|
|
373
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
374
|
+
{
|
|
361
375
|
let event_route = route.traversal_only();
|
|
362
376
|
let event_entries = load_history_entries(
|
|
363
377
|
HistoryViewDescriptor {
|
|
@@ -428,7 +442,7 @@ async fn load_file_history_rows(
|
|
|
428
442
|
.unwrap_or_else(|| descriptor.id.clone());
|
|
429
443
|
|
|
430
444
|
output.push(FileHistoryOutputRow {
|
|
431
|
-
|
|
445
|
+
entity_pk: descriptor.id.clone(),
|
|
432
446
|
id,
|
|
433
447
|
path,
|
|
434
448
|
directory_id: descriptor.directory_id.clone(),
|
|
@@ -440,18 +454,18 @@ async fn load_file_history_rows(
|
|
|
440
454
|
});
|
|
441
455
|
}
|
|
442
456
|
output.retain(|row| {
|
|
443
|
-
let
|
|
457
|
+
let entity_pk = entity_pk_json_array(&row.entity_pk).ok();
|
|
444
458
|
route.matches_surface_row(
|
|
445
459
|
FILE_DESCRIPTOR_SCHEMA_KEY,
|
|
446
|
-
|
|
447
|
-
Some(&row.
|
|
460
|
+
entity_pk.as_deref().unwrap_or(&row.entity_pk),
|
|
461
|
+
Some(&row.entity_pk),
|
|
448
462
|
row.event.depth,
|
|
449
463
|
)
|
|
450
464
|
});
|
|
451
465
|
|
|
452
466
|
output.sort_by(|left, right| {
|
|
453
|
-
left.
|
|
454
|
-
.cmp(&right.
|
|
467
|
+
left.entity_pk
|
|
468
|
+
.cmp(&right.entity_pk)
|
|
455
469
|
.then(left.event.start_commit_id.cmp(&right.event.start_commit_id))
|
|
456
470
|
.then(left.event.depth.cmp(&right.event.depth))
|
|
457
471
|
.then(
|
|
@@ -575,7 +589,7 @@ fn parse_file_history_descriptors(
|
|
|
575
589
|
.map(|entry| {
|
|
576
590
|
let Some(snapshot_content) = entry.change.snapshot_content.as_deref() else {
|
|
577
591
|
return Ok(FileHistoryDescriptorRecord {
|
|
578
|
-
id: entry.change.
|
|
592
|
+
id: entry.change.entity_pk.as_single_string_owned()?,
|
|
579
593
|
directory_id: None,
|
|
580
594
|
name: None,
|
|
581
595
|
hidden: None,
|
|
@@ -640,9 +654,9 @@ fn parse_file_history_blobs(
|
|
|
640
654
|
file_id: entry.change.file_id.clone().unwrap_or_else(|| {
|
|
641
655
|
entry
|
|
642
656
|
.change
|
|
643
|
-
.
|
|
657
|
+
.entity_pk
|
|
644
658
|
.as_single_string_owned()
|
|
645
|
-
.expect("canonical change entity
|
|
659
|
+
.expect("canonical change entity primary key should project")
|
|
646
660
|
}),
|
|
647
661
|
blob_hash: None,
|
|
648
662
|
entry: entry.clone(),
|
|
@@ -807,15 +821,15 @@ fn file_history_column_array(
|
|
|
807
821
|
.map(|row| row.data.as_deref())
|
|
808
822
|
.collect::<Vec<_>>(),
|
|
809
823
|
)) as ArrayRef,
|
|
810
|
-
|
|
824
|
+
HISTORY_COL_ENTITY_PK => Arc::new(StringArray::from(
|
|
811
825
|
rows.iter()
|
|
812
|
-
.map(|row|
|
|
826
|
+
.map(|row| entity_pk_json_array(&row.entity_pk).map(Some))
|
|
813
827
|
.collect::<std::result::Result<Vec<_>, _>>()?,
|
|
814
828
|
)) as ArrayRef,
|
|
815
829
|
HISTORY_COL_SCHEMA_KEY => {
|
|
816
830
|
string_array(rows.iter().map(|_| Some(FILE_DESCRIPTOR_SCHEMA_KEY)))
|
|
817
831
|
}
|
|
818
|
-
HISTORY_COL_FILE_ID => string_array(rows.iter().map(|row| Some(row.
|
|
832
|
+
HISTORY_COL_FILE_ID => string_array(rows.iter().map(|row| Some(row.entity_pk.as_str()))),
|
|
819
833
|
HISTORY_COL_CHANGE_ID => {
|
|
820
834
|
string_array(rows.iter().map(|row| Some(row.event.change.id.as_str())))
|
|
821
835
|
}
|
|
@@ -861,7 +875,7 @@ fn file_history_column_array(
|
|
|
861
875
|
})
|
|
862
876
|
}
|
|
863
877
|
|
|
864
|
-
fn lix_file_history_schema() -> SchemaRef {
|
|
878
|
+
pub(super) fn lix_file_history_schema() -> SchemaRef {
|
|
865
879
|
Arc::new(Schema::new(vec![
|
|
866
880
|
Field::new("id", DataType::Utf8, false),
|
|
867
881
|
Field::new("path", DataType::Utf8, true),
|
|
@@ -869,7 +883,7 @@ fn lix_file_history_schema() -> SchemaRef {
|
|
|
869
883
|
Field::new("name", DataType::Utf8, true),
|
|
870
884
|
Field::new("hidden", DataType::Boolean, true),
|
|
871
885
|
Field::new("data", DataType::Binary, true),
|
|
872
|
-
json_field(
|
|
886
|
+
json_field(HISTORY_COL_ENTITY_PK, false),
|
|
873
887
|
Field::new(HISTORY_COL_SCHEMA_KEY, DataType::Utf8, false),
|
|
874
888
|
Field::new(HISTORY_COL_FILE_ID, DataType::Utf8, true),
|
|
875
889
|
json_field(HISTORY_COL_SNAPSHOT_CONTENT, true),
|
|
@@ -894,17 +908,17 @@ fn string_array<'a>(values: impl Iterator<Item = Option<&'a str>>) -> ArrayRef {
|
|
|
894
908
|
}
|
|
895
909
|
|
|
896
910
|
fn datafusion_error_to_lix_error(error: DataFusionError) -> LixError {
|
|
897
|
-
|
|
911
|
+
crate::sql2::error::datafusion_error_to_lix_error(error)
|
|
898
912
|
}
|
|
899
913
|
|
|
900
|
-
fn
|
|
901
|
-
serde_json::to_string(&[
|
|
914
|
+
fn entity_pk_json_array(entity_pk: &str) -> Result<String, LixError> {
|
|
915
|
+
serde_json::to_string(&[entity_pk]).map_err(|error| {
|
|
902
916
|
LixError::unknown(format!(
|
|
903
|
-
"failed to encode history entity
|
|
917
|
+
"failed to encode history entity pk as JSON: {error}"
|
|
904
918
|
))
|
|
905
919
|
})
|
|
906
920
|
}
|
|
907
921
|
|
|
908
922
|
fn lix_error_to_datafusion_error(error: LixError) -> DataFusionError {
|
|
909
|
-
|
|
923
|
+
crate::sql2::error::lix_error_to_datafusion_error(error)
|
|
910
924
|
}
|
|
@@ -23,44 +23,49 @@ use tokio::sync::Mutex;
|
|
|
23
23
|
use crate::commit_graph::CommitGraphReader;
|
|
24
24
|
use crate::{serialize_row_metadata, LixError};
|
|
25
25
|
|
|
26
|
-
use
|
|
26
|
+
use crate::sql2::history_route::{
|
|
27
27
|
load_history_entries, parse_history_filter, HistoryColumnStyle, HistoryRoute,
|
|
28
28
|
HistoryViewDescriptor,
|
|
29
29
|
};
|
|
30
|
-
use
|
|
31
|
-
use
|
|
30
|
+
use crate::sql2::result_metadata::json_field;
|
|
31
|
+
use crate::sql2::SqlHistoryQuerySource;
|
|
32
|
+
use crate::storage::StorageRead;
|
|
32
33
|
|
|
33
|
-
pub(
|
|
34
|
+
pub(super) async fn register_history_provider<S>(
|
|
34
35
|
session: &SessionContext,
|
|
36
|
+
surface_name: &str,
|
|
35
37
|
commit_graph: Box<dyn CommitGraphReader>,
|
|
36
|
-
query_source:
|
|
37
|
-
) -> Result<Arc<dyn TableProvider>, LixError>
|
|
38
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
39
|
+
) -> Result<Arc<dyn TableProvider>, LixError>
|
|
40
|
+
where
|
|
41
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
42
|
+
{
|
|
38
43
|
let provider: Arc<dyn TableProvider> = Arc::new(LixStateHistoryProvider::new(
|
|
39
44
|
Arc::new(Mutex::new(commit_graph)),
|
|
40
45
|
query_source,
|
|
41
46
|
));
|
|
42
47
|
session
|
|
43
|
-
.register_table(
|
|
48
|
+
.register_table(surface_name, Arc::clone(&provider))
|
|
44
49
|
.map_err(datafusion_error_to_lix_error)?;
|
|
45
50
|
Ok(provider)
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
pub(crate) struct LixStateHistoryProvider {
|
|
53
|
+
pub(crate) struct LixStateHistoryProvider<S> {
|
|
49
54
|
schema: SchemaRef,
|
|
50
55
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
51
|
-
query_source:
|
|
56
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
impl std::fmt::Debug for LixStateHistoryProvider {
|
|
59
|
+
impl<S> std::fmt::Debug for LixStateHistoryProvider<S> {
|
|
55
60
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
56
61
|
f.debug_struct("LixStateHistoryProvider").finish()
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
impl LixStateHistoryProvider {
|
|
65
|
+
impl<S> LixStateHistoryProvider<S> {
|
|
61
66
|
pub(crate) fn new(
|
|
62
67
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
63
|
-
query_source:
|
|
68
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
64
69
|
) -> Self {
|
|
65
70
|
Self {
|
|
66
71
|
schema: lix_state_history_schema(),
|
|
@@ -71,7 +76,10 @@ impl LixStateHistoryProvider {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
#[async_trait]
|
|
74
|
-
impl TableProvider for LixStateHistoryProvider
|
|
79
|
+
impl<S> TableProvider for LixStateHistoryProvider<S>
|
|
80
|
+
where
|
|
81
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
82
|
+
{
|
|
75
83
|
fn as_any(&self) -> &dyn Any {
|
|
76
84
|
self
|
|
77
85
|
}
|
|
@@ -119,9 +127,9 @@ impl TableProvider for LixStateHistoryProvider {
|
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
|
|
122
|
-
struct LixStateHistoryScanExec {
|
|
130
|
+
struct LixStateHistoryScanExec<S> {
|
|
123
131
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
124
|
-
query_source:
|
|
132
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
125
133
|
schema: SchemaRef,
|
|
126
134
|
projection: Option<Vec<usize>>,
|
|
127
135
|
route: HistoryRoute,
|
|
@@ -129,7 +137,7 @@ struct LixStateHistoryScanExec {
|
|
|
129
137
|
properties: Arc<PlanProperties>,
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
impl std::fmt::Debug for LixStateHistoryScanExec {
|
|
140
|
+
impl<S> std::fmt::Debug for LixStateHistoryScanExec<S> {
|
|
133
141
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
134
142
|
f.debug_struct("LixStateHistoryScanExec")
|
|
135
143
|
.field("limit", &self.limit)
|
|
@@ -138,10 +146,10 @@ impl std::fmt::Debug for LixStateHistoryScanExec {
|
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
|
|
141
|
-
impl LixStateHistoryScanExec {
|
|
149
|
+
impl<S> LixStateHistoryScanExec<S> {
|
|
142
150
|
fn new(
|
|
143
151
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
144
|
-
query_source:
|
|
152
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
145
153
|
schema: SchemaRef,
|
|
146
154
|
projection: Option<Vec<usize>>,
|
|
147
155
|
route: HistoryRoute,
|
|
@@ -165,7 +173,7 @@ impl LixStateHistoryScanExec {
|
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
|
|
168
|
-
impl DisplayAs for LixStateHistoryScanExec {
|
|
176
|
+
impl<S> DisplayAs for LixStateHistoryScanExec<S> {
|
|
169
177
|
fn fmt_as(&self, t: DisplayFormatType, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
170
178
|
match t {
|
|
171
179
|
DisplayFormatType::Default | DisplayFormatType::Verbose => {
|
|
@@ -180,7 +188,10 @@ impl DisplayAs for LixStateHistoryScanExec {
|
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
190
|
|
|
183
|
-
impl ExecutionPlan for LixStateHistoryScanExec
|
|
191
|
+
impl<S> ExecutionPlan for LixStateHistoryScanExec<S>
|
|
192
|
+
where
|
|
193
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
194
|
+
{
|
|
184
195
|
fn name(&self) -> &str {
|
|
185
196
|
"LixStateHistoryScanExec"
|
|
186
197
|
}
|
|
@@ -266,9 +277,9 @@ impl ExecutionPlan for LixStateHistoryScanExec {
|
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
279
|
|
|
269
|
-
fn lix_state_history_schema() -> SchemaRef {
|
|
280
|
+
pub(super) fn lix_state_history_schema() -> SchemaRef {
|
|
270
281
|
Arc::new(Schema::new(vec![
|
|
271
|
-
json_field("
|
|
282
|
+
json_field("entity_pk", false),
|
|
272
283
|
Field::new("schema_key", DataType::Utf8, false),
|
|
273
284
|
Field::new("file_id", DataType::Utf8, true),
|
|
274
285
|
json_field("snapshot_content", true),
|
|
@@ -298,7 +309,7 @@ fn projected_schema(base_schema: &SchemaRef, projection: Option<&Vec<usize>>) ->
|
|
|
298
309
|
|
|
299
310
|
#[derive(Debug, Clone)]
|
|
300
311
|
struct StateHistorySqlRow {
|
|
301
|
-
|
|
312
|
+
entity_pk: String,
|
|
302
313
|
schema_key: String,
|
|
303
314
|
file_id: Option<String>,
|
|
304
315
|
snapshot_content: Option<String>,
|
|
@@ -319,7 +330,7 @@ fn state_history_record_batch(
|
|
|
319
330
|
.iter()
|
|
320
331
|
.map(|field| {
|
|
321
332
|
Ok(match field.name().as_str() {
|
|
322
|
-
"
|
|
333
|
+
"entity_pk" => string_array(rows.iter().map(|row| Some(row.entity_pk.as_str()))),
|
|
323
334
|
"schema_key" => string_array(rows.iter().map(|row| Some(row.schema_key.as_str()))),
|
|
324
335
|
"file_id" => string_array(rows.iter().map(|row| row.file_id.as_deref())),
|
|
325
336
|
"snapshot_content" => {
|
|
@@ -358,11 +369,14 @@ fn string_array<'a>(values: impl Iterator<Item = Option<&'a str>>) -> ArrayRef {
|
|
|
358
369
|
Arc::new(StringArray::from(values.collect::<Vec<_>>())) as ArrayRef
|
|
359
370
|
}
|
|
360
371
|
|
|
361
|
-
async fn load_state_history_rows(
|
|
372
|
+
async fn load_state_history_rows<S>(
|
|
362
373
|
commit_graph: Arc<Mutex<Box<dyn CommitGraphReader>>>,
|
|
363
|
-
query_source:
|
|
374
|
+
query_source: SqlHistoryQuerySource<S>,
|
|
364
375
|
route: &HistoryRoute,
|
|
365
|
-
) -> Result<Vec<StateHistorySqlRow>, LixError>
|
|
376
|
+
) -> Result<Vec<StateHistorySqlRow>, LixError>
|
|
377
|
+
where
|
|
378
|
+
S: StorageRead + Clone + Send + Sync + 'static,
|
|
379
|
+
{
|
|
366
380
|
let entries = load_history_entries(
|
|
367
381
|
HistoryViewDescriptor {
|
|
368
382
|
view_name: "lix_state_history",
|
|
@@ -378,7 +392,7 @@ async fn load_state_history_rows(
|
|
|
378
392
|
.into_iter()
|
|
379
393
|
.map(|entry| -> Result<StateHistorySqlRow, LixError> {
|
|
380
394
|
Ok(StateHistorySqlRow {
|
|
381
|
-
|
|
395
|
+
entity_pk: entry.change.entity_pk.as_json_array_text()?,
|
|
382
396
|
schema_key: entry.change.schema_key,
|
|
383
397
|
file_id: entry.change.file_id,
|
|
384
398
|
snapshot_content: entry.change.snapshot_content,
|
|
@@ -393,8 +407,8 @@ async fn load_state_history_rows(
|
|
|
393
407
|
.collect::<Result<Vec<_>, _>>()?;
|
|
394
408
|
|
|
395
409
|
rows.sort_by(|left, right| {
|
|
396
|
-
left.
|
|
397
|
-
.cmp(&right.
|
|
410
|
+
left.entity_pk
|
|
411
|
+
.cmp(&right.entity_pk)
|
|
398
412
|
.then(left.file_id.cmp(&right.file_id))
|
|
399
413
|
.then(left.schema_key.cmp(&right.schema_key))
|
|
400
414
|
.then(left.depth.cmp(&right.depth))
|
|
@@ -404,9 +418,9 @@ async fn load_state_history_rows(
|
|
|
404
418
|
}
|
|
405
419
|
|
|
406
420
|
fn datafusion_error_to_lix_error(error: DataFusionError) -> LixError {
|
|
407
|
-
|
|
421
|
+
crate::sql2::error::datafusion_error_to_lix_error(error)
|
|
408
422
|
}
|
|
409
423
|
|
|
410
424
|
fn lix_error_to_datafusion_error(error: LixError) -> DataFusionError {
|
|
411
|
-
|
|
425
|
+
crate::sql2::error::lix_error_to_datafusion_error(error)
|
|
412
426
|
}
|