[
https://issues.apache.org/jira/browse/HBASE-13448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14539554#comment-14539554
]
Anoop Sam John commented on HBASE-13448:
----------------------------------------
Using below addition in KeyValue.java we can better track #calls
{code}
@Override
public short getRowLength() {
incInvokeCounts("getRowLength", this);
return Bytes.toShort(this.bytes, getKeyOffset());
}
private static Map<String, Map<String, Pair<Integer, StringBuilder>>>
invokeCounts = new HashMap<String, Map<String, Pair<Integer, StringBuilder>>>();
private static final byte NEW_LINE = '\n';
private static void incInvokeCounts(String method, Cell thisObj){
ByteBufferOutputStream os = new ByteBufferOutputStream(100);
new Exception().printStackTrace(new PrintStream(os));
byte[] bb = os.getByteBuffer().array();
int offset = nThIndexOf(bb, NEW_LINE, 3) + 1;
int endOffset = nThIndexOf(bb, NEW_LINE, 9);
String msg = null;
if (endOffset == -1) {
msg = Bytes.toString(bb, offset);
} else {
msg = Bytes.toString(bb, offset, (endOffset - 1 - offset));
}
msg = msg.replaceAll("\\r?\\n\\tat", " -> ");
String s = thisObj.toString();
String key = s.substring(0, s.lastIndexOf('/'));
Map<String, Pair<Integer, StringBuilder>> methodMap =
invokeCounts.get(method);
if(methodMap == null){
methodMap = new HashMap<String, Pair<Integer, StringBuilder>>();
invokeCounts.put(method, methodMap);
}
Pair<Integer, StringBuilder> p = methodMap.get(key);
if(p == null){
p = new Pair<Integer, StringBuilder>(0, new StringBuilder());
methodMap.put(key, p);
}
p.setFirst(p.getFirst().intValue()+1);
StringBuilder sb = p.getSecond();
sb.append('\n').append(msg);
}
public static void printInvokeCounts() {
for (Entry<String, Map<String, Pair<Integer, StringBuilder>>> entry :
invokeCounts.entrySet()) {
for (Entry<String, Pair<Integer, StringBuilder>> e :
entry.getValue().entrySet()) {
System.out.println(e.getKey() + "#" + entry.getKey() + " : " +
e.getValue().getFirst());
System.out.println(e.getValue().getSecond().toString());
}
System.out.println("=================================================");
}
}
public static void cleanInvokeCounts() {
invokeCounts.clear();
}
private static int nThIndexOf(byte[] array, byte target, int n) {
int c = 1;
for (int i = 0; i < array.length; i++) {
if (array[i] == target) {
if(c==n) return i;
c++;
}
}
return -1;
}
{code}
> New Cell implementation with cached component offsets/lengths
> -------------------------------------------------------------
>
> Key: HBASE-13448
> URL: https://issues.apache.org/jira/browse/HBASE-13448
> Project: HBase
> Issue Type: Sub-task
> Components: Scanners
> Reporter: Anoop Sam John
> Assignee: Anoop Sam John
> Fix For: 2.0.0
>
> Attachments: HBASE-13448.patch, HBASE-13448_V2.patch, gc.png, hits.png
>
>
> This can be extension to KeyValue and can be instantiated and used in read
> path.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)