Search in sources :

Example 1 with SplitInfos

use of org.apache.hadoop.hive.metastore.Metastore.SplitInfos in project hive by apache.

the class OrcFileFormatProxy method applySargToMetadata.

@Override
public SplitInfos applySargToMetadata(SearchArgument sarg, ByteBuffer fileMetadata) throws IOException {
    // TODO: ideally we should store shortened representation of only the necessary fields
    //       in HBase; it will probably require custom SARG application code.
    OrcTail orcTail = ReaderImpl.extractFileTail(fileMetadata);
    OrcProto.Footer footer = orcTail.getFooter();
    int stripeCount = footer.getStripesCount();
    boolean[] result = OrcInputFormat.pickStripesViaTranslatedSarg(sarg, orcTail.getWriterVersion(), footer.getTypesList(), orcTail.getStripeStatistics(), stripeCount);
    // For ORC case, send the boundaries of the stripes so we don't have to send the footer.
    SplitInfos.Builder sb = SplitInfos.newBuilder();
    List<StripeInformation> stripes = orcTail.getStripes();
    boolean isEliminated = true;
    for (int i = 0; i < result.length; ++i) {
        if (result != null && !result[i])
            continue;
        isEliminated = false;
        StripeInformation si = stripes.get(i);
        if (LOG.isDebugEnabled()) {
            LOG.debug("PPD is adding a split " + i + ": " + si.getOffset() + ", " + si.getLength());
        }
        sb.addInfos(SplitInfo.newBuilder().setIndex(i).setOffset(si.getOffset()).setLength(si.getLength()));
    }
    return isEliminated ? null : sb.build();
}
Also used : OrcProto(org.apache.orc.OrcProto) SplitInfos(org.apache.hadoop.hive.metastore.Metastore.SplitInfos) StripeInformation(org.apache.orc.StripeInformation) OrcTail(org.apache.orc.impl.OrcTail)

Example 2 with SplitInfos

use of org.apache.hadoop.hive.metastore.Metastore.SplitInfos in project hive by apache.

the class OrcFileMetadataHandler method getFileMetadataByExpr.

@Override
public void getFileMetadataByExpr(List<Long> fileIds, byte[] expr, ByteBuffer[] metadatas, ByteBuffer[] results, boolean[] eliminated) throws IOException {
    SearchArgument sarg = getExpressionProxy().createSarg(expr);
    // For now, don't push anything into HBase, nor store anything special in HBase
    if (metadatas == null) {
        // null means don't return metadata; we'd need the array anyway for now.
        metadatas = new ByteBuffer[results.length];
    }
    getStore().getFileMetadata(fileIds, metadatas);
    for (int i = 0; i < metadatas.length; ++i) {
        eliminated[i] = false;
        results[i] = null;
        if (metadatas[i] == null)
            continue;
        // Duplicate to avoid modification.
        ByteBuffer metadata = metadatas[i].duplicate();
        SplitInfos result = null;
        try {
            result = getFileFormatProxy().applySargToMetadata(sarg, metadata);
        } catch (IOException ex) {
            LOG.error("Failed to apply SARG to metadata", ex);
            metadatas[i] = null;
            continue;
        }
        eliminated[i] = (result == null);
        if (!eliminated[i]) {
            results[i] = ByteBuffer.wrap(result.toByteArray());
        }
    }
}
Also used : SearchArgument(org.apache.hadoop.hive.ql.io.sarg.SearchArgument) IOException(java.io.IOException) SplitInfos(org.apache.hadoop.hive.metastore.Metastore.SplitInfos) ByteBuffer(java.nio.ByteBuffer)

Aggregations

SplitInfos (org.apache.hadoop.hive.metastore.Metastore.SplitInfos)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 SearchArgument (org.apache.hadoop.hive.ql.io.sarg.SearchArgument)1 OrcProto (org.apache.orc.OrcProto)1 StripeInformation (org.apache.orc.StripeInformation)1 OrcTail (org.apache.orc.impl.OrcTail)1