本文整理汇总了Java中com.netflix.astyanax.model.Rows.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Rows.getKeys方法的具体用法?Java Rows.getKeys怎么用?Java Rows.getKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.model.Rows
的用法示例。
在下文中一共展示了Rows.getKeys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsSingleRowOnly
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* Return true if we have < 2 rows with columns, false otherwise
*/
private boolean containsSingleRowOnly( final Rows<R, C> result ) {
int count = 0;
for ( R key : result.getKeys() ) {
if ( result.getRow( key ).getColumns().size() > 0 ) {
count++;
//we have more than 1 row with values, return them
if ( count > 1 ) {
return false;
}
}
}
return true;
}
示例2: mergeResults
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* Multiple rows are present, merge them into a single result set
* @param result
* @return
*/
private List<T> mergeResults( final Rows<R, C> result, final int maxSize ) {
if (logger.isTraceEnabled()) logger.trace( "Multiple rows have columns. Merging" );
final List<T> mergedResults = new ArrayList<>(maxSize);
for ( final R key : result.getKeys() ) {
final ColumnList<C> columns = result.getRow( key ).getColumns();
for (final Column<C> column :columns ) {
final T returnedValue = columnParser.parseColumn( column );
//Use an O(log n) search, same as a tree, but with fast access to indexes for later operations
int searchIndex = Collections.binarySearch( mergedResults, returnedValue, comparator );
/**
* DO NOT remove this section of code. If you're seeing inconsistent results during shard transition,
* you'll
* need to enable this
*/
//
// if ( previous != null && comparator.compare( previous, returnedValue ) == 0 ) {
// throw new RuntimeException( String.format(
// "Cassandra returned 2 unique columns,
// but your comparator marked them as equal. This " +
// "indicates a bug in your comparator. Previous value was %s and
// current value is " +
// "%s",
// previous, returnedValue ) );
// }
//
// previous = returnedValue;
//we've already seen it, no-op
if(searchIndex > -1){
continue;
}
final int insertIndex = (searchIndex+1)*-1;
//it's at the end of the list, don't bother inserting just to remove it
if(insertIndex >= maxSize){
continue;
}
if (logger.isTraceEnabled()) logger.trace( "Adding value {} to merged set at index {}", returnedValue, insertIndex );
mergedResults.add( insertIndex, returnedValue );
//prune the mergedResults
while ( mergedResults.size() > maxSize ) {
if (logger.isTraceEnabled()) logger.trace( "Trimming results to size {}", maxSize );
//just remove from our tail until the size falls to the correct value
mergedResults.remove(mergedResults.size()-1);
}
}
if (logger.isTraceEnabled()) logger.trace( "Candidate result set size is {}", mergedResults.size() );
}
return mergedResults;
}
示例3: processResults
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* Process the result set and filter any duplicates that may have already been seen in previous shards. During
* a shard transition, there could be the same columns in multiple shards (rows). This will also allow for
* filtering the startColumn (the seek starting point) when paging a row in Cassandra.
*
* @param result
* @return
*/
private List<T> processResults(final Rows<R, C> result, final int maxSize ) {
final List<T> mergedResults = new ArrayList<>(maxSize);
for ( final R key : result.getKeys() ) {
final ColumnList<C> columns = result.getRow( key ).getColumns();
for (final Column<C> column :columns ) {
final T returnedValue = columnParser.parseColumn( column );
// use an O(log n) search, same as a tree, but with fast access to indexes for later operations
int searchIndex = Collections.binarySearch( resultsTracking, returnedValue, comparator );
//we've already seen the column, filter it out as we might be in a shard transition or our start column
if(searchIndex > -1){
if(logger.isTraceEnabled()){
logger.trace("skipping column as it was already retrieved before");
}
skipSize++;
continue;
}
resultsTracking.add(returnedValue);
mergedResults.add(returnedValue );
}
if (logger.isTraceEnabled()) logger.trace( "Candidate result set size is {}", mergedResults.size() );
}
return mergedResults;
}
示例4: singleRowResult
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* A single row is present, only parse the single row
* @param result
* @return
*/
private List<T> singleRowResult( final Rows<R, C> result ) {
if (logger.isTraceEnabled()) logger.trace( "Only a single row has columns. Parsing directly" );
for ( R key : result.getKeys() ) {
final ColumnList<C> columnList = result.getRow( key ).getColumns();
final int size = columnList.size();
if ( size > 0 ) {
final List<T> results = new ArrayList<>(size);
for(Column<C> column: columnList){
results.add(columnParser.parseColumn( column ));
}
return results;
}
}
//we didn't have any results, just return nothing
return Collections.<T>emptyList();
}