use of org.gradoop.storage.hbase.impl.predicate.filter.impl.HBaseLabelIn in project gradoop by dbs-leipzig.
the class HBaseDataSinkSourceTest method testReadWithLabelInPredicate.
/**
* Test reading a graph collection from {@link HBaseDataSource}
* with a {@link HBaseLabelIn} predicate on each graph element
*
* @throws Exception on failure
*/
@Test(dataProvider = "store index")
public void testReadWithLabelInPredicate(int storeIndex) throws Exception {
// Extract parts of social graph to filter for
List<EPGMGraphHead> graphHeads = Lists.newArrayList(getSocialGraphHeads()).stream().filter(e -> e.getLabel().equals(LABEL_FORUM)).collect(Collectors.toList());
List<EPGMEdge> edges = Lists.newArrayList(getSocialEdges()).stream().filter(e -> e.getLabel().equals(LABEL_HAS_MODERATOR) || e.getLabel().equals(LABEL_HAS_MEMBER)).collect(Collectors.toList());
List<EPGMVertex> vertices = Lists.newArrayList(getSocialVertices()).stream().filter(e -> e.getLabel().equals(LABEL_TAG) || e.getLabel().equals(LABEL_FORUM)).collect(Collectors.toList());
// Define HBase source
HBaseDataSource hBaseDataSource = new HBaseDataSource(epgmStores[storeIndex], getConfig());
// Apply graph predicate
hBaseDataSource = hBaseDataSource.applyGraphPredicate(Query.elements().fromAll().where(HBaseFilters.labelIn(LABEL_FORUM)));
// Apply edge predicate
hBaseDataSource = hBaseDataSource.applyEdgePredicate(Query.elements().fromAll().where(HBaseFilters.labelIn(LABEL_HAS_MODERATOR, LABEL_HAS_MEMBER)));
// Apply vertex predicate
hBaseDataSource = hBaseDataSource.applyVertexPredicate(Query.elements().fromAll().where(HBaseFilters.labelIn(LABEL_TAG, LABEL_FORUM)));
assertTrue(hBaseDataSource.isFilterPushedDown());
GraphCollection graphCollection = hBaseDataSource.getGraphCollection();
Collection<EPGMGraphHead> loadedGraphHeads = graphCollection.getGraphHeads().collect();
Collection<EPGMVertex> loadedVertices = graphCollection.getVertices().collect();
Collection<EPGMEdge> loadedEdges = graphCollection.getEdges().collect();
validateElementCollections(graphHeads, loadedGraphHeads);
validateElementCollections(vertices, loadedVertices);
validateGraphElementCollections(vertices, loadedVertices);
validateElementCollections(edges, loadedEdges);
validateGraphElementCollections(edges, loadedEdges);
}
use of org.gradoop.storage.hbase.impl.predicate.filter.impl.HBaseLabelIn in project gradoop by dbs-leipzig.
the class HBaseLabelInTest method testToHBaseFilter.
/**
* Test the toHBaseFilter function
*/
@Test
public void testToHBaseFilter() {
String testLabel1 = "test1";
String testLabel2 = "test2";
HBaseLabelIn<EPGMEdge> edgeFilter = new HBaseLabelIn<>(testLabel1, testLabel2);
FilterList expectedFilterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
for (String label : Arrays.asList(testLabel2, testLabel1)) {
SingleColumnValueFilter valueFilter = new SingleColumnValueFilter(Bytes.toBytesBinary(CF_META), Bytes.toBytesBinary(COL_LABEL), CompareFilter.CompareOp.EQUAL, Bytes.toBytesBinary(label));
expectedFilterList.addFilter(valueFilter);
}
assertEquals(edgeFilter.toHBaseFilter(false).toString(), expectedFilterList.toString());
}
Aggregations