use of org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper in project drill by apache.
the class HiveScan method getSpecificScan.
@Override
public SubScan getSpecificScan(final int minorFragmentId) throws ExecutionSetupException {
try {
final List<InputSplitWrapper> splits = mappings.get(minorFragmentId);
List<HivePartitionWrapper> parts = Lists.newArrayList();
final List<String> encodedInputSplits = Lists.newArrayList();
final List<String> splitTypes = Lists.newArrayList();
for (final InputSplitWrapper split : splits) {
final Partition splitPartition = split.getPartition();
if (splitPartition != null) {
HiveTableWithColumnCache table = hiveReadEntry.getTable();
parts.add(createPartitionWithSpecColumns(new HiveTableWithColumnCache(table, new ColumnListsCache(table)), splitPartition));
}
encodedInputSplits.add(serializeInputSplit(split.getSplit()));
splitTypes.add(split.getSplit().getClass().getName());
}
if (parts.size() <= 0) {
parts = null;
}
final HiveReadEntry subEntry = new HiveReadEntry(hiveReadEntry.getTableWrapper(), parts);
return new HiveSubScan(getUserName(), encodedInputSplits, subEntry, splitTypes, columns, storagePlugin);
} catch (IOException | ReflectiveOperationException e) {
throw new ExecutionSetupException(e);
}
}
use of org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper in project drill by apache.
the class HiveScan method getOperatorAffinity.
@Override
public List<EndpointAffinity> getOperatorAffinity() {
final Map<String, DrillbitEndpoint> endpointMap = new HashMap<>();
for (final DrillbitEndpoint endpoint : storagePlugin.getContext().getBits()) {
endpointMap.put(endpoint.getAddress(), endpoint);
logger.debug("endpoing address: {}", endpoint.getAddress());
}
final Map<DrillbitEndpoint, EndpointAffinity> affinityMap = new HashMap<>();
try {
long totalSize = 0;
final List<InputSplitWrapper> inputSplits = getInputSplits();
for (final InputSplitWrapper split : inputSplits) {
totalSize += Math.max(1, split.getSplit().getLength());
}
for (final InputSplitWrapper split : inputSplits) {
final float affinity = ((float) Math.max(1, split.getSplit().getLength())) / totalSize;
for (final String loc : split.getSplit().getLocations()) {
logger.debug("split location: {}", loc);
final DrillbitEndpoint endpoint = endpointMap.get(loc);
if (endpoint != null) {
if (affinityMap.containsKey(endpoint)) {
affinityMap.get(endpoint).addAffinity(affinity);
} else {
affinityMap.put(endpoint, new EndpointAffinity(endpoint, affinity));
}
}
}
}
} catch (final IOException e) {
throw new DrillRuntimeException(e);
}
for (final DrillbitEndpoint ep : affinityMap.keySet()) {
Preconditions.checkNotNull(ep);
}
for (final EndpointAffinity a : affinityMap.values()) {
Preconditions.checkNotNull(a.getEndpoint());
}
return Lists.newArrayList(affinityMap.values());
}
use of org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper in project drill by apache.
the class HiveScan method applyAssignments.
@Override
public void applyAssignments(final List<CoordinationProtos.DrillbitEndpoint> endpoints) {
mappings = Lists.newArrayList();
for (int i = 0; i < endpoints.size(); i++) {
mappings.add(new ArrayList<InputSplitWrapper>());
}
final int count = endpoints.size();
final List<InputSplitWrapper> inputSplits = getInputSplits();
for (int i = 0; i < inputSplits.size(); i++) {
mappings.get(i % count).add(inputSplits.get(i));
}
}
Aggregations