* Duplicate instance to keep all the objects in memory till flushing.
* @see org.apache.gora.store.DataStore#put(java.lang.Object, org.apache.gora.persistency.Persistent)
*/
@Override
public void put(K key, T value) throws IOException {
T p = (T) value.newInstance(new StateManagerImpl());
Schema schema = value.getSchema();
for (Field field: schema.getFields()) {
if (value.isDirty(field.pos())) {
Object fieldValue = value.get(field.pos());
// check if field has a nested structure (map or record)
Schema fieldSchema = field.schema();
Type type = fieldSchema.getType();
switch(type) {
case RECORD:
Persistent persistent = (Persistent) fieldValue;
Persistent newRecord = persistent.newInstance(new StateManagerImpl());
for (Field member: fieldSchema.getFields()) {
newRecord.put(member.pos(), persistent.get(member.pos()));
}
fieldValue = newRecord;
break;