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


Java SSTableScanner.hasNext方法代码示例

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


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

示例1: testNoExpire

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
@Test
public void testNoExpire() throws InterruptedException
{
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore("Standard1");
    cfs.disableAutoCompaction();
    cfs.metadata.gcGraceSeconds(0);
    long timestamp = System.currentTimeMillis();
    Mutation rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
    rm.add("Standard1", Util.cellname("col"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);
    rm.add("Standard1", Util.cellname("col7"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);

    rm.applyUnsafe();
    cfs.forceBlockingFlush();

    rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
            rm.add("Standard1", Util.cellname("col2"),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   1);
            rm.applyUnsafe();
    cfs.forceBlockingFlush();
    rm = new Mutation(KEYSPACE1, Util.dk("ttl").getKey());
    rm.add("Standard1", Util.cellname("col3"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp,
               1);
    rm.applyUnsafe();
    cfs.forceBlockingFlush();
    DecoratedKey noTTLKey = Util.dk("nottl");
    rm = new Mutation(KEYSPACE1, noTTLKey.getKey());
    rm.add("Standard1", Util.cellname("col311"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp);
    rm.applyUnsafe();
    cfs.forceBlockingFlush();
    Thread.sleep(2000); // wait for ttl to expire
    assertEquals(4, cfs.getSSTables().size());
    cfs.enableAutoCompaction(true);
    assertEquals(1, cfs.getSSTables().size());
    SSTableReader sstable = cfs.getSSTables().iterator().next();
    SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
    assertTrue(scanner.hasNext());
    while(scanner.hasNext())
    {
        OnDiskAtomIterator iter = scanner.next();
        assertEquals(noTTLKey, iter.getKey());
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:55,代码来源:TTLExpiryTest.java

示例2: antiCompactOne

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.disableAutoCompaction();
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 10; i++)
    {
        DecoratedKey key = Util.dk(Integer.toString(i));
        Mutation rm = new Mutation(KEYSPACE1, key.getKey());
        for (int j = 0; j < 10; j++)
            rm.add(CF, Util.cellname(Integer.toString(j)),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   0);
        rm.applyUnsafe();
    }
    store.forceBlockingFlush();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);

    assertEquals(2, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().getToken()));
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().getToken()));
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 4);
    assertEquals(nonRepairedKeys, 6);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:53,代码来源:AntiCompactionTest.java

示例3: antiCompactTen

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
public void antiCompactTen(String compactionStrategy) throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.setCompactionStrategyClass(compactionStrategy);
    store.disableAutoCompaction();

    for (int table = 0; table < 10; table++)
    {
        generateSStable(store,Integer.toString(table));
    }
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());

    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);
    /*
    Anticompaction will be anti-compacting 10 SSTables but will be doing this two at a time
    so there will be no net change in the number of sstables
     */
    assertEquals(10, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().getToken()));
                assertEquals(repairedAt, sstable.getSSTableMetadata().repairedAt);
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().getToken()));
                assertEquals(ActiveRepairService.UNREPAIRED_SSTABLE, sstable.getSSTableMetadata().repairedAt);
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 40);
    assertEquals(nonRepairedKeys, 60);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:51,代码来源:AntiCompactionTest.java

示例4: testNoExpire

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
@Test
public void testNoExpire() throws ExecutionException, InterruptedException
{
    ColumnFamilyStore cfs = Keyspace.open("Keyspace1").getColumnFamilyStore("Standard1");
    cfs.disableAutoCompaction();
    cfs.metadata.gcGraceSeconds(0);
    long timestamp = System.currentTimeMillis();
    Mutation rm = new Mutation("Keyspace1", Util.dk("ttl").key);
    rm.add("Standard1", Util.cellname("col"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);
    rm.add("Standard1", Util.cellname("col7"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);

    rm.apply();
    cfs.forceBlockingFlush();

    rm = new Mutation("Keyspace1", Util.dk("ttl").key);
            rm.add("Standard1", Util.cellname("col2"),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   1);
            rm.apply();
    cfs.forceBlockingFlush();
    rm = new Mutation("Keyspace1", Util.dk("ttl").key);
    rm.add("Standard1", Util.cellname("col3"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp,
               1);
    rm.apply();
    cfs.forceBlockingFlush();
    DecoratedKey noTTLKey = Util.dk("nottl");
    rm = new Mutation("Keyspace1", noTTLKey.key);
    rm.add("Standard1", Util.cellname("col311"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp);
    rm.apply();
    cfs.forceBlockingFlush();
    Thread.sleep(2000); // wait for ttl to expire
    assertEquals(4, cfs.getSSTables().size());
    cfs.enableAutoCompaction(true);
    assertEquals(1, cfs.getSSTables().size());
    SSTableReader sstable = cfs.getSSTables().iterator().next();
    SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
    assertTrue(scanner.hasNext());
    while(scanner.hasNext())
    {
        OnDiskAtomIterator iter = scanner.next();
        assertEquals(noTTLKey, iter.getKey());
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:55,代码来源:TTLExpiryTest.java

示例5: testNoExpire

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
@Test
public void testNoExpire() throws InterruptedException
{
    ColumnFamilyStore cfs = Keyspace.open("Keyspace1").getColumnFamilyStore("Standard1");
    cfs.disableAutoCompaction();
    cfs.metadata.gcGraceSeconds(0);
    long timestamp = System.currentTimeMillis();
    Mutation rm = new Mutation("Keyspace1", Util.dk("ttl").key);
    rm.add("Standard1", Util.cellname("col"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);
    rm.add("Standard1", Util.cellname("col7"),
           ByteBufferUtil.EMPTY_BYTE_BUFFER,
           timestamp,
           1);

    rm.apply();
    cfs.forceBlockingFlush();

    rm = new Mutation("Keyspace1", Util.dk("ttl").key);
            rm.add("Standard1", Util.cellname("col2"),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   1);
            rm.apply();
    cfs.forceBlockingFlush();
    rm = new Mutation("Keyspace1", Util.dk("ttl").key);
    rm.add("Standard1", Util.cellname("col3"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp,
               1);
    rm.apply();
    cfs.forceBlockingFlush();
    DecoratedKey noTTLKey = Util.dk("nottl");
    rm = new Mutation("Keyspace1", noTTLKey.key);
    rm.add("Standard1", Util.cellname("col311"),
               ByteBufferUtil.EMPTY_BYTE_BUFFER,
               timestamp);
    rm.apply();
    cfs.forceBlockingFlush();
    Thread.sleep(2000); // wait for ttl to expire
    assertEquals(4, cfs.getSSTables().size());
    cfs.enableAutoCompaction(true);
    assertEquals(1, cfs.getSSTables().size());
    SSTableReader sstable = cfs.getSSTables().iterator().next();
    SSTableScanner scanner = sstable.getScanner(DataRange.allData(sstable.partitioner));
    assertTrue(scanner.hasNext());
    while(scanner.hasNext())
    {
        OnDiskAtomIterator iter = scanner.next();
        assertEquals(noTTLKey, iter.getKey());
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:55,代码来源:TTLExpiryTest.java

示例6: antiCompactOne

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.disableAutoCompaction();
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 10; i++)
    {
        DecoratedKey key = Util.dk(Integer.toString(i));
        Mutation rm = new Mutation(KEYSPACE1, key.key);
        for (int j = 0; j < 10; j++)
            rm.add("Standard1", Util.cellname(Integer.toString(j)),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   0);
        rm.apply();
    }
    store.forceBlockingFlush();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);

    assertEquals(2, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().token));
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().token));
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 4);
    assertEquals(nonRepairedKeys, 6);
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:53,代码来源:AntiCompactionTest.java

示例7: run

import org.apache.cassandra.io.sstable.SSTableScanner; //导入方法依赖的package包/类
private static void run(Descriptor desc, CommandLine cmd, PrintStream out) throws IOException {
  // Since we don't have a schema, make one up!
  CFMetaData cfm = new CFMetaData(desc.ksname, desc.cfname, ColumnFamilyType.Standard,
                                  UTF8Type.instance, UTF8Type.instance);

  SSTableReader reader = SSTableReader.open(desc, cfm);
  SSTableScanner scanner = reader.getScanner();

  long totalTombstones = 0, totalColumns = 0;
  if (cmd.hasOption("l")) {
    out.printf(desc.baseFilename() + "\n");
    out.printf("rowkey #tombstones (#columns)\n");
  }
  while (scanner.hasNext()) {
    SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();

    int tombstonesCount = 0, columnsCount = 0;
    while (row.hasNext())
    {
      OnDiskAtom column = row.next();
      long now = System.currentTimeMillis();
      if (column instanceof Column && ((Column) column).isMarkedForDelete(now)) {
        tombstonesCount++;
      }
      columnsCount++;
    }
    totalTombstones += tombstonesCount;
    totalColumns += columnsCount;

    if (tombstonesCount > 0) {
      String key;
      try {
        key = UTF8Type.instance.getString(row.getKey().key);
      } catch (RuntimeException e) {
        key = BytesType.instance.getString(row.getKey().key);
      }
      out.printf("%s %d (%d)%n", key, tombstonesCount, columnsCount);
    }

  }

  if (cmd.hasOption("l")) {
    out.printf("#total_tombstones (#total_columns)\n");
  }
  out.printf("%d (%d)%n", totalTombstones, totalColumns);

  scanner.close();
}
 
开发者ID:spotify,项目名称:cassandra-opstools,代码行数:49,代码来源:CountTombstones.java


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