public ColumnNameIterator( RowQuery<?, C> rowQuery, final ColumnParser<C, T> parser, final boolean skipFirst ) { this.rowQuery = rowQuery.autoPaginate( true ); this.parser = parser; this.skipFirst = skipFirst; }
@Override public Iterator<Shard> getShardMetaData( final ApplicationScope scope, final Optional<Shard> start, final DirectedEdgeMeta metaData ) { ValidationUtils.validateApplicationScope( scope ); GraphValidation.validateDirectedEdgeMeta( metaData ); Preconditions.checkNotNull( metaData, "metadata must be present" ); /** * If the edge is present, we need to being seeking from this */ final RangeBuilder rangeBuilder = new RangeBuilder().setLimit( graphFig.getScanPageSize() ); if ( start.isPresent() ) { final Shard shard = start.get(); GraphValidation.valiateShard( shard ); rangeBuilder.setStart( shard.getShardIndex() ); } final ScopedRowKey rowKey = ScopedRowKey.fromKey( scope.getApplication(), metaData ); final RowQuery<ScopedRowKey<DirectedEdgeMeta>, Long> query = keyspace.prepareQuery( EDGE_SHARDS ).setConsistencyLevel( cassandraConfig.getReadCL() ).getKey( rowKey ) .autoPaginate( true ).withColumnRange( rangeBuilder.build() ); return new ColumnNameIterator<>( query, COLUMN_PARSER, false ); }
/** * Get the edge types from the search criteria. * * @param scope The org scope * @param search The edge type search info * @param cf The column family to execute on */ private Iterator<String> getEdgeTypes( final ApplicationScope scope, final SearchEdgeType search, final MultiTenantColumnFamily<ScopedRowKey<Id>, String> cf ) { ValidationUtils.validateApplicationScope( scope ); GraphValidation.validateSearchEdgeType( search ); final ScopedRowKey< Id> sourceKey = new ScopedRowKey<>( scope.getApplication(), search.getNode() ); //resume from the last if specified. Also set the range final RangeBuilder rangeBuilder = createRange( search ); RowQuery<ScopedRowKey<Id>, String> query = keyspace.prepareQuery( cf ).getKey( sourceKey ).autoPaginate( true ) .withColumnRange( rangeBuilder.build() ); return new ColumnNameIterator<>( query, PARSER, search.getLast().isPresent() ); }
/** * Get the id types from the specified column family * * @param scope The organization scope to use * @param search The search criteria * @param cf The column family to search */ public Iterator<String> getIdTypes( final ApplicationScope scope, final SearchIdType search, final MultiTenantColumnFamily<ScopedRowKey<EdgeIdTypeKey>, String> cf ) { ValidationUtils.validateApplicationScope( scope ); GraphValidation.validateSearchEdgeIdType( search ); final ScopedRowKey<EdgeIdTypeKey> sourceTypeKey = new ScopedRowKey<>( scope.getApplication(), new EdgeIdTypeKey( search.getNode(), search.getEdgeType() ) ); final RangeBuilder rangeBuilder = createRange( search ); RowQuery<ScopedRowKey<EdgeIdTypeKey>, String> query = keyspace.prepareQuery( cf ).getKey( sourceTypeKey ).autoPaginate( true ) .withColumnRange( rangeBuilder.build() ); return new ColumnNameIterator<>( query, PARSER, search.getLast().isPresent() ); }
@Override public Map<UUID, String> loadSegments(String queue) { Map<UUID, String> resultMap = Maps.newHashMap(); Iterator<Column<UUID>> iter = executePaginated( _keyspace.prepareQuery(CF_DEDUP_MD, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(queue) .withColumnRange(new RangeBuilder().setLimit(100).build()) .autoPaginate(true)); while (iter.hasNext()) { Column<UUID> column = iter.next(); resultMap.put(column.getName(), column.getStringValue()); } return resultMap; }
@Override public Map<UUID, String> loadSegments(String queue) { Map<UUID, String> resultMap = Maps.newHashMap(); Iterator<Column<UUID>> iter = executePaginated( _keyspace.prepareQuery(CF_DEDUP_MD, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(queue) .withColumnRange(new RangeBuilder().setLimit(100).build()) .autoPaginate(true)); while (iter.hasNext()) { Column<UUID> column = iter.next(); resultMap.put(column.getName(), column.getStringValue()); } return resultMap; }
@Override public boolean moveIfFast(String fromChannel, String toChannel) { Iterator<Column<ByteBuffer>> manifestColumns = executePaginated( _keyspace.prepareQuery(ColumnFamilies.MANIFEST, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(fromChannel) .withColumnRange(new RangeBuilder().setLimit(50).build()) .autoPaginate(true)); List<ByteBuffer> closedSlabs = Lists.newArrayList(); boolean movedAll = true; while (manifestColumns.hasNext()) { Column<ByteBuffer> manifestColumn = manifestColumns.next(); ByteBuffer slabId = manifestColumn.getName(); boolean open = manifestColumn.getBooleanValue(); if (open) { // Can't safely re-assign open slabs to another channel since writers may still be writing. movedAll = false; // All events in the open slab might be deleted, but don't check for that here. continue; } closedSlabs.add(slabId); if (closedSlabs.size() >= SLAB_MOVE_BATCH) { _manifestPersister.move(fromChannel, toChannel, closedSlabs, false); closedSlabs.clear(); } } if (!closedSlabs.isEmpty()) { _manifestPersister.move(fromChannel, toChannel, closedSlabs, false); } return movedAll; }
@Override public boolean moveIfFast(String fromChannel, String toChannel) { Iterator<Column<ByteBuffer>> manifestColumns = executePaginated( _keyspace.prepareQuery(ColumnFamilies.MANIFEST, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(fromChannel) .withColumnRange(new RangeBuilder().setLimit(50).build()) .autoPaginate(true)); List<ByteBuffer> closedSlabs = Lists.newArrayList(); boolean movedAll = true; while (manifestColumns.hasNext()) { Column<ByteBuffer> manifestColumn = manifestColumns.next(); ByteBuffer slabId = manifestColumn.getName(); boolean open = manifestColumn.getBooleanValue(); if (open) { // Can't safely re-assign open slabs to another channel since writers may still be writing. movedAll = false; // All events in the open slab might be deleted, but don't check for that here. continue; } closedSlabs.add(slabId); if (closedSlabs.size() >= SLAB_MOVE_BATCH) { _manifestPersister.move(fromChannel, toChannel, closedSlabs, false); closedSlabs.clear(); } } if (!closedSlabs.isEmpty()) { _manifestPersister.move(fromChannel, toChannel, closedSlabs, false); } return movedAll; }
@Override public Iterator<ByteBuffer> scanRecords(UUID dataId, @Nullable ByteBuffer from, @Nullable final ByteBuffer to, int batchSize, int limit) { final Iterator<Column<ByteBuffer>> iter = executePaginated( _keyspace.prepareQuery(CF_DEDUP_DATA, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(dataId) .withColumnRange(new RangeBuilder() .setStart(Objects.firstNonNull(from, EMPTY_BUFFER)) .setEnd(Objects.firstNonNull(to, EMPTY_BUFFER)) .setLimit(batchSize) .build()) .autoPaginate(true)); return Iterators.limit(new AbstractIterator<ByteBuffer>() { @Override protected ByteBuffer computeNext() { while (iter.hasNext()) { ByteBuffer record = iter.next().getName(); if (!record.equals(to)) { // To is exclusive return record; } } return endOfData(); } }, limit); }
@Override public Iterator<ByteBuffer> scanRecords(UUID dataId, @Nullable ByteBuffer from, @Nullable final ByteBuffer to, int batchSize, int limit) { final Iterator<Column<ByteBuffer>> iter = executePaginated( _keyspace.prepareQuery(CF_DEDUP_DATA, ConsistencyLevel.CL_LOCAL_QUORUM) .getKey(dataId) .withColumnRange(new RangeBuilder() .setStart(Objects.firstNonNull(from, EMPTY_BUFFER)) .setEnd(Objects.firstNonNull(to, EMPTY_BUFFER)) .setLimit(batchSize) .build()) .autoPaginate(true)); return Iterators.limit(new AbstractIterator<ByteBuffer>() { @Override protected ByteBuffer computeNext() { while (iter.hasNext()) { ByteBuffer record = iter.next().getName(); if (!record.equals(to)) { // To is exclusive return record; } } return endOfData(); } }, limit); }
private void paginateColumnsForRowKey(String rowKey, boolean rowDeleted, int pageSize) throws Exception { ColumnList<String> columns; RowQuery<String, String> query = keyspace .prepareQuery(TestUtils.CF_COLUMN_RANGE_TEST) .getKey(rowKey) .autoPaginate(true) .withColumnRange( new CqlRangeBuilder<String>().setStart("a") .setFetchSize(pageSize).build()); int count = 1; while (!(columns = query.execute().getResult()).isEmpty()) { Assert.assertTrue(columns.size() <= pageSize); for (Column<String> col : columns) { int value = col.getName().charAt(0) - 'a' + 1; Assert.assertEquals(count, value); count++; } } if (rowDeleted) { Assert.assertTrue(count == 1); } }
.prepareQuery(CF_LONGCOLUMN) .getKey("A") .autoPaginate(true) .withColumnRange( new CqlRangeBuilder<Long>() .prepareQuery(CF_LONGCOLUMN) .getKey("A") .autoPaginate(true) .withColumnRange( new CqlRangeBuilder<Long>()
+ startTime)) .setEnd(TimeUUIDUtils.getTimeUUID(columnTime + endTime)).build()).autoPaginate(true); OperationResult<ColumnList<UUID>> result3; int pageCount = 0;
.getKey(channel) .withColumnRange(new RangeBuilder().setLimit(100).build()) .autoPaginate(true));
.getKey(channel) .withColumnRange(new RangeBuilder().setLimit(100).build()) .autoPaginate(true));
.getKey(channel) .withColumnRange(range.build()) .autoPaginate(true));
.getKey(channel) .withColumnRange(range.build()) .autoPaginate(true));
.setConsistencyLevel(ConsistencyLevel.CL_QUORUM).getKey(rowKey) .withColumnRange(new RangeBuilder().setLimit(pageSize).build()) .autoPaginate(true);