Search in sources :

Example 11 with OrcTail

use of org.apache.orc.impl.OrcTail in project hive by apache.

the class TestOrcMetadataCache method testGetOrcTailForPathWithFileId.

@Test
public void testGetOrcTailForPathWithFileId() throws Exception {
    DummyMemoryManager mm = new DummyMemoryManager();
    DummyCachePolicy cp = new DummyCachePolicy();
    final int MAX_ALLOC = 64;
    LlapDaemonCacheMetrics metrics = LlapDaemonCacheMetrics.create("", "");
    BuddyAllocator alloc = new BuddyAllocator(false, false, 8, MAX_ALLOC, 1, 4 * 4096, 0, null, mm, metrics, null, true);
    MetadataCache cache = new MetadataCache(alloc, mm, cp, true, metrics);
    Path path = new Path("../data/files/alltypesorc");
    Configuration jobConf = new Configuration();
    Configuration daemonConf = new Configuration();
    CacheTag tag = CacheTag.build("test-table");
    FileSystem fs = FileSystem.get(daemonConf);
    FileStatus fileStatus = fs.getFileStatus(path);
    OrcTail uncached = OrcEncodedDataReader.getOrcTailForPath(fileStatus.getPath(), jobConf, tag, daemonConf, cache, new SyntheticFileId(fileStatus));
    jobConf.set(HiveConf.ConfVars.LLAP_IO_CACHE_ONLY.varname, "true");
    // this should work from the cache, by recalculating the same fileId
    OrcTail cached = OrcEncodedDataReader.getOrcTailForPath(fileStatus.getPath(), jobConf, tag, daemonConf, cache, null);
    assertEquals(uncached.getSerializedTail(), cached.getSerializedTail());
    assertEquals(uncached.getFileTail(), cached.getFileTail());
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) Configuration(org.apache.hadoop.conf.Configuration) SyntheticFileId(org.apache.hadoop.hive.ql.io.SyntheticFileId) MetadataCache(org.apache.hadoop.hive.llap.io.metadata.MetadataCache) LlapDaemonCacheMetrics(org.apache.hadoop.hive.llap.metrics.LlapDaemonCacheMetrics) FileSystem(org.apache.hadoop.fs.FileSystem) CacheTag(org.apache.hadoop.hive.common.io.CacheTag) OrcTail(org.apache.orc.impl.OrcTail) Test(org.junit.Test)

Example 12 with OrcTail

use of org.apache.orc.impl.OrcTail in project hive by apache.

the class OrcNewSplit method readFields.

@Override
public void readFields(DataInput in) throws IOException {
    // deserialize path, offset, length using FileSplit
    super.readFields(in);
    byte flags = in.readByte();
    hasFooter = (OrcSplit.FOOTER_FLAG & flags) != 0;
    isOriginal = (OrcSplit.ORIGINAL_FLAG & flags) != 0;
    hasBase = (OrcSplit.BASE_FLAG & flags) != 0;
    deltas.clear();
    int numDeltas = in.readInt();
    for (int i = 0; i < numDeltas; i++) {
        AcidInputFormat.DeltaMetaData dmd = new AcidInputFormat.DeltaMetaData();
        dmd.readFields(in);
        deltas.add(dmd);
    }
    if (hasFooter) {
        int tailLen = WritableUtils.readVInt(in);
        byte[] tailBuffer = new byte[tailLen];
        in.readFully(tailBuffer);
        OrcProto.FileTail fileTail = OrcProto.FileTail.parseFrom(tailBuffer);
        orcTail = new OrcTail(fileTail, null);
    }
}
Also used : AcidInputFormat(org.apache.hadoop.hive.ql.io.AcidInputFormat) OrcProto(org.apache.orc.OrcProto) OrcTail(org.apache.orc.impl.OrcTail)

Example 13 with OrcTail

use of org.apache.orc.impl.OrcTail in project hive by apache.

the class ExternalCache method createOrcTailFromMs.

private static OrcTail createOrcTailFromMs(HdfsFileStatusWithId file, ByteBuffer bb) throws IOException {
    if (bb == null) {
        return null;
    }
    FileStatus fs = file.getFileStatus();
    ByteBuffer copy = bb.duplicate();
    try {
        OrcTail orcTail = ReaderImpl.extractFileTail(copy, copy.limit(), fs.getModificationTime());
        return orcTail;
    } catch (Exception ex) {
        byte[] data = new byte[bb.remaining()];
        System.arraycopy(bb.array(), bb.arrayOffset() + bb.position(), data, 0, data.length);
        String msg = "Failed to parse the footer stored in cache for file ID " + file.getFileId() + " " + bb + " [ " + Hex.encodeHexString(data) + " ]";
        LOG.error(msg, ex);
        return null;
    }
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) ByteBuffer(java.nio.ByteBuffer) IOException(java.io.IOException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) OrcTail(org.apache.orc.impl.OrcTail)

Aggregations

OrcTail (org.apache.orc.impl.OrcTail)13 OrcProto (org.apache.orc.OrcProto)6 IOException (java.io.IOException)4 Path (org.apache.hadoop.fs.Path)4 ByteBuffer (java.nio.ByteBuffer)3 OrcSplit (org.apache.hadoop.hive.ql.io.orc.OrcSplit)3 StripeInformation (org.apache.orc.StripeInformation)3 Test (org.junit.Test)3 Configuration (org.apache.hadoop.conf.Configuration)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 CacheTag (org.apache.hadoop.hive.common.io.CacheTag)2 MetadataCache (org.apache.hadoop.hive.llap.io.metadata.MetadataCache)2 LlapDaemonCacheMetrics (org.apache.hadoop.hive.llap.metrics.LlapDaemonCacheMetrics)2 SplitInfos (org.apache.hadoop.hive.metastore.Metastore.SplitInfos)2 AcidInputFormat (org.apache.hadoop.hive.ql.io.AcidInputFormat)2 SyntheticFileId (org.apache.hadoop.hive.ql.io.SyntheticFileId)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 FileSystem (org.apache.hadoop.fs.FileSystem)1 IllegalCacheConfigurationException (org.apache.hadoop.hive.llap.IllegalCacheConfigurationException)1 LlapBufferOrBuffers (org.apache.hadoop.hive.llap.io.metadata.MetadataCache.LlapBufferOrBuffers)1