Search in sources :

Example 36 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ByteEntityBloomElementFunctorTest method shouldTransformRangeWhenUsingRangeNotExact.

@Test
public void shouldTransformRangeWhenUsingRangeNotExact() {
    try {
        // Create SimpleEntity
        final Entity simpleEntity = new Entity(TestGroups.ENTITY);
        simpleEntity.setVertex("1");
        final Key key = elementConverter.getKeyFromEntity(simpleEntity);
        final Range range = Range.exact(key.getRow());
        final org.apache.hadoop.util.bloom.Key expectedBloomKey1 = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(key.getRowData().getBackingArray()));
        assertNotNull(elementFunctor.transform(range));
        assertEquals(expectedBloomKey1, elementFunctor.transform(range));
    } catch (AccumuloElementConversionException e) {
        fail("ConversionException " + e);
    }
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) AccumuloElementConversionException(uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException) Test(org.junit.Test)

Example 37 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ByteEntityBloomElementFunctorTest method shouldTransformRangeWhenRangeHasUnspecifiedStartOrEndKey.

@Test
public void shouldTransformRangeWhenRangeHasUnspecifiedStartOrEndKey() {
    try {
        // Create Range with unspecified start key and shouldRetieveElementsInRangeBetweenSeeds - should get null
        final Edge edge1 = new Edge(TestGroups.EDGE);
        edge1.setSource("3");
        edge1.setDestination("4");
        final Pair<Key> keys = elementConverter.getKeysFromEdge(edge1);
        final Range range1 = new Range(null, true, keys.getFirst().getRow(), true);
        assertNull(elementFunctor.transform(range1));
        // Create Range with unspecified end key and shouldRetieveElementsInRangeBetweenSeeds - should get null
        final Range range2 = new Range(keys.getFirst().getRow(), true, null, true);
        assertNull(elementFunctor.transform(range2));
    } catch (AccumuloElementConversionException e) {
        fail("ConversionException " + e);
    }
}
Also used : Range(org.apache.accumulo.core.data.Range) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) AccumuloElementConversionException(uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException) Test(org.junit.Test)

Example 38 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ByteEntityBloomElementFunctorTest method shouldTransformKeyEdge.

@Test
public void shouldTransformKeyEdge() throws AccumuloElementConversionException {
    // Create Key formed from edge and shouldRetieveElementsInRangeBetweenSeeds
    final Edge edge1 = new Edge(TestGroups.EDGE);
    edge1.setSource(1);
    edge1.setDestination(2);
    final Pair<Key> keys = elementConverter.getKeysFromEdge(edge1);
    final Range range1 = new Range(keys.getFirst().getRow(), true, keys.getFirst().getRow(), true);
    final org.apache.hadoop.util.bloom.Key expectedBloomKey1 = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(keys.getFirst().getRowData().getBackingArray()));
    assertEquals(expectedBloomKey1, elementFunctor.transform(range1));
    final Range range2 = new Range(keys.getSecond().getRow(), true, keys.getSecond().getRow(), true);
    final org.apache.hadoop.util.bloom.Key expectedBloomKey2 = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(keys.getSecond().getRowData().getBackingArray()));
    assertEquals(expectedBloomKey2, elementFunctor.transform(range2));
}
Also used : Range(org.apache.accumulo.core.data.Range) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 39 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ByteEntityBloomElementFunctorTest method shouldTransformRangeFromEntityToEntityAndSomeEdges.

@Test
public void shouldTransformRangeFromEntityToEntityAndSomeEdges() throws AccumuloElementConversionException {
    // Create entity
    final Entity entity = new Entity(TestGroups.ENTITY);
    entity.setVertex(1);
    //        String key1 = ConversionUtils.getRowKeyFromEntity(entity1);
    final Key key1 = elementConverter.getKeyFromEntity(entity);
    // Create edge from that entity
    final Edge edge = new Edge(TestGroups.EDGE);
    edge.setSource(1);
    edge.setDestination(2);
    //        String key2 = ConversionUtils.getRowKeysFromEdge(edge).getFirst();
    final Key key2 = elementConverter.getKeysFromEdge(edge).getFirst();
    // Create range from entity to edge inclusive
    final Range range = new Range(key1.getRow(), true, key2.getRow(), true);
    // Check don't get null Bloom key
    assertNotNull(elementFunctor.transform(range));
    // Check get correct Bloom key
    final org.apache.hadoop.util.bloom.Key expectedBloomKey = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(key1.getRowData().getBackingArray()));
    assertEquals(expectedBloomKey, elementFunctor.transform(range));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Range(org.apache.accumulo.core.data.Range) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 40 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class Gaffer1BloomElementFunctorTest method shouldTransformKeyEdge.

@Test
public void shouldTransformKeyEdge() throws AccumuloElementConversionException {
    // Create Key formed from edge and shouldRetieveElementsInRangeBetweenSeeds
    final Edge edge1 = new Edge(TestGroups.EDGE);
    edge1.setSource(1);
    edge1.setDestination(2);
    final Pair<Key> keys = elementConverter.getKeysFromEdge(edge1);
    final Range range1 = new Range(keys.getFirst().getRow(), true, keys.getFirst().getRow(), true);
    final org.apache.hadoop.util.bloom.Key expectedBloomKey1 = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(keys.getFirst().getRowData().getBackingArray()));
    assertEquals(expectedBloomKey1, elementFunctor.transform(range1));
    final Range range2 = new Range(keys.getSecond().getRow(), true, keys.getSecond().getRow(), true);
    final org.apache.hadoop.util.bloom.Key expectedBloomKey2 = new org.apache.hadoop.util.bloom.Key(elementFunctor.getVertexFromRangeKey(keys.getSecond().getRowData().getBackingArray()));
    assertEquals(expectedBloomKey2, elementFunctor.transform(range2));
}
Also used : Range(org.apache.accumulo.core.data.Range) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

Key (org.apache.accumulo.core.data.Key)115 Value (org.apache.accumulo.core.data.Value)68 Test (org.junit.Test)66 Edge (uk.gov.gchq.gaffer.data.element.Edge)44 Range (org.apache.accumulo.core.data.Range)35 HashMap (java.util.HashMap)29 Text (org.apache.hadoop.io.Text)23 Element (uk.gov.gchq.gaffer.data.element.Element)23 Scanner (org.apache.accumulo.core.client.Scanner)19 Authorizations (org.apache.accumulo.core.security.Authorizations)18 Mutation (org.apache.accumulo.core.data.Mutation)17 Entity (uk.gov.gchq.gaffer.data.element.Entity)15 Entry (java.util.Map.Entry)14 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)13 AccumuloException (org.apache.accumulo.core.client.AccumuloException)11 Connector (org.apache.accumulo.core.client.Connector)11 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)11 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)11 ExprNodeConstantDesc (org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc)11 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)11