[ https://issues.apache.org/jira/browse/RYA-260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15979031#comment-15979031 ]
ASF GitHub Bot commented on RYA-260: ------------------------------------ Github user kchilton2 commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/156#discussion_r112728756 --- Diff: extras/rya.pcj.fluo/pcj.fluo.app/src/main/java/org/apache/rya/indexing/pcj/fluo/app/QueryResultUpdater.java --- @@ -53,32 +54,46 @@ * @param tx - The transaction all Fluo queries will use. (not null) * @param childBindingSet - A binding set that the query's child node has emmitted. (not null) * @param queryMetadata - The metadata of the Query whose results will be updated. (not null) + * @throws Exception A problem caused the update to fail. */ public void updateQueryResults( final TransactionBase tx, final VisibilityBindingSet childBindingSet, - final QueryMetadata queryMetadata) { + final QueryMetadata queryMetadata) throws Exception { checkNotNull(tx); checkNotNull(childBindingSet); checkNotNull(queryMetadata); + log.trace( + "Transaction ID: " + tx.getStartTimestamp() + "\n" + + "Join Node ID: " + queryMetadata.getNodeId() + "\n" + + "Child Node ID: " + queryMetadata.getChildNodeId() + "\n" + + "Child Binding Set:\n" + childBindingSet + "\n"); + // Create the query's Binding Set from the child node's binding set. final VariableOrder queryVarOrder = queryMetadata.getVariableOrder(); + final BindingSet queryBindingSet = BindingSetUtil.keepBindings(queryVarOrder, childBindingSet); - final MapBindingSet queryBindingSet = new MapBindingSet(); - for(final String bindingName : queryVarOrder) { - if(childBindingSet.hasBinding(bindingName)) { - final Binding binding = childBindingSet.getBinding(bindingName); - queryBindingSet.addBinding(binding); - } + // Create the Row Key for the result. If the child node groups results, then the key must only contain the Group By variables. + final Bytes resultRow; + + final String childNodeId = queryMetadata.getChildNodeId(); + final boolean isGrouped = childNodeId.startsWith( IncrementalUpdateConstants.AGGREGATION_PREFIX ); + if(isGrouped) { --- End diff -- Ok, I don't know if this is related, but here was the initial motivation. We're not going to write on top of the existing query result every time if we don't use the group by arguments as the Row Key for the result. So if we're doing the Max function and the first binding set that is written isn't always the max, then you'll have at least two binding sets. We are not guaranteed that the order of the binding set notification will match the order that the binding sets were written, so it's possible for the older result to be exported after the newer result. Which is wrong. > Add Aggregation support for Fluo/PCJ app > ---------------------------------------- > > Key: RYA-260 > URL: https://issues.apache.org/jira/browse/RYA-260 > Project: Rya > Issue Type: New Feature > Reporter: Andrew Smith > Assignee: Kevin Chilton > > A user must be able to submit a PCJ query that contains the following > aggregation functions from SPARQL: > * Sum > * Count > * Average > * Min > * Max > This task does not include any aggregations that appear within a GroupBy > clause. We only need to support queries that have the aggregation within the > SELECT section. > For example, the following query should be processed: > {code} > SELECT (avg(?price) as ?averagePrice) > { > urn:BookA urn:price ?price. > } > {code} > And the following query should not be processed because it requires a group > by: > {code} > SELECT ?title (avg(?price) as ?averagePrice) > { > ?title urn:price ?price. > } > GROUP BY ?title > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)