@SuppressWarnings({ "unchecked" }) @Test @Ignore public void testMapperOn177() throws IOException { mapDriver.clearInput(); File file = new File("src/test/resources/data/test_cal_dt/part-r-00000"); FileReader reader = new FileReader(file); BufferedReader breader = new BufferedReader(reader); String s = breader.readLine(); int i = 0; while (s != null) { LongWritable inputKey = new LongWritable(i++); mapDriver.addInput(inputKey, new Text(s)); s = breader.readLine(); } // breader.close(); List<Pair<IntWritable, BytesWritable>> result = mapDriver.run(); breader.close(); assertEquals(9, result.size()); int key1 = result.get(0).getFirst().get(); BytesWritable value1 = result.get(0).getSecond(); byte[] bytes = value1.getBytes(); HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(); hllc.readRegisters(ByteBuffer.wrap(bytes)); assertTrue(key1 > 0); assertEquals(8, hllc.getCountEstimate()); }
@SuppressWarnings("unchecked") @Test public void testMapperOnComma() throws IOException { mapDriver.clearInput(); LongWritable inputKey1 = new LongWritable(1); LongWritable inputKey2 = new LongWritable(2); LongWritable inputKey3 = new LongWritable(3); LongWritable inputKey4 = new LongWritable(4); LongWritable inputKey5 = new LongWritable(5); LongWritable inputKey6 = new LongWritable(6); LongWritable inputKey7 = new LongWritable(7); mapDriver.addInput(inputKey1, new Text()); mapDriver.addInput(inputKey2, new Text(strArr)); mapDriver.addInput(inputKey3, new Text(strArr)); mapDriver.addInput(inputKey4, new Text(strArr)); mapDriver.addInput(inputKey5, new Text(strArr)); mapDriver.addInput(inputKey6, new Text(strArr)); mapDriver.addInput(inputKey7, new Text(strArr)); List<Pair<IntWritable, BytesWritable>> result = mapDriver.run(); assertEquals(9, result.size()); int key1 = result.get(0).getFirst().get(); BytesWritable value1 = result.get(0).getSecond(); byte[] bytes = value1.getBytes(); HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(); hllc.readRegisters(ByteBuffer.wrap(bytes)); System.out.println("ab\177ab".length()); assertTrue(key1 > 0); assertEquals(1, hllc.getCountEstimate()); }