throws IOException {
if(result == null)
return null;
T persistent = newPersistent();
StateManager stateManager = persistent.getStateManager();
for (String f : fields) {
CassandraColumn col = columnMap.get(f);
Field field = fieldMap.get(f);
Schema fieldSchema = field.schema();
Map<String, byte[]> qualMap;
switch(fieldSchema.getType()) {
case MAP:
if (col.isSuperColumn()) {
qualMap = result.getSuperColumn(col.family, col.superColumn);
} else {
qualMap = result.getColumn(col.family);
}
if (qualMap == null) {
continue;
}
Schema valueSchema = fieldSchema.getValueType();
StatefulMap map = new StatefulHashMap();
for (Entry<String, byte[]> e : qualMap.entrySet()) {
Utf8 mapKey = new Utf8(e.getKey());
map.put(mapKey, ByteUtils.fromBytes(e.getValue(), valueSchema, datumReader, null));
map.putState(mapKey, State.CLEAN);
}
setField(persistent, field, map);
break;
case ARRAY:
if (col.isSuperColumn()) {
qualMap = result.getSuperColumn(col.family, col.superColumn);
} else {
qualMap = result.getColumn(col.family);
}
if (qualMap == null) {
continue;
}
valueSchema = fieldSchema.getElementType();
ArrayList arrayList = new ArrayList();
for (Entry<String, byte[]> e : qualMap.entrySet()) {
arrayList.add(ByteUtils.fromBytes(e.getValue(), valueSchema, datumReader, null));
}
ListGenericArray arr = new ListGenericArray(fieldSchema, arrayList);
setField(persistent, field, arr);
break;
default:
byte[] val;
if (col.isSuperColumn()) {
val = result.get(col.family, col.superColumn, col.column);
} else {
val = result.get(col.family, col.column);
}
if (val == null) {
continue;
}
setField(persistent, field, val);
break;
}
}
stateManager.clearDirty(persistent);
return persistent;
}