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/"));
}
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")));
}
Aggregations