当前位置: 首页>>代码示例>>Java>>正文


Java SSTableScanner.seekTo方法代码示例

本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableScanner.seekTo方法的典型用法代码示例。如果您正苦于以下问题:Java SSTableScanner.seekTo方法的具体用法?Java SSTableScanner.seekTo怎么用?Java SSTableScanner.seekTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.io.sstable.SSTableScanner的用法示例。


在下文中一共展示了SSTableScanner.seekTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIterator

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
/**
 * Get a row iterator over the provided memtables and sstables, between the provided keys
 * and filtered by the queryfilter.
 * @param memtables Memtables pending flush.
 * @param sstables SStables to scan through.
 * @param startWith Start at this key
 * @param stopAt Stop and this key
 * @param filter Used to decide which columns to pull out
 * @param cfs
 * @return A row iterator following all the given restrictions
 */
public static CloseableIterator<Row> getIterator(final Iterable<Memtable> memtables,
                                      final Collection<SSTableReader> sstables,
                                      final RowPosition startWith,
                                      final RowPosition stopAt,
                                      final QueryFilter filter,
                                      final ColumnFamilyStore cfs)
{
    // fetch data from current memtable, historical memtables, and SSTables in the correct order.
    final List<CloseableIterator<OnDiskAtomIterator>> iterators = new ArrayList<CloseableIterator<OnDiskAtomIterator>>();

    // memtables
    for (Memtable memtable : memtables)
    {
        iterators.add(new ConvertToColumnIterator(filter, memtable.getEntryIterator(startWith, stopAt)));
    }

    for (SSTableReader sstable : sstables)
    {
        final SSTableScanner scanner = sstable.getScanner(filter);
        scanner.seekTo(startWith);
        iterators.add(scanner);
    }

    // reduce rows from all sources into a single row
    return MergeIterator.get(iterators, COMPARE_BY_KEY, new MergeIterator.Reducer<OnDiskAtomIterator, Row>()
    {
        private final int gcBefore = (int) (System.currentTimeMillis() / 1000) - cfs.metadata.getGcGraceSeconds();
        private final List<OnDiskAtomIterator> colIters = new ArrayList<OnDiskAtomIterator>();
        private DecoratedKey key;
        private ColumnFamily returnCF;

        @Override
        protected void onKeyChange()
        {
            this.returnCF = ColumnFamily.create(cfs.metadata);
        }

        public void reduce(OnDiskAtomIterator current)
        {
            this.colIters.add(current);
            this.key = current.getKey();
            this.returnCF.delete(current.getColumnFamily());
        }

        protected Row getReduced()
        {

            // First check if this row is in the rowCache. If it is we can skip the rest
            ColumnFamily cached = cfs.getRawCachedRow(key);
            if (cached == null)
            {
                // not cached: collate
                filter.collateOnDiskAtom(returnCF, colIters, gcBefore);
            }
            else
            {
                QueryFilter keyFilter = new QueryFilter(key, filter.path, filter.filter);
                returnCF = cfs.filterColumnFamily(cached, keyFilter, gcBefore);
            }

            Row rv = new Row(key, returnCF);
            colIters.clear();
            key = null;
            return rv;
        }
    });
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:79,代码来源:RowIteratorFactory.java


注:本文中的org.apache.cassandra.io.sstable.SSTableScanner.seekTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。