use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SchemaChangeLogCodec method writeData.
@Override
public byte[] writeData(SchemaChangeLog schemaChangeLog) {
final Buffer buffer = new AutomaticBuffer();
buffer.putShort(CURRENT_VERSION);
buffer.putPrefixedString(schemaChangeLog.getId());
buffer.putLong(schemaChangeLog.getExecTimestamp());
buffer.putInt(schemaChangeLog.getExecOrder());
CheckSum checkSum = schemaChangeLog.getCheckSum();
buffer.putInt(checkSum.getVersion());
buffer.putPrefixedString(checkSum.getCheckSum());
buffer.putPrefixedString(schemaChangeLog.getValue());
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentStatMapperV2 method mapRow.
@Override
public List<T> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
final byte[] distributedRowKey = result.getRow();
final String agentId = this.hbaseOperationFactory.getAgentId(distributedRowKey);
final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey);
List<T> dataPoints = new ArrayList<>();
for (Cell cell : result.rawCells()) {
if (CellUtil.matchingFamily(cell, targetHbaseColumnFamily.getName())) {
Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer);
AgentStatDecodingContext decodingContext = new AgentStatDecodingContext();
decodingContext.setAgentId(agentId);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
List<T> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
for (T candidate : candidates) {
if (filter(candidate)) {
continue;
}
dataPoints.add(candidate);
}
}
}
// Reverse sort as timestamp is stored in a reversed order.
dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR);
return dataPoints;
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationTranscoder method encodeIntStringStringValue.
private byte[] encodeIntStringStringValue(Object o) {
final IntStringStringValue tIntStringStringValue = (IntStringStringValue) o;
final int intValue = tIntStringStringValue.getIntValue();
final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
// TODO increase by a more precise value
final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
final Buffer buffer = new AutomaticBuffer(bufferSize);
buffer.putSVInt(intValue);
buffer.putPrefixedBytes(stringValue1);
buffer.putPrefixedBytes(stringValue2);
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeLongIntIntByteByteStringValue.
private Object decodeLongIntIntByteByteStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final byte bitField = buffer.readByte();
final long longValue = buffer.readVLong();
final int intValue1 = buffer.readVInt();
int intValue2 = -1;
if (BitFieldUtils.testBit(bitField, 0)) {
intValue2 = buffer.readVInt();
}
byte byteValue1 = -1;
if (BitFieldUtils.testBit(bitField, 1)) {
byteValue1 = buffer.readByte();
}
byte byteValue2 = -1;
if (BitFieldUtils.testBit(bitField, 2)) {
byteValue2 = buffer.readByte();
}
String stringValue = null;
if (BitFieldUtils.testBit(bitField, 3)) {
stringValue = BytesUtils.toString(buffer.readPrefixedBytes());
}
return new LongIntIntByteByteStringValue(longValue, intValue1, intValue2, byteValue1, byteValue2, stringValue);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeStringStringValue.
// private Object decodeIntStringStringValue(byte[] data) {
// final Buffer buffer = new FixedBuffer(data);
// final int intValue = buffer.readSVInt();
// final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
// final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
// return new IntStringStringValue(intValue, stringValue1, stringValue2);
// }
//
// private byte[] encodeIntStringStringValue(Object o) {
// final TIntStringStringValue tIntStringStringValue = (TIntStringStringValue) o;
// final int intValue = tIntStringStringValue.getIntValue();
// final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
// final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
// // TODO increase by a more precise value
// final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
// final Buffer buffer = new AutomaticBuffer(bufferSize);
// buffer.putSVInt(intValue);
// buffer.putPrefixedBytes(stringValue1);
// buffer.putPrefixedBytes(stringValue2);
// return buffer.getBuffer();
// }
//
// private int getBufferSize(byte[] stringValue1, byte[] stringValue2, int reserve) {
// int length = 0;
// if (stringValue1 != null) {
// length += stringValue1.length;
// }
// if (stringValue2 != null) {
// length += stringValue2.length;
//
// }
// return length + reserve;
// }
//
private Object decodeStringStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
return new StringStringValue(stringValue1, stringValue2);
}
Aggregations