Search in sources :

Example 1 with InputSplitWrapper

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);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) Partition(org.apache.hadoop.hive.metastore.api.Partition) InputSplitWrapper(org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper) IOException(java.io.IOException) HivePartitionWrapper(org.apache.drill.exec.store.hive.HiveTableWrapper.HivePartitionWrapper)

Example 2 with InputSplitWrapper

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());
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) HashMap(java.util.HashMap) InputSplitWrapper(org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper) EndpointAffinity(org.apache.drill.exec.physical.EndpointAffinity) IOException(java.io.IOException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException)

Example 3 with InputSplitWrapper

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));
    }
}
Also used : InputSplitWrapper(org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Aggregations

InputSplitWrapper (org.apache.drill.exec.store.hive.HiveMetadataProvider.InputSplitWrapper)3 IOException (java.io.IOException)2 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)2 HashMap (java.util.HashMap)1 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)1 EndpointAffinity (org.apache.drill.exec.physical.EndpointAffinity)1 HivePartitionWrapper (org.apache.drill.exec.store.hive.HiveTableWrapper.HivePartitionWrapper)1 Partition (org.apache.hadoop.hive.metastore.api.Partition)1