6.7. Analytic Querying¶
GeoMesa provides advanced query capabilities through GeoTools query hints. You can use these hints to control various aspects of query processing, or to trigger distributed analytic processing. See Setting Query Hints for details on setting query hints.
6.7.1. Feature Sampling¶
Instead of returning all features for a query, GeoMesa can use statistical sampling to return a certain percentage of results. This can be useful when rendering maps, or when there are too many features to be meaningful.
Features can either be sampled absolutely, or sampled by a certain attribute. For example, given a series of points in a track, you may wish to sample by the track identifier so that no tracks are completely sampled out.
The sampling value should be a float in the range (0, 1), which represents the fractional value of features that will be returned. Due to distributed processing, the actual count returned is not guaranteed to equal the requested percentage - however, there will never be less features than requested. For example, if you sample 5 features at 10%, you will get back anywhere from 1 to 5 features, depending on how your data is distributed in the cluster.
|QueryHints.SAMPLE_BY||String - attribute name (optional)||any string|
6.7.2. Density Query¶
To populate heatmaps or other pre-rendered maps, GeoMesa can use server-side aggregation to map features to pixels. This results in much less network traffic, and subsequently much faster queries.
The result from a density query is an encoded iterator of
(x, y, count), where
y refer to
the coordinates for the center of a pixel. In GeoServer, you can use the WPS DensityProcess to create a
heatmap from the query result. See Heatmaps for more information.
6.7.3. Arrow Encoding¶
GeoMesa supports returning features as Apache Arrow encoded vectors. This provides an optimized columnar memory layout for fast processing and interoperability with other systems.
The result of an Arrow query will be an iterator of SimpleFeatures, where the first attribute of each will be a byte array. Concatenated together, the byte arrays will form an Arrow file, in the Arrow streaming format (i.e. no footer).
In GeoServer you can use the
ArrowConversionProcess. Otherwise, the encoding is controlled through the
following query hints:
Arrow conversion requires
jackson-core-2.6.x. Some versions of GeoServer ship with an older
jackson-core-2.5.0.jar. After installing the GeoMesa GeoServer plugin, be sure to delete
the older JAR from GeoServer’s
184.108.40.206. Explanation of Hints¶
This hint is used to trigger an Arrow query.
This hint controls whether to include the feature ID as an Arrow vector or not. The default is to include it.
This hint allows for sorting the results by a particular attribute. Only attribute names are supported, not arbitrary CQL.
This hint is used to flip sort order from normal (ascending) to reverse (descending).
This hint indicates which simple feature attributes should be dictionary encoded. It should be a comma-separated list of attribute names.
This hint indicates known dictionary values to use for encoding each field. This allows for specifying a known dictionary up front, which means the dictionary doesn’t have to be computed. Values which are not indicated in the dictionary will be grouped under ‘other’.
The hint should be an encoded map of attribute names to attribute values. The hint should be encoded in
comma-separated values format, where each line indicates a different attribute. The first item in each line is
the attribute name, and the subsequent items are dictionary values. Standard CSV escaping can be used. The function
org.locationtech.geomesa.utils.text.StringSerialization.encodeSeqMap can be used to encode a map of values.
This hint indicates that cached statistics (top-k) will be used for dictionaries, if available. Otherwise, dictionaries will be computed based on the data returned, which may be slower.
This hint will cause multiple logical Arrow files to be returned, instead of a single file. This will generally be faster, as no client-side merging needs to be done. However, any sorting will only be applied per file, not globally. Also, the end result tends to be larger (in bytes), as metadata and dictionary values may be repeated in different logical files.
This hint will cause any dictionaries to be computed first, through a separate scan. A second scan will construct the Arrow files. This is the behavior of the initial GeoMesa Arrow implementation, and is only included for back compatibility.
This hint will restrict the number of features included in each Arrow record batch. An Arrow file contains a series of record batches -limiting the max size of each batch can allow memory-constrained systems to operate more easily.