Search in sources :

Example 1 with IteratorSettingException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException in project Gaffer by gchq.

the class AccumuloRangeIDRetrieverTest method shouldRetieveElementsInRangeBetweenSeeds.

private void shouldRetieveElementsInRangeBetweenSeeds(final AccumuloStore store) throws StoreException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0000"), new EntitySeed("0999")));
    // Retrieve elements when less simple entities are provided than the max number of entries for the batch scanner
    final GetElementsOperation<Pair<ElementSeed>, CloseableIterable<Element>> operation = new GetElementsInRanges<>(defaultView, simpleEntityRanges);
    try {
        final AccumuloRangeIDRetriever retriever = new AccumuloRangeIDRetriever(store, operation, new User());
        assertEquals(numEntries, Iterables.size(retriever));
    } catch (IteratorSettingException e) {
        fail("Unable to construct Range Retriever");
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 2 with IteratorSettingException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException in project Gaffer by gchq.

the class AbstractGetRDDHandler method addIterators.

public void addIterators(final AccumuloStore accumuloStore, final Configuration conf, final User user, final GetElementsOperation<?, ?> operation) throws OperationException {
    try {
        // Update configuration with instance name, table name, zookeepers, and with view
        accumuloStore.updateConfiguration(conf, operation.getView(), user);
        // Add iterators based on operation-specific (i.e. not view related) options
        final IteratorSetting edgeEntityDirectionFilter = accumuloStore.getKeyPackage().getIteratorFactory().getEdgeEntityDirectionFilterIteratorSetting(operation);
        if (edgeEntityDirectionFilter != null) {
            InputConfigurator.addIterator(AccumuloInputFormat.class, conf, edgeEntityDirectionFilter);
        }
        final IteratorSetting queryTimeAggregator = accumuloStore.getKeyPackage().getIteratorFactory().getQueryTimeAggregatorIteratorSetting(operation.getView(), accumuloStore);
        if (queryTimeAggregator != null) {
            InputConfigurator.addIterator(AccumuloInputFormat.class, conf, queryTimeAggregator);
        }
    } catch (final StoreException | IteratorSettingException e) {
        throw new OperationException("Failed to update configuration", e);
    }
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 3 with IteratorSettingException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException in project Gaffer by gchq.

the class GetAdjacentEntitySeedsHandler method doOperation.

public CloseableIterable<EntitySeed> doOperation(final GetAdjacentEntitySeeds operation, final User user, final AccumuloStore store) throws OperationException {
    operation.addOption(AccumuloStoreConstants.OPERATION_RETURN_MATCHED_SEEDS_AS_EDGE_SOURCE, "true");
    final AccumuloRetriever<?> edgeRetriever;
    try {
        operation.setIncludeEntities(false);
        if (IncludeEdgeType.NONE == operation.getIncludeEdges()) {
            operation.setIncludeEdges(IncludeEdgeType.ALL);
        }
        final IteratorSettingFactory iteratorFactory = store.getKeyPackage().getIteratorFactory();
        edgeRetriever = new AccumuloSingleIDRetriever(store, operation, user, iteratorFactory.getElementPreAggregationFilterIteratorSetting(operation.getView(), store), iteratorFactory.getElementPostAggregationFilterIteratorSetting(operation.getView(), store), iteratorFactory.getEdgeEntityDirectionFilterIteratorSetting(operation), iteratorFactory.getQueryTimeAggregatorIteratorSetting(operation.getView(), store));
    } catch (IteratorSettingException | StoreException e) {
        throw new OperationException(e.getMessage(), e);
    }
    return new ExtractDestinationEntitySeed(edgeRetriever);
}
Also used : IteratorSettingFactory(uk.gov.gchq.gaffer.accumulostore.key.IteratorSettingFactory) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) AccumuloSingleIDRetriever(uk.gov.gchq.gaffer.accumulostore.retriever.impl.AccumuloSingleIDRetriever) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 4 with IteratorSettingException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException in project Gaffer by gchq.

the class AccumuloSingleIDRetrieverTest method testUndirectedEdgeSeedQueries.

private void testUndirectedEdgeSeedQueries(final AccumuloStore store) throws AccumuloException, StoreException {
    setupGraph(store, numEntries);
    final User user = new User();
    // Create set to query for
    final Set<ElementSeed> ids = new HashSet<>();
    for (int i = 0; i < numEntries; i++) {
        ids.add(new EdgeSeed("" + i, "B", false));
        ids.add(new EdgeSeed("" + i, "C", true));
    }
    final View view = new View.Builder().edge(TestGroups.EDGE).build();
    AccumuloSingleIDRetriever retriever = null;
    final GetElements<ElementSeed, ?> operation = new GetElements<>(view, ids);
    operation.setIncludeEdges(IncludeEdgeType.UNDIRECTED);
    try {
        retriever = new AccumuloSingleIDRetriever(store, operation, user);
    } catch (IteratorSettingException e) {
        e.printStackTrace();
    }
    for (final Element element : retriever) {
        Edge edge = (Edge) element;
        assertEquals("B", edge.getDestination());
    }
    //We should have only 1000 returned the i-B edges that are undirected
    assertEquals(numEntries, Iterables.size(retriever));
}
Also used : User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) HashSet(java.util.HashSet)

Example 5 with IteratorSettingException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException in project Gaffer by gchq.

the class AccumuloSingleIDRetrieverTest method testEntitySeedQueryEdgesOnly.

private void testEntitySeedQueryEdgesOnly(final AccumuloStore store) throws AccumuloException, StoreException {
    setupGraph(store, numEntries);
    final User user = new User();
    // Create set to query for
    final Set<ElementSeed> ids = new HashSet<>();
    for (int i = 0; i < numEntries; i++) {
        ids.add(new EntitySeed("" + i));
    }
    final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
    AccumuloSingleIDRetriever retriever = null;
    final GetElements<ElementSeed, ?> operation = new GetElements<>(view, ids);
    operation.setIncludeEntities(false);
    try {
        retriever = new AccumuloSingleIDRetriever(store, operation, user);
    } catch (IteratorSettingException e) {
        e.printStackTrace();
    }
    //Should find both i-B and i-C edges.
    assertEquals(numEntries * 2, Iterables.size(retriever));
}
Also used : User(uk.gov.gchq.gaffer.user.User) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) HashSet(java.util.HashSet)

Aggregations

IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)26 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)16 User (uk.gov.gchq.gaffer.user.User)16 HashSet (java.util.HashSet)15 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)15 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)12 Element (uk.gov.gchq.gaffer.data.element.Element)10 StoreException (uk.gov.gchq.gaffer.store.StoreException)9 Edge (uk.gov.gchq.gaffer.data.element.Edge)7 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)7 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)7 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)6 OperationException (uk.gov.gchq.gaffer.operation.OperationException)6 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)3 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)3 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Entry (java.util.Map.Entry)2 BatchWriter (org.apache.accumulo.core.client.BatchWriter)2