本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.singleton方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.singleton方法的具体用法?Java FBUtilities.singleton怎么用?Java FBUtilities.singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.utils.FBUtilities
的用法示例。
在下文中一共展示了FBUtilities.singleton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetColumn
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testGetColumn()
{
Keyspace keyspace = Keyspace.open("Keyspace1");
CellNameType type = keyspace.getColumnFamilyStore("Standard1").getComparator();
Mutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new Mutation("Keyspace1", dk.getKey());
rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("abcd"), 0);
rm.apply();
ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.getKey(), "Standard1", System.currentTimeMillis(), new NamesQueryFilter(FBUtilities.singleton(Util.cellname("Column1"), type)));
Row row = command.getRow(keyspace);
Cell col = row.cf.getColumn(Util.cellname("Column1"));
assertEquals(col.value(), ByteBuffer.wrap("abcd".getBytes()));
}
示例2: testTruncateWithoutSnapshotNonDurable
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testTruncateWithoutSnapshotNonDurable() throws ExecutionException, InterruptedException
{
CommitLog.instance.resetUnsafe();
boolean prevAutoSnapshot = DatabaseDescriptor.isAutoSnapshot();
DatabaseDescriptor.setAutoSnapshot(false);
Keyspace notDurableKs = Keyspace.open("NoCommitlogSpace");
Assert.assertFalse(notDurableKs.metadata.durableWrites);
ColumnFamilyStore cfs = notDurableKs.getColumnFamilyStore("Standard1");
CellNameType type = notDurableKs.getColumnFamilyStore("Standard1").getComparator();
Mutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new Mutation("NoCommitlogSpace", dk.getKey());
rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("abcd"), 0);
rm.apply();
ReadCommand command = new SliceByNamesReadCommand("NoCommitlogSpace", dk.getKey(), "Standard1", System.currentTimeMillis(), new NamesQueryFilter(FBUtilities.singleton(Util.cellname("Column1"), type)));
Row row = command.getRow(notDurableKs);
Cell col = row.cf.getColumn(Util.cellname("Column1"));
Assert.assertEquals(col.value(), ByteBuffer.wrap("abcd".getBytes()));
cfs.truncateBlocking();
DatabaseDescriptor.setAutoSnapshot(prevAutoSnapshot);
row = command.getRow(notDurableKs);
Assert.assertEquals(null, row.cf);
}
示例3: createClustering
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public NavigableSet<Clustering> createClustering(QueryOptions options)
throws InvalidRequestException
{
if (appliesOnlyToStaticColumns() && !restrictions.hasClusteringColumnsRestriction())
return FBUtilities.singleton(CBuilder.STATIC_BUILDER.build(), cfm.comparator);
return restrictions.getClusteringColumns(options);
}
示例4: testCassandra6778
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testCassandra6778() throws CharacterCodingException
{
String cfname = "StandardInteger1";
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
// insert two columns that represent the same integer but have different binary forms (the
// second one is padded with extra zeros)
Mutation rm = new Mutation("Keyspace1", ByteBufferUtil.bytes("k1"));
CellName column1 = cellname(ByteBuffer.wrap(new byte[]{1}));
rm.add(cfname, column1, ByteBufferUtil.bytes("data1"), 1);
rm.apply();
cfs.forceBlockingFlush();
rm = new Mutation("Keyspace1", ByteBufferUtil.bytes("k1"));
CellName column2 = cellname(ByteBuffer.wrap(new byte[]{0, 0, 1}));
rm.add(cfname, column2, ByteBufferUtil.bytes("data2"), 2);
rm.apply();
cfs.forceBlockingFlush();
// fetch by the first column name; we should get the second version of the column value
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(
"Keyspace1", ByteBufferUtil.bytes("k1"), cfname, System.currentTimeMillis(),
new NamesQueryFilter(FBUtilities.singleton(column1, cfs.getComparator())));
ColumnFamily cf = cmd.getRow(keyspace).cf;
assertEquals(1, cf.getColumnCount());
Cell cell = cf.getColumn(column1);
assertEquals("data2", ByteBufferUtil.string(cell.value()));
assertEquals(column2, cell.name());
// fetch by the second column name; we should get the second version of the column value
cmd = new SliceByNamesReadCommand(
"Keyspace1", ByteBufferUtil.bytes("k1"), cfname, System.currentTimeMillis(),
new NamesQueryFilter(FBUtilities.singleton(column2, cfs.getComparator())));
cf = cmd.getRow(keyspace).cf;
assertEquals(1, cf.getColumnCount());
cell = cf.getColumn(column2);
assertEquals("data2", ByteBufferUtil.string(cell.value()));
assertEquals(column2, cell.name());
}
示例5: NamesQueryFilter
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public NamesQueryFilter(ByteBuffer column)
{
this(FBUtilities.singleton(column));
}