use of org.apache.drill.exec.store.hbase.HBaseScanSpec in project drill by apache.
the class MapRDBFilterBuilder method mergeScanSpecs.
private HBaseScanSpec mergeScanSpecs(String functionName, HBaseScanSpec leftScanSpec, HBaseScanSpec rightScanSpec) {
Filter newFilter = null;
byte[] startRow = HConstants.EMPTY_START_ROW;
byte[] stopRow = HConstants.EMPTY_END_ROW;
switch(functionName) {
case "booleanAnd":
//HBaseUtils.LAST_FILTER
newFilter = HBaseUtils.andFilterAtIndex(leftScanSpec.getFilter(), -1, rightScanSpec.getFilter());
startRow = HBaseUtils.maxOfStartRows(leftScanSpec.getStartRow(), rightScanSpec.getStartRow());
stopRow = HBaseUtils.minOfStopRows(leftScanSpec.getStopRow(), rightScanSpec.getStopRow());
break;
case "booleanOr":
//HBaseUtils.LAST_FILTER
newFilter = HBaseUtils.orFilterAtIndex(leftScanSpec.getFilter(), -1, rightScanSpec.getFilter());
startRow = HBaseUtils.minOfStartRows(leftScanSpec.getStartRow(), rightScanSpec.getStartRow());
stopRow = HBaseUtils.maxOfStopRows(leftScanSpec.getStopRow(), rightScanSpec.getStopRow());
}
return new HBaseScanSpec(groupScan.getTableName(), startRow, stopRow, newFilter);
}
use of org.apache.drill.exec.store.hbase.HBaseScanSpec in project drill by apache.
the class TestHBaseRegionScanAssignments method testHBaseGroupScanAssignmentNoAfinity.
@Test
public void testHBaseGroupScanAssignmentNoAfinity() throws Exception {
NavigableMap<HRegionInfo, ServerName> regionsToScan = Maps.newTreeMap();
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[0], splits[1]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[1], splits[2]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[2], splits[3]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[3], splits[4]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[4], splits[5]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[5], splits[6]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[6], splits[7]), SERVER_X);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[7], splits[0]), SERVER_X);
final List<DrillbitEndpoint> endpoints = Lists.newArrayList();
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_B).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_C).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_D).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_E).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_F).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_G).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_H).setControlPort(1234).build());
HBaseGroupScan scan = new HBaseGroupScan();
scan.setRegionsToScan(regionsToScan);
scan.setHBaseScanSpec(new HBaseScanSpec(TABLE_NAME_STR, splits[0], splits[0], null));
scan.applyAssignments(endpoints);
int i = 0;
// 'A'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'B'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'C'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'D'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'E'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'F'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'G'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'H'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
testParallelizationWidth(scan, i);
}
use of org.apache.drill.exec.store.hbase.HBaseScanSpec in project drill by apache.
the class TestHBaseRegionScanAssignments method testHBaseGroupScanAssignmentOneEach.
@Test
public void testHBaseGroupScanAssignmentOneEach() throws Exception {
NavigableMap<HRegionInfo, ServerName> regionsToScan = Maps.newTreeMap();
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[0], splits[1]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[1], splits[2]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[2], splits[3]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[3], splits[4]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[4], splits[5]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[5], splits[6]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[6], splits[7]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[7], splits[8]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[8], splits[0]), SERVER_A);
final List<DrillbitEndpoint> endpoints = Lists.newArrayList();
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_B).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_C).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_D).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_E).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_F).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_G).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_H).setControlPort(1234).build());
HBaseGroupScan scan = new HBaseGroupScan();
scan.setRegionsToScan(regionsToScan);
scan.setHBaseScanSpec(new HBaseScanSpec(TABLE_NAME_STR, splits[0], splits[0], null));
scan.applyAssignments(endpoints);
int i = 0;
// 'A'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'A'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'B'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'C'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'D'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'E'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'F'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'G'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'H'
assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size());
testParallelizationWidth(scan, i);
}
use of org.apache.drill.exec.store.hbase.HBaseScanSpec in project drill by apache.
the class TestHBaseRegionScanAssignments method testHBaseGroupScanAssignmentAllPreferred.
@Test
public void testHBaseGroupScanAssignmentAllPreferred() throws Exception {
NavigableMap<HRegionInfo, ServerName> regionsToScan = Maps.newTreeMap();
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[0], splits[1]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[1], splits[2]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[2], splits[3]), SERVER_B);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[3], splits[4]), SERVER_B);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[4], splits[5]), SERVER_C);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[5], splits[6]), SERVER_C);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[6], splits[7]), SERVER_D);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[7], splits[0]), SERVER_D);
final List<DrillbitEndpoint> endpoints = Lists.newArrayList();
final DrillbitEndpoint DB_A = DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build();
endpoints.add(DB_A);
final DrillbitEndpoint DB_B = DrillbitEndpoint.newBuilder().setAddress(HOST_B).setControlPort(1234).build();
endpoints.add(DB_B);
final DrillbitEndpoint DB_D = DrillbitEndpoint.newBuilder().setAddress(HOST_C).setControlPort(1234).build();
endpoints.add(DB_D);
final DrillbitEndpoint DB_X = DrillbitEndpoint.newBuilder().setAddress(HOST_D).setControlPort(1234).build();
endpoints.add(DB_X);
HBaseGroupScan scan = new HBaseGroupScan();
scan.setRegionsToScan(regionsToScan);
scan.setHBaseScanSpec(new HBaseScanSpec(TABLE_NAME_STR, splits[0], splits[0], null));
scan.applyAssignments(endpoints);
int i = 0;
// 'A'
assertEquals(2, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'B'
assertEquals(2, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'C'
assertEquals(2, scan.getSpecificScan(i++).getRegionScanSpecList().size());
// 'D'
assertEquals(2, scan.getSpecificScan(i++).getRegionScanSpecList().size());
testParallelizationWidth(scan, i);
}
use of org.apache.drill.exec.store.hbase.HBaseScanSpec in project drill by apache.
the class MapRDBFilterBuilder method createRowKeyPrefixScanSpec.
private HBaseScanSpec createRowKeyPrefixScanSpec(FunctionCall call, CompareFunctionsProcessor processor) {
byte[] startRow = processor.getRowKeyPrefixStartRow();
byte[] stopRow = processor.getRowKeyPrefixStopRow();
Filter filter = processor.getRowKeyPrefixFilter();
if (startRow != HConstants.EMPTY_START_ROW || stopRow != HConstants.EMPTY_END_ROW || filter != null) {
return new HBaseScanSpec(groupScan.getTableName(), startRow, stopRow, filter);
}
// else
return null;
}
Aggregations