Search in sources :

Example 71 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class StoreValidationIT method shouldRemoveInvalidElements.

@Test
@TraitRequirement(StoreTrait.STORE_VALIDATION)
public void shouldRemoveInvalidElements() throws OperationException, InterruptedException {
    // Given
    final User user = new User();
    final Entity entity = new Entity(TestGroups.ENTITY_2, VERTEX);
    entity.putProperty(TestPropertyNames.INT, 100);
    // add elements but skip the validation
    graph.execute(new AddElements.Builder().elements(Collections.<Element>singleton(entity)).validate(false).build(), user);
    // When
    final CloseableIterable<Entity> results1 = graph.execute(new GetEntities.Builder<>().addSeed(new EntitySeed(VERTEX)).build(), user);
    // Then
    final List<Entity> results1List = Lists.newArrayList(results1);
    assertTrue(results1List.isEmpty());
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 72 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class TransformationIT method setup.

@Override
@Before
public void setup() throws Exception {
    super.setup();
    addDefaultElements();
    final Collection<Element> elements = new ArrayList<>(2);
    final Edge sampleEdgeWithTransientProperty = new Edge(TestGroups.EDGE, VERTEX + SOURCE, VERTEX + DEST, true);
    sampleEdgeWithTransientProperty.putProperty(TestPropertyNames.COUNT, 1L);
    sampleEdgeWithTransientProperty.putProperty(TestPropertyNames.TRANSIENT_1, "test");
    elements.add(sampleEdgeWithTransientProperty);
    final Entity sampleEntityWithTransientProperty = new Entity(TestGroups.ENTITY, VERTEX);
    sampleEntityWithTransientProperty.putProperty(TestPropertyNames.TRANSIENT_1, "test");
    elements.add(sampleEntityWithTransientProperty);
    graph.execute(new AddElements(elements), getUser());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) Edge(uk.gov.gchq.gaffer.data.element.Edge) Before(org.junit.Before)

Example 73 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class DataGenerator12 method getElements.

@Override
public Iterable<Element> getElements(final String line) {
    final Set<Element> elements = new HashSet<>();
    for (int i = 0; i < 1000; i++) {
        final ReservoirItemsUnion<String> reservoirStringsUnion = ReservoirItemsUnion.getInstance(20);
        reservoirStringsUnion.update(getRandomString());
        final Edge edge = new Edge.Builder().group("red").source("A").dest("B").property("stringsSample", reservoirStringsUnion).build();
        elements.add(edge);
    }
    for (int i = 0; i < 500; i++) {
        final Edge edge = new Edge.Builder().group("blue").source("X").dest("Y" + i).build();
        elements.add(edge);
        final ReservoirItemsUnion<String> reservoirStringsUnionX = ReservoirItemsUnion.getInstance(20);
        reservoirStringsUnionX.update("Y" + i);
        final Entity entityX = new Entity.Builder().group("blueEntity").vertex("X").property("neighboursSample", reservoirStringsUnionX).build();
        elements.add(entityX);
        final ReservoirItemsUnion<String> reservoirStringsUnionY = ReservoirItemsUnion.getInstance(20);
        reservoirStringsUnionY.update("X");
        final Entity entityY = new Entity.Builder().group("blueEntity").vertex("Y" + i).property("neighboursSample", reservoirStringsUnionY).build();
        elements.add(entityY);
    }
    return elements;
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) Edge(uk.gov.gchq.gaffer.data.element.Edge) HashSet(java.util.HashSet)

Example 74 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class DataGenerator13 method getElements.

@Override
public Iterable<Element> getElements(final String line) {
    final Set<Element> elements = new HashSet<>();
    // On day 10/1/17 there are 1000 edges A-B0, A-B1, ..., A-B999.
    // For each edge we create an Entity with a union sketch containing the source and destination from the edge
    final Date midnight9th = LoadAndQuery8.getDate("09/01/17");
    final Date midnight10th = LoadAndQuery8.getDate("10/01/17");
    for (int i = 0; i < 1000; i++) {
        final Edge edge = new Edge.Builder().group("red").source("A").dest("B" + i).property("startDate", midnight9th).property("endDate", midnight10th).property("count", 1L).build();
        elements.add(edge);
        final Union union = Sketches.setOperationBuilder().buildUnion();
        union.update("A-B" + i);
        final Entity entity = new Entity.Builder().group("size").vertex("graph").property("startDate", midnight9th).property("endDate", midnight10th).property("size", union).build();
        elements.add(entity);
    }
    // On day 11/1/17 there are 500 edges A-B750, A-B751, ..., A-B1249.
    final Date midnight11th = LoadAndQuery8.getDate("11/01/17");
    for (int i = 750; i < 1250; i++) {
        final Edge edge = new Edge.Builder().group("red").source("A").dest("B" + i).property("startDate", midnight10th).property("endDate", midnight11th).property("count", 1L).build();
        elements.add(edge);
        final Union union = Sketches.setOperationBuilder().buildUnion();
        union.update("A-B" + i);
        final Entity entity = new Entity.Builder().group("size").vertex("graph").property("startDate", midnight10th).property("endDate", midnight11th).property("size", union).build();
        elements.add(entity);
    }
    return elements;
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) Edge(uk.gov.gchq.gaffer.data.element.Edge) Date(java.util.Date) Union(com.yahoo.sketches.theta.Union) HashSet(java.util.HashSet)

Example 75 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class DataGenerator method getElement.

@Override
public Element getElement(final String line) {
    final String[] t = line.split(",");
    final Element element;
    if (t.length > 2) {
        element = new Edge.Builder().group("edge").source(Integer.parseInt(t[0])).dest(Integer.parseInt(t[1])).directed(true).property("count", Integer.parseInt(t[2])).build();
    } else {
        element = new Entity.Builder().group("entity").vertex(Integer.parseInt(t[0])).property("count", Integer.parseInt(t[1])).build();
    }
    return element;
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Aggregations

Element (uk.gov.gchq.gaffer.data.element.Element)182 Test (org.junit.Test)102 Edge (uk.gov.gchq.gaffer.data.element.Edge)72 User (uk.gov.gchq.gaffer.user.User)53 Entity (uk.gov.gchq.gaffer.data.element.Entity)52 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)50 HashSet (java.util.HashSet)47 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)42 ArrayList (java.util.ArrayList)33 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)32 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)26 Key (org.apache.accumulo.core.data.Key)23 Value (org.apache.accumulo.core.data.Value)23 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)17 Graph (uk.gov.gchq.gaffer.graph.Graph)16 HashMap (java.util.HashMap)14 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)14 Configuration (org.apache.hadoop.conf.Configuration)12 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)12