use of org.apache.spark.sql.catalyst.util.MapData in project spark-cassandra-bulkreader by jberragan.
the class CqlMap method sparkSqlRowValue.
@Override
public Object sparkSqlRowValue(GenericInternalRow row, int pos) {
final MapData map = row.getMap(pos);
final ArrayData keys = map.keyArray();
final ArrayData values = map.valueArray();
final Map<Object, Object> result = new HashMap<>(keys.numElements());
for (int i = 0; i < keys.numElements(); i++) {
final Object key = keyType().toTestRowType(keys.get(i, keyType().sparkSqlType()));
final Object value = valueType().toTestRowType(values.get(i, valueType().sparkSqlType()));
result.put(key, value);
}
return result;
}
Aggregations