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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations