Skip to content

Commit

Permalink
remove some useless things
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 16, 2024
1 parent eda03ac commit c82cb51
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 267 deletions.
17 changes: 6 additions & 11 deletions raphtory/src/core/entities/graph/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ pub(crate) trait TimeCounterTrait {
}
}
}
fn get(&self) -> i64;
#[inline(always)]
fn get(&self) -> i64 {
self.counter().load(Ordering::Relaxed)
}
}

#[derive(Serialize, Deserialize, Debug)]
Expand All @@ -40,14 +43,10 @@ impl TimeCounterTrait for MinCounter {
new_value < current_value
}

#[inline(always)]
fn counter(&self) -> &AtomicI64 {
&self.counter
}

#[inline]
fn get(&self) -> i64 {
self.counter.load(Ordering::Relaxed)
}
}

#[derive(Serialize, Deserialize, Debug)]
Expand All @@ -67,14 +66,10 @@ impl TimeCounterTrait for MaxCounter {
fn cmp(a: i64, b: i64) -> bool {
a > b
}
#[inline(always)]
fn counter(&self) -> &AtomicI64 {
&self.counter
}

#[inline]
fn get(&self) -> i64 {
self.counter.load(Ordering::Relaxed)
}
}

#[cfg(test)]
Expand Down
29 changes: 5 additions & 24 deletions raphtory/src/core/entities/properties/tcell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ impl<A: Sync + Send> TCell<A> {
}

pub fn iter_t(&self) -> BoxedLIter<(i64, &A)> {
match self {
TCell::Empty => Box::new(std::iter::empty()),
TCell::TCell1(t, value) => Box::new(std::iter::once((t.t(), value))),
TCell::TCellCap(svm) => Box::new(svm.iter().map(|(ti, v)| (ti.t(), v))),
TCell::TCellN(btm) => Box::new(btm.iter().map(|(ti, v)| (ti.t(), v))),
}
Box::new(self.iter().map(|(t, a)| (t.t(), a)))
}

pub fn iter_window(
Expand All @@ -107,24 +102,10 @@ impl<A: Sync + Send> TCell<A> {
}

pub fn iter_window_t(&self, r: Range<i64>) -> Box<dyn Iterator<Item = (i64, &A)> + Send + '_> {
match self {
TCell::Empty => Box::new(std::iter::empty()),
TCell::TCell1(t, value) => {
if r.contains(&t.t()) {
Box::new(std::iter::once((t.t(), value)))
} else {
Box::new(std::iter::empty())
}
}
TCell::TCellCap(svm) => Box::new(
svm.range(TimeIndexEntry::range(r))
.map(|(ti, v)| (ti.t(), v)),
),
TCell::TCellN(btm) => Box::new(
btm.range(TimeIndexEntry::range(r))
.map(|(ti, v)| (ti.t(), v)),
),
}
Box::new(
self.iter_window(TimeIndexEntry::range(r))
.map(|(t, a)| (t.t(), a)),
)
}

pub fn last_before(&self, t: TimeIndexEntry) -> Option<(TimeIndexEntry, &A)> {
Expand Down
23 changes: 0 additions & 23 deletions raphtory/src/core/entities/properties/tprop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,29 +420,6 @@ impl<'a> TPropOps<'a> for &'a TProp {
TProp::Map(cell) => cell.at(ti).map(|v| Prop::Map(v.clone())),
}
}

// fn len(self) -> usize {
// match self {
// TProp::Empty => 0,
// TProp::Str(v) => v.len(),
// TProp::U8(v) => v.len(),
// TProp::U16(v) => v.len(),
// TProp::I32(v) => v.len(),
// TProp::I64(v) => v.len(),
// TProp::U32(v) => v.len(),
// TProp::U64(v) => v.len(),
// TProp::F32(v) => v.len(),
// TProp::F64(v) => v.len(),
// TProp::Bool(v) => v.len(),
// TProp::DTime(v) => v.len(),
// TProp::NDTime(v) => v.len(),
// TProp::Graph(v) => v.len(),
// TProp::PersistentGraph(v) => v.len(),
// TProp::Document(v) => v.len(),
// TProp::List(v) => v.len(),
// TProp::Map(v) => v.len(),
// }
// }
}

#[cfg(test)]
Expand Down
6 changes: 0 additions & 6 deletions raphtory/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,6 @@ impl From<Vec<Prop>> for Prop {
}
}

impl<P: Into<Prop>> FromIterator<P> for Prop {
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> Self {
Prop::List(Arc::new(iter.into_iter().map(|v| v.into()).collect()))
}
}

impl From<&Prop> for Prop {
fn from(value: &Prop) -> Self {
value.clone()
Expand Down
43 changes: 0 additions & 43 deletions raphtory/src/core/storage/lazy_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ impl<T: Default> MaskedCol<T> {
self.mask.len()
}

pub fn iter_mut(&mut self) -> impl Iterator<Item = Option<&mut T>> {
let ts_len = self.ts.len();
self.ts
.iter_mut()
.zip(&self.mask[0..ts_len])
.map(|(t, &is_some)| is_some.then(|| t))
.chain(self.mask[ts_len..].iter().map(|_| None))
}

pub fn iter(&self) -> impl Iterator<Item = Option<&T>> {
let ts_len = self.ts.len();
self.ts
Expand All @@ -84,19 +75,6 @@ impl<T: Default> MaskedCol<T> {
.map(|(t, &is_some)| is_some.then(|| t))
.chain(self.mask[ts_len..].iter().map(|_| None))
}

pub fn into_iter(self) -> impl Iterator<Item = Option<T>> {
let empty_tail = self.mask.len() - self.ts.len();
self.ts
.into_iter()
.zip(self.mask.into_iter())
.map(|(t, is_some)| is_some.then(|| t))
.chain(std::iter::from_fn(|| None).take(empty_tail))
}

pub fn filled_len(&self) -> usize {
self.mask.iter().filter(|v| **v).count()
}
}

#[derive(Default, Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -416,19 +394,6 @@ mod lazy_vec_tests {
assert_eq!(vec.len(), 3);
}

// #[test]
// fn lazy_vec_is_opt_vec_insert() {
// proptest!(|(
// v in Vec::<Option<u32>>::arbitrary(),
// )| {
// let mut lazy_vec = LazyVec::<u32>::Empty;
// for (i, value) in v.iter().enumerate() {
// lazy_vec.insert(i, *value);
// }
// check_lazy_vec(&lazy_vec, v);
// });
// }

#[test]
fn lazy_vec_is_opt_vec_push() {
proptest!(|(
Expand All @@ -442,14 +407,6 @@ mod lazy_vec_tests {
});
}

// #[test]
// fn none_1_lazy_vec() {
// let mut vec = LazyVec::<u32>::Empty;
// vec.insert(0, None);

// assert_eq!(vec.len(), 1);
// }

#[test]
fn normal_operation() {
let mut vec = LazyVec::<u32>::Empty;
Expand Down
16 changes: 2 additions & 14 deletions raphtory/src/core/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ where
self.locks.par_iter().flat_map(|v| v.par_iter())
}

#[allow(unused)]
#[cfg(test)]
pub(crate) fn into_iter(self) -> impl Iterator<Item = ArcEntry> {
self.locks.into_iter().flat_map(|data| {
(0..data.as_ref().len()).map(move |offset| ArcEntry {
Expand All @@ -450,18 +450,6 @@ where
})
})
}

#[allow(unused)]
pub(crate) fn into_par_iter(self) -> impl ParallelIterator<Item = ArcEntry> {
self.locks.into_par_iter().flat_map(|data| {
(0..data.as_ref().len())
.into_par_iter()
.map(move |offset| ArcEntry {
guard: data.clone(),
i: offset,
})
})
}
}

impl NodeStorage {
Expand Down Expand Up @@ -862,7 +850,7 @@ impl<'a, NS: DerefMut<Target = NodeSlot> + 'a> EntryMut<'a, &'a mut NS> {
&self.guard[self.i]
}

pub fn get_mut(&mut self) -> &mut NodeStore {
pub fn node_store_mut(&mut self) -> &mut NodeStore {
&mut self.guard[self.i]
}

Expand Down
8 changes: 4 additions & 4 deletions raphtory/src/core/storage/node_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{borrow::Cow, ops::Range};

use raphtory_api::core::{
entities::{edges::edge_ref::EdgeRef, GidRef, VID},
storage::timeindex::{TimeIndexEntry, TimeIndexOps},
storage::timeindex::TimeIndexEntry,
Direction,
};

Expand Down Expand Up @@ -71,9 +71,9 @@ impl<'a> NodeEntry<'a> {
w: Range<TimeIndexEntry>,
) -> impl Iterator<Item = (TimeIndexEntry, Row<'a>)> + Send + Sync {
let tcell = &self.node.timestamps().props_ts;
tcell.range(w).iter_values().filter_map(move |(t, row)| {
let row = MemRow::new(self.t_props_log, row);
Some((t, Row::Mem(row)))
tcell.iter_window(w).filter_map(move |(t, row)| {
let row = MemRow::new(self.t_props_log, *row);
Some((*t, Row::Mem(row)))
})
}
}
Expand Down
31 changes: 6 additions & 25 deletions raphtory/src/core/storage/timeindex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::locked_view::LockedView;
use crate::core::entities::{properties::tcell::TCell, LayerIds};
use crate::core::entities::LayerIds;
use itertools::Itertools;
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -134,10 +134,6 @@ impl<T: AsTime> TimeIndexLike for TimeIndex<T> {
Box::new(self.range_iter(w))
}

fn first_range(&self, w: Range<Self::IndexType>) -> Option<Self::IndexType> {
self.range_iter(w).next()
}

fn last_range(&self, w: Range<Self::IndexType>) -> Option<Self::IndexType> {
self.range_iter(w).next_back()
}
Expand All @@ -150,18 +146,6 @@ pub enum TimeIndexWindow<'a, T: AsTime, TI> {
All(&'a TI),
}

impl<'a, A: Copy + Send + Sync> TimeIndexWindow<'a, TimeIndexEntry, TCell<A>> {
pub fn iter_values(self) -> Box<dyn Iterator<Item = (TimeIndexEntry, A)> + Send + Sync + 'a> {
match self {
TimeIndexWindow::Empty => Box::new(iter::empty()),
TimeIndexWindow::TimeIndexRange { timeindex, range } => {
Box::new(timeindex.iter_window(range.clone()).map(|(t, v)| (*t, *v)))
}
TimeIndexWindow::All(timeindex) => Box::new(timeindex.iter().map(|(t, v)| (*t, *v))),
}
}
}

impl<'a, T: AsTime, TI: TimeIndexLike<IndexType = T>> TimeIndexWindow<'a, T, TI> {
pub fn len(&self) -> usize {
match self {
Expand Down Expand Up @@ -199,8 +183,9 @@ impl<'a, T: AsTime, TI: TimeIndexLike<IndexType = T>> TimeIndexIntoOps
if ts.len() == 0 {
TimeIndexWindow::Empty
} else {
if let Some(min_val) = ts.first() {
if let Some(max_val) = ts.last() {
ts.first()
.zip(ts.last())
.map(|(min_val, max_val)| {
if min_val >= w.start && max_val < w.end {
TimeIndexWindow::All(ts)
} else {
Expand All @@ -209,12 +194,8 @@ impl<'a, T: AsTime, TI: TimeIndexLike<IndexType = T>> TimeIndexIntoOps
range: w,
}
}
} else {
TimeIndexWindow::Empty
}
} else {
TimeIndexWindow::Empty
}
})
.unwrap_or(TimeIndexWindow::Empty)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion raphtory/src/db/api/properties/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub trait TemporalPropertyViewOps {

pub trait TemporalPropertiesRowView {
fn rows(&self) -> BoxedLIter<(TimeIndexEntry, Vec<(usize, Prop)>)>;
fn edge_ts(&self) -> BoxedLIter<TimeIndexEntry>;
}

#[enum_dispatch]
Expand Down
6 changes: 3 additions & 3 deletions raphtory/src/db/api/storage/graph/storage_ops/additions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ impl InternalAdditionOps for TemporalGraph {
}
let vid = self.resolve_node(id)?;
let mut entry = self.storage.get_node_mut(vid.inner());
let mut a = entry.to_mut();
let node_store = a.get_mut();
let mut entry_ref = entry.to_mut();
let node_store = entry_ref.node_store_mut();
if node_store.node_type == 0 {
let node_type_id = self.node_meta.get_or_create_node_type_id(node_type);
node_store.update_node_type(node_type_id.inner());
Expand Down Expand Up @@ -152,7 +152,7 @@ impl InternalAdditionOps for TemporalGraph {
(*prop_id, prop)
}))?;

a.get_mut().update_t_prop_time(t, prop_i);
a.node_store_mut().update_t_prop_time(t, prop_i);
Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,6 @@ impl TimeSemantics for GraphStorage {
res
}

// fn has_temporal_edge_prop(&self, e: EdgeRef, prop_id: usize, layer_ids: &LayerIds) -> bool {
// let entry = self.core_edge(e.pid());
// (&entry).has_temporal_prop(&layer_ids.constrain_from_edge(e), prop_id)
// }

fn temporal_edge_prop_hist<'a>(
&'a self,
e: EdgeRef,
Expand Down
4 changes: 0 additions & 4 deletions raphtory/src/db/api/storage/graph/tprop_storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,4 @@ impl<'a> TPropOps<'a> for TPropRef<'a> {
fn at(self, ti: &TimeIndexEntry) -> Option<Prop> {
for_all!(self, tprop => tprop.at(ti))
}

// fn len(self) -> usize {
// for_all!(self, tprop => tprop.len())
// }
}
Loading

0 comments on commit c82cb51

Please sign in to comment.