use of java.io.DataInputStream in project pinot by linkedin.
the class AggregationPhaseMapOutputKey method fromBytes.
public static AggregationPhaseMapOutputKey fromBytes(byte[] buffer) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer));
int length;
int size;
List<String> dimensions = new ArrayList<>();
byte[] bytes;
// time
long time = dis.readLong();
// dimensions size
size = dis.readInt();
// dimension value
for (int i = 0; i < size; i++) {
length = dis.readInt();
bytes = new byte[length];
dis.read(bytes);
dimensions.add(new String(bytes));
}
AggregationPhaseMapOutputKey wrapper;
wrapper = new AggregationPhaseMapOutputKey(time, dimensions);
return wrapper;
}
use of java.io.DataInputStream in project pinot by linkedin.
the class AggregationPhaseMapOutputValue method fromBytes.
public static AggregationPhaseMapOutputValue fromBytes(byte[] buffer, List<MetricType> metricTypes) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer));
int length;
// metric values
length = dis.readInt();
Number[] metricValues = new Number[length];
for (int i = 0; i < length; i++) {
MetricType metricType = metricTypes.get(i);
switch(metricType) {
case SHORT:
metricValues[i] = dis.readShort();
break;
case LONG:
metricValues[i] = dis.readLong();
break;
case INT:
metricValues[i] = dis.readInt();
break;
case FLOAT:
metricValues[i] = dis.readFloat();
break;
case DOUBLE:
metricValues[i] = dis.readDouble();
break;
}
}
AggregationPhaseMapOutputValue wrapper;
wrapper = new AggregationPhaseMapOutputValue(metricValues, metricTypes);
return wrapper;
}
use of java.io.DataInputStream in project pinot by linkedin.
the class TopKPhaseMapOutputValue method fromBytes.
public static TopKPhaseMapOutputValue fromBytes(byte[] buffer, List<MetricType> metricTypes) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer));
int length;
// metric values
length = dis.readInt();
Number[] metricValues = new Number[length];
for (int i = 0; i < length; i++) {
MetricType metricType = metricTypes.get(i);
switch(metricType) {
case SHORT:
metricValues[i] = dis.readShort();
break;
case LONG:
metricValues[i] = dis.readLong();
break;
case INT:
metricValues[i] = dis.readInt();
break;
case FLOAT:
metricValues[i] = dis.readFloat();
break;
case DOUBLE:
metricValues[i] = dis.readDouble();
break;
}
}
TopKPhaseMapOutputValue wrapper;
wrapper = new TopKPhaseMapOutputValue(metricValues, metricTypes);
return wrapper;
}
use of java.io.DataInputStream in project hadoop by apache.
the class LeveldbRMStateStore method loadDelegationToken.
private RMDelegationTokenIdentifierData loadDelegationToken(byte[] data) throws IOException {
RMDelegationTokenIdentifierData tokenData = new RMDelegationTokenIdentifierData();
DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
try {
tokenData.readFields(in);
} finally {
IOUtils.cleanup(LOG, in);
}
return tokenData;
}
use of java.io.DataInputStream in project hadoop by apache.
the class LeveldbRMStateStore method loadDelegationKey.
private DelegationKey loadDelegationKey(byte[] data) throws IOException {
DelegationKey key = new DelegationKey();
DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
try {
key.readFields(in);
} finally {
IOUtils.cleanup(LOG, in);
}
return key;
}
Aggregations