in iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/utils/PipeMemoryWeightUtil.java [169:228]
public static long calculateTabletSizeInBytes(Tablet tablet) {
long totalSizeInBytes = 0;
if (tablet == null) {
return totalSizeInBytes;
}
long[] timestamps = tablet.getTimestamps();
Object[] tabletValues = tablet.getValues();
// timestamps
if (timestamps != null) {
totalSizeInBytes += timestamps.length * 8L;
}
// values
final List<IMeasurementSchema> timeseries = tablet.getSchemas();
if (timeseries != null) {
for (int column = 0; column < timeseries.size(); column++) {
final IMeasurementSchema measurementSchema = timeseries.get(column);
if (measurementSchema == null) {
continue;
}
final TSDataType tsDataType = measurementSchema.getType();
if (tsDataType == null) {
continue;
}
if (tsDataType.isBinary()) {
if (tabletValues == null || tabletValues.length <= column) {
continue;
}
final Binary[] values = ((Binary[]) tabletValues[column]);
if (values == null) {
continue;
}
for (Binary value : values) {
totalSizeInBytes +=
value == null ? 0 : (value.getLength() == -1 ? 0 : value.getLength());
}
} else {
totalSizeInBytes += (long) timestamps.length * tsDataType.getDataTypeSize();
}
}
}
// bitMaps
BitMap[] bitMaps = tablet.getBitMaps();
if (bitMaps != null) {
for (int i = 0; i < bitMaps.length; i++) {
totalSizeInBytes += bitMaps[i] == null ? 0 : bitMaps[i].getSize();
}
}
// estimate other dataStructures size
totalSizeInBytes += 100;
return totalSizeInBytes;
}