@Before public void setUp() throws IOException { MapFileDemo.main(new String[] {MAP_URI}); Configuration conf = new Configuration(); fs = FileSystem.get(URI.create(MAP_URI), conf); reader = new MapFile.Reader(fs, MAP_URI, conf); key = (WritableComparable<?>) ReflectionUtils.newInstance(reader.getKeyClass(), conf); value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf); }
@Override public long next(HdfsInputStream hdfsistr, Holder<Object> key, Holder<Object> value) { try { MapFile.Reader reader = (BloomMapFile.Reader) hdfsistr.getIn(); Holder<Integer> keySize = new Holder<Integer>(); WritableComparable<?> keyWritable = (WritableComparable<?>) ReflectionUtils.newInstance(reader.getKeyClass(), new Configuration()); Holder<Integer> valueSize = new Holder<Integer>(); Writable valueWritable = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), new Configuration()); if (reader.next(keyWritable, valueWritable)) { key.value = getObject(keyWritable, keySize); value.value = getObject(valueWritable, valueSize); return keySize.value + valueSize.value; } else { return 0; } } catch (Exception ex) { throw new RuntimeCamelException(ex); } }