use of org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMultimap in project ignite by apache.
the class HadoopHashMapSelfTest method testMapSimple.
/**
* Test simple map.
*
* @throws Exception If failed.
*/
public void testMapSimple() throws Exception {
GridUnsafeMemory mem = new GridUnsafeMemory(0);
Random rnd = new Random();
int mapSize = 16 << rnd.nextInt(3);
HadoopTaskContext taskCtx = new TaskContext();
final HadoopHashMultimap m = new HadoopHashMultimap(new JobInfo(), mem, mapSize);
HadoopMultimap.Adder a = m.startAdding(taskCtx);
Multimap<Integer, Integer> mm = ArrayListMultimap.create();
for (int i = 0, vals = 4 * mapSize + rnd.nextInt(25); i < vals; i++) {
int key = rnd.nextInt(mapSize);
int val = rnd.nextInt();
a.write(new IntWritable(key), new IntWritable(val));
mm.put(key, val);
X.println("k: " + key + " v: " + val);
a.close();
check(m, mm, taskCtx);
a = m.startAdding(taskCtx);
}
// a.add(new IntWritable(10), new IntWritable(2));
// mm.put(10, 2);
// check(m, mm);
a.close();
X.println("Alloc: " + mem.allocatedSize());
m.close();
assertEquals(0, mem.allocatedSize());
}
Aggregations