[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [geomesa-users] Possible bug with removing features, cannot add a feature with same ID as a feature that has been removed
|
Beau,
There may be a reasonable explanation for what you're seeing in your
test.
Removing a row from Accumulo -- and I apologize for lecturing --
actually inserts a DELETE record in the table that cuts short subsequent
scans for matching keys. Records are not actually removed (with the
corresponding DELETE markers) until a major compaction occurs. Because
the new record contains the same indexed data (ID and geometry), it will
receive the same key as the entry it replaces, which means that it will
not be visible in the table until after major compaction.
To test this out, try scheduling a major compaction on your test table
(after the insertions and deletions run), and scan it to see if your new
id1 record is present. My suspicion is that it will be.
Please let me know if this doesn't address your issue.
Thanks, as always!
Sincerely,
-- Chris
On Fri, 2014-07-18 at 17:46 +0000, Beau Lalonde wrote:
> Hi,
>
>
>
> I am using a mid-June version of GeoMesa. Perhaps this issue has been
> fixed since mid-June, but if it hasn’t been I thought I should report
> it.
>
>
>
> I am having trouble with the featureStore.removeFeatures(filter)
> capability in GeoMesa. My problem is that I cannot seem to be able to
> add a feature once I have removed a feature with the same feature ID.
> When I invoke “featureStore.addFeatures(features)”, I do not get an
> exception; however, the feature is not added to GeoMesa. I would like
> to be able to add/remove/add features with the same ID.
>
>
>
> Here is some partial code that illustrates my problem. Please note
> the line that I have commented with “this assertion fails”.
>
>
>
> @Test
>
> public void testRemoveFeatureByID_AddRemoveAdd()
>
> {
>
> // add three features, then remove one
> and verify its removal
>
>
>
> String id1 = "ID1";
>
> assertTrue(addFeature(id1, 45.1d,
> 123.4, 15L));
>
> String id2 = "ID2";
>
> assertTrue(addFeature(id2, 45.0d,
> 123.3, 16L));
>
> String id3 = "ID3";
>
> assertTrue(addFeature(id3, 45.2d,
> 123.5, 17L));
>
>
>
>
> this.geoMesaHelper.removeFeatureByID(GeoMesaHelperTest.FEATURE_NAME,
> id1);
>
>
>
> Set<String> ids =
> this.geoMesaHelper.getIDsFromFeatureCollection(this.geoMesaHelper.query(this.dataStore, GeoMesaHelperTest.FEATURE_NAME, ""));
>
>
>
> assertNotNull(ids);
>
> assertEquals(2, ids.size());
>
> assertTrue(ids.contains(id2));
>
> assertTrue(ids.contains(id3));
>
>
>
> // add back feature with id1 with
> different SKU
>
> assertTrue(addFeature(id1, 45.1d,
> 123.4, 25L));
>
>
>
> // add a uniquely new feature that
> hasn't been added before
>
> String id4 = "ID4";
>
> assertTrue(addFeature(id4, 45.25d,
> 123.55, 18L));
>
>
>
> ids =
> this.geoMesaHelper.getIDsFromFeatureCollection(this.geoMesaHelper.query(this.dataStore, GeoMesaHelperTest.FEATURE_NAME, ""));
>
>
>
> assertNotNull(ids);
>
> assertTrue(ids.contains(id4));
>
> assertTrue(ids.contains(id2));
>
> assertTrue(ids.contains(id3));
>
> assertTrue(ids.contains(id1)); // this
> assertion fails
>
> assertEquals(4, ids.size());
>
> }
>
>
>
> private boolean addFeature(String uniqueID, double
> latitude, double longitude, long sku)
>
> {
>
> String featureSchema =
> "NAME:String,SKU:java.lang.Long,COST:Double,SELL_BY:Date," +
>
> "*" +
> GeoMesaHelperTest.GEOMESA_GEOMETRY + ":Geometry:srid=4326," +
>
>
> GeoMesaHelperTest.GEOMESA_TIME + ":Date";
>
>
>
> // Create feature
>
> SimpleFeatureType featureType =
> this.geoMesaHelper.createFeatureType(dataStore,
> GeoMesaHelperTest.FEATURE_NAME, featureSchema,
> GeoMesaIndexer.GEOMESA_TIME_ATTRIBUTE_NAME);
>
> SimpleFeatureBuilder
> simpleFeatureBuilder = new SimpleFeatureBuilder(featureType);
>
> Object[] noValues = {};
>
> SimpleFeature feature =
> simpleFeatureBuilder.buildFeature(uniqueID, noValues);
>
>
> feature.getUserData().put(Hints.USE_PROVIDED_FID,
> java.lang.Boolean.TRUE);
>
>
>
> // create a geometric rectangle
> centered at the input latitude/longitude
>
> double DLAT = 2.0d;
>
> double DLON = 2.0d;
>
> double minlat = latitude-DLAT/2.0d;
>
> double minlon = longitude-DLON/2.0d;
>
> double maxlat = latitude+DLAT/2.0d;
>
> double maxlon = longitude+DLON/2.0d;
>
> int srid = 4326;
>
> Geometry geometry =
> GeoIndexerUtilities.createRectangleFromLatLon(minlat, minlon, maxlat,
> maxlon, srid);
>
> feature.setAttribute(GEOMESA_GEOMETRY,
> geometry);
>
>
>
> feature.setAttribute("NAME",
> GeoMesaHelperTest.NAME_ATTRIBUTE);
>
> feature.setAttribute("SKU", sku);
>
> feature.setAttribute("COST", 1.23);
>
> feature.setAttribute("SELL_BY", new
> Date());
>
> feature.setAttribute(GEOMESA_TIME, new
> Date());
>
>
>
> // Add feature to GeoMesa
>
> FeatureStore<SimpleFeatureType,
> SimpleFeature> featureStore =
> this.geoMesaHelper.createFeatureStore(dataStore,
> GeoMesaHelperTest.FEATURE_NAME);
>
> DefaultFeatureCollection features =
> new DefaultFeatureCollection();
>
> features.add(feature);
>
> try
>
> {
>
>
> featureStore.addFeatures(features);
>
> }
>
> catch (IOException e)
>
> {
>
> return false;
>
> }
>
>
>
> return true;
>
> }
>
>
>
>
>
> Is there something I am doing wrong? Is there a workaround?
>
>
>
> Thanks,
>
>
>
> Beau
>
>
> _______________________________________________
> geomesa-users mailing list
> geomesa-users@xxxxxxxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> http://www.locationtech.org/mailman/listinfo/geomesa-users