Skip to content

Commit

Permalink
use indexmap in gj (oof)
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Oct 9, 2024
1 parent ad4f8a8 commit 12ecb21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/function/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
use smallvec::SmallVec;
use symbol_table::GlobalSymbol;

use crate::{unionfind::UnionFind, util::HashMap, Value};
use crate::{unionfind::UnionFind, Value};

use super::IndexMap;

pub(crate) type Offset = u32;

#[derive(Clone, Debug)]
pub(crate) struct ColumnIndex {
sort: GlobalSymbol,
ids: HashMap<u64, SmallVec<[Offset; 8]>>,
ids: IndexMap<u64, SmallVec<[Offset; 8]>>,
}

impl ColumnIndex {
Expand Down
12 changes: 5 additions & 7 deletions src/gj.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use hashbrown::hash_map::Entry as HEntry;
use indexmap::map::Entry;
use log::log_enabled;
use smallvec::SmallVec;
Expand Down Expand Up @@ -793,7 +792,7 @@ impl Debug for LazyTrie {
}
}

type SparseMap = HashMap<Value, LazyTrie>;
type SparseMap = IndexMap<Value, LazyTrie>;
type RowIdx = u32;

#[derive(Debug)]
Expand Down Expand Up @@ -889,8 +888,8 @@ impl LazyTrie {
LazyTrieInner::Borrowed { index, map } => {
let ixs = index.get(&value)?;
match map.entry(value) {
HEntry::Occupied(o) => Some(o.into_mut()),
HEntry::Vacant(v) => {
Entry::Occupied(o) => Some(o.into_mut()),
Entry::Vacant(v) => {
Some(v.insert(LazyTrie::from_indexes(access.filter_live(ixs))?))
}
}
Expand Down Expand Up @@ -938,19 +937,18 @@ impl<'a> TrieAccess<'a> {
let arity = self.function.schema.input.len();
let mut map = SparseMap::default();
let mut insert = |i: usize, tup: &[Value], out: &TupleOutput, val: Value| {
use hashbrown::hash_map::Entry;
if self.timestamp_range.contains(&out.timestamp)
&& self.constraints.iter().all(|c| c.check(tup, out))
{
match map.entry(val) {
Entry::Occupied(mut e) => {
indexmap::map::Entry::Occupied(mut e) => {
if let LazyTrieInner::Delayed(ref mut v) = e.get_mut().0.get_mut() {
v.push(i as RowIdx)
} else {
unreachable!()
}
}
Entry::Vacant(e) => {
indexmap::map::Entry::Vacant(e) => {
e.insert(LazyTrie(UnsafeCell::new(LazyTrieInner::Delayed(
smallvec::smallvec![i as RowIdx,],
))));
Expand Down

0 comments on commit 12ecb21

Please sign in to comment.