From 5000b72355d7b02acd525375ac4861445d10d89f Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 23 Jun 2022 11:18:21 +0200 Subject: 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. --- .../main/kotlin/org/opendc/compute/workload/export/parquet/Utils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'opendc-compute') 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) } -- cgit v1.2.3