MCPcopy Create free account
hub / github.com/carsonpo/haystackdb / get_uncommitted

Method get_uncommitted

src/structures/wal.rs:292–333  ·  view source on GitHub ↗
(&mut self, last_seconds: u64)

Source from the content-addressed store, hash-verified

290 }
291
292 pub fn get_uncommitted(&mut self, last_seconds: u64) -> Result<Vec<CommitListItem>, io::Error> {
293 let start = SystemTime::now()
294 .duration_since(UNIX_EPOCH)
295 .unwrap()
296 .as_secs()
297 - last_seconds;
298
299 let end = SystemTime::now()
300 .duration_since(UNIX_EPOCH)
301 .unwrap()
302 .as_secs()
303 + 1;
304
305 let all_hashes = self.timestamps.get_range(start, end)?;
306
307 let mut commits = Vec::new();
308
309 for (_, hashes) in all_hashes {
310 for hash in hashes {
311 match self.commit_finish.has_key(hash) {
312 Ok(has_key) => {
313 if !has_key {
314 match self.commit_list.search(hash) {
315 Ok(commit) => match commit {
316 Some(c) => {
317 commits.push(c);
318 }
319 None => {}
320 },
321 Err(_) => {}
322 }
323 }
324 }
325 Err(_) => {}
326 }
327 }
328 }
329
330 // commits.dedup_by_key(|c| c.hash);
331
332 Ok(commits)
333 }
334
335 pub fn compute_hash(
336 &self,

Callers 1

commitMethod · 0.80

Calls 4

get_rangeMethod · 0.80
has_keyMethod · 0.80
pushMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected