Class AggregatorUtil


  • public final class AggregatorUtil
    extends Object
    Utility methods to help with doing aggregation of elements. Aggregation differs depending on if it ingest or query time aggregation. Ingest aggregation uses the groupBy properties in a Schema, whereas query time aggregation first checks the View to see if the groupBy properties have been overridden.
    • Method Detail

      • ingestAggregate

        public static Iterable<Element> ingestAggregate​(Iterable<? extends Element> elements,
                                                        Schema schema)
        Applies ingest aggregation to the provided iterable of Elements. This uses the groupBy properties in the provided Schema to group the elements prior to aggregating them.

        NOTE - this is done in memory so the size of the iterable should be limited.

        Parameters:
        elements - the elements to be aggregated
        schema - the schema containing the aggregators and groupBy properties to use
        Returns:
        the aggregated elements.
      • queryAggregate

        public static Iterable<Element> queryAggregate​(Iterable<? extends Element> elements,
                                                       Schema schema,
                                                       View view)
        Applies query time aggregation to the provided iterable of Elements. This uses the groupBy properties in the provided View or Schema to group the elements prior to aggregating them. The Matched Vertex field is ignored during aggregation.

        NOTE - this is done in memory so the size of the iterable should be limited.

        Parameters:
        elements - the elements to be aggregated
        schema - the schema containing the aggregators and groupBy properties to use
        view - the view containing the aggregators and groupBy properties to use
        Returns:
        the aggregated elements.
      • queryAggregate

        public static Iterable<Element> queryAggregate​(Iterable<? extends Element> elements,
                                                       Schema schema,
                                                       View view,
                                                       boolean includeMatchedVertex)
        Applies query time aggregation to the provided iterable of Elements. This uses the groupBy properties in the provided View or Schema to group the elements prior to aggregating them. Aggregation of Edges can optionally be configured to include the Matched Vertex field.

        NOTE - this is done in memory so the size of the iterable should be limited.

        Parameters:
        elements - the elements to be aggregated
        schema - the schema containing the aggregators and groupBy properties to use
        view - the view containing the aggregators and groupBy properties to use
        includeMatchedVertex - whether aggregation groups should include the Edge Matched Vertex
        Returns:
        the aggregated elements.