Search in sources :

Example 21 with MapStoreProperties

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;
}
Also used : HashMapCacheService(uk.gov.gchq.gaffer.cache.impl.HashMapCacheService) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties)

Example 22 with MapStoreProperties

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);
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) Edge(uk.gov.gchq.gaffer.data.element.Edge) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 23 with MapStoreProperties

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);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) StoreException(uk.gov.gchq.gaffer.store.StoreException) User(uk.gov.gchq.gaffer.user.User) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Set(java.util.Set) Entity(uk.gov.gchq.gaffer.data.element.Entity) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) HashSet(java.util.HashSet) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) List(java.util.List) Graph(uk.gov.gchq.gaffer.graph.Graph) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Edge(uk.gov.gchq.gaffer.data.element.Edge) OperationException(uk.gov.gchq.gaffer.operation.OperationException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Streams(uk.gov.gchq.gaffer.commonutil.stream.Streams) StreamUtil(uk.gov.gchq.gaffer.commonutil.StreamUtil) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Graph(uk.gov.gchq.gaffer.graph.Graph) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 24 with MapStoreProperties

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);
}
Also used : MultiMap(uk.gov.gchq.gaffer.mapstore.multimap.MultiMap) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MultiMap(uk.gov.gchq.gaffer.mapstore.multimap.MultiMap) Map(java.util.Map) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 25 with MapStoreProperties

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);
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties)

Aggregations

MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)42 Schema (uk.gov.gchq.gaffer.store.schema.Schema)34 Graph (uk.gov.gchq.gaffer.graph.Graph)28 Test (org.junit.Test)19 Test (org.junit.jupiter.api.Test)15 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)10 Set (java.util.Set)7 Error (uk.gov.gchq.gaffer.core.exception.Error)7 HashSet (java.util.HashSet)6 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)5 LinkedHashMap (java.util.LinkedHashMap)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)4 Map (java.util.Map)3 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)3 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3