@Override public Map<String, Object> extractEntityTuple(Session session, EntityKey key) { SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory(); IgniteCache<Object, BinaryObject> cache = getEntityCache( sessionFactory, key.getMetadata() ); Object cacheKey = getProvider( sessionFactory ).createKeyObject( key ); Map<String, Object> result = new HashMap<>(); BinaryObject po = cache.get( cacheKey ); TupleSnapshot snapshot = new IgniteTupleSnapshot( cacheKey, po, key.getMetadata() ); for ( String fieldName : snapshot.getColumnNames() ) { result.put( fieldName, snapshot.get( fieldName ) ); } return result; }
@Override TupleSnapshot createTupleSnapshot(List<?> value) { Map<String, Object> map = new HashMap<>(); for ( int i = 0; i < value.size(); i++ ) { ScalarReturn ret = (ScalarReturn) queryReturns.get( i ); map.put( ret.getColumnAlias(), value.get( i ) ); } return new MapTupleSnapshot( map ); }
@Override public Tuple get(RowKey rowKey) { TupleSnapshot row = rows.get( rowKey ); return row != null ? new Tuple( row, SnapshotType.UPDATE ) : null; }
@Override TupleSnapshot createTupleSnapshot(List<?> value) { return new IgniteTupleSnapshot( /* _KEY */ value.get( 0 ), /* _VAL */ (BinaryObject) value.get( 1 ), keyMetadata ); }
abstract TupleSnapshot createTupleSnapshot(T value);