Search in sources :

Example 1 with GetTraits

use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.

the class FederatedGraphStorage method getTraits.

/**
 * returns a set of {@link StoreTrait} that are common for all visible graphs.
 * traits1 = [a,b,c]
 * traits2 = [b,c]
 * traits3 = [a,b]
 * return [b]
 *
 * @param op      the GetTraits operation
 * @param context the user context
 * @return the set of {@link StoreTrait} that are common for all visible graphs
 * @deprecated use {@link uk.gov.gchq.gaffer.store.Store#execute(uk.gov.gchq.gaffer.operation.Operation, Context)} with GetTraits Operation.
 */
@Deprecated
public Set<StoreTrait> getTraits(final GetTraits op, final Context context) {
    boolean firstPass = true;
    final Set<StoreTrait> traits = new HashSet<>();
    if (null != op) {
        final List<String> graphIds = FederatedStoreUtil.getGraphIds(op.getOptions());
        final Collection<Graph> graphs = get(context.getUser(), graphIds);
        final GetTraits getTraits = op.shallowClone();
        for (final Graph graph : graphs) {
            try {
                Set<StoreTrait> execute = graph.execute(getTraits, context);
                if (firstPass) {
                    traits.addAll(execute);
                    firstPass = false;
                } else {
                    traits.retainAll(execute);
                }
            } catch (final OperationException e) {
                throw new RuntimeException("Unable to fetch traits from graph " + graph.getGraphId(), e);
            }
        }
    }
    return traits;
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) CacheOperationException(uk.gov.gchq.gaffer.cache.exception.CacheOperationException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with GetTraits

use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.

the class FederatedStoreTest method shouldCombineTraitsToMin.

@Test
public void shouldCombineTraitsToMin() throws Exception {
    // Given
    final GetTraits getTraits = new GetTraits.Builder().currentTraits(true).build();
    // When
    final Set<StoreTrait> before = store.getTraits(getTraits, userContext);
    store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
    store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(ACC_ID_1).storeProperties(PROPERTIES_1).build(), new Context(testUser()));
    final Set<StoreTrait> afterAcc = store.getTraits(getTraits, userContext);
    StoreProperties TestStoreImp = new StoreProperties();
    TestStoreImp.setStoreClass(FederatedGetTraitsHandlerTest.TestStoreImpl.class);
    store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(MAP_ID_1).storeProperties(TestStoreImp).build(), new Context(testUser()));
    final Set<StoreTrait> afterMap = store.getTraits(getTraits, userContext);
    // Then
    assertNotEquals(SingleUseAccumuloStore.TRAITS, new HashSet<>(Arrays.asList(StoreTrait.INGEST_AGGREGATION, StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.TRANSFORMATION, StoreTrait.POST_TRANSFORMATION_FILTERING, StoreTrait.MATCHED_VERTEX)));
    assertEquals(Collections.emptySet(), before, "No traits should be found for an empty FederatedStore");
    assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, ORDERED, MATCHED_VERTEX), afterAcc);
    assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, MATCHED_VERTEX), afterMap);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Builder(uk.gov.gchq.gaffer.store.schema.Schema.Builder) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Example 3 with GetTraits

use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.

the class FederatedGraphStorageTraitsTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    graphStorage = new FederatedGraphStorage();
    acc = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_ACCUMULO)).properties(ACCUMULO_PROPERTIES).schema(new Schema.Builder().entity("entities", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build()).build();
    map = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_MAP)).properties(MAP_PROPERTIES).schema(new Schema.Builder().edge("edges", new SchemaEdgeDefinition.Builder().source("string").destination("string").build()).type("string", String.class).build()).build();
    nullUser = nullUser();
    testUser = testUser();
    authUser = authUser();
    blankUser = blankUser();
    testUserContext = new Context(testUser);
    authUserContext = new Context(authUser);
    blankUserContext = new Context(blankUser);
    blockingAccessPredicate = new NoAccessPredicate();
    permissiveAccessPredicate = new UnrestrictedAccessPredicate();
    getTraits = new GetTraits();
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Context(uk.gov.gchq.gaffer.store.Context) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) UnrestrictedAccessPredicate(uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with GetTraits

use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.

the class FederatedStoreGetTraitsTest method setUp.

@Before
public void setUp() throws Exception {
    federatedStore = new FederatedStore();
    federatedStore.initialise("testFed", new Schema(), new FederatedStoreProperties());
    acc = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_ACCUMULO)).properties(ACCUMULO_PROPERTIES).schema(new Schema.Builder().entity("entities", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build()).build();
    map = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_MAP)).properties(MAP_PROPERTIES).schema(new Schema.Builder().edge("edges", new SchemaEdgeDefinition.Builder().source("string").destination("string").build()).type("string", String.class).build()).build();
    nullUser = nullUser();
    testUser = testUser();
    authUser = authUser();
    blankUser = blankUser();
    testUserContext = new Context(testUser);
    authUserContext = new Context(authUser);
    blankUserContext = new Context(blankUser);
    blockingAccessPredicate = new NoAccessPredicate();
    permissiveAccessPredicate = new UnrestrictedAccessPredicate();
    getTraits = new GetTraits();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) Schema(uk.gov.gchq.gaffer.store.schema.Schema) UnrestrictedAccessPredicate(uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) Before(org.junit.Before)

Aggregations

GetTraits (uk.gov.gchq.gaffer.store.operation.GetTraits)4 Context (uk.gov.gchq.gaffer.store.Context)3 NoAccessPredicate (uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate)2 UnrestrictedAccessPredicate (uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate)2 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)2 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)2 StoreTrait (uk.gov.gchq.gaffer.store.StoreTrait)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 CacheOperationException (uk.gov.gchq.gaffer.cache.exception.CacheOperationException)1 FederatedGetTraitsHandlerTest (uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)1 GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)1