summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-06-23 11:18:21 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-06-23 11:31:43 +0200
commit5000b72355d7b02acd525375ac4861445d10d89f (patch)
tree83bdc7071dc4cfd5f1825f369e23fcdf192287fe
parent150a6b07ac84c1a5c5fd65a23072e7644090f1e4 (diff)
bug(compute/workload): Fix conversion from UUID to Binary
This change fixes an issue with the metric exporting code in OpenDC where a UUID is not converted correctly into a `Binary` object that is consumed by the Apache Parquet library.
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt6
1 files changed, 3 insertions, 3 deletions
diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt
index 9921f5b8..050e0f0a 100644
--- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt
+++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt
@@ -27,12 +27,12 @@ import java.nio.ByteBuffer
import java.util.UUID
/**
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ * Helper method to convert a [UUID] into a [Binary] object consumed by Parquet.
*/
internal fun UUID.toBinary(): Binary {
- val bb = ByteBuffer.wrap(ByteArray(16))
+ val bb = ByteBuffer.allocate(16)
bb.putLong(mostSignificantBits)
bb.putLong(leastSignificantBits)
+ bb.rewind()
return Binary.fromConstantByteBuffer(bb)
}