private void resolveViews(final Operations<?> operations) { for (final Operation operation : operations.getOperations()) { if (operation instanceof OperationView) { final OperationView opView = ((OperationView) operation); if (opView.getView() instanceof NamedView) { opView.setView(resolveView((NamedView) opView.getView())); } } else if (operation instanceof Operations) { resolveViews((Operations<?>) operation); } } }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge") @Override public List<Range> getRange(final ElementId elementId, final GraphFilters operation) throws RangeFactoryException { final SeededGraphFilters.IncludeIncomingOutgoingType inOutType = (operation instanceof SeededGraphFilters) ? ((SeededGraphFilters) operation).getIncludeIncomingOutGoing() : SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING; return getRange(elementId, operation, inOutType); }
private GetAllElements getGetAllElements(final OP getRDDOfAllElements) { return new GetAllElements.Builder() .view(getRDDOfAllElements.getView()) .directedType(getRDDOfAllElements.getDirectedType()) .options(getRDDOfAllElements.getOptions()) .build(); }
protected final View.Builder mergeView(final OperationView operationView, final View viewToMerge) { View.Builder viewBuilder = new View.Builder() .merge(operationView.getView()); if (null != viewToMerge) { viewBuilder.merge(viewToMerge.clone()); } return viewBuilder; }
@Override public IteratorSetting getEdgeEntityDirectionFilterIteratorSetting(final GraphFilters operation) { final boolean includeEntities = operation.getView().hasEntities(); final boolean includeEdges = operation.getView().hasEdges(); final DirectedType directedType = operation.getDirectedType(); final IncludeIncomingOutgoingType inOutType; if (operation instanceof SeededGraphFilters) { inOutType = ((SeededGraphFilters) operation).getIncludeIncomingOutGoing(); } else { inOutType = IncludeIncomingOutgoingType.OUTGOING;
private List<Range> getRange(final ElementId elementId, final GraphFilters operation, final SeededGraphFilters.IncludeIncomingOutgoingType inOutType) throws RangeFactoryException { if (elementId instanceof EntityId) { return getRange(((EntityId) elementId).getVertex(), operation, operation.getView().hasEdges()); } else { final EdgeId edgeId = (EdgeId) elementId; final List<Range> ranges = new ArrayList<>(); if (operation.getView().hasEdges() && DirectedType.areCompatible(operation.getDirectedType(), edgeId.getDirectedType())) { // EQUALS and RELATED seed matching. final DirectedType directed = DirectedType.and(operation.getDirectedType(), edgeId.getDirectedType()); ranges.addAll(getRange(edgeId.getSource(), edgeId.getDestination(), directed, operation, inOutType)); } // Do related - if operation doesn't have seed matching or it has seed matching equal to RELATED final boolean doRelated = !(operation instanceof SeedMatching) || !SeedMatching.SeedMatchingType.EQUAL.equals(((SeedMatching) operation).getSeedMatching()); if (doRelated && operation.getView().hasEntities()) { // Get Entities related to EdgeIds ranges.addAll(getRange(edgeId.getSource(), operation, false)); ranges.addAll(getRange(edgeId.getDestination(), operation, false)); } return ranges; } }
@Override public IteratorSetting getElementPropertyRangeQueryFilter(final GraphFilters operation) { final boolean includeEntities = operation.getView().hasEntities(); final boolean includeEdges = operation.getView().hasEdges(); if (includeEntities && includeEdges) { LOGGER.debug("Returning null from getElementPropertyRangeQueryFilter as includeEntities = {} and includeEdges = {}", includeEntities, includeEdges); return null; } final IteratorSetting is = new IteratorSettingBuilder( AccumuloStoreConstants.RANGE_ELEMENT_PROPERTY_FILTER_ITERATOR_PRIORITY, AccumuloStoreConstants.RANGE_ELEMENT_PROPERTY_FILTER_ITERATOR_NAME, RANGE_ELEMENT_PROPERTY_FILTER_ITERATOR).all() .includeEdges(includeEdges) .includeEntities(includeEntities) .build(); LOGGER.debug("Creating IteratorSetting for iterator class {} with priority = {}, " + "includeEdges = {}, includeEntities = {}", RANGE_ELEMENT_PROPERTY_FILTER_ITERATOR, AccumuloStoreConstants.RANGE_ELEMENT_PROPERTY_FILTER_ITERATOR_PRIORITY, includeEdges, includeEntities); return is; }
@Override public void preExecute(final OperationChain<?> opChain, final Context context) { if (!edges.isEmpty() || !entities.isEmpty()) { final List<Operation> updatedOps = new ArrayList<>(); for (final Operation op : new ArrayList<>(opChain.flatten())) { updatedOps.add(op); if (OperationView.hasView(op)) { updatedOps.addAll(migrateOperation(op)); } } opChain.updateOperations(updatedOps); } }
private void updateView(final OperationChain<?> opChain) { for (final Operation operation : opChain.flatten()) { if (operation instanceof OperationView) { final OperationView operationView = (OperationView) operation; final View.Builder viewBuilder = mergeView(operationView, getViewToMerge()); if ((null != whiteListElementGroups && !whiteListElementGroups.isEmpty()) || (null != blackListElementGroups && !blackListElementGroups.isEmpty())) { viewBuilder.removeEntities(this::removeElementGroups); viewBuilder.removeEdges(this::removeElementGroups); } if (!addExtraGroups && null != operationView.getView()) { final Set<String> entityGroups = operationView.getView().getEntityGroups(); viewBuilder.removeEntities(grp -> null == entityGroups || !entityGroups.contains(grp.getKey())); final Set<String> edgeGroups = operationView.getView().getEdgeGroups(); viewBuilder.removeEdges(grp -> null == edgeGroups || !edgeGroups.contains(grp.getKey())); } viewBuilder.expandGlobalDefinitions(); operationView.setView(viewBuilder.build()); } } }
public AccumuloSingleIDRetriever(final AccumuloStore store, final OP operation, final User user) throws IteratorSettingException, StoreException { this(store, operation, user, store.getKeyPackage().getIteratorFactory().getElementPreAggregationFilterIteratorSetting(operation.getView(), store), store.getKeyPackage().getIteratorFactory().getElementPostAggregationFilterIteratorSetting(operation.getView(), store), store.getKeyPackage().getIteratorFactory().getEdgeEntityDirectionFilterIteratorSetting(operation)); }
@Override public IteratorSetting getElementPropertyRangeQueryFilter(final GraphFilters operation) { final boolean includeEntities = operation.getView().hasEntities(); final boolean includeEdges = operation.getView().hasEdges(); final DirectedType directedType = operation.getDirectedType(); final SeededGraphFilters.IncludeIncomingOutgoingType inOutType; if (operation instanceof SeededGraphFilters) { inOutType = ((SeededGraphFilters) operation).getIncludeIncomingOutGoing(); } else { inOutType = SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING;
derivedView = ((GraphFilters) operation).getView(); operation = applyPropertyFilters(derivedView, operation); return operation;
private List<Operation> migrateOperation(final Operation op) { final OperationView opView = OperationView.class.cast(op); final Map<String, ViewMigration> migratedEntities = migrateViewElements(entities, opView.getView()::getEntity); final Map<String, ViewMigration> migratedEdges = migrateViewElements(edges, opView.getView()::getEdge); final View.Builder viewBuilder = new View.Builder().merge(opView.getView()); for (final Map.Entry<String, ViewMigration> entry : migratedEntities.entrySet()) { viewBuilder.entity(entry.getKey(), entry.getValue().buildViewElementDefinition()); } for (final Map.Entry<String, ViewMigration> entry : migratedEdges.entrySet()) { viewBuilder.edge(entry.getKey(), entry.getValue().buildViewElementDefinition()); } viewBuilder.config(ViewValidator.SKIP_VIEW_VALIDATION, TRUE); final View updatedView = viewBuilder.build(); LOGGER.debug("Migrated view: {}", updatedView); opView.setView(updatedView); final List<Operation> migrationOps = ViewMigration.createMigrationOps(aggregateAfter, migratedEdges.values(), migratedEntities.values()); if (LOGGER.isDebugEnabled()) { try { LOGGER.debug("Migrated operations: {}", StringUtil.toString(JSONSerialiser.serialise(new OperationChain<>(migrationOps), true))); } catch (final SerialisationException e) { LOGGER.debug("Failed to json serialise the migration operations: {}", new OperationChain<>(migrationOps)); } } return migrationOps; }
/** * Performs any transformations specified in a view on an element * * @param element the element to transform */ public void doTransformation(final Element element) { final ViewElementDefinition viewDef = operation.getView().getElement(element.getGroup()); if (null != viewDef) { transform(element, viewDef.getTransformer()); } }
private static void updateOperationChainViews(final Operations<?> operations, final Schema schema) { for (final Operation operation : operations.getOperations()) { if (operation instanceof Operations) { updateOperationChainViews((Operations) operation, schema); } else if (operation instanceof OperationView) { View opView = ((OperationView) operation).getView(); if (null == opView) { opView = createView(schema); } else if (!(opView instanceof NamedView) && !opView.hasGroups() && !opView.isAllEdges() && !opView.isAllEntities()) { opView = new View.Builder() .merge(createView(schema)) .merge(opView) .build(); } else if (opView.isAllEdges() || opView.isAllEntities()) { View.Builder opViewBuilder = new View.Builder() .merge(opView); if (opView.isAllEdges()) { opViewBuilder.edges(schema.getEdgeGroups()); } if (opView.isAllEntities()) { opViewBuilder.entities(schema.getEntityGroups()); } opView = opViewBuilder.build(); } opView.expandGlobalDefinitions(); ((OperationView) operation).setView(opView); } } }
/** * Performs any post Filtering specified in a view on an element * * @param element the element to post Filter * @return the result of validating the element against the post filters */ public boolean doPostFilter(final Element element) { final ViewElementDefinition viewDef = operation.getView().getElement(element.getGroup()); if (null != viewDef) { return postFilter(element, viewDef.getPostTransformFilter()); } return true; }
private void updateOperationChainView(final Operations<?> operations) { for (final Operation operation : operations.getOperations()) { if (operation instanceof Operations) { updateOperationChainView((Operations) operation); } else if (operation instanceof OperationView) { View opView = ((OperationView) operation).getView(); if (null == opView) { opView = config.getView(); } else if (!(opView instanceof NamedView) && !opView.hasGroups() && !opView.isAllEdges() && !opView.isAllEntities()) { opView = new View.Builder() .merge(config.getView()) .merge(opView) .build(); } else if (opView.isAllEdges() || opView.isAllEntities()) { View.Builder opViewBuilder = new View.Builder() .merge(opView); if (opView.isAllEdges()) { opViewBuilder.edges(getSchema().getEdgeGroups()); } if (opView.isAllEntities()) { opViewBuilder.entities(getSchema().getEntityGroups()); } opView = opViewBuilder.build(); } opView.expandGlobalDefinitions(); ((OperationView) operation).setView(opView); } } }
LOGGER.debug("Added {} ranges to BatchScanner", ranges.size()); for (final String col : operation.getView().getEdgeGroups()) { scanner.fetchColumnFamily(new Text(col)); LOGGER.debug("Added {} as a column family to fetch", col); for (final String col : operation.getView().getEntityGroups()) { scanner.fetchColumnFamily(new Text(col)); LOGGER.debug("Added {} as a column family to fetch", col);
public AccumuloRangeIDRetriever(final AccumuloStore store, final OP operation, final User user) throws IteratorSettingException, StoreException { this(store, operation, user, store.getKeyPackage().getIteratorFactory().getElementPreAggregationFilterIteratorSetting(operation.getView(), store), store.getKeyPackage().getIteratorFactory().getEdgeEntityDirectionFilterIteratorSetting(operation), store.getKeyPackage().getIteratorFactory().getElementPropertyRangeQueryFilter(operation)); }
.getQueryTimeAggregatorIteratorSetting(operation.getView(), accumuloStore); if (null != queryTimeAggregator) { InputConfigurator.addIterator(AccumuloInputFormat.class, conf, queryTimeAggregator);