Skip to content

Commit b168506

Browse files
Remove use of timely_sort crate (TimelyDataflow#313)
* remove use of timely_sort crate * correct tests
1 parent d3bf8c2 commit b168506

File tree

11 files changed

+16
-173
lines changed

11 files changed

+16
-173
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ serde = "1.0"
2929
serde_derive = "1.0"
3030
abomonation = "0.7"
3131
abomonation_derive = "0.5"
32-
timely_sort="0.1.6"
3332
#timely = { version = "0.11", default-features = false }
3433
timely = { git = "https://github.com/TimelyDataflow/timely-dataflow", default-features = false }
3534
#timely = { path = "../timely-dataflow/timely/", default-features = false }

dogsdogsdogs/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ license = "MIT"
88
abomonation = "0.7"
99
abomonation_derive = "0.5"
1010
timely = { git = "https://github.com/TimelyDataflow/timely-dataflow", default-features = false }
11-
timely_sort = "0.1.6"
1211
differential-dataflow = { path = "../", default-features = false }
1312
serde = "1"
1413
serde_derive = "1"

dogsdogsdogs/src/operators/lookup_map.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use timely::dataflow::channels::pact::{Pipeline, Exchange};
66
use timely::dataflow::operators::Operator;
77
use timely::progress::Antichain;
88

9-
use timely_sort::Unsigned;
10-
119
use differential_dataflow::{ExchangeData, Collection, AsCollection, Hashable};
1210
use differential_dataflow::difference::{Semigroup, Monoid};
1311
use differential_dataflow::lattice::Lattice;
@@ -58,7 +56,7 @@ where
5856
let mut key: Tr::Key = supplied_key0;
5957
let exchange = Exchange::new(move |update: &(D,G::Timestamp,R)| {
6058
logic1(&update.0, &mut key);
61-
key.hashed().as_u64()
59+
key.hashed().into()
6260
});
6361

6462
let mut key1: Tr::Key = supplied_key1;

src/hashable.rs

Lines changed: 1 addition & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
//! distributed integers can perhaps do something simpler (like report their own value).
1616
1717
use std::hash::Hasher;
18-
use std::ops::Deref;
19-
20-
use abomonation::Abomonation;
21-
22-
use timely_sort::Unsigned;
2318

2419
/// Types with a `hashed` method, producing an unsigned output of some type.
2520
///
@@ -28,7 +23,7 @@ use timely_sort::Unsigned;
2823
/// can take advantage of the smaller size.
2924
pub trait Hashable {
3025
/// The type of the output value.
31-
type Output: Unsigned+Copy;
26+
type Output: Into<u64>+Copy;
3227
/// A well-distributed integer derived from the data.
3328
fn hashed(&self) -> Self::Output;
3429
}
@@ -41,139 +36,3 @@ impl<T: ::std::hash::Hash> Hashable for T {
4136
h.finish()
4237
}
4338
}
44-
45-
/// A marker trait for types whose `Ord` implementation orders first by `hashed()`.
46-
///
47-
/// Types implementing this trait *must* implement `Ord` and satisfy the property that two values
48-
/// with different hashes have the same order as their hashes. This trait allows implementations
49-
/// that sort by hash value to rely on the `Ord` implementation of the type.
50-
pub trait HashOrdered : Ord+Hashable { }
51-
impl<T: Ord+Hashable> HashOrdered for OrdWrapper<T> { }
52-
impl<T: Ord+Hashable> HashOrdered for HashableWrapper<T> { }
53-
impl<T: Unsigned+Copy> HashOrdered for UnsignedWrapper<T> { }
54-
55-
// It would be great to use the macros for these, but I couldn't figure out how to get it
56-
// to work with constraints (i.e. `Hashable`) on the generic parameters.
57-
impl<T: Ord+Hashable+Abomonation> Abomonation for OrdWrapper<T> {
58-
#[inline] unsafe fn entomb<W: ::std::io::Write>(&self, write: &mut W) -> ::std::io::Result<()> {
59-
self.item.entomb(write)
60-
}
61-
#[inline] unsafe fn exhume<'a,'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
62-
let temp = bytes;
63-
bytes = self.item.exhume(temp)?;
64-
Some(bytes)
65-
}
66-
}
67-
68-
// It would be great to use the macros for these, but I couldn't figure out how to get it
69-
// to work with constraints (i.e. `Hashable`) on the generic parameters.
70-
impl<T: Hashable+Abomonation> Abomonation for HashableWrapper<T> {
71-
72-
#[inline] unsafe fn entomb<W: ::std::io::Write>(&self, write: &mut W) -> ::std::io::Result<()> {
73-
self.item.entomb(write)
74-
}
75-
#[inline] unsafe fn exhume<'a,'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
76-
let temp = bytes;
77-
bytes = self.item.exhume(temp)?;
78-
Some(bytes)
79-
}
80-
}
81-
82-
impl<T: Unsigned+Copy+Hashable+Abomonation> Abomonation for UnsignedWrapper<T> {
83-
84-
#[inline] unsafe fn entomb<W: ::std::io::Write>(&self, write: &mut W) -> ::std::io::Result<()> {
85-
self.item.entomb(write)
86-
}
87-
#[inline] unsafe fn exhume<'a,'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
88-
let temp = bytes;
89-
bytes = self.item.exhume(temp)?;
90-
Some(bytes)
91-
}
92-
}
93-
94-
95-
/// A wrapper around hashable types that ensures an implementation of `Ord` that compares
96-
/// hash values first.
97-
#[derive(Clone, Eq, PartialEq, Debug, Default)]
98-
pub struct OrdWrapper<T: Ord+Hashable> {
99-
/// The item, so you can grab it.
100-
pub item: T
101-
}
102-
103-
impl<T: Ord+Hashable> PartialOrd for OrdWrapper<T> {
104-
#[inline]
105-
fn partial_cmp(&self, other: &Self) -> Option<::std::cmp::Ordering> {
106-
(self.item.hashed(), &self.item).partial_cmp(&(other.item.hashed(), &other.item))
107-
}
108-
}
109-
impl<T: Ord+Hashable> Ord for OrdWrapper<T> {
110-
#[inline]
111-
fn cmp(&self, other: &Self) -> ::std::cmp::Ordering {
112-
(self.item.hashed(), &self.item).cmp(&(other.item.hashed(), &other.item))
113-
}
114-
}
115-
116-
impl<T: Ord+Hashable> Hashable for OrdWrapper<T> {
117-
type Output = T::Output;
118-
fn hashed(&self) -> T::Output { self.item.hashed() }
119-
}
120-
121-
impl<T: Ord+Hashable> Deref for OrdWrapper<T> {
122-
type Target = T;
123-
fn deref(&self) -> &T { &self.item }
124-
}
125-
126-
127-
/// Wrapper to stash hash value with the actual value.
128-
#[derive(Clone, Default, Ord, PartialOrd, Eq, PartialEq, Debug, Copy)]
129-
pub struct HashableWrapper<T: Hashable> {
130-
hash: T::Output,
131-
/// The item, for reference.
132-
pub item: T,
133-
}
134-
135-
impl<T: Hashable> Hashable for HashableWrapper<T> {
136-
type Output = T::Output;
137-
#[inline]
138-
fn hashed(&self) -> T::Output { self.hash }
139-
}
140-
141-
impl<T: Hashable> Deref for HashableWrapper<T> {
142-
type Target = T;
143-
#[inline]
144-
fn deref(&self) -> &T { &self.item }
145-
}
146-
147-
impl<T: Hashable> From<T> for HashableWrapper<T> {
148-
#[inline]
149-
fn from(item: T) -> HashableWrapper<T> {
150-
HashableWrapper {
151-
hash: item.hashed(),
152-
item,
153-
}
154-
}
155-
}
156-
157-
/// A wrapper around an unsigned integer, providing `hashed` as the value itself.
158-
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Default, Debug, Copy)]
159-
pub struct UnsignedWrapper<T: Unsigned+Copy> {
160-
/// The item.
161-
pub item: T,
162-
}
163-
164-
impl<T: Unsigned+Copy> Hashable for UnsignedWrapper<T> {
165-
type Output = T;
166-
#[inline]
167-
fn hashed(&self) -> Self::Output { self.item }
168-
}
169-
170-
impl<T: Unsigned+Copy> Deref for UnsignedWrapper<T> {
171-
type Target = T;
172-
#[inline]
173-
fn deref(&self) -> &T { &self.item }
174-
}
175-
176-
impl<T: Unsigned+Copy> From<T> for UnsignedWrapper<T> {
177-
#[inline]
178-
fn from(item: T) -> Self { UnsignedWrapper { item } }
179-
}

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ impl<T: timely::ExchangeData + Ord + Debug> ExchangeData for T { }
9292

9393
extern crate fnv;
9494
extern crate timely;
95-
extern crate timely_sort;
9695

9796
#[macro_use]
9897
extern crate abomonation_derive;

src/operators/arrange/agent.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ where
187187
/// use differential_dataflow::operators::reduce::Reduce;
188188
/// use differential_dataflow::trace::Trace;
189189
/// use differential_dataflow::trace::implementations::ord::OrdValSpine;
190-
/// use differential_dataflow::hashable::OrdWrapper;
191190
///
192191
/// fn main() {
193192
/// ::timely::execute(Config::thread(), |worker| {
@@ -247,7 +246,6 @@ where
247246
/// use differential_dataflow::operators::reduce::Reduce;
248247
/// use differential_dataflow::trace::Trace;
249248
/// use differential_dataflow::trace::implementations::ord::OrdValSpine;
250-
/// use differential_dataflow::hashable::OrdWrapper;
251249
///
252250
/// fn main() {
253251
/// ::timely::execute(Config::thread(), |worker| {
@@ -361,7 +359,6 @@ where
361359
/// use differential_dataflow::trace::Trace;
362360
/// use differential_dataflow::trace::TraceReader;
363361
/// use differential_dataflow::trace::implementations::ord::OrdValSpine;
364-
/// use differential_dataflow::hashable::OrdWrapper;
365362
/// use differential_dataflow::input::Input;
366363
///
367364
/// fn main() {

src/operators/arrange/arrangement.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ use timely::progress::Timestamp;
2626
use timely::progress::{Antichain, frontier::AntichainRef};
2727
use timely::dataflow::operators::Capability;
2828

29-
use timely_sort::Unsigned;
30-
3129
use ::{Data, ExchangeData, Collection, AsCollection, Hashable};
3230
use ::difference::Semigroup;
3331
use lattice::Lattice;
@@ -274,7 +272,7 @@ where
274272
Tr: 'static,
275273
{
276274
// while the arrangement is already correctly distributed, the query stream may not be.
277-
let exchange = Exchange::new(move |update: &(Tr::Key,G::Timestamp)| update.0.hashed().as_u64());
275+
let exchange = Exchange::new(move |update: &(Tr::Key,G::Timestamp)| update.0.hashed().into());
278276
queries.binary_frontier(&self.stream, exchange, Pipeline, "TraceQuery", move |_capability, _info| {
279277

280278
let mut trace = Some(self.trace.clone());
@@ -484,7 +482,7 @@ where
484482
Tr::Batch: Batch<K, V, G::Timestamp, R>,
485483
Tr::Cursor: Cursor<K, V, G::Timestamp, R>,
486484
{
487-
let exchange = Exchange::new(move |update: &((K,V),G::Timestamp,R)| (update.0).0.hashed().as_u64());
485+
let exchange = Exchange::new(move |update: &((K,V),G::Timestamp,R)| (update.0).0.hashed().into());
488486
self.arrange_core(exchange, name)
489487
}
490488

src/operators/arrange/upsert.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ use timely::progress::Timestamp;
115115
use timely::progress::Antichain;
116116
use timely::dataflow::operators::Capability;
117117

118-
use timely_sort::Unsigned;
119-
120118
use ::{ExchangeData, Hashable};
121119
use lattice::Lattice;
122120
use trace::{Trace, TraceReader, Batch, Cursor};
@@ -157,7 +155,7 @@ where
157155

158156
let reader = &mut reader;
159157

160-
let exchange = Exchange::new(move |update: &(Tr::Key,Option<Tr::Val>,G::Timestamp)| (update.0).hashed().as_u64());
158+
let exchange = Exchange::new(move |update: &(Tr::Key,Option<Tr::Val>,G::Timestamp)| (update.0).hashed().into());
161159

162160
stream.unary_frontier(exchange, name, move |_capability, info| {
163161

src/operators/join.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ pub trait JoinCore<G: Scope, K: 'static, V: 'static, R: Semigroup> where G::Time
237237
/// use differential_dataflow::operators::join::JoinCore;
238238
/// use differential_dataflow::trace::Trace;
239239
/// use differential_dataflow::trace::implementations::ord::OrdValSpine;
240-
/// use differential_dataflow::hashable::OrdWrapper;
241240
///
242241
/// fn main() {
243242
/// ::timely::example(|scope| {

src/operators/reduce.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ pub trait ReduceCore<G: Scope, K: Data, V: Data, R: Semigroup> where G::Timestam
253253
/// use differential_dataflow::operators::reduce::ReduceCore;
254254
/// use differential_dataflow::trace::Trace;
255255
/// use differential_dataflow::trace::implementations::ord::OrdValSpine;
256-
/// use differential_dataflow::hashable::OrdWrapper;
257256
///
258257
/// fn main() {
259258
/// ::timely::example(|scope| {

0 commit comments

Comments
 (0)