@Test public void loadAscendingHistory() throws ConnectionException { final Id applicationId = new SimpleId( "application" ); ApplicationScope context = new ApplicationScopeImpl( applicationId ); final UUID entityId = UUIDGenerator.newTimeUUID(); final UUID version1 = UUIDGenerator.newTimeUUID(); final String type = "test"; final Id id = new SimpleId(entityId, type); Entity entityv1 = new Entity(id); EntityUtils.setVersion(entityv1, version1); MvccEntity saved = new MvccEntityImpl(id, version1, MvccEntity.Status.COMPLETE, Optional.of(entityv1)); serializationStrategy.write(context, saved).execute(); Entity entityv2 = new Entity(id); UUID version2 = UUIDGenerator.newTimeUUID(); EntityUtils.setVersion(entityv1, version2); MvccEntity savedV2 = new MvccEntityImpl(id, version2, MvccEntity.Status.COMPLETE, Optional.of(entityv2)); serializationStrategy.write(context, savedV2).execute(); Iterator<MvccEntity> entities = serializationStrategy.loadAscendingHistory( context, id, savedV2.getVersion(), 20 ); assertTrue(entities.hasNext()); assertEquals(saved.getVersion(), entities.next().getVersion()); assertEquals(savedV2.getVersion(), entities.next().getVersion()); assertFalse(entities.hasNext()); }
@Override public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); final Id applicationId = applicationScope.getApplication(); final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query = keyspace.prepareQuery( columnFamily ).getKey( rowKey ) .withColumnRange( null, version, true, fetchSize ); return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false ); }
MvccEntitySerializationStrategyImpl implements MvccEntitySerializationStrategy { @Override public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); final Id applicationId = applicationScope.getApplication(); final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query = keyspace.prepareQuery( columnFamily ).getKey( rowKey ) .withColumnRange( null, version, true, fetchSize ); return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false ); } }
MvccEntitySerializationStrategyImpl implements MvccEntitySerializationStrategy { @Override public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); final Id applicationId = applicationScope.getApplication(); final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query = keyspace.prepareQuery( columnFamily ).getKey( rowKey ) .withColumnRange( null, version, true, fetchSize ); return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false ); } @Inject  MvccEntitySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig serializationFig,
                                                final CassandraFig cassandraFig ); }
MvccEntitySerializationStrategyImpl implements MvccEntitySerializationStrategy { @Override public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); final Id applicationId = applicationScope.getApplication(); final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query = keyspace.prepareQuery( columnFamily ).getKey( rowKey ) .withColumnRange( null, version, true, fetchSize ); return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false ); } @Inject  MvccEntitySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig serializationFig,
                                                final CassandraFig cassandraFig ); @Override MutationBatch write( final ApplicationScope applicationScope, final MvccEntity entity ); @Override EntitySet load( final ApplicationScope applicationScope, final Collection<Id> entityIds,
                           final UUID maxVersion ); @Override Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope applicationScope, final Id entityId,
                                                       final UUID version, final int fetchSize ); @Override Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId,
                                                      final UUID version, final int fetchSize ); @Override Optional<MvccEntity> load( final ApplicationScope scope, final Id entityId ); @Override MutationBatch mark( final ApplicationScope applicationScope, final Id entityId, final UUID version ); @Override MutationBatch delete( final ApplicationScope applicationScope, final Id entityId, final UUID version ); @Override java.util.Collection getColumnFamilies(); @Override Collection<TableDefinition> getTables(); }
MvccEntitySerializationStrategyImpl implements MvccEntitySerializationStrategy { @Override public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); final Id applicationId = applicationScope.getApplication(); final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query = keyspace.prepareQuery( columnFamily ).getKey( rowKey ) .withColumnRange( null, version, true, fetchSize ); return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false ); } @Inject  MvccEntitySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig serializationFig,
                                                final CassandraFig cassandraFig ); @Override MutationBatch write( final ApplicationScope applicationScope, final MvccEntity entity ); @Override EntitySet load( final ApplicationScope applicationScope, final Collection<Id> entityIds,
                           final UUID maxVersion ); @Override Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope applicationScope, final Id entityId,
                                                       final UUID version, final int fetchSize ); @Override Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId,
                                                      final UUID version, final int fetchSize ); @Override Optional<MvccEntity> load( final ApplicationScope scope, final Id entityId ); @Override MutationBatch mark( final ApplicationScope applicationScope, final Id entityId, final UUID version ); @Override MutationBatch delete( final ApplicationScope applicationScope, final Id entityId, final UUID version ); @Override java.util.Collection getColumnFamilies(); @Override Collection<TableDefinition> getTables();  }