/** Map function for non-indexed blocks */ public void map( final Prism cellMbr, final Writable value, final OutputCollector<Writable, IntWritable> output, Reporter reporter) throws IOException { if (value instanceof Shape) { try { Shape shape = (Shape) value; Class<?> c = shape.getClass(); Field f; f = c.getDeclaredField(queryField); f.setAccessible(true); if (shape.isIntersected(queryShape)) { boolean report_result = false; if (cellMbr.isValid()) { // Check for duplicate avoidance using reference // point // technique double reference_t = Math.max(queryMbr.t1, shape.getMBR().t1); double reference_x = Math.max(queryMbr.x1, shape.getMBR().x1); double reference_y = Math.max(queryMbr.y1, shape.getMBR().y1); report_result = cellMbr.contains(reference_t, reference_x, reference_y); } else { // A heap block, report right away report_result = true; } if (report_result) { Writable result = null; if (f.getType().equals(Integer.TYPE)) { try { result = new IntWritable((int) f.get(shape)); } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (f.getType().equals(Long.TYPE)) { try { result = new LongWritable((int) f.get(shape)); } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (f.getType().equals(Double.TYPE)) { try { result = new DoubleWritable((int) f.get(shape)); } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } output.collect(result, one); } } } catch (IllegalArgumentException | NoSuchFieldException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (value instanceof RTree) { RTree<Shape> shapes = (RTree<Shape>) value; if (shapes.columnar) { shapes.searchColumnar( queryMbr, new ResultCollector<Writable>() { @Override public void collect(Writable shape) { try { output.collect(shape, one); } catch (IOException e) { e.printStackTrace(); } } }, queryField); } else { shapes.search( queryMbr, new ResultCollector<Shape>() { @Override public void collect(Shape shape) { try { Class<?> c = shape.getClass(); Field f; f = c.getDeclaredField(queryField); f.setAccessible(true); Writable result = null; if (f.getType().equals(Integer.class)) { result = new IntWritable((int) f.get(shape)); } else if (f.getType().equals(Integer.class)) { result = new IntWritable((int) f.get(shape)); } else if (f.getType().equals(Integer.class)) { result = new IntWritable((int) f.get(shape)); } output.collect(result, one); } catch (IOException e) { e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, queryField); } } }