use of org.apache.rya.indexing.pcj.fluo.app.query.ConstructQueryMetadata in project incubator-rya by apache.
the class QueryReportRenderer method render.
/**
* Pretty render a {@link QueryReport}.
*
* @param queryReport - The report that will be rendered. (not null)
* @return A pretty render of the report.
* @throws Exception Indicates the SPARQL could not be rendered for some reason.
*/
public String render(final QueryReport queryReport) throws Exception {
checkNotNull(queryReport);
final Report.Builder builder = Report.builder();
final FluoQuery metadata = queryReport.getFluoQuery();
QueryMetadata queryMetadata = metadata.getQueryMetadata();
builder.appendItem(new ReportItem(""));
builder.appendItem(new ReportItem("QUERY NODE"));
builder.appendItem(new ReportItem("Node ID", queryMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", queryMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("SPARQL", queryMetadata.getSparql()));
builder.appendItem(new ReportItem("Child Node ID", queryMetadata.getChildNodeId()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(queryMetadata.getNodeId())));
if (metadata.getQueryType() == QueryType.CONSTRUCT) {
builder.appendItem(new ReportItem(""));
final ConstructQueryMetadata constructMetadata = metadata.getConstructQueryMetadata().get();
builder.appendItem(new ReportItem("CONSTRUCT QUERY NODE"));
builder.appendItem(new ReportItem("Node ID", constructMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", constructMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("Parent Node ID", constructMetadata.getParentNodeId()));
builder.appendItem(new ReportItem("Child Node ID", constructMetadata.getChildNodeId()));
builder.appendItem(new ReportItem("Construct Graph", constructMetadata.getConstructGraph().toString()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(constructMetadata.getNodeId())));
}
for (ProjectionMetadata projectionMetadata : metadata.getProjectionMetadata()) {
builder.appendItem(new ReportItem(""));
builder.appendItem(new ReportItem("PROJECTION NODE"));
builder.appendItem(new ReportItem("Node ID", projectionMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", projectionMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("Parent Node ID", projectionMetadata.getParentNodeId()));
builder.appendItem(new ReportItem("Child Node ID", projectionMetadata.getChildNodeId()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(projectionMetadata.getNodeId())));
}
for (final FilterMetadata filterMetadata : metadata.getFilterMetadata()) {
builder.appendItem(new ReportItem(""));
builder.appendItem(new ReportItem("FILTER NODE"));
builder.appendItem(new ReportItem("Node ID", filterMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", filterMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("Filter SPARQL", prettyFormatSparql(filterMetadata.getFilterSparql())));
builder.appendItem(new ReportItem("Parent Node ID", filterMetadata.getParentNodeId()));
builder.appendItem(new ReportItem("Child Node ID", filterMetadata.getChildNodeId()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(filterMetadata.getNodeId())));
}
for (final JoinMetadata joinMetadata : metadata.getJoinMetadata()) {
builder.appendItem(new ReportItem(""));
builder.appendItem(new ReportItem("JOIN NODE"));
builder.appendItem(new ReportItem("Node ID", joinMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", joinMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("Parent Node ID", joinMetadata.getParentNodeId()));
builder.appendItem(new ReportItem("Left Child Node ID", joinMetadata.getLeftChildNodeId()));
builder.appendItem(new ReportItem("Right Child Node ID", joinMetadata.getRightChildNodeId()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(joinMetadata.getNodeId())));
}
for (final StatementPatternMetadata spMetadata : metadata.getStatementPatternMetadata()) {
builder.appendItem(new ReportItem(""));
builder.appendItem(new ReportItem("STATEMENT PATTERN NODE"));
builder.appendItem(new ReportItem("Node ID", spMetadata.getNodeId()));
builder.appendItem(new ReportItem("Variable Order", spMetadata.getVariableOrder().toString()));
builder.appendItem(new ReportItem("Statement Pattern", spMetadata.getStatementPattern()));
builder.appendItem(new ReportItem("Parent Node ID", spMetadata.getParentNodeId()));
builder.appendItem(new ReportItem("Count", "" + queryReport.getCount(spMetadata.getNodeId())));
}
return builder.build().toString();
}
use of org.apache.rya.indexing.pcj.fluo.app.query.ConstructQueryMetadata in project incubator-rya by apache.
the class BindingSetUpdater method process.
@Override
public final void process(final TransactionBase tx, final Bytes row, final Column col) {
checkNotNull(tx);
checkNotNull(row);
checkNotNull(col);
final Observation observation;
try {
observation = parseObservation(tx, row);
} catch (final Exception e) {
log.error("Unable to parse an Observation from a Row and Column pair, so this notification will be skipped. " + "Row: " + row + " Column: " + col, e);
return;
}
final String observedNodeId = observation.getObservedNodeId();
final VisibilityBindingSet observedBindingSet = observation.getObservedBindingSet();
final String parentNodeId = observation.getParentId();
// Figure out which node needs to handle the new metadata.
final NodeType parentNodeType = NodeType.fromNodeId(parentNodeId).get();
switch(parentNodeType) {
case QUERY:
final QueryMetadata parentQuery = queryDao.readQueryMetadata(tx, parentNodeId);
try {
queryUpdater.updateQueryResults(tx, observedBindingSet, parentQuery);
} catch (final Exception e) {
throw new RuntimeException("Could not process a Query node.", e);
}
break;
case PROJECTION:
final ProjectionMetadata projectionQuery = queryDao.readProjectionMetadata(tx, parentNodeId);
try {
projectionUpdater.updateProjectionResults(tx, observedBindingSet, projectionQuery);
} catch (final Exception e) {
throw new RuntimeException("Could not process a Query node.", e);
}
break;
case CONSTRUCT:
final ConstructQueryMetadata constructQuery = queryDao.readConstructQueryMetadata(tx, parentNodeId);
try {
constructUpdater.updateConstructQueryResults(tx, observedBindingSet, constructQuery);
} catch (final Exception e) {
throw new RuntimeException("Could not process a Query node.", e);
}
break;
case FILTER:
final FilterMetadata parentFilter = queryDao.readFilterMetadata(tx, parentNodeId);
try {
filterUpdater.updateFilterResults(tx, observedBindingSet, parentFilter);
} catch (final Exception e) {
throw new RuntimeException("Could not process a Filter node.", e);
}
break;
case JOIN:
final JoinMetadata parentJoin = queryDao.readJoinMetadata(tx, parentNodeId);
try {
joinUpdater.updateJoinResults(tx, observedNodeId, observedBindingSet, parentJoin);
} catch (final Exception e) {
throw new RuntimeException("Could not process a Join node.", e);
}
break;
case PERIODIC_QUERY:
final PeriodicQueryMetadata parentPeriodicQuery = queryDao.readPeriodicQueryMetadata(tx, parentNodeId);
try {
periodicQueryUpdater.updatePeriodicBinResults(tx, observedBindingSet, parentPeriodicQuery);
} catch (Exception e) {
throw new RuntimeException("Could not process PeriodicBin node.", e);
}
break;
case AGGREGATION:
final AggregationMetadata parentAggregation = queryDao.readAggregationMetadata(tx, parentNodeId);
try {
aggregationUpdater.updateAggregateResults(tx, observedBindingSet, parentAggregation);
} catch (final Exception e) {
throw new RuntimeException("Could not process an Aggregation node.", e);
}
break;
default:
throw new IllegalArgumentException("The parent node's NodeType must be of type Aggregation, Projection, ConstructQuery, Filter, Join, PeriodicBin or Query, but was " + parentNodeType);
}
}
Aggregations