Search in sources :

Example 26 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class ExamplesService method getEntities.

@Override
public GetEntities getEntities() {
    final GetEntities op = new GetEntities();
    final List<ElementSeed> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntitySeed(1));
    }
    if (hasEdges()) {
        seeds.add(getEdgeSeed(1, 2));
    }
    op.setSeeds(seeds);
    populateOperation(op);
    return op;
}
Also used : ArrayList(java.util.ArrayList) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities)

Example 27 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetElementsOperationTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final String identifier = "identifier";
    final ElementSeed input = new EntitySeed(identifier);
    final GetElementsOperationImpl<ElementSeed, Element> op = new GetElementsOperationImpl<>(Collections.singletonList(input));
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetElementsOperationImpl<ElementSeed, Element> deserialisedOp = serialiser.deserialise(json, GetElementsOperationImpl.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(identifier, ((EntitySeed) deserialisedOp.getInput().iterator().next()).getVertex());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetElementsOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetElementsOperationImpl) Test(org.junit.Test)

Example 28 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetElementsOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final GetIterableElementsOperation<ElementSeed, ?> operationToCopy = mock(GetIterableElementsOperation.class);
    final View view = mock(View.class);
    final GetOperation.IncludeEdgeType includeEdges = GetOperation.IncludeEdgeType.ALL;
    final boolean includeEntities = true;
    final boolean populateProperties = true;
    final CloseableIterable<ElementSeed> input = mock(CloseableIterable.class);
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getIncludeEdges()).willReturn(includeEdges);
    given(operationToCopy.isIncludeEntities()).willReturn(includeEntities);
    given(operationToCopy.isPopulateProperties()).willReturn(populateProperties);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final GetElementsOperationImpl<ElementSeed, Element> operation = new GetElementsOperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(includeEdges, operation.getIncludeEdges());
    assertEquals(includeEntities, operation.isIncludeEntities());
    assertSame(input, operation.getInput());
    assertEquals(populateProperties, operation.isPopulateProperties());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetElementsOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetElementsOperationImpl) Test(org.junit.Test)

Example 29 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class AbstractGetOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final GetOperation<ElementSeed, ?> operationToCopy = mock(GetOperation.class);
    final View view = mock(View.class);
    final GetOperation.IncludeEdgeType includeEdges = GetOperation.IncludeEdgeType.ALL;
    final boolean includeEntities = true;
    final boolean populateProperties = true;
    final CloseableIterable<ElementSeed> input = mock(CloseableIterable.class);
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final GetOperation<ElementSeed, Element> operation = new GetOperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(input, operation.getInput());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetOperationImpl) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 30 with ElementSeed

use of uk.gov.gchq.gaffer.operation.data.ElementSeed in project Gaffer by gchq.

the class BloomFilter18IT method seek.

private void seek(final FileSKVIterator reader, final EntitySeed seed, final RangeFactory rangeFactory) throws IOException, RangeFactoryException {
    final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
    final GetElements<ElementSeed, ?> operation = new GetElements<>(view);
    final List<Range> range = rangeFactory.getRange(seed, operation);
    for (final Range ran : range) {
        reader.seek(ran, new ArrayList<ByteSequence>(), false);
    }
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) Range(org.apache.accumulo.core.data.Range) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ByteSequence(org.apache.accumulo.core.data.ByteSequence)

Aggregations

ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)41 Element (uk.gov.gchq.gaffer.data.element.Element)26 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)26 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)19 HashSet (java.util.HashSet)13 User (uk.gov.gchq.gaffer.user.User)13 Test (org.junit.Test)12 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)12 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)9 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)9 Edge (uk.gov.gchq.gaffer.data.element.Edge)8 ArrayList (java.util.ArrayList)7 GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)6 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)6 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)6 Entity (uk.gov.gchq.gaffer.data.element.Entity)4 Range (org.apache.accumulo.core.data.Range)3 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)3 LinkedList (java.util.LinkedList)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2