@peerbit/native-backbone 0.2.8 → 0.2.10
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 +55 -20
- package/dist/src/index.d.ts +101 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1120 -74
- package/dist/src/index.js.map +1 -1
- package/dist/wasm/README.md +55 -20
- package/dist/wasm/native_backbone.d.ts +118 -79
- package/dist/wasm/native_backbone.js +227 -0
- package/dist/wasm/native_backbone_bg.wasm +0 -0
- package/dist/wasm/native_backbone_bg.wasm.d.ts +87 -79
- package/package.json +1 -1
- package/src/append_tx/committed_latest.rs +10 -5
- package/src/append_tx/committed_no_next.rs +6 -3
- package/src/append_tx/facts.rs +427 -1
- package/src/append_tx/mod.rs +51 -18
- package/src/append_tx/storage.rs +12 -2
- package/src/index.ts +1703 -231
|
@@ -7,7 +7,7 @@ use wasm_bindgen::prelude::*;
|
|
|
7
7
|
|
|
8
8
|
use crate::append_tx::{
|
|
9
9
|
ensure_batch_append_lens, ensure_batch_projection_lens, no_next_compact_entry_row,
|
|
10
|
-
push_optional_trim_result, required_projection_encoded_document,
|
|
10
|
+
push_optional_trim_result, push_trim_gid_extension, required_projection_encoded_document,
|
|
11
11
|
LatestCompactBatchPendingAppend,
|
|
12
12
|
};
|
|
13
13
|
use crate::documents::{
|
|
@@ -965,7 +965,7 @@ impl NativePeerbitBackbone {
|
|
|
965
965
|
let (meta_data, payload_data) =
|
|
966
966
|
self.copy_append_inputs_profiled(meta_datas.get(index_u32), &payload_bytes)?;
|
|
967
967
|
|
|
968
|
-
let (entry_facts, trim_hashes) = self.prepare_no_next_log_append_profiled(
|
|
968
|
+
let (entry_facts, trim_hashes, trim_gids) = self.prepare_no_next_log_append_profiled(
|
|
969
969
|
wall_times.get_index(index_u32),
|
|
970
970
|
logicals.get_index(index_u32),
|
|
971
971
|
gid.clone(),
|
|
@@ -1000,6 +1000,7 @@ impl NativePeerbitBackbone {
|
|
|
1000
1000
|
gid,
|
|
1001
1001
|
entry_facts,
|
|
1002
1002
|
trim_hashes,
|
|
1003
|
+
trim_gids,
|
|
1003
1004
|
document_index_commit,
|
|
1004
1005
|
previous_document_context: None,
|
|
1005
1006
|
delete_trimmed_document_heads,
|
|
@@ -1061,6 +1062,7 @@ impl NativePeerbitBackbone {
|
|
|
1061
1062
|
document_trimmed_heads_processed,
|
|
1062
1063
|
);
|
|
1063
1064
|
}
|
|
1065
|
+
push_trim_gid_extension(&row, pending.trim_gids);
|
|
1064
1066
|
out.push(&row);
|
|
1065
1067
|
if let Some(started) = result_row_started {
|
|
1066
1068
|
self.append_profile.result_row_ms += crate::time::now_ms() - started;
|
|
@@ -1098,7 +1100,7 @@ impl NativePeerbitBackbone {
|
|
|
1098
1100
|
let (meta_data, payload_data) =
|
|
1099
1101
|
self.copy_append_inputs_profiled(meta_data, &payload_data)?;
|
|
1100
1102
|
|
|
1101
|
-
let (entry_facts, trim_hashes) = self.prepare_no_next_log_append_profiled(
|
|
1103
|
+
let (entry_facts, trim_hashes, trim_gids) = self.prepare_no_next_log_append_profiled(
|
|
1102
1104
|
wall_time,
|
|
1103
1105
|
logical,
|
|
1104
1106
|
gid.clone(),
|
|
@@ -1156,6 +1158,7 @@ impl NativePeerbitBackbone {
|
|
|
1156
1158
|
let result_row_started = profile_enabled.then(crate::time::now_ms);
|
|
1157
1159
|
let out = no_next_compact_entry_row(&self.resolution, &entry_facts, &coordinate_facts);
|
|
1158
1160
|
push_optional_trim_result(&out, trim_hashes, document_trimmed_heads_processed);
|
|
1161
|
+
push_trim_gid_extension(&out, trim_gids);
|
|
1159
1162
|
if let Some(started) = result_row_started {
|
|
1160
1163
|
self.append_profile.result_row_ms += crate::time::now_ms() - started;
|
|
1161
1164
|
}
|
package/src/append_tx/facts.rs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use js_sys::{Array, Uint8Array};
|
|
2
|
-
use peerbit_log_rust::LogIndexEntry;
|
|
2
|
+
use peerbit_log_rust::{LogIndexEntry, NativeCommittedEntryFacts};
|
|
3
3
|
use wasm_bindgen::prelude::*;
|
|
4
4
|
|
|
5
5
|
use crate::append_tx::{
|
|
@@ -41,8 +41,82 @@ fn log_trim_entries_to_rows(values: Vec<LogIndexEntry>) -> Array {
|
|
|
41
41
|
out
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/// Additive compact row carrying the gid paired with every trimmed hash.
|
|
45
|
+
/// The legacy hash-only compact row remains frozen in `append_tx::mod`.
|
|
46
|
+
fn compact_committed_entry_facts_trim_refs_to_row(
|
|
47
|
+
entry: &NativeCommittedEntryFacts,
|
|
48
|
+
trim_hashes: Vec<String>,
|
|
49
|
+
trim_gids: Vec<String>,
|
|
50
|
+
document_trimmed_heads_processed: bool,
|
|
51
|
+
) -> Array {
|
|
52
|
+
let row = Array::new();
|
|
53
|
+
row.push(&JsValue::from_str(&entry.hash));
|
|
54
|
+
row.push(&JsValue::from_f64(entry.byte_length as f64));
|
|
55
|
+
row.push(&Uint8Array::from(entry.meta_bytes.as_slice()));
|
|
56
|
+
row.push(&Uint8Array::from(entry.hash_digest_bytes.as_slice()));
|
|
57
|
+
row.push(&strings_to_array(trim_hashes));
|
|
58
|
+
row.push(&strings_to_array(trim_gids));
|
|
59
|
+
row.push(&JsValue::from_bool(document_trimmed_heads_processed));
|
|
60
|
+
row
|
|
61
|
+
}
|
|
62
|
+
|
|
44
63
|
#[wasm_bindgen]
|
|
45
64
|
impl NativePeerbitBackbone {
|
|
65
|
+
/// Compact counterpart to `prepare_plain_entry_commit_facts`. This is an
|
|
66
|
+
/// additive export so older native bundles retain their frozen row shape.
|
|
67
|
+
#[allow(clippy::too_many_arguments)]
|
|
68
|
+
pub fn prepare_plain_entry_commit_facts_trim_refs(
|
|
69
|
+
&mut self,
|
|
70
|
+
wall_time: u64,
|
|
71
|
+
logical: u32,
|
|
72
|
+
gid: String,
|
|
73
|
+
next: Array,
|
|
74
|
+
entry_type: u8,
|
|
75
|
+
meta_data: JsValue,
|
|
76
|
+
payload_data: Uint8Array,
|
|
77
|
+
trim_length_to: usize,
|
|
78
|
+
) -> Result<Array, JsValue> {
|
|
79
|
+
let (entry_facts, trim_refs) = if next.length() == 0 {
|
|
80
|
+
self.log
|
|
81
|
+
.prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_trim_refs(
|
|
82
|
+
&self.builder,
|
|
83
|
+
&mut self.blocks,
|
|
84
|
+
wall_time,
|
|
85
|
+
logical,
|
|
86
|
+
gid,
|
|
87
|
+
entry_type,
|
|
88
|
+
optional_bytes_from_js(meta_data, "meta data")?,
|
|
89
|
+
payload_data.to_vec(),
|
|
90
|
+
trim_length_to,
|
|
91
|
+
None,
|
|
92
|
+
)?
|
|
93
|
+
} else {
|
|
94
|
+
self.log
|
|
95
|
+
.prepare_entry_v0_plain_entry_commit_facts_core_profiled_and_put_with_builder_trim_refs(
|
|
96
|
+
&self.builder,
|
|
97
|
+
&mut self.blocks,
|
|
98
|
+
wall_time,
|
|
99
|
+
logical,
|
|
100
|
+
gid,
|
|
101
|
+
strings_from_array(next)?,
|
|
102
|
+
entry_type,
|
|
103
|
+
optional_bytes_from_js(meta_data, "meta data")?,
|
|
104
|
+
payload_data.to_vec(),
|
|
105
|
+
Some(trim_length_to),
|
|
106
|
+
None,
|
|
107
|
+
)?
|
|
108
|
+
};
|
|
109
|
+
let out = Array::new();
|
|
110
|
+
out.push(&committed_entry_facts_to_row(
|
|
111
|
+
&entry_facts,
|
|
112
|
+
!entry_facts.next.is_empty(),
|
|
113
|
+
));
|
|
114
|
+
let (trim_hashes, trim_gids) = trim_refs.into_iter().unzip();
|
|
115
|
+
out.push(&strings_to_array(trim_hashes));
|
|
116
|
+
out.push(&strings_to_array(trim_gids));
|
|
117
|
+
Ok(out)
|
|
118
|
+
}
|
|
119
|
+
|
|
46
120
|
#[allow(clippy::too_many_arguments)]
|
|
47
121
|
pub fn prepare_plain_entry_commit_facts(
|
|
48
122
|
&mut self,
|
|
@@ -472,6 +546,55 @@ impl NativePeerbitBackbone {
|
|
|
472
546
|
)
|
|
473
547
|
}
|
|
474
548
|
|
|
549
|
+
/// Additive trim-ref counterpart to the compact inline document-index
|
|
550
|
+
/// append. The hash-only export above retains its frozen row layout.
|
|
551
|
+
#[allow(clippy::too_many_arguments)]
|
|
552
|
+
pub fn prepare_plain_entry_commit_no_next_facts_document_index_compact_trim_refs(
|
|
553
|
+
&mut self,
|
|
554
|
+
wall_time: u64,
|
|
555
|
+
logical: u32,
|
|
556
|
+
gid: String,
|
|
557
|
+
entry_type: u8,
|
|
558
|
+
meta_data: JsValue,
|
|
559
|
+
payload_data: Uint8Array,
|
|
560
|
+
trim_length_to: usize,
|
|
561
|
+
document_key: String,
|
|
562
|
+
document_value_prefix_bytes: Vec<u8>,
|
|
563
|
+
document_existing_created: String,
|
|
564
|
+
document_byte_element_index_limit: usize,
|
|
565
|
+
document_delete_trimmed_heads: bool,
|
|
566
|
+
document_projection_plan: JsValue,
|
|
567
|
+
document_projection_encoded_document: JsValue,
|
|
568
|
+
document_projection_signer: JsValue,
|
|
569
|
+
) -> Result<Array, JsValue> {
|
|
570
|
+
let document_gid = gid.clone();
|
|
571
|
+
let payload_size = payload_data.length();
|
|
572
|
+
let document_index_commit = document_index_append_commit(
|
|
573
|
+
document_key,
|
|
574
|
+
document_value_prefix_bytes,
|
|
575
|
+
document_existing_created,
|
|
576
|
+
document_byte_element_index_limit,
|
|
577
|
+
document_delete_trimmed_heads,
|
|
578
|
+
document_projection_plan,
|
|
579
|
+
document_projection_encoded_document,
|
|
580
|
+
document_projection_signer,
|
|
581
|
+
)?;
|
|
582
|
+
Ok(
|
|
583
|
+
self.prepare_plain_entry_commit_no_next_document_index_compact_trim_refs(
|
|
584
|
+
wall_time,
|
|
585
|
+
logical,
|
|
586
|
+
gid,
|
|
587
|
+
entry_type,
|
|
588
|
+
meta_data,
|
|
589
|
+
payload_data,
|
|
590
|
+
trim_length_to,
|
|
591
|
+
document_gid,
|
|
592
|
+
payload_size,
|
|
593
|
+
document_index_commit,
|
|
594
|
+
)?,
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
|
|
475
598
|
#[allow(clippy::too_many_arguments)]
|
|
476
599
|
pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_trim_hashes(
|
|
477
600
|
&mut self,
|
|
@@ -560,6 +683,50 @@ impl NativePeerbitBackbone {
|
|
|
560
683
|
)
|
|
561
684
|
}
|
|
562
685
|
|
|
686
|
+
/// Additive trim-ref counterpart to the latest-context document-index
|
|
687
|
+
/// append. Gids are returned parallel to the existing trimmed hashes.
|
|
688
|
+
#[allow(clippy::too_many_arguments)]
|
|
689
|
+
pub fn prepare_plain_entry_commit_latest_facts_document_index_trim_refs(
|
|
690
|
+
&mut self,
|
|
691
|
+
wall_time: u64,
|
|
692
|
+
logical: u32,
|
|
693
|
+
fallback_gid: String,
|
|
694
|
+
entry_type: u8,
|
|
695
|
+
meta_data: JsValue,
|
|
696
|
+
payload_data: Uint8Array,
|
|
697
|
+
trim_length_to: JsValue,
|
|
698
|
+
document_key: String,
|
|
699
|
+
document_value_prefix_bytes: Vec<u8>,
|
|
700
|
+
document_byte_element_index_limit: usize,
|
|
701
|
+
document_delete_trimmed_heads: bool,
|
|
702
|
+
document_projection_plan: JsValue,
|
|
703
|
+
document_projection_encoded_document: JsValue,
|
|
704
|
+
document_projection_signer: JsValue,
|
|
705
|
+
) -> Result<Array, JsValue> {
|
|
706
|
+
let document_index_commit = document_index_append_commit(
|
|
707
|
+
document_key,
|
|
708
|
+
document_value_prefix_bytes,
|
|
709
|
+
String::new(),
|
|
710
|
+
document_byte_element_index_limit,
|
|
711
|
+
document_delete_trimmed_heads,
|
|
712
|
+
document_projection_plan,
|
|
713
|
+
document_projection_encoded_document,
|
|
714
|
+
document_projection_signer,
|
|
715
|
+
)?;
|
|
716
|
+
Ok(
|
|
717
|
+
self.prepare_plain_entry_commit_latest_document_index_trim_refs_inner(
|
|
718
|
+
wall_time,
|
|
719
|
+
logical,
|
|
720
|
+
fallback_gid,
|
|
721
|
+
entry_type,
|
|
722
|
+
meta_data,
|
|
723
|
+
payload_data,
|
|
724
|
+
trim_length_to,
|
|
725
|
+
document_index_commit,
|
|
726
|
+
)?,
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
|
|
563
730
|
#[allow(clippy::too_many_arguments)]
|
|
564
731
|
pub fn prepare_plain_entry_commit_latest_facts_document_index_cached_plan_trim_hashes(
|
|
565
732
|
&mut self,
|
|
@@ -600,6 +767,48 @@ impl NativePeerbitBackbone {
|
|
|
600
767
|
)
|
|
601
768
|
}
|
|
602
769
|
|
|
770
|
+
/// Cached-plan counterpart to
|
|
771
|
+
/// `prepare_plain_entry_commit_latest_facts_document_index_trim_refs`.
|
|
772
|
+
#[allow(clippy::too_many_arguments)]
|
|
773
|
+
pub fn prepare_plain_entry_commit_latest_facts_document_index_cached_plan_trim_refs(
|
|
774
|
+
&mut self,
|
|
775
|
+
wall_time: u64,
|
|
776
|
+
logical: u32,
|
|
777
|
+
fallback_gid: String,
|
|
778
|
+
entry_type: u8,
|
|
779
|
+
meta_data: JsValue,
|
|
780
|
+
payload_data: Uint8Array,
|
|
781
|
+
trim_length_to: JsValue,
|
|
782
|
+
document_key: String,
|
|
783
|
+
document_byte_element_index_limit: usize,
|
|
784
|
+
document_delete_trimmed_heads: bool,
|
|
785
|
+
document_projection_plan_id: u32,
|
|
786
|
+
document_projection_encoded_document: JsValue,
|
|
787
|
+
document_projection_signer: JsValue,
|
|
788
|
+
) -> Result<Array, JsValue> {
|
|
789
|
+
let document_index_commit = document_index_cached_projection_append_commit(
|
|
790
|
+
document_key,
|
|
791
|
+
String::new(),
|
|
792
|
+
document_byte_element_index_limit,
|
|
793
|
+
document_delete_trimmed_heads,
|
|
794
|
+
document_projection_plan_id,
|
|
795
|
+
document_projection_encoded_document,
|
|
796
|
+
document_projection_signer,
|
|
797
|
+
)?;
|
|
798
|
+
Ok(
|
|
799
|
+
self.prepare_plain_entry_commit_latest_document_index_trim_refs_inner(
|
|
800
|
+
wall_time,
|
|
801
|
+
logical,
|
|
802
|
+
fallback_gid,
|
|
803
|
+
entry_type,
|
|
804
|
+
meta_data,
|
|
805
|
+
payload_data,
|
|
806
|
+
trim_length_to,
|
|
807
|
+
document_index_commit,
|
|
808
|
+
)?,
|
|
809
|
+
)
|
|
810
|
+
}
|
|
811
|
+
|
|
603
812
|
#[allow(clippy::too_many_arguments)]
|
|
604
813
|
pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes(
|
|
605
814
|
&mut self,
|
|
@@ -646,6 +855,52 @@ impl NativePeerbitBackbone {
|
|
|
646
855
|
)
|
|
647
856
|
}
|
|
648
857
|
|
|
858
|
+
/// Additive trim-ref counterpart to the cached-plan compact append.
|
|
859
|
+
#[allow(clippy::too_many_arguments)]
|
|
860
|
+
pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_refs(
|
|
861
|
+
&mut self,
|
|
862
|
+
wall_time: u64,
|
|
863
|
+
logical: u32,
|
|
864
|
+
gid: String,
|
|
865
|
+
entry_type: u8,
|
|
866
|
+
meta_data: JsValue,
|
|
867
|
+
payload_data: Uint8Array,
|
|
868
|
+
trim_length_to: usize,
|
|
869
|
+
document_key: String,
|
|
870
|
+
document_existing_created: String,
|
|
871
|
+
document_byte_element_index_limit: usize,
|
|
872
|
+
document_delete_trimmed_heads: bool,
|
|
873
|
+
document_projection_plan_id: u32,
|
|
874
|
+
document_projection_encoded_document: JsValue,
|
|
875
|
+
document_projection_signer: JsValue,
|
|
876
|
+
) -> Result<Array, JsValue> {
|
|
877
|
+
let document_gid = gid.clone();
|
|
878
|
+
let payload_size = payload_data.length();
|
|
879
|
+
let document_index_commit = document_index_cached_projection_append_commit(
|
|
880
|
+
document_key,
|
|
881
|
+
document_existing_created,
|
|
882
|
+
document_byte_element_index_limit,
|
|
883
|
+
document_delete_trimmed_heads,
|
|
884
|
+
document_projection_plan_id,
|
|
885
|
+
document_projection_encoded_document,
|
|
886
|
+
document_projection_signer,
|
|
887
|
+
)?;
|
|
888
|
+
Ok(
|
|
889
|
+
self.prepare_plain_entry_commit_no_next_document_index_compact_trim_refs(
|
|
890
|
+
wall_time,
|
|
891
|
+
logical,
|
|
892
|
+
gid,
|
|
893
|
+
entry_type,
|
|
894
|
+
meta_data,
|
|
895
|
+
payload_data,
|
|
896
|
+
trim_length_to,
|
|
897
|
+
document_gid,
|
|
898
|
+
payload_size,
|
|
899
|
+
document_index_commit,
|
|
900
|
+
)?,
|
|
901
|
+
)
|
|
902
|
+
}
|
|
903
|
+
|
|
649
904
|
#[allow(clippy::too_many_arguments)]
|
|
650
905
|
pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes_plain_put_payload(
|
|
651
906
|
&mut self,
|
|
@@ -706,6 +961,71 @@ impl NativePeerbitBackbone {
|
|
|
706
961
|
document_trimmed_heads_processed,
|
|
707
962
|
))
|
|
708
963
|
}
|
|
964
|
+
|
|
965
|
+
/// Additive trim-ref counterpart to the cached-plan compact append that
|
|
966
|
+
/// reuses the plain payload bytes for the document-index put.
|
|
967
|
+
#[allow(clippy::too_many_arguments)]
|
|
968
|
+
pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_refs_plain_put_payload(
|
|
969
|
+
&mut self,
|
|
970
|
+
wall_time: u64,
|
|
971
|
+
logical: u32,
|
|
972
|
+
gid: String,
|
|
973
|
+
entry_type: u8,
|
|
974
|
+
meta_data: JsValue,
|
|
975
|
+
payload_data: Uint8Array,
|
|
976
|
+
trim_length_to: usize,
|
|
977
|
+
document_key: String,
|
|
978
|
+
document_existing_created: String,
|
|
979
|
+
document_byte_element_index_limit: usize,
|
|
980
|
+
document_delete_trimmed_heads: bool,
|
|
981
|
+
document_projection_plan_id: u32,
|
|
982
|
+
document_projection_signer: JsValue,
|
|
983
|
+
) -> Result<Array, JsValue> {
|
|
984
|
+
let document_gid = gid.clone();
|
|
985
|
+
let payload_size = payload_data.length();
|
|
986
|
+
let payload_data = payload_data.to_vec();
|
|
987
|
+
let document_index_commit =
|
|
988
|
+
document_index_cached_projection_plain_put_payload_append_commit(
|
|
989
|
+
document_key,
|
|
990
|
+
document_existing_created,
|
|
991
|
+
document_byte_element_index_limit,
|
|
992
|
+
document_delete_trimmed_heads,
|
|
993
|
+
document_projection_plan_id,
|
|
994
|
+
document_projection_signer,
|
|
995
|
+
)?;
|
|
996
|
+
let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
|
|
997
|
+
let (entry_facts, trim_refs) = self
|
|
998
|
+
.log
|
|
999
|
+
.prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_trim_refs_borrowed(
|
|
1000
|
+
&self.builder,
|
|
1001
|
+
&mut self.blocks,
|
|
1002
|
+
wall_time,
|
|
1003
|
+
logical,
|
|
1004
|
+
gid,
|
|
1005
|
+
entry_type,
|
|
1006
|
+
optional_bytes_from_js(meta_data, "meta data")?,
|
|
1007
|
+
&payload_data,
|
|
1008
|
+
trim_length_to,
|
|
1009
|
+
None,
|
|
1010
|
+
)?;
|
|
1011
|
+
self.put_document_index_for_append_with_plain_put_payload(
|
|
1012
|
+
Some(document_index_commit),
|
|
1013
|
+
wall_time,
|
|
1014
|
+
&entry_facts.hash,
|
|
1015
|
+
&document_gid,
|
|
1016
|
+
payload_size,
|
|
1017
|
+
Some(&payload_data),
|
|
1018
|
+
)?;
|
|
1019
|
+
let (trim_hashes, trim_gids): (Vec<String>, Vec<String>) = trim_refs.into_iter().unzip();
|
|
1020
|
+
let document_trimmed_heads_processed = delete_trimmed_document_heads
|
|
1021
|
+
&& self.delete_documents_by_context_heads_profiled(&trim_hashes);
|
|
1022
|
+
Ok(compact_committed_entry_facts_trim_refs_to_row(
|
|
1023
|
+
&entry_facts,
|
|
1024
|
+
trim_hashes,
|
|
1025
|
+
trim_gids,
|
|
1026
|
+
document_trimmed_heads_processed,
|
|
1027
|
+
))
|
|
1028
|
+
}
|
|
709
1029
|
}
|
|
710
1030
|
|
|
711
1031
|
impl NativePeerbitBackbone {
|
|
@@ -798,6 +1118,53 @@ impl NativePeerbitBackbone {
|
|
|
798
1118
|
Ok(out)
|
|
799
1119
|
}
|
|
800
1120
|
|
|
1121
|
+
#[allow(clippy::too_many_arguments)]
|
|
1122
|
+
fn prepare_plain_entry_commit_no_next_document_index_compact_trim_refs(
|
|
1123
|
+
&mut self,
|
|
1124
|
+
wall_time: u64,
|
|
1125
|
+
logical: u32,
|
|
1126
|
+
gid: String,
|
|
1127
|
+
entry_type: u8,
|
|
1128
|
+
meta_data: JsValue,
|
|
1129
|
+
payload_data: Uint8Array,
|
|
1130
|
+
trim_length_to: usize,
|
|
1131
|
+
document_gid: String,
|
|
1132
|
+
payload_size: u32,
|
|
1133
|
+
document_index_commit: DocumentIndexAppendCommit,
|
|
1134
|
+
) -> Result<Array, BackboneError> {
|
|
1135
|
+
let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
|
|
1136
|
+
let (entry_facts, trim_refs) = self
|
|
1137
|
+
.log
|
|
1138
|
+
.prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_trim_refs(
|
|
1139
|
+
&self.builder,
|
|
1140
|
+
&mut self.blocks,
|
|
1141
|
+
wall_time,
|
|
1142
|
+
logical,
|
|
1143
|
+
gid,
|
|
1144
|
+
entry_type,
|
|
1145
|
+
optional_bytes_from_js(meta_data, "meta data")?,
|
|
1146
|
+
payload_data.to_vec(),
|
|
1147
|
+
trim_length_to,
|
|
1148
|
+
None,
|
|
1149
|
+
)?;
|
|
1150
|
+
self.put_document_index_for_append(
|
|
1151
|
+
Some(document_index_commit),
|
|
1152
|
+
wall_time,
|
|
1153
|
+
&entry_facts.hash,
|
|
1154
|
+
&document_gid,
|
|
1155
|
+
payload_size,
|
|
1156
|
+
)?;
|
|
1157
|
+
let (trim_hashes, trim_gids): (Vec<String>, Vec<String>) = trim_refs.into_iter().unzip();
|
|
1158
|
+
let document_trimmed_heads_processed = delete_trimmed_document_heads
|
|
1159
|
+
&& self.delete_documents_by_context_heads_profiled(&trim_hashes);
|
|
1160
|
+
Ok(compact_committed_entry_facts_trim_refs_to_row(
|
|
1161
|
+
&entry_facts,
|
|
1162
|
+
trim_hashes,
|
|
1163
|
+
trim_gids,
|
|
1164
|
+
document_trimmed_heads_processed,
|
|
1165
|
+
))
|
|
1166
|
+
}
|
|
1167
|
+
|
|
801
1168
|
#[allow(clippy::too_many_arguments)]
|
|
802
1169
|
fn prepare_plain_entry_commit_latest_document_index_trim_hashes_inner(
|
|
803
1170
|
&mut self,
|
|
@@ -854,4 +1221,63 @@ impl NativePeerbitBackbone {
|
|
|
854
1221
|
);
|
|
855
1222
|
Ok(out)
|
|
856
1223
|
}
|
|
1224
|
+
|
|
1225
|
+
#[allow(clippy::too_many_arguments)]
|
|
1226
|
+
fn prepare_plain_entry_commit_latest_document_index_trim_refs_inner(
|
|
1227
|
+
&mut self,
|
|
1228
|
+
wall_time: u64,
|
|
1229
|
+
logical: u32,
|
|
1230
|
+
fallback_gid: String,
|
|
1231
|
+
entry_type: u8,
|
|
1232
|
+
meta_data: JsValue,
|
|
1233
|
+
payload_data: Uint8Array,
|
|
1234
|
+
trim_length_to: JsValue,
|
|
1235
|
+
mut document_index_commit: DocumentIndexAppendCommit,
|
|
1236
|
+
) -> Result<Array, BackboneError> {
|
|
1237
|
+
let trim_length_to = optional_usize_from_js(trim_length_to, "trimLengthTo")?;
|
|
1238
|
+
let (previous_context, gid, next_hashes) =
|
|
1239
|
+
self.resolve_latest_document_append_context(&mut document_index_commit, fallback_gid)?;
|
|
1240
|
+
let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
|
|
1241
|
+
let payload_size = payload_data.length();
|
|
1242
|
+
let (entry_facts, trim_refs) = self
|
|
1243
|
+
.log
|
|
1244
|
+
.prepare_entry_v0_plain_entry_commit_facts_core_profiled_and_put_with_builder_trim_refs(
|
|
1245
|
+
&self.builder,
|
|
1246
|
+
&mut self.blocks,
|
|
1247
|
+
wall_time,
|
|
1248
|
+
logical,
|
|
1249
|
+
gid.clone(),
|
|
1250
|
+
next_hashes,
|
|
1251
|
+
entry_type,
|
|
1252
|
+
optional_bytes_from_js(meta_data, "meta data")?,
|
|
1253
|
+
payload_data.to_vec(),
|
|
1254
|
+
trim_length_to,
|
|
1255
|
+
None,
|
|
1256
|
+
)?;
|
|
1257
|
+
self.put_document_index_for_append(
|
|
1258
|
+
Some(document_index_commit),
|
|
1259
|
+
wall_time,
|
|
1260
|
+
&entry_facts.hash,
|
|
1261
|
+
&gid,
|
|
1262
|
+
payload_size,
|
|
1263
|
+
)?;
|
|
1264
|
+
let (trim_hashes, trim_gids): (Vec<String>, Vec<String>) = trim_refs.into_iter().unzip();
|
|
1265
|
+
let document_trimmed_heads_processed = delete_trimmed_document_heads
|
|
1266
|
+
&& self.delete_documents_by_context_heads_profiled(&trim_hashes);
|
|
1267
|
+
let out = Array::new();
|
|
1268
|
+
out.push(&committed_entry_facts_to_row(
|
|
1269
|
+
&entry_facts,
|
|
1270
|
+
!entry_facts.next.is_empty(),
|
|
1271
|
+
));
|
|
1272
|
+
out.push(&strings_to_array(trim_hashes));
|
|
1273
|
+
out.push(&strings_to_array(trim_gids));
|
|
1274
|
+
out.push(&JsValue::from_bool(document_trimmed_heads_processed));
|
|
1275
|
+
out.push(
|
|
1276
|
+
&previous_context
|
|
1277
|
+
.as_ref()
|
|
1278
|
+
.map(|context| document_context_facts_to_row(context).into())
|
|
1279
|
+
.unwrap_or(JsValue::UNDEFINED),
|
|
1280
|
+
);
|
|
1281
|
+
Ok(out)
|
|
1282
|
+
}
|
|
857
1283
|
}
|