use of org.apache.spark.sql.catalyst.util.ArrayBasedMapData in project java-pubsublite-spark by googleapis.
the class PslSparkUtils method convertAttributesToSparkMap.
@VisibleForTesting
public static ArrayBasedMapData convertAttributesToSparkMap(ListMultimap<String, ByteString> attributeMap) {
List<UTF8String> keyList = new ArrayList<>();
List<GenericArrayData> valueList = new ArrayList<>();
attributeMap.asMap().forEach((key, value) -> {
keyList.add(UTF8String.fromString(key));
List<byte[]> attributeVals = value.stream().map(v -> ByteArray.concat(v.toByteArray())).collect(Collectors.toList());
valueList.add(new GenericArrayData(asScalaBufferConverter(attributeVals).asScala()));
});
return new ArrayBasedMapData(new GenericArrayData(asScalaBufferConverter(keyList).asScala()), new GenericArrayData(asScalaBufferConverter(valueList).asScala()));
}
Aggregations