Search in sources :

Example 11 with CacheTag

use of org.apache.hadoop.hive.common.io.CacheTag in project hive by apache.

the class TestCacheContentsTracker method testEncodingDecoding.

@Test
public void testEncodingDecoding() throws Exception {
    LinkedHashMap<String, String> partDescs = new LinkedHashMap<>();
    partDescs.put("pytha=goras", "a2+b2=c2");
    CacheTag tag = CacheTag.build("math.rules", partDescs);
    CacheTag.SinglePartitionCacheTag stag = ((CacheTag.SinglePartitionCacheTag) tag);
    assertEquals("pytha=goras=a2+b2=c2", stag.partitionDescToString());
    assertEquals(1, stag.getPartitionDescMap().size());
    assertEquals("a2+b2=c2", stag.getPartitionDescMap().get("pytha=goras"));
    partDescs.clear();
    partDescs.put("mutli=one", "one=/1");
    partDescs.put("mutli=two/", "two=2");
    tag = CacheTag.build("math.rules", partDescs);
    CacheTag.MultiPartitionCacheTag mtag = ((CacheTag.MultiPartitionCacheTag) tag);
    assertEquals("mutli=one=one=/1/mutli=two/=two=2", mtag.partitionDescToString());
    assertEquals(2, mtag.getPartitionDescMap().size());
    assertEquals("one=/1", mtag.getPartitionDescMap().get("mutli=one"));
    assertEquals("two=2", mtag.getPartitionDescMap().get("mutli=two/"));
}
Also used : CacheTag(org.apache.hadoop.hive.common.io.CacheTag) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 12 with CacheTag

use of org.apache.hadoop.hive.common.io.CacheTag in project hive by apache.

the class CacheContentsTracker method debugDumpShort.

@Override
public void debugDumpShort(StringBuilder sb) {
    ArrayList<String> endResult = new ArrayList<>();
    Map<CacheTag, TagState> summaries = new TreeMap<>();
    for (TagState state : tagInfo.values()) {
        synchronized (state) {
            endResult.add(unsafePrintTagState(state));
            // Handle summary calculation
            CacheTag parentTag = CacheTag.createParentCacheTag(state.cacheTag);
            while (parentTag != null) {
                if (!summaries.containsKey(parentTag)) {
                    summaries.put(parentTag, new TagState(parentTag));
                }
                TagState parentState = summaries.get(parentTag);
                parentState.bufferCount += state.bufferCount;
                parentState.maxCount += state.maxCount;
                parentState.totalSize += state.totalSize;
                parentState.maxSize += state.maxSize;
                parentTag = CacheTag.createParentCacheTag(parentTag);
            }
        }
    }
    for (TagState state : summaries.values()) {
        endResult.add(unsafePrintTagState(state));
    }
    sb.append("\nCache state: \n");
    sb.append(endResult.stream().sorted().collect(joining("\n")));
}
Also used : ArrayList(java.util.ArrayList) CacheTag(org.apache.hadoop.hive.common.io.CacheTag) TreeMap(java.util.TreeMap)

Aggregations

CacheTag (org.apache.hadoop.hive.common.io.CacheTag)12 Test (org.junit.Test)8 Path (org.apache.hadoop.fs.Path)7 LlapDaemonCacheMetrics (org.apache.hadoop.hive.llap.metrics.LlapDaemonCacheMetrics)5 Configuration (org.apache.hadoop.conf.Configuration)4 MetadataCache (org.apache.hadoop.hive.llap.io.metadata.MetadataCache)4 IOException (java.io.IOException)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 DiskRangeList (org.apache.hadoop.hive.common.io.DiskRangeList)3 SyntheticFileId (org.apache.hadoop.hive.ql.io.SyntheticFileId)3 OrcTail (org.apache.orc.impl.OrcTail)3 ByteBuffer (java.nio.ByteBuffer)2 Random (java.util.Random)2 Predicate (java.util.function.Predicate)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 DiskRange (org.apache.hadoop.hive.common.io.DiskRange)2 IllegalCacheConfigurationException (org.apache.hadoop.hive.llap.IllegalCacheConfigurationException)2 INVALIDATE_OK (org.apache.hadoop.hive.llap.cache.LlapCacheableBuffer.INVALIDATE_OK)2 Priority (org.apache.hadoop.hive.llap.cache.LowLevelCache.Priority)2 MapWork (org.apache.hadoop.hive.ql.plan.MapWork)2