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


Java Util.getOnlyPartitionUnfiltered方法代码示例

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


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

示例1: testColumnStatsRecordsRowDeletesCorrectly

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testColumnStatsRecordsRowDeletesCorrectly()
{
    long timestamp = System.currentTimeMillis();
    int localDeletionTime = (int) (timestamp / 1000);

    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_TENCOL);
    RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 5, "key1").clustering("c").add("val", "val1");
    for (int i = 0; i < 10; i++)
        builder.add("val" + i, "val" + i);
    builder.build().applyUnsafe();

    RowUpdateBuilder.deleteRowAt(cfs.metadata, 10L, localDeletionTime, "key1", "c").applyUnsafe();
    ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key1").build());
    EncodingStats stats = partition.stats();
    assertEquals(localDeletionTime, stats.minLocalDeletionTime);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:PartitionTest.java

示例2: testDeletePartition

import org.apache.cassandra.Util; //导入方法依赖的package包/类
public void testDeletePartition(DecoratedKey key, boolean flushBeforeRemove, boolean flushAfterRemove)
{
    ColumnFamilyStore store = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD1);
    ColumnDefinition column = store.metadata.getColumnDefinition(ByteBufferUtil.bytes("val"));

    // write
    new RowUpdateBuilder(store.metadata, 0, key.getKey())
            .clustering("Column1")
            .add("val", "asdf")
            .build()
            .applyUnsafe();

    // validate that data's written
    FilteredPartition partition = Util.getOnlyPartition(Util.cmd(store, key).build());
    assertTrue(partition.rowCount() > 0);
    Row r = partition.iterator().next();
    assertTrue(r.getCell(column).value().equals(ByteBufferUtil.bytes("asdf")));

    if (flushBeforeRemove)
        store.forceBlockingFlush();

    // delete the partition
    new Mutation(KEYSPACE1, key)
            .add(PartitionUpdate.fullPartitionDelete(store.metadata, key, 0, FBUtilities.nowInSeconds()))
            .applyUnsafe();

    if (flushAfterRemove)
        store.forceBlockingFlush();

    // validate removal
    ImmutableBTreePartition partitionUnfiltered = Util.getOnlyPartitionUnfiltered(Util.cmd(store, key).build());
    assertFalse(partitionUnfiltered.partitionLevelDeletion().isLive());
    assertFalse(partitionUnfiltered.iterator().hasNext());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:35,代码来源:DeletePartitionTest.java

示例3: testFullRound

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testFullRound() throws Exception
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARDDYNCOMPOSITE);

    ByteBuffer cname1 = createDynamicCompositeKey("test1", null, -1, false);
    ByteBuffer cname2 = createDynamicCompositeKey("test1", uuids[0], 24, false);
    ByteBuffer cname3 = createDynamicCompositeKey("test1", uuids[0], 42, false);
    ByteBuffer cname4 = createDynamicCompositeKey("test2", uuids[0], -1, false);
    ByteBuffer cname5 = createDynamicCompositeKey("test2", uuids[1], 42, false);

    ByteBuffer key = ByteBufferUtil.bytes("k");
    long ts = FBUtilities.timestampMicros();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname5).add("val", "cname5").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname1).add("val", "cname1").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname4).add("val", "cname4").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname2).add("val", "cname2").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname3).add("val", "cname3").build().applyUnsafe();

    ColumnDefinition cdef = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val"));

    ImmutableBTreePartition readPartition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
    Iterator<Row> iter = readPartition.iterator();

    compareValues(iter.next().getCell(cdef), "cname1");
    compareValues(iter.next().getCell(cdef), "cname2");
    compareValues(iter.next().getCell(cdef), "cname3");
    compareValues(iter.next().getCell(cdef), "cname4");
    compareValues(iter.next().getCell(cdef), "cname5");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:32,代码来源:DynamicCompositeTypeTest.java

示例4: testFullRoundReversed

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testFullRoundReversed() throws Exception
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARDDYNCOMPOSITE);

    ByteBuffer cname1 = createDynamicCompositeKey("test1", null, -1, false, true);
    ByteBuffer cname2 = createDynamicCompositeKey("test1", uuids[0], 24, false, true);
    ByteBuffer cname3 = createDynamicCompositeKey("test1", uuids[0], 42, false, true);
    ByteBuffer cname4 = createDynamicCompositeKey("test2", uuids[0], -1, false, true);
    ByteBuffer cname5 = createDynamicCompositeKey("test2", uuids[1], 42, false, true);

    ByteBuffer key = ByteBufferUtil.bytes("kr");

    long ts = FBUtilities.timestampMicros();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname5).add("val", "cname5").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname1).add("val", "cname1").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname4).add("val", "cname4").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname2).add("val", "cname2").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname3).add("val", "cname3").build().applyUnsafe();

    ColumnDefinition cdef = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val"));

    ImmutableBTreePartition readPartition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
    Iterator<Row> iter = readPartition.iterator();

    compareValues(iter.next().getCell(cdef), "cname5");
    compareValues(iter.next().getCell(cdef), "cname4");
    compareValues(iter.next().getCell(cdef), "cname1"); // null UUID < reversed value
    compareValues(iter.next().getCell(cdef), "cname3");
    compareValues(iter.next().getCell(cdef), "cname2");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:DynamicCompositeTypeTest.java

示例5: testFullRound

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void testFullRound() throws Exception
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARDCOMPOSITE);

    ByteBuffer cname1 = createCompositeKey("test1", null, -1, false);
    ByteBuffer cname2 = createCompositeKey("test1", uuids[0], 24, false);
    ByteBuffer cname3 = createCompositeKey("test1", uuids[0], 42, false);
    ByteBuffer cname4 = createCompositeKey("test2", uuids[0], -1, false);
    ByteBuffer cname5 = createCompositeKey("test2", uuids[1], 42, false);

    ByteBuffer key = ByteBufferUtil.bytes("k");

    long ts = FBUtilities.timestampMicros();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname5).add("val", "cname5").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname1).add("val", "cname1").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname4).add("val", "cname4").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname2).add("val", "cname2").build().applyUnsafe();
    new RowUpdateBuilder(cfs.metadata, ts, key).clustering(cname3).add("val", "cname3").build().applyUnsafe();

    ColumnDefinition cdef = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("val"));

    ImmutableBTreePartition readPartition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
    Iterator<Row> iter = readPartition.iterator();

    compareValues(iter.next().getCell(cdef), "cname1");
    compareValues(iter.next().getCell(cdef), "cname2");
    compareValues(iter.next().getCell(cdef), "cname3");
    compareValues(iter.next().getCell(cdef), "cname4");
    compareValues(iter.next().getCell(cdef), "cname5");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:CompositeTypeTest.java

示例6: readAndDigest

import org.apache.cassandra.Util; //导入方法依赖的package包/类
private ByteBuffer readAndDigest(String partitionKey)
{
    /*
     * In 2.2, this must be replaced by:
     *   ColumnFamily partition = getCurrentColumnFamilyStore().getColumnFamily(QueryFilter.getIdentityFilter(Util.dk(partitionKey), currentTable(), System.currentTimeMillis()));
     *   return ColumnFamily.digest(partition);
     */

    ReadCommand cmd = Util.cmd(getCurrentColumnFamilyStore(), partitionKey).build();
    ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(cmd);
    MessageDigest digest = FBUtilities.threadLocalMD5Digest();
    UnfilteredRowIterators.digest(cmd, partition.unfilteredIterator(), digest, MessagingService.VERSION_22);
    return ByteBuffer.wrap(digest.digest());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DigestBackwardCompatibilityTest.java

示例7: validateKeys

import org.apache.cassandra.Util; //导入方法依赖的package包/类
private void validateKeys(Keyspace ks)
{
    for (int i = 0; i < 100; i++)
    {
        DecoratedKey key = Util.dk(Integer.toString(i));
        ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(ks.getColumnFamilyStore(CF), key).build());
        assertTrue(partition != null && partition.rowCount() > 0);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:SSTableRewriterTest.java

示例8: testMinTimestampPurge

import org.apache.cassandra.Util; //导入方法依赖的package包/类
/**
 * verify that we don't drop tombstones during a minor compaction that might still be relevant
 */
@Test
public void testMinTimestampPurge()
{
    CompactionManager.instance.disableAutoCompaction();

    Keyspace keyspace = Keyspace.open(KEYSPACE2);
    String cfName = "Standard1";
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
    String key3 = "key3";

    // inserts
    new RowUpdateBuilder(cfs.metadata, 8, key3)
        .clustering("c1")
        .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
        .build().applyUnsafe();

    new RowUpdateBuilder(cfs.metadata, 8, key3)
    .clustering("c2")
    .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
    .build().applyUnsafe();

    cfs.forceBlockingFlush();
    // delete c1
    RowUpdateBuilder.deleteRow(cfs.metadata, 10, key3, "c1").applyUnsafe();

    cfs.forceBlockingFlush();
    Collection<SSTableReader> sstablesIncomplete = cfs.getLiveSSTables();

    // delete c2 so we have new delete in a diffrent SSTable
    RowUpdateBuilder.deleteRow(cfs.metadata, 9, key3, "c2").applyUnsafe();
    cfs.forceBlockingFlush();

    // compact the sstables with the c1/c2 data and the c1 tombstone
    cfs.getCompactionStrategyManager().getUserDefinedTask(sstablesIncomplete, Integer.MAX_VALUE).execute(null);

    // We should have both the c1 and c2 tombstones still. Since the min timestamp in the c2 tombstone
    // sstable is older than the c1 tombstone, it is invalid to throw out the c1 tombstone.
    ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key3).build());
    assertEquals(2, partition.rowCount());
    for (Row row : partition)
        assertFalse(row.hasLiveData(FBUtilities.nowInSeconds()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:46,代码来源:CompactionsPurgeTest.java

示例9: overlappingRangeTest

import org.apache.cassandra.Util; //导入方法依赖的package包/类
@Test
public void overlappingRangeTest() throws Exception
{
    CompactionManager.instance.disableAutoCompaction();
    Keyspace keyspace = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CFNAME);

    // Inserting data
    String key = "k2";

    UpdateBuilder builder = UpdateBuilder.create(cfs.metadata, key).withTimestamp(0);
    for (int i = 0; i < 20; i++)
        builder.newRow(i).add("val", i);
    builder.applyUnsafe();
    cfs.forceBlockingFlush();

    new RowUpdateBuilder(cfs.metadata, 1, key).addRangeTombstone(5, 15).build().applyUnsafe();
    cfs.forceBlockingFlush();

    new RowUpdateBuilder(cfs.metadata, 1, key).addRangeTombstone(5, 10).build().applyUnsafe();
    cfs.forceBlockingFlush();

    new RowUpdateBuilder(cfs.metadata, 2, key).addRangeTombstone(5, 8).build().applyUnsafe();
    cfs.forceBlockingFlush();

    Partition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
    int nowInSec = FBUtilities.nowInSeconds();

    for (int i = 0; i < 5; i++)
        assertTrue("Row " + i + " should be live", partition.getRow(new Clustering(bb(i))).hasLiveData(nowInSec));
    for (int i = 16; i < 20; i++)
        assertTrue("Row " + i + " should be live", partition.getRow(new Clustering(bb(i))).hasLiveData(nowInSec));
    for (int i = 5; i <= 15; i++)
        assertFalse("Row " + i + " shouldn't be live", partition.getRow(new Clustering(bb(i))).hasLiveData(nowInSec));

    // Compact everything and re-test
    CompactionManager.instance.performMaximal(cfs, false);
    partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());

    for (int i = 0; i < 5; i++)
        assertTrue("Row " + i + " should be live", partition.getRow(new Clustering(bb(i))).hasLiveData(FBUtilities.nowInSeconds()));
    for (int i = 16; i < 20; i++)
        assertTrue("Row " + i + " should be live", partition.getRow(new Clustering(bb(i))).hasLiveData(FBUtilities.nowInSeconds()));
    for (int i = 5; i <= 15; i++)
        assertFalse("Row " + i + " shouldn't be live", partition.getRow(new Clustering(bb(i))).hasLiveData(nowInSec));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:47,代码来源:RangeTombstoneTest.java

示例10: testDigest

import org.apache.cassandra.Util; //导入方法依赖的package包/类
public void testDigest(int version) throws NoSuchAlgorithmException
{
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_TENCOL);

    try
    {
        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 5, "key1").clustering("c").add("val", "val1");
        for (int i = 0; i < 10; i++)
            builder.add("val" + i, "val" + i);
        builder.build().applyUnsafe();

        new RowUpdateBuilder(cfs.metadata, 5, "key2").clustering("c").add("val", "val2").build().applyUnsafe();

        ReadCommand cmd1 = Util.cmd(cfs, "key1").build();
        ReadCommand cmd2 = Util.cmd(cfs, "key2").build();
        ImmutableBTreePartition p1 = Util.getOnlyPartitionUnfiltered(cmd1);
        ImmutableBTreePartition p2 = Util.getOnlyPartitionUnfiltered(cmd2);

        MessageDigest digest1 = MessageDigest.getInstance("MD5");
        MessageDigest digest2 = MessageDigest.getInstance("MD5");
        UnfilteredRowIterators.digest(cmd1, p1.unfilteredIterator(), digest1, version);
        UnfilteredRowIterators.digest(cmd2, p2.unfilteredIterator(), digest2, version);
        assertFalse(Arrays.equals(digest1.digest(), digest2.digest()));

        p1 = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key2").build());
        p2 = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key2").build());
        digest1 = MessageDigest.getInstance("MD5");
        digest2 = MessageDigest.getInstance("MD5");
        UnfilteredRowIterators.digest(cmd1, p1.unfilteredIterator(), digest1, version);
        UnfilteredRowIterators.digest(cmd2, p2.unfilteredIterator(), digest2, version);
        assertTrue(Arrays.equals(digest1.digest(), digest2.digest()));

        p1 = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key2").build());
        RowUpdateBuilder.deleteRow(cfs.metadata, 6, "key2", "c").applyUnsafe();
        p2 = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, "key2").build());
        digest1 = MessageDigest.getInstance("MD5");
        digest2 = MessageDigest.getInstance("MD5");
        UnfilteredRowIterators.digest(cmd1, p1.unfilteredIterator(), digest1, version);
        UnfilteredRowIterators.digest(cmd2, p2.unfilteredIterator(), digest2, version);
        assertFalse(Arrays.equals(digest1.digest(), digest2.digest()));
    }
    finally
    {
        cfs.truncateBlocking();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:47,代码来源:PartitionTest.java


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