com.netflix.astyanax.query.RowQuery.autoPaginate()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中com.netflix.astyanax.query.RowQuery.autoPaginate方法的一些代码示例,展示了RowQuery.autoPaginate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowQuery.autoPaginate方法的具体详情如下:
包路径:com.netflix.astyanax.query.RowQuery
类名称:RowQuery
方法名:autoPaginate

RowQuery.autoPaginate介绍

[英]When used in conjunction with a column range this will call subsequent calls to execute() to get the next block of columns.
[中]当与列范围一起使用时,它将调用后续调用execute(),以获取下一个列块。

代码示例

代码示例来源:origin: apache/usergrid

public ColumnNameIterator( RowQuery<?, C> rowQuery, final ColumnParser<C, T> parser, final boolean skipFirst ) {
  this.rowQuery = rowQuery.autoPaginate( true );
  this.parser = parser;
  this.skipFirst = skipFirst;
}

代码示例来源:origin: apache/usergrid

@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 );
}

代码示例来源:origin: apache/usergrid

/**
 * 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() );
}

代码示例来源:origin: apache/usergrid

/**
 * 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() );
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-event

@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;
}

代码示例来源:origin: bazaarvoice/emodb

@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;
}

代码示例来源:origin: bazaarvoice/emodb

@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;
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-event

@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;
}

代码示例来源:origin: bazaarvoice/emodb

@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);
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-event

@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);
}

代码示例来源:origin: com.netflix.astyanax/astyanax-test

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);
  }
}

代码示例来源:origin: com.netflix.astyanax/astyanax-test

.prepareQuery(CF_LONGCOLUMN)
.getKey("A")
.autoPaginate(true)
.withColumnRange(
    new CqlRangeBuilder<Long>()
.prepareQuery(CF_LONGCOLUMN)
.getKey("A")
.autoPaginate(true)
.withColumnRange(
    new CqlRangeBuilder<Long>()

代码示例来源:origin: com.netflix.astyanax/astyanax-test

+ startTime))
            .setEnd(TimeUUIDUtils.getTimeUUID(columnTime
                + endTime)).build()).autoPaginate(true);
OperationResult<ColumnList<UUID>> result3;
int pageCount = 0;

代码示例来源:origin: com.bazaarvoice.emodb/emodb-event

.getKey(channel)
.withColumnRange(new RangeBuilder().setLimit(100).build())
.autoPaginate(true));

代码示例来源:origin: bazaarvoice/emodb

.getKey(channel)
.withColumnRange(new RangeBuilder().setLimit(100).build())
.autoPaginate(true));

代码示例来源:origin: bazaarvoice/emodb

.getKey(channel)
.withColumnRange(range.build())
.autoPaginate(true));

代码示例来源:origin: com.bazaarvoice.emodb/emodb-event

.getKey(channel)
.withColumnRange(range.build())
.autoPaginate(true));

代码示例来源:origin: com.netflix.astyanax/astyanax-test

.setConsistencyLevel(ConsistencyLevel.CL_QUORUM).getKey(rowKey)
.withColumnRange(new RangeBuilder().setLimit(pageSize).build())
.autoPaginate(true);

相关文章

微信公众号

最新文章

更多