Skip to content

Commit

Permalink
Merge pull request #1922 from emeroad/TraceV2/TraceFormatV2
Browse files Browse the repository at this point in the history
#1819 trace format v2
  • Loading branch information
emeroad authored Jul 20, 2016
2 parents 74343d4 + 85dbf11 commit 6ec0fca
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ public interface SpanDecoder {

void next(SpanDecodingContext decodingContext);

void finish(SpanDecodingContext decodingContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,6 @@ public void next(SpanDecodingContext decodingContext) {
decodingContext.next();
}

@Override
public void finish(SpanDecodingContext decodingContext) {
decodingContext.finish();
}


// resolve type miss match
private interface SpanAdaptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public interface Buffer {
@Deprecated
void put(byte[] v);

byte getByte(int index);

byte readByte();

int readUnsignedByte();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ public void put(final byte[] v) {
putBytes(v);
}


@Override
public byte getByte(int index) {
return this.buffer[offset];
}

@Override
public byte readByte() {
return this.buffer[offset++];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
decodingContext.setTransactionId(transactionId);

for (Cell cell : rawCells) {
SpanDecoder spanDecoder = null;
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HBaseTables.TRACE_V2_CF_SPAN)) {

Expand All @@ -88,20 +89,38 @@ public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Buffer columnValue = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());

this.spanDecoder.decode(qualifier, columnValue, decodingContext, out);
spanDecoder = resolveDecoder(columnValue);
spanDecoder.decode(qualifier, columnValue, decodingContext, out);

} else {
logger.warn("Unknown ColumnFamily :{}", Bytes.toStringBinary(CellUtil.cloneFamily(cell)));
}
this.spanDecoder.next(decodingContext);
nextCell(spanDecoder, decodingContext);
}
this.spanDecoder.finish(decodingContext);
decodingContext.finish();


return buildSpanBoList(out);

}

private void nextCell(SpanDecoder spanDecoder, SpanDecodingContext decodingContext) {
if (spanDecoder != null) {
spanDecoder.next(decodingContext);
} else {
decodingContext.next();
}
}

private SpanDecoder resolveDecoder(Buffer columnValue) {
final byte version = columnValue.getByte(0);
if (version == 0) {
return this.spanDecoder;
} else {
throw new IllegalStateException("unsupported version");
}
}

private TransactionId newTransactionId(byte[] rowKey, int offset) {

String agentId = BytesUtils.toStringAndRightTrim(rowKey, offset, AGENT_NAME_MAX_LEN);
Expand Down

0 comments on commit 6ec0fca

Please sign in to comment.