remove comments

main
Ziyang Hu 2 years ago
parent 6faed23a6e
commit 93f07aa388

@ -32,18 +32,7 @@ impl Tuple {
for val in self.0.iter() {
ret.encode_datavalue(val);
}
// println!("encoded as key {:?}", ret);
ret
// for (idx, val) in self.0.iter().enumerate() {
// if idx > 0 {
// let pos = (ret.len() as u32).to_be_bytes();
// for (i, u) in pos.iter().enumerate() {
// ret[4 * (1 + idx) + i] = *u;
// }
// }
// val.serialize(&mut Serializer::new(&mut ret)).unwrap();
// }
// ret
}
pub(crate) fn decode_from_key(key: &[u8]) -> Self {
let mut remaining = &key[ENCODED_KEY_MIN_LEN..];
@ -56,129 +45,4 @@ impl Tuple {
Tuple(ret)
}
}
pub(crate) const ENCODED_KEY_MIN_LEN: usize = 8;
//
// #[derive(Copy, Clone, Debug)]
// pub(crate) struct EncodedTuple<'a>(pub(crate) &'a [u8]);
//
// impl<'a> From<&'a [u8]> for EncodedTuple<'a> {
// fn from(s: &'a [u8]) -> Self {
// EncodedTuple(s)
// }
// }
//
// impl<'a> EncodedTuple<'a> {
// pub(crate) fn prefix(&self) -> RelationId {
// debug_assert!(self.0.len() >= 6, "bad data: {:x?}", self.0);
// let id = u64::from_be_bytes([
// 0, 0, self.0[0], self.0[1], self.0[2], self.0[3], self.0[4], self.0[5],
// ]);
// RelationId(id)
// }
// pub(crate) fn arity(&self) -> usize {
// if self.0.len() == 6 {
// return 0;
// }
// debug_assert!(self.0.len() >= 8, "bad data: {:x?}", self.0);
// u16::from_be_bytes([self.0[6], self.0[7]]) as usize
// }
// fn force_get(&self, idx: usize) -> DataValue {
// let pos = if idx == 0 {
// let arity = u16::from_be_bytes([self.0[6], self.0[7]]) as usize;
// 4 * (arity + 1)
// } else {
// let len_pos = (idx + 1) * 4;
// u32::from_be_bytes([
// self.0[len_pos],
// self.0[len_pos + 1],
// self.0[len_pos + 2],
// self.0[len_pos + 3],
// ]) as usize
// };
// rmp_serde::from_slice(&self.0[pos..]).unwrap()
// }
// pub(crate) fn get(&self, idx: usize) -> DataValue {
// let pos = if idx == 0 {
// 4 * (self.arity() + 1)
// } else {
// let len_pos = (idx + 1) * 4;
// debug_assert!(self.0.len() >= len_pos + 4, "bad data: {:x?}", self.0);
// u32::from_be_bytes([
// self.0[len_pos],
// self.0[len_pos + 1],
// self.0[len_pos + 2],
// self.0[len_pos + 3],
// ]) as usize
// };
// debug_assert!(
// pos < self.0.len(),
// "bad data length for data: {:x?}",
// self.0
// );
// rmp_serde::from_slice(&self.0[pos..]).expect("data corruption when getting from tuple")
// }
//
// pub(crate) fn iter(&self) -> EncodedTupleIter<'a> {
// EncodedTupleIter {
// tuple: *self,
// size: 0,
// pos: 0,
// }
// }
// pub(crate) fn decode(&self) -> Tuple {
// Tuple(self.iter().collect())
// }
// }
//
// pub(crate) struct EncodedTupleIter<'a> {
// tuple: EncodedTuple<'a>,
// size: usize,
// pos: usize,
// }
//
// impl<'a> Iterator for EncodedTupleIter<'a> {
// type Item = DataValue;
//
// fn next(&mut self) -> Option<Self::Item> {
// if self.size == 0 {
// let arity = self.tuple.arity();
// self.size = arity;
// }
// if self.pos == self.size {
// None
// } else {
// let pos = self.pos;
// self.pos += 1;
// Some(self.tuple.get(pos))
// }
// }
// }
//
// pub(crate) fn rusty_scratch_cmp(a: &[u8], b: &[u8]) -> i8 {
// match compare_tuple_keys(a, b) {
// Ordering::Greater => 1,
// Ordering::Equal => 0,
// Ordering::Less => -1,
// }
// }
//
//
// pub(crate) fn compare_tuple_keys(a: &[u8], b: &[u8]) -> Ordering {
// let a = EncodedTuple(a);
// let b = EncodedTuple(b);
// match a.prefix().cmp(&b.prefix()) {
// Ordering::Equal => {}
// o => return o,
// }
// let a_len = a.arity();
// let b_len = b.arity();
// for idx in 0..min(a_len, b_len) {
// let av = a.force_get(idx);
// let bv = b.force_get(idx);
// match av.cmp(&bv) {
// Ordering::Equal => {}
// o => return o,
// }
// }
// a_len.cmp(&b_len)
// }
pub(crate) const ENCODED_KEY_MIN_LEN: usize = 8;

@ -2,7 +2,7 @@
* Copyright 2022, The Cozo Project Authors. Licensed under AGPL-3 or later.
*/
use std::cmp::{Ordering};
use std::cmp::Ordering;
use std::collections::BTreeMap;
use itertools::Itertools;

@ -124,10 +124,6 @@ impl SessionTx {
tup.0.push(val);
remaining = nxt;
}
// let v_tup = EncodedTuple(&existing);
// if v_tup.arity() > 0 {
// tup.0.extend(v_tup.decode().0);
// }
}
old_tuples.push(DataValue::List(tup.0));
}
@ -305,9 +301,6 @@ impl SessionTx {
let key = relation_store.adhoc_encode_key(&extracted, *span)?;
let val = relation_store.adhoc_encode_val(&extracted, *span)?;
// println!("adhoc encoded key {:?}, {:?}", key, extracted);
// println!("adhoc encoded val {:?}", val);
if has_triggers {
if let Some(existing) = self.tx.get(&key, false)? {
let mut tup = extracted.clone();
@ -317,12 +310,6 @@ impl SessionTx {
tup.0.push(val);
remaining = nxt;
}
// if !existing.is_empty() {
// let v_tup = EncodedTuple(&existing);
// if v_tup.arity() > 0 {
// tup.0.extend(v_tup.decode().0);
// }
// }
old_tuples.push(DataValue::List(tup.0));
}

@ -2,17 +2,17 @@
* Copyright 2022, The Cozo Project Authors. Licensed under AGPL-3 or later.
*/
use std::{fs, thread};
use std::collections::BTreeMap;
use std::fmt::{Debug, Formatter};
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{fs, thread};
use either::{Left, Right};
use itertools::Itertools;
use miette::{bail, Diagnostic, ensure, Result, WrapErr};
use miette::{bail, ensure, Diagnostic, Result, WrapErr};
use serde_json::json;
use smartstring::SmartString;
use thiserror::Error;
@ -22,14 +22,13 @@ use cozorocks::{DbBuilder, RocksDb};
use crate::data::json::JsonValue;
use crate::data::program::{InputProgram, QueryAssertion, RelationOp};
use crate::data::symb::Symbol;
use crate::data::tuple::{SCRATCH_DB_KEY_PREFIX_LEN, Tuple};
use crate::data::tuple::{Tuple, SCRATCH_DB_KEY_PREFIX_LEN};
use crate::data::value::{DataValue, LARGEST_UTF_CHAR};
use crate::parse::{CozoScript, parse_script, SourceSpan};
use crate::parse::sys::SysOp;
use crate::parse::{parse_script, CozoScript, SourceSpan};
use crate::query::compile::{CompiledProgram, CompiledRule, CompiledRuleSet};
use crate::query::relation::{
FilteredRA, InMemRelationRA, InnerJoin, NegJoin, RelAlgebra, ReorderRA, StoredRA,
UnificationRA,
FilteredRA, InMemRelationRA, InnerJoin, NegJoin, RelAlgebra, ReorderRA, StoredRA, UnificationRA,
};
use crate::runtime::relation::{RelationHandle, RelationId};
use crate::runtime::transact::SessionTx;
@ -124,7 +123,6 @@ impl Db {
let db_builder = builder
.create_if_missing(is_new)
.use_capped_prefix_extractor(true, SCRATCH_DB_KEY_PREFIX_LEN)
// .use_custom_comparator("cozo_rusty_cmp", rusty_scratch_cmp, false)
.use_bloom_filter(true, 9.9, true)
.path(store_path.to_str().unwrap());
@ -729,9 +727,6 @@ impl Db {
if upper.as_slice() <= k_slice {
break;
}
// if compare_tuple_keys(&upper, k_slice) != Greater {
// break;
// }
let meta = RelationHandle::decode(v_slice)?;
let n_keys = meta.metadata.keys.len();
let n_dependents = meta.metadata.non_keys.len();

@ -246,7 +246,6 @@ impl InMemRelation {
let val = &tuple.0[invert_indices[idx]];
if let Some((aggr_op, _aggr_args)) = aggr {
let op = aggr_op.normal_op.as_mut().unwrap();
// (aggr_op.meet_combine)(&mut aggr_res[idx], val, aggr_args)?;
op.set(val)?;
}
}
@ -365,24 +364,3 @@ impl InMemRelation {
res.into_iter()
}
}
//
// struct SortedIter {
// it: DbIter,
// started: bool,
// }
//
// impl Iterator for SortedIter {
// type Item = Result<Tuple>;
// fn next(&mut self) -> Option<Self::Item> {
// if !self.started {
// self.started = true;
// } else {
// self.it.next();
// }
// match self.it.pair() {
// Err(e) => Some(Err(e.into())),
// Ok(None) => None,
// Ok(Some((_, v_slice))) => Some(Ok(EncodedTuple(v_slice).decode())),
// }
// }
// }

Loading…
Cancel
Save