in core/src/main/java/org/apache/iceberg/variants/PrimitiveWrapper.java [83:124]
public int sizeInBytes() {
switch (type()) {
case NULL:
case BOOLEAN_TRUE:
case BOOLEAN_FALSE:
return 1; // 1 header only
case INT8:
return 2; // 1 header + 1 value
case INT16:
return 3; // 1 header + 2 value
case INT32:
case DATE:
case FLOAT:
return 5; // 1 header + 4 value
case INT64:
case DOUBLE:
case TIMESTAMPTZ:
case TIMESTAMPNTZ:
case TIMESTAMPTZ_NANOS:
case TIMESTAMPNTZ_NANOS:
case TIME:
return 9; // 1 header + 8 value
case DECIMAL4:
return 6; // 1 header + 1 scale + 4 unscaled value
case DECIMAL8:
return 10; // 1 header + 1 scale + 8 unscaled value
case DECIMAL16:
return 18; // 1 header + 1 scale + 16 unscaled value
case BINARY:
return 5 + ((ByteBuffer) value).remaining(); // 1 header + 4 length + value length
case STRING:
if (null == buffer) {
this.buffer = ByteBuffer.wrap(((String) value).getBytes(StandardCharsets.UTF_8));
}
return 5 + buffer.remaining(); // 1 header + 4 length + value length
case UUID:
return 1 + 16; // 1 header + 16 length
}
throw new UnsupportedOperationException("Unsupported primitive type: " + type());
}