Source:
public JavaPairRDD<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>> getIndexedGeometryRDD( double bufferAmount, boolean recalculate ) { verifyParameters(); if (!geowaveRDD.isLoaded()) { LOGGER.error("Must provide a loaded RDD."); return null; } if (rawGeometryRDD == null || recalculate == true) { rawGeometryRDD = geowaveRDD .getRawRDD() .flatMapToPair( new PairFlatMapFunction<Tuple2<GeoWaveInputKey, SimpleFeature>, ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>() { @Override public Iterator<Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>> call( Tuple2<GeoWaveInputKey, SimpleFeature> t ) throws Exception { SimpleFeature inputFeature = t._2; Geometry geom = (Geometry) inputFeature.getDefaultGeometry(); if (geom == null) { return Iterators.emptyIterator(); } Envelope internalEnvelope = geom.getEnvelopeInternal(); if (internalEnvelope.isNull()) { return Iterators.emptyIterator(); } internalEnvelope.expandBy(bufferAmount); MultiDimensionalNumericData boundsRange = GeometryUtils.getBoundsFromEnvelope(internalEnvelope); NumericIndexStrategy index = indexStrategy.value(); InsertionIds insertIds = index.getInsertionIds( boundsRange, 80); if(bufferAmount == 0.0) { insertIds = RDDUtils.trimIndexIds(insertIds, geom, index); } List<Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>> result = Lists .newArrayListWithCapacity(insertIds.getSize()); for (Iterator<ByteArrayId> iter = insertIds.getCompositeInsertionIds().iterator(); iter .hasNext();) { ByteArrayId id = iter.next(); Tuple2<GeoWaveInputKey, Geometry> valuePair = new Tuple2<>( t._1, geom); Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>> indexPair = new Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>( id, valuePair); result.add(indexPair); } return result.iterator(); } }); } return rawGeometryRDD; }

Target:
public JavaPairRDD<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>> getIndexedGeometryRDD( double bufferAmount, boolean recalculate ) { verifyParameters(); if (!geowaveRDD.isLoaded()) { LOGGER.error("Must provide a loaded RDD."); return null; } if (rawGeometryRDD == null || recalculate) { rawGeometryRDD = geowaveRDD .getRawRDD() .filter(t -> (t._2.getDefaultGeometry() != null && !((Geometry)t._2.getDefaultGeometry()).getEnvelopeInternal().isNull())) .flatMapToPair( new PairFlatMapFunction<Tuple2<GeoWaveInputKey, SimpleFeature>, ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>() { @Override public Iterator<Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>> call( Tuple2<GeoWaveInputKey, SimpleFeature> t ) throws Exception { SimpleFeature inputFeature = t._2; Geometry geom = (Geometry) inputFeature.getDefaultGeometry(); Envelope internalEnvelope = geom.getEnvelopeInternal(); internalEnvelope.expandBy(bufferAmount); MultiDimensionalNumericData boundsRange = GeometryUtils .getBoundsFromEnvelope(internalEnvelope); NumericIndexStrategy index = indexStrategy.value(); InsertionIds insertIds = index.getInsertionIds( boundsRange, 80); if (bufferAmount == 0.0) { insertIds = RDDUtils.trimIndexIds( insertIds, geom, index); } List<Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>> result = Lists .newArrayListWithCapacity(insertIds.getSize()); for (Iterator<ByteArrayId> iter = insertIds.getCompositeInsertionIds().iterator(); iter .hasNext();) { ByteArrayId id = iter.next(); Tuple2<GeoWaveInputKey, Geometry> valuePair = new Tuple2<>( t._1, geom); Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>> indexPair = new Tuple2<ByteArrayId, Tuple2<GeoWaveInputKey, Geometry>>( id, valuePair); result.add(indexPair); } return result.iterator(); } }); } return rawGeometryRDD; }