Merge pull request #3425 from killerswan/fix_incoming
(partially fix incoming) More hash function simplification
This commit is contained in:
commit
6be5fe2d47
@ -66,7 +66,7 @@ fn read_line() {
|
||||
fn str_set() {
|
||||
let r = rand::Rng();
|
||||
|
||||
let s = map::hashmap(str::hash, str::eq);
|
||||
let s = map::hashmap();
|
||||
|
||||
for int::range(0, 1000) |_i| {
|
||||
map::set_add(s, r.gen_str(10));
|
||||
|
@ -67,11 +67,9 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] {
|
||||
}
|
||||
}
|
||||
|
||||
pure fn node_hash(n: &node_id) -> uint { *n as uint }
|
||||
|
||||
fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
|
||||
let graph = do vec::from_fn(N) |_i| {
|
||||
map::hashmap::<node_id, ()>(node_hash, sys::shape_eq)
|
||||
map::hashmap::<node_id, ()>()
|
||||
};
|
||||
|
||||
do vec::each(edges) |e| {
|
||||
@ -87,7 +85,7 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
|
||||
}
|
||||
|
||||
fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
|
||||
let keys = map::hashmap::<node_id, ()>(node_hash, sys::shape_eq);
|
||||
let keys = map::hashmap::<node_id, ()>();
|
||||
let r = rand::Rng();
|
||||
|
||||
while keys.size() < n {
|
||||
|
@ -39,13 +39,6 @@ trait hash_key {
|
||||
pure fn eq(&&k: self) -> bool;
|
||||
}
|
||||
|
||||
fn mk_hash<K: Const hash_key, V: Copy>() -> map::hashmap<K, V> {
|
||||
pure fn hashfn<K: Const hash_key>(k: &K) -> uint { k.hash() }
|
||||
pure fn hasheq<K: Const hash_key>(k1: &K, k2: &K) -> bool { k1.eq(*k2) }
|
||||
|
||||
map::hashmap(hashfn, hasheq)
|
||||
}
|
||||
|
||||
impl ~str: hash_key {
|
||||
pure fn hash() -> uint { str::hash(&self) }
|
||||
pure fn eq(&&x: ~str) -> bool { self == x }
|
||||
@ -175,11 +168,12 @@ mod map_reduce {
|
||||
input: K1)
|
||||
{
|
||||
// log(error, "map_task " + input);
|
||||
let intermediates = mk_hash();
|
||||
let intermediates = map::hashmap();
|
||||
|
||||
do map(input) |key, val| {
|
||||
let mut c = None;
|
||||
match intermediates.find(key) {
|
||||
let found = intermediates.find(key);
|
||||
match found {
|
||||
Some(_c) => { c = Some(_c); }
|
||||
None => {
|
||||
do ctrl.swap |ctrl| {
|
||||
@ -251,7 +245,7 @@ mod map_reduce {
|
||||
// This task becomes the master control task. It task::_spawns
|
||||
// to do the rest.
|
||||
|
||||
let reducers = mk_hash();
|
||||
let reducers = map::hashmap();
|
||||
let mut tasks = start_mappers(map, ctrl, inputs);
|
||||
let mut num_mappers = vec::len(inputs) as int;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user