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);
}
}
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);
}
}
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));
}
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));
}
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));
}
Aggregations