Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] Scanning some particular index

Hi Serge,

As a way to demonstrate some these queries, I've updated the GeoMesa Accumulo Quickstart here: https://github.com/locationtech/geomesa/tree/master/geomesa-examples/geomesa-accumulo-quickstart

The new function secondaryIndexExample (1) illustrates setting properties (for a SQL-like 'projection') and also optionally providing a SortBy.

Anyhow, I hope this helps answer your questions more completely.

While we're talking about QuickStart's, I'd also point the Kafka QuickStart here: https://github.com/locationtech/geomesa/tree/master/geomesa-examples/geomesa-kafka-quickstart with associated docs here: http://www.geomesa.org/geomesa-kafka-quickstart/.

Cheers,

Jim

(1) https://github.com/locationtech/geomesa/blob/master/geomesa-examples/geomesa-accumulo-quickstart/src/main/java/org/locationtech/geomesa/examples/AccumuloQuickStart.java#L261-265

On 08/03/2015 05:55 PM, Jim Hughes wrote:
Hi Serge,

Great questions.  They require a little bit of understanding of the GeoTools API and what a SimpleFeature is, etc.

If you want to make a query like "Who = 'Bierce'" and receive only the feature IDs, then we'll need to work around things a little bit.  A GeoTools query can specify which properties to return.  The feature ID is always returned, and a SimpleFeature without a geometry is a bit silly, so I'd suggest requesting only the geometry field (in the example 'Where').  Something like this should do it

String[] props = new String[]{"Who'};
query.setPropertyNames(props);

If you do this, then the SimpleFeatures returned from the query should just have a geometry and a feature ID.  (feature.getID() should return the ID.)

To answer your questions:
1.  Yes, generally, you should be using the GeoTools DataStore/FeatureStore API.  The query language is ECQL and is similar to the 'where' clause from a SQL query.

2-4.  To do otherwise, you'd have to dig into the GeoMesa query planner.  I'd encourage you to ask more questions about the GeoTools api on the list until we've clarified what you achieve that way.  If there's something requiring more direct access, we chat through that as well.

I'm kicking around a branch where I add the code above to the GeoMesa Accumulo Quickstart.  Once I have something tested, I'll shout. 

Cheers,

Jim

On 08/03/2015 11:53 AM, Serge Vilvovsky wrote:
Hi,

I need to scan a secondary index and see the list of primary Ids. 

I started with geotable example by adding index=full for "What" attibute.

        // list the attributes that constitute the feature type
        List<String> attributes = Lists.newArrayList(
                "Who:String:index=full",
                "What:java.lang.Long:index=full",     // some types require full qualification (see DataUtilities docs)
                "When:Date",               // a date-time field is optional, but can be indexed
                "*Where:Point:srid=4326",  // the "*" denotes the default geometry (used for indexing)
                "Why:String"               // you may have as many other attributes as you like...
        );

What I need is by scanning 'What' index to receive the sorted List of pairs (What, Primary Feature Id)

For my understanding the fastest way to do it is just scanning directly the index table and finding the feature Id instead of scanning the index and seeking whole the feature at the records table. But may be the whole feature is encoded at the index table, so it does not require seeking in records table. 

For two features I see the next rows:

root@singlenode> scan -t geotable_attr_idx

\x01\x00\x00Addams\x0080000148368cObservation.0 : []    \x02\x00\x00\x00=Observation.\xB0Addam\xF3\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01H6\x8C\xF3\x00\x01\x01\xC0S\x03\xB1\xD6N4\xB6\xC0B\xCE\xD8n\x884\xE0\x80\x12\x18!*<

\x01\x00\x00Bierce\x00800001456f2aObservation.1 : []    \x02\x00\x00\x00=Observation.\xB1Bierc\xE5\x01\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x01Eo*\xE7\xB0\x01\x01\xC0S_\x053\xD3\x90%\xC0Co\xE8 Z\xB1>\x80\x12\x18!*<

\x01\x00\x018000000000000000\x0080000148368cObservation.0 : []    \x02\x00\x00\x00=Observation.\xB0Addam\xF3\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01H6\x8C\xF3\x00\x01\x01\xC0S\x03\xB1\xD6N4\xB6\xC0B\xCE\xD8n\x884\xE0\x80\x12\x18!*<

\x01\x00\x018000000000000001\x00800001456f2aObservation.1 : []    \x02\x00\x00\x00=Observation.\xB1Bierc\xE5\x01\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x01Eo*\xE7\xB0\x01\x01\xC0S_\x053\xD3\x90%\xC0Co\xE8 Z\xB1>\x80\x12\x18!*<


My questions are:

1. Is it any efficient top level API that I can use?

If not:

2. Am I looking at the right table?

3. How to scan the rows to ignore the Who index and use only What index?

4. How to decode the received rows?

Thank you!

Serge



_______________________________________________
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



_______________________________________________
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


Back to the top