Save and apply an already-built git-import graph change. This bypasses record/globalize and eager CRDT table writes. The caller has already compiled Git's snapshot delta into line-level graph ops.
(
&self,
change: Change,
deleted_paths: &[String],
options: InsertOptions,
)
| 906 | /// This bypasses record/globalize and eager CRDT table writes. The caller |
| 907 | /// has already compiled Git's snapshot delta into line-level graph ops. |
| 908 | pub fn write_import_graph_change( |
| 909 | &self, |
| 910 | change: Change, |
| 911 | deleted_paths: &[String], |
| 912 | options: InsertOptions, |
| 913 | ) -> Result<ImportWriteOutcome, RepositoryError> { |
| 914 | let mut timings = ImportWriteTimings::default(); |
| 915 | let view_name = options.view.as_deref().unwrap_or(&self.current_view); |
| 916 | |
| 917 | let mut txn = self |
| 918 | .pristine |
| 919 | .write_txn() |
| 920 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 921 | |
| 922 | let assemble_start = std::time::Instant::now(); |
| 923 | let mut v3_bytes = Vec::new(); |
| 924 | let hash = change |
| 925 | .serialize(&mut v3_bytes) |
| 926 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 927 | let (final_change, verified_hash) = Change::deserialize(&mut v3_bytes.as_slice()) |
| 928 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 929 | debug_assert_eq!(hash, verified_hash); |
| 930 | timings.assemble_ms = assemble_start.elapsed().as_millis(); |
| 931 | |
| 932 | let save_start = std::time::Instant::now(); |
| 933 | self.save_change_bytes(&hash, &v3_bytes, &final_change)?; |
| 934 | timings.save_ms = save_start.elapsed().as_millis(); |
| 935 | |
| 936 | let change_id = txn |
| 937 | .register_change(&hash) |
| 938 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 939 | txn.put_change_deps(change_id, final_change.dependencies()) |
| 940 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 941 | |
| 942 | let apply_start = std::time::Instant::now(); |
| 943 | let insert = if import_graph_first_can_apply(&final_change) { |
| 944 | let (insert, graph_ms, crdt_ms) = self.write_import_graph_first_direct( |
| 945 | &mut txn, |
| 946 | view_name, |
| 947 | change_id, |
| 948 | &hash, |
| 949 | &final_change, |
| 950 | &options, |
| 951 | )?; |
| 952 | timings.direct_graph_ms = graph_ms; |
| 953 | timings.direct_crdt_ms = crdt_ms; |
| 954 | insert |
| 955 | } else { |
| 956 | write_change_to_graph( |
| 957 | &mut txn, |
| 958 | view_name, |
| 959 | change_id, |
| 960 | &hash, |
| 961 | &final_change, |
| 962 | &options, |
| 963 | false, |
| 964 | ) |
| 965 | .map_err(|e| RepositoryError::Apply(e.to_string()))? |
no test coverage detected