Search in sources :

Example 1 with MapData

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;
}
Also used : HashMap(java.util.HashMap) MapData(org.apache.spark.sql.catalyst.util.MapData) ArrayBasedMapData(org.apache.spark.sql.catalyst.util.ArrayBasedMapData) ArrayData(org.apache.spark.sql.catalyst.util.ArrayData)

Aggregations

HashMap (java.util.HashMap)1 ArrayBasedMapData (org.apache.spark.sql.catalyst.util.ArrayBasedMapData)1 ArrayData (org.apache.spark.sql.catalyst.util.ArrayData)1 MapData (org.apache.spark.sql.catalyst.util.MapData)1