本文整理汇总了Java中org.apache.cassandra.db.filter.QueryFilter类的典型用法代码示例。如果您正苦于以下问题:Java QueryFilter类的具体用法?Java QueryFilter怎么用?Java QueryFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryFilter类属于org.apache.cassandra.db.filter包,在下文中一共展示了QueryFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public Future<Pair<CounterCacheKey, ClockAndCount>> deserialize(DataInputStream in, final ColumnFamilyStore cfs) throws IOException
{
final ByteBuffer partitionKey = ByteBufferUtil.readWithLength(in);
final CellName cellName = cfs.metadata.comparator.cellFromByteBuffer(ByteBufferUtil.readWithLength(in));
return StageManager.getStage(Stage.READ).submit(new Callable<Pair<CounterCacheKey, ClockAndCount>>()
{
public Pair<CounterCacheKey, ClockAndCount> call() throws Exception
{
DecoratedKey key = cfs.partitioner.decorateKey(partitionKey);
QueryFilter filter = QueryFilter.getNamesFilter(key,
cfs.metadata.cfName,
FBUtilities.singleton(cellName, cfs.metadata.comparator),
Long.MIN_VALUE);
ColumnFamily cf = cfs.getTopLevelColumns(filter, Integer.MIN_VALUE);
if (cf == null)
return null;
Cell cell = cf.getColumn(cellName);
if (cell == null || !cell.isLive(Long.MIN_VALUE))
return null;
ClockAndCount clockAndCount = CounterContext.instance().getLocalClockAndCount(cell.value());
return Pair.create(CounterCacheKey.create(cfs.metadata.cfId, partitionKey, cellName), clockAndCount);
}
});
}
示例2: testRemoveSubColumn
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
@Test
public void testRemoveSubColumn()
{
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore store = keyspace.getColumnFamilyStore("Super1");
Mutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new Mutation("Keyspace1", dk.getKey());
Util.addMutation(rm, "Super1", "SC1", 1, "asdf", 0);
rm.apply();
store.forceBlockingFlush();
CellName cname = CellNames.compositeDense(ByteBufferUtil.bytes("SC1"), getBytes(1L));
// remove
rm = new Mutation("Keyspace1", dk.getKey());
rm.delete("Super1", cname, 1);
rm.apply();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, "Super1", System.currentTimeMillis()));
assertFalse(retrieved.getColumn(cname).isLive());
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
示例3: testGetColumnWithWrongBF
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
@Test
public void testGetColumnWithWrongBF()
{
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("Standard1");
cfs.truncateBlocking();
List<Mutation> rms = new LinkedList<>();
Mutation rm = new Mutation("Keyspace1", ByteBufferUtil.bytes("key1"));
rm.add("Standard1", cellname("Column1"), ByteBufferUtil.bytes("asdf"), 0);
rm.add("Standard1", cellname("Column2"), ByteBufferUtil.bytes("asdf"), 0);
rms.add(rm);
Util.writeColumnFamily(rms);
List<SSTableReader> ssTables = keyspace.getAllSSTables();
assertEquals(1, ssTables.size());
ssTables.get(0).forceFilterFailures();
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key2"), "Standard1", System.currentTimeMillis()));
assertNull(cf);
}
示例4: testDuplicateCells
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
@Test
public void testDuplicateCells() throws WriteTimeoutException
{
ColumnFamilyStore cfs = Keyspace.open(KS).getColumnFamilyStore(CF1);
cfs.truncateBlocking();
ColumnFamily cells = ArrayBackedSortedColumns.factory.create(cfs.metadata);
cells.addCounter(cellname(1), 1L);
cells.addCounter(cellname(1), 2L);
cells.addCounter(cellname(1), 3L);
cells.addCounter(cellname(1), 4L);
new CounterMutation(new Mutation(KS, bytes(1), cells), ConsistencyLevel.ONE).apply();
ColumnFamily current = cfs.getColumnFamily(QueryFilter.getIdentityFilter(dk(bytes(1)), CF1, System.currentTimeMillis()));
ByteBuffer context = current.getColumn(cellname(1)).value();
assertEquals(10L, CounterContext.instance().total(context));
assertEquals(ClockAndCount.create(1L, 10L), CounterContext.instance().getLocalClockAndCount(context));
assertEquals(ClockAndCount.create(1L, 10L), cfs.getCachedCounter(bytes(1), cellname(1)));
}
示例5: getCurrentLocalCounterId
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
/**
* Read the current local node id from the system keyspace or null if no
* such node id is recorded.
*/
public static CounterId getCurrentLocalCounterId()
{
Keyspace keyspace = Keyspace.open(Keyspace.SYSTEM_KS);
// Get the last CounterId (since CounterId are timeuuid is thus ordered from the older to the newer one)
QueryFilter filter = QueryFilter.getSliceFilter(decorate(ALL_LOCAL_NODE_ID_KEY),
COUNTER_ID_CF,
ByteBufferUtil.EMPTY_BYTE_BUFFER,
ByteBufferUtil.EMPTY_BYTE_BUFFER,
true,
1,
System.currentTimeMillis());
ColumnFamily cf = keyspace.getColumnFamilyStore(COUNTER_ID_CF).getColumnFamily(filter);
if (cf != null && cf.getColumnCount() != 0)
return CounterId.wrap(cf.iterator().next().name());
else
return null;
}
示例6: getOldLocalCounterIds
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public static List<CounterId.CounterIdRecord> getOldLocalCounterIds()
{
List<CounterId.CounterIdRecord> l = new ArrayList<CounterId.CounterIdRecord>();
Keyspace keyspace = Keyspace.open(Keyspace.SYSTEM_KS);
QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY), COUNTER_ID_CF, System.currentTimeMillis());
ColumnFamily cf = keyspace.getColumnFamilyStore(COUNTER_ID_CF).getColumnFamily(filter);
CounterId previous = null;
for (Column c : cf)
{
if (previous != null)
l.add(new CounterId.CounterIdRecord(previous, c.timestamp()));
// this will ignore the last column on purpose since it is the
// current local node id
previous = CounterId.wrap(c.name());
}
return l;
}
示例7: getFromTable
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
private Column getFromTable(Keyspace keyspace, String cfName, String keyName, String columnName)
{
ColumnFamily cf;
ColumnFamilyStore cfStore = keyspace.getColumnFamilyStore(cfName);
if (cfStore == null)
{
return null;
}
cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter(Util.dk(keyName),
cfName,
ByteBufferUtil.bytes(columnName),
System.currentTimeMillis()));
if (cf == null)
{
return null;
}
return cf.getColumn(ByteBufferUtil.bytes(columnName));
}
示例8: getTopLevelColumns
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public ColumnFamily getTopLevelColumns(QueryFilter filter, int gcBefore)
{
Tracing.trace("Executing single-partition query on {}", name);
CollationController controller = new CollationController(this, filter, gcBefore);
ColumnFamily columns;
/* @daidong The read order, used to track accesses to off-heap memtable storage */
try (OpOrder.Group op = readOrdering.start())
{
//@daidong There are three different MemtablePool instances. HeapPool.needToCopyOnHeap = false;
//@daidong NativePool.needToCopyOnHeap = true; SlabPool is not so sure, based on the construction paramter.
/*
if (filter.filter instanceof NamesQueryFilter && this.metadata.getDefaultValidator() != CounterColumnType.instance)
logger.info("@daidong debug: " + "collectTimeOrderedData");
else
//@daidong To me, most time, we hit this path.
logger.info("@daidong debug: " + "collectAllData");
*/
columns = controller.getTopLevelColumns(Memtable.MEMORY_POOL.needToCopyOnHeap());
}
metric.updateSSTableIterated(controller.getSstablesIterated());
return columns;
}
示例9: deserialize
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public Future<Pair<CounterCacheKey, ClockAndCount>> deserialize(DataInputStream in, final ColumnFamilyStore cfs) throws IOException
{
final ByteBuffer partitionKey = ByteBufferUtil.readWithLength(in);
final CellName cellName = cfs.metadata.comparator.cellFromByteBuffer(ByteBufferUtil.readWithLength(in));
return StageManager.getStage(Stage.READ).submit(new Callable<Pair<CounterCacheKey, ClockAndCount>>()
{
public Pair<CounterCacheKey, ClockAndCount> call() throws Exception
{
DecoratedKey key = cfs.partitioner.decorateKey(partitionKey);
QueryFilter filter = QueryFilter.getNamesFilter(key,
cfs.metadata.cfName,
FBUtilities.singleton(cellName, cfs.metadata.comparator),
Long.MIN_VALUE);
ColumnFamily cf = cfs.getTopLevelColumns(filter, Integer.MIN_VALUE);
if (cf == null)
return null;
Cell cell = cf.getColumn(cellName);
if (cell == null || cell.isMarkedForDelete(Long.MIN_VALUE))
return null;
ClockAndCount clockAndCount = CounterContext.instance().getLocalClockAndCount(cell.value());
return Pair.create(CounterCacheKey.create(cfs.metadata.cfId, partitionKey, cellName), clockAndCount);
}
});
}
示例10: getOldLocalCounterIds
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public static List<CounterId.CounterIdRecord> getOldLocalCounterIds()
{
List<CounterId.CounterIdRecord> l = new ArrayList<CounterId.CounterIdRecord>();
Keyspace keyspace = Keyspace.open(Keyspace.SYSTEM_KS);
QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY), COUNTER_ID_CF, System.currentTimeMillis());
ColumnFamily cf = keyspace.getColumnFamilyStore(COUNTER_ID_CF).getColumnFamily(filter);
CounterId previous = null;
for (Cell c : cf)
{
if (previous != null)
l.add(new CounterId.CounterIdRecord(previous, c.timestamp()));
// this will ignore the last column on purpose since it is the
// current local node id
previous = CounterId.wrap(c.name().toByteBuffer());
}
return l;
}
示例11: testRemoveSubColumn
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
@Test
public void testRemoveSubColumn()
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore store = keyspace.getColumnFamilyStore("Super1");
Mutation rm;
DecoratedKey dk = Util.dk("key1");
// add data
rm = new Mutation(KEYSPACE1, dk.getKey());
Util.addMutation(rm, "Super1", "SC1", 1, "asdf", 0);
rm.applyUnsafe();
store.forceBlockingFlush();
CellName cname = CellNames.compositeDense(ByteBufferUtil.bytes("SC1"), getBytes(1L));
// remove
rm = new Mutation(KEYSPACE1, dk.getKey());
rm.delete("Super1", cname, 1);
rm.applyUnsafe();
ColumnFamily retrieved = store.getColumnFamily(QueryFilter.getIdentityFilter(dk, "Super1", System.currentTimeMillis()));
assertFalse(retrieved.getColumn(cname).isLive());
assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
}
示例12: getOldLocalCounterIds
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
public static List<CounterId.CounterIdRecord> getOldLocalCounterIds()
{
List<CounterId.CounterIdRecord> l = new ArrayList<CounterId.CounterIdRecord>();
Table table = Table.open(Table.SYSTEM_KS);
QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY), new QueryPath(COUNTER_ID_CF));
ColumnFamily cf = table.getColumnFamilyStore(COUNTER_ID_CF).getColumnFamily(filter);
CounterId previous = null;
for (IColumn c : cf)
{
if (previous != null)
l.add(new CounterId.CounterIdRecord(previous, c.timestamp()));
// this will ignore the last column on purpose since it is the
// current local node id
previous = CounterId.wrap(c.name());
}
return l;
}
示例13: testDuplicateCells
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
@Test
public void testDuplicateCells() throws WriteTimeoutException
{
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF1);
cfs.truncateBlocking();
ColumnFamily cells = ArrayBackedSortedColumns.factory.create(cfs.metadata);
cells.addCounter(cellname(1), 1L);
cells.addCounter(cellname(1), 2L);
cells.addCounter(cellname(1), 3L);
cells.addCounter(cellname(1), 4L);
new CounterMutation(new Mutation(KEYSPACE1, bytes(1), cells), ConsistencyLevel.ONE).apply();
ColumnFamily current = cfs.getColumnFamily(QueryFilter.getIdentityFilter(dk(bytes(1)), CF1, System.currentTimeMillis()));
ByteBuffer context = current.getColumn(cellname(1)).value();
assertEquals(10L, CounterContext.instance().total(context));
assertEquals(ClockAndCount.create(1L, 10L), CounterContext.instance().getLocalClockAndCount(context));
assertEquals(ClockAndCount.create(1L, 10L), cfs.getCachedCounter(bytes(1), cellname(1)));
}
示例14: getFromTable
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
private IColumn getFromTable(Table table, String cfName, String keyName, String columnName)
{
ColumnFamily cf;
ColumnFamilyStore cfStore = table.getColumnFamilyStore(cfName);
if (cfStore == null)
{
return null;
}
cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter(
Util.dk(keyName), new QueryPath(cfName), ByteBufferUtil.bytes(columnName)));
if (cf == null)
{
return null;
}
return cf.getColumn(ByteBufferUtil.bytes(columnName));
}
示例15: reduceNameFilter
import org.apache.cassandra.db.filter.QueryFilter; //导入依赖的package包/类
/**
* remove columns from @param filter where we already have data in @param returnCF newer than @param sstableTimestamp
*/
private void reduceNameFilter(QueryFilter filter, ColumnFamily returnCF, long sstableTimestamp)
{
AbstractColumnContainer container = filter.path.superColumnName == null
? returnCF
: (SuperColumn) returnCF.getColumn(filter.path.superColumnName);
if (container == null)
return;
for (Iterator<ByteBuffer> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
{
ByteBuffer filterColumn = iterator.next();
IColumn column = container.getColumn(filterColumn);
if (column != null && column.timestamp() > sstableTimestamp)
iterator.remove();
}
}