use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project gaffer-doc by gchq.
the class AbstractWalkthrough method getMapStoreProperties.
public static StoreProperties getMapStoreProperties() {
final MapStoreProperties properties = new MapStoreProperties();
properties.setStoreClass(SingleUseMapStore.class);
properties.set(CacheProperties.CACHE_SERVICE_CLASS, HashMapCacheService.class.getName());
properties.setJobTrackerEnabled(true);
properties.setOperationDeclarationPaths("sparkAccumuloOperationsDeclarations.json,ResultCacheExportOperations.json,ExportToOtherGraphOperationDeclarations.json,ScoreOperationChainDeclaration.json");
return properties;
}
use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.
the class FederatedStoreToFederatedStoreTest method shouldMaintainView.
@Test
public void shouldMaintainView() throws OperationException {
// Given
final String mapStoreGraphId = "mapStoreWithFullSchema";
restApiFederatedGraph.execute(new AddGraph.Builder().storeProperties(new MapStoreProperties()).graphId(mapStoreGraphId).schema(Schema.fromJson(getClass().getResourceAsStream("/schema/basicEntitySchema.json"), getClass().getResourceAsStream("/schema/basicEdgeSchema.json"))).build(), new User());
Entity entity = new Entity.Builder().group(BASIC_ENTITY).vertex("myVertex").property("property1", 1).build();
Edge edge = new Edge.Builder().source("mySource").dest("myDest").group(BASIC_EDGE).property("columnQualifier", 2).property("prooperty1", 1).build();
restApiFederatedGraph.execute(new AddElements.Builder().input(entity, edge).option(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, mapStoreGraphId).build(), new User());
// When
List<? extends Element> results = Lists.newArrayList(federatedStoreGraph.execute(new GetAllElements.Builder().view(new View.Builder().entity(BASIC_ENTITY).build()).build(), new User()));
// Then
assertThat(results).hasSize(1);
}
use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.
the class OperationChainTest method testOperationChain.
@Test
public void testOperationChain() throws StoreException, OperationException {
// Given
final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graph1").build()).addSchemas(StreamUtil.openStreams(getClass(), "example-schema")).storeProperties(new MapStoreProperties()).build();
final AddElements addElements = new AddElements.Builder().input(getElements()).build();
graph.execute(addElements, new User());
// When
final CloseableIterable<? extends Element> results = graph.execute(new OperationChain.Builder().first(new GetAdjacentIds.Builder().input(new EntitySeed("vertex1")).build()).then(new GetElements.Builder().view(new View.Builder().edge("edge").build()).build()).build(), new User());
// Then
final Set<Element> resultsSet = new HashSet<>();
Streams.toStream(results).forEach(resultsSet::add);
final Set<Element> expectedResults = new HashSet<>();
getElements().stream().filter(e -> e instanceof Edge).filter(e -> {
final Edge edge = (Edge) e;
return edge.getSource().equals("vertex1") || edge.getDestination().equals("vertex2");
}).forEach(expectedResults::add);
assertEquals(expectedResults, resultsSet);
}
use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.
the class MapImplTest method shouldCreateMapsUsingMapFactory.
@Test
public void shouldCreateMapsUsingMapFactory() throws StoreException {
// Given
final Schema schema = mock(Schema.class);
final MapStoreProperties properties = mock(MapStoreProperties.class);
final Map aggElements = mock(Map.class);
final Map nonAggElements = mock(Map.class);
final MultiMap entityIdToElements = mock(MultiMap.class);
final MultiMap edgeIdToElements = mock(MultiMap.class);
given(schema.getGroups()).willReturn(Sets.newHashSet(TestGroups.EDGE));
given(properties.getMapFactory()).willReturn(TestMapFactory.class.getName());
given(properties.getCreateIndex()).willReturn(true);
given(mockMapFactory.getMap(TestGroups.EDGE + "|" + MapImpl.AGG_ELEMENTS, Element.class, GroupedProperties.class)).willReturn(aggElements);
given(mockMapFactory.getMap(TestGroups.EDGE + "|" + MapImpl.NON_AGG_ELEMENTS, Element.class, Integer.class)).willReturn(nonAggElements);
given(mockMapFactory.getMultiMap(MapImpl.ENTITY_ID_TO_ELEMENTS, EntityId.class, Element.class)).willReturn(entityIdToElements);
given(mockMapFactory.getMultiMap(MapImpl.EDGE_ID_TO_ELEMENTS, EdgeId.class, Element.class)).willReturn(edgeIdToElements);
// When
new MapImpl(schema, properties);
// Then
verify(mockMapFactory).getMap(TestGroups.EDGE + "|" + MapImpl.AGG_ELEMENTS, Element.class, GroupedProperties.class);
verify(mockMapFactory).getMap(TestGroups.EDGE + "|" + MapImpl.NON_AGG_ELEMENTS, Element.class, Long.class);
verify(mockMapFactory).getMultiMap(MapImpl.ENTITY_ID_TO_ELEMENTS, EntityId.class, Element.class);
verify(mockMapFactory).getMultiMap(MapImpl.EDGE_ID_TO_ELEMENTS, EdgeId.class, Element.class);
}
use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.
the class VisibilityTest method executeOperation.
public static <OUTPUT, OPERATION extends Operation & Output<OUTPUT>> void executeOperation(final OPERATION operation, final BiConsumer<OUTPUT, String[]> resultConsumer) throws OperationException {
final MapStoreProperties storeProperties = new MapStoreProperties();
final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graph1").build()).addSchema(SCHEMA).storeProperties(storeProperties).build();
final AddElements addElements = new AddElements.Builder().input(createElements()).build();
graph.execute(addElements, getUserWithDataAuths(PUBLIC, PRIVATE));
for (final String[] dataAuths : DATA_AUTH_COMBINATIONS) {
resultConsumer.accept(graph.execute(operation, getUserWithDataAuths(dataAuths)), dataAuths);
}
}
Aggregations