Search in sources :

Example 6 with Output

use of uk.gov.gchq.gaffer.operation.io.Output in project Gaffer by gchq.

the class GetElementsInRangesHandlerTest method shouldHaveNoIncomingEdges.

private void shouldHaveNoIncomingEdges(final AccumuloStore store) throws OperationException {
    // Given - get everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    final Set<Pair<ElementId, ElementId>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("1")));
    final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
    // all Edges stored should be incoming from our provided seeds.
    final Output operation = createOperation(simpleEntityRanges, view, IncludeIncomingOutgoingType.INCOMING, DirectedType.EITHER);
    // When
    final List<Element> results = executeOperation(operation, store);
    // Then - should be no incoming edges in the provided range
    assertThat(results).isEmpty();
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Output(uk.gov.gchq.gaffer.operation.io.Output) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) HashSet(java.util.HashSet)

Example 7 with Output

use of uk.gov.gchq.gaffer.operation.io.Output in project Gaffer by gchq.

the class GetElementsInRangesHandlerTest method shouldReturnNothingWhenNoEdgesSet.

private void shouldReturnNothingWhenNoEdgesSet(final AccumuloStore store) throws OperationException {
    // Given - get everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    final Set<Pair<ElementId, ElementId>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("1")));
    final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
    final Output operation = createOperation(simpleEntityRanges, view, IncludeIncomingOutgoingType.EITHER, DirectedType.UNDIRECTED);
    // When
    final List<Element> results = executeOperation(operation, store);
    // Then - there should be no undirected edges in the provided range
    assertThat(results).isEmpty();
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Output(uk.gov.gchq.gaffer.operation.io.Output) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) HashSet(java.util.HashSet)

Example 8 with Output

use of uk.gov.gchq.gaffer.operation.io.Output in project Gaffer by gchq.

the class GetElementsInRangesHandlerTest method shouldReturnElementsNoSummarisation.

private void shouldReturnElementsNoSummarisation(final AccumuloStore store) throws OperationException {
    // Given - everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    final Set<Pair<ElementId, ElementId>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("1")));
    final Output operation = createOperation(simpleEntityRanges, defaultView, IncludeIncomingOutgoingType.EITHER, DirectedType.EITHER);
    // When
    List<Element> results = executeOperation(operation, store);
    // Then - each Edge was put in 3 times with different col qualifiers, without summarisation we expect this number
    ElementUtil.assertElementEquals(createElements(NUM_ENTRIES), results);
    // Given - this should get everything between 0 and 0799 (again being string ordering 0800 is more than 08)
    simpleEntityRanges.clear();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("08")));
    // When
    results = executeOperation(operation, store);
    // Then - each Edge was put in 3 times with different col qualifiers, without summarisation we expect this number
    ElementUtil.assertElementEquals(createElements(800), results);
}
Also used : Output(uk.gov.gchq.gaffer.operation.io.Output) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) HashSet(java.util.HashSet)

Example 9 with Output

use of uk.gov.gchq.gaffer.operation.io.Output in project Gaffer by gchq.

the class GetElementsInRangesHandlerTest method shouldSummariseOutGoingEdgesOnly.

private void shouldSummariseOutGoingEdgesOnly(final AccumuloStore store) throws OperationException {
    // Given - get everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    final Set<Pair<ElementId, ElementId>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("C")));
    final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
    // all Edges stored should be outgoing from our provided seeds.
    final Output operation = createOperation(simpleEntityRanges, view, IncludeIncomingOutgoingType.OUTGOING, DirectedType.EITHER);
    // When
    List<Element> results = executeOperation(operation, store);
    // Then
    ElementUtil.assertElementEquals(createSummarisedElements(NUM_ENTRIES), results);
    // Given - this should get everything between 0 and 0799 (again being string ordering 0800 is more than 08)
    simpleEntityRanges.clear();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0"), new EntitySeed("08")));
    // When
    results = executeOperation(operation, store);
    // Then
    ElementUtil.assertElementEquals(createSummarisedElements(800), results);
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Output(uk.gov.gchq.gaffer.operation.io.Output) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) HashSet(java.util.HashSet)

Example 10 with Output

use of uk.gov.gchq.gaffer.operation.io.Output in project Gaffer by gchq.

the class FederatedStore method addAdditionalOperationHandlers.

@Override
protected void addAdditionalOperationHandlers() {
    // Override the Operations that don't have an output
    getSupportedOperations().stream().filter(op -> !Output.class.isAssignableFrom(op) && !AddElements.class.equals(op) && !AddNamedOperation.class.equals(op) && !AddNamedView.class.equals(op)).forEach(op -> addOperationHandler(op, new FederatedOperationHandler()));
    addOperationHandler(GetSchema.class, new FederatedGetSchemaHandler());
    addOperationHandler(Filter.class, new FederatedFilterHandler());
    addOperationHandler(Aggregate.class, new FederatedAggregateHandler());
    addOperationHandler(Transform.class, new FederatedTransformHandler());
    addOperationHandler(Validate.class, new FederatedValidateHandler());
    addOperationHandler(GetAllGraphIds.class, new FederatedGetAllGraphIDHandler());
    addOperationHandler(AddGraph.class, new FederatedAddGraphHandler());
    addOperationHandler(AddGraphWithHooks.class, new FederatedAddGraphWithHooksHandler());
    addOperationHandler(RemoveGraph.class, new FederatedRemoveGraphHandler());
    addOperationHandler(FederatedOperationChain.class, new FederatedOperationChainHandler());
    addOperationHandler(GetTraits.class, new FederatedGetTraitsHandler());
    addOperationHandler(GetAllGraphInfo.class, new FederatedGetAllGraphInfoHandler());
    addOperationHandler(ChangeGraphAccess.class, new FederatedChangeGraphAccessHandler());
    addOperationHandler(ChangeGraphId.class, new FederatedChangeGraphIdHandler());
}
Also used : StorageException(uk.gov.gchq.gaffer.federatedstore.exception.StorageException) FederatedAddGraphWithHooksHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphWithHooksHandler) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) FederatedOperationChainValidator(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChainValidator) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) Element(uk.gov.gchq.gaffer.data.element.Element) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) Graph(uk.gov.gchq.gaffer.graph.Graph) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Map(java.util.Map) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedGetAllElementsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllElementsHandler) Objects.isNull(java.util.Objects.isNull) GetAllGraphInfo(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) FederatedChangeGraphIdHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphIdHandler) FederatedGetAdjacentIdsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAdjacentIdsHandler) FederatedGetAllGraphInfoHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphInfoHandler) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) Collection(java.util.Collection) FederatedAddGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphHandler) Set(java.util.Set) FederatedChangeGraphAccessHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphAccessHandler) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) FederatedViewValidator(uk.gov.gchq.gaffer.federatedstore.schema.FederatedViewValidator) Store(uk.gov.gchq.gaffer.store.Store) FederatedStoreUtil.getCleanStrings(uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil.getCleanStrings) List(java.util.List) Context(uk.gov.gchq.gaffer.store.Context) IS_PUBLIC_ACCESS_ALLOWED_DEFAULT(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties.IS_PUBLIC_ACCESS_ALLOWED_DEFAULT) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedRemoveGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphHandler) FederatedOperationChainHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationChainHandler) FederatedAggregateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedAggregateHandler) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) FederatedGetTraitsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandler) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) Objects.nonNull(java.util.Objects.nonNull) FederatedOperationHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedOperationHandler) FederatedGetSchemaHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedGetSchemaHandler) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) StoreException(uk.gov.gchq.gaffer.store.StoreException) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) User(uk.gov.gchq.gaffer.user.User) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) HashMap(java.util.HashMap) FederatedGetElementsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetElementsHandler) FederatedStoreUtil(uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) FederatedValidateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedValidateHandler) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) Transform(uk.gov.gchq.gaffer.operation.impl.function.Transform) Output(uk.gov.gchq.gaffer.operation.io.Output) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) Aggregate(uk.gov.gchq.gaffer.operation.impl.function.Aggregate) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) ChangeGraphAccess(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess) EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Logger(org.slf4j.Logger) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) AddGraphWithHooks(uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks) ChangeGraphId(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId) FederatedGetAllGraphIDHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphIDHandler) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Operation(uk.gov.gchq.gaffer.operation.Operation) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) Collections(java.util.Collections) FederatedRemoveGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphHandler) FederatedGetSchemaHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedGetSchemaHandler) FederatedValidateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedValidateHandler) FederatedGetTraitsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandler) FederatedChangeGraphIdHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphIdHandler) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) FederatedChangeGraphAccessHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphAccessHandler) FederatedAddGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphHandler) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedAddGraphWithHooksHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphWithHooksHandler) FederatedOperationChainHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationChainHandler) FederatedGetAllGraphIDHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphIDHandler) FederatedOperationHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedOperationHandler) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) FederatedAggregateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedAggregateHandler) FederatedGetAllGraphInfoHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphInfoHandler)

Aggregations

Output (uk.gov.gchq.gaffer.operation.io.Output)10 Element (uk.gov.gchq.gaffer.data.element.Element)6 HashSet (java.util.HashSet)5 Pair (uk.gov.gchq.gaffer.commonutil.pair.Pair)5 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)5 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)4 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)4 Strings (com.google.common.base.Strings)1 Sets (com.google.common.collect.Sets)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects.isNull (java.util.Objects.isNull)1 Objects.nonNull (java.util.Objects.nonNull)1 Random (java.util.Random)1