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


Java NamesQueryFilter类代码示例

本文整理汇总了Java中org.apache.cassandra.db.filter.NamesQueryFilter的典型用法代码示例。如果您正苦于以下问题:Java NamesQueryFilter类的具体用法?Java NamesQueryFilter怎么用?Java NamesQueryFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NamesQueryFilter类属于org.apache.cassandra.db.filter包,在下文中一共展示了NamesQueryFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrentValuesFromCFS

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
private void getCurrentValuesFromCFS(List<CounterUpdateCell> counterUpdateCells,
                                     ColumnFamilyStore cfs,
                                     ClockAndCount[] currentValues)
{
    SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator);
    for (int i = 0; i < currentValues.length; i++)
        if (currentValues[i] == null)
            names.add(counterUpdateCells.get(i).name());

    ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names));
    Row row = cmd.getRow(cfs.keyspace);
    ColumnFamily cf = row == null ? null : row.cf;

    for (int i = 0; i < currentValues.length; i++)
    {
        if (currentValues[i] != null)
            continue;

        Cell cell = cf == null ? null : cf.getColumn(counterUpdateCells.get(i).name());
        if (cell == null || !cell.isLive()) // absent or a tombstone.
            currentValues[i] = ClockAndCount.BLANK;
        else
            currentValues[i] = CounterContext.instance().getLocalClockAndCount(cell.value());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:CounterMutation.java

示例2: testGetColumn

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的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()));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:ReadMessageTest.java

示例3: testGetColumn

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
@Test
public void testGetColumn() throws IOException, ColumnFamilyNotDefinedException
{
    Keyspace keyspace = Keyspace.open("Keyspace1");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");

    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    rm.add("Standard1", ByteBufferUtil.bytes("Column1"), ByteBufferUtil.bytes("abcd"), 0);
    rm.apply();

    ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.key, "Standard1", System.currentTimeMillis(), new NamesQueryFilter(ByteBufferUtil.bytes("Column1")));
    Row row = command.getRow(keyspace);
    Column col = row.cf.getColumn(ByteBufferUtil.bytes("Column1"));
    assertEquals(col.value(), ByteBuffer.wrap("abcd".getBytes()));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:ReadMessageTest.java

示例4: retryDummyRead

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {

        final long limit = System.currentTimeMillis() + (60L * 1000L);

        while (System.currentTimeMillis() < limit) {
            try {
                SortedSet<ByteBuffer> ss = new TreeSet<ByteBuffer>();
                ss.add(ByteBufferUtil.zeroByteBuffer(1));
                NamesQueryFilter nqf = new NamesQueryFilter(ss);
                SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
                StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
                log.info("Read on CF {} in KS {} succeeded", cf, ks);
                return;
            } catch (Throwable t) {
                log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
            }

            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                throw new PermanentBackendException(e);
            }
        }

        throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
    }
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:27,代码来源:CassandraEmbeddedStoreManager.java

示例5: testGetColumn

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的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()));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:ReadMessageTest.java

示例6: reduceNameFilter

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的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();
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:20,代码来源:CollationController.java

示例7: testGetColumn

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
@Test
public void testGetColumn() throws IOException, ColumnFamilyNotDefinedException
{
    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.key);
    rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("abcd"), 0);
    rm.apply();

    ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.key, "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()));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:19,代码来源:ReadMessageTest.java

示例8: getCurrentValuesFromCFS

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
private void getCurrentValuesFromCFS(List<CounterUpdateCell> counterUpdateCells,
                                     ColumnFamilyStore cfs,
                                     ClockAndCount[] currentValues)
{
    SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator);
    for (int i = 0; i < currentValues.length; i++)
        if (currentValues[i] == null)
            names.add(counterUpdateCells.get(i).name);

    ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names));
    Row row = cmd.getRow(cfs.keyspace);
    ColumnFamily cf = row == null ? null : row.cf;

    for (int i = 0; i < currentValues.length; i++)
    {
        if (currentValues[i] != null)
            continue;

        Cell cell = cf == null ? null : cf.getColumn(counterUpdateCells.get(i).name());
        if (cell == null || cell.isMarkedForDelete(Long.MIN_VALUE)) // absent or a tombstone.
            currentValues[i] = ClockAndCount.BLANK;
        else
            currentValues[i] = CounterContext.instance().getLocalClockAndCount(cell.value());
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:26,代码来源:CounterMutation.java

示例9: testGetColumn

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的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.key);
    rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("abcd"), 0);
    rm.apply();

    ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.key, "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()));
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:19,代码来源:ReadMessageTest.java

示例10: retryDummyRead

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {

        final long limit = System.currentTimeMillis() + (60L * 1000L);

        while (System.currentTimeMillis() < limit) {
            try {
                SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() {
                    // This is a singleton set.  We need to define a comparator because SimpleDenseCellName is not
                    // comparable, but it doesn't have to be a useful comparator
                    @Override
                    public int compare(CellName o1, CellName o2)
                    {
                        return 0;
                    }
                });
                names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1)));
                NamesQueryFilter nqf = new NamesQueryFilter(names);
                SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
                StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
                log.info("Read on CF {} in KS {} succeeded", cf, ks);
                return;
            } catch (Throwable t) {
                log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
            }

            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                throw new PermanentBackendException(e);
            }
        }

        throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
    }
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:35,代码来源:CassandraEmbeddedStoreManager.java

示例11: getTopLevelColumns

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
public ColumnFamily getTopLevelColumns(boolean copyOnHeap)
{
    return filter.filter instanceof NamesQueryFilter
           && cfs.metadata.getDefaultValidator() != CounterColumnType.instance
           ? collectTimeOrderedData(copyOnHeap)
           : collectAllData(copyOnHeap);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:CollationController.java

示例12: reduceNameFilter

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
/**
 * remove columns from @param filter where we already have data in @param container newer than @param sstableTimestamp
 */
private void reduceNameFilter(QueryFilter filter, ColumnFamily container, long sstableTimestamp)
{
    if (container == null)
        return;

    for (Iterator<CellName> iterator = ((NamesQueryFilter) filter.filter).columns.iterator(); iterator.hasNext(); )
    {
        CellName filterColumn = iterator.next();
        Cell cell = container.getColumn(filterColumn);
        if (cell != null && cell.timestamp() > sstableTimestamp)
            iterator.remove();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:CollationController.java

示例13: create

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
public static ReadCommand create(String ksName, ByteBuffer key, String cfName, long timestamp, IDiskAtomFilter filter)
{
    if (filter instanceof SliceQueryFilter)
        return new SliceFromReadCommand(ksName, key, cfName, timestamp, (SliceQueryFilter)filter);
    else
        return new SliceByNamesReadCommand(ksName, key, cfName, timestamp, (NamesQueryFilter)filter);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:ReadCommand.java

示例14: namesFilter

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
public static NamesQueryFilter namesFilter(ColumnFamilyStore cfs, String... names)
{
    SortedSet<CellName> s = new TreeSet<CellName>(cfs.getComparator());
    for (String str : names)
        s.add(cellname(str));
    return new NamesQueryFilter(s);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:Util.java

示例15: testSliceByNamesCommandOnUUIDTypeSCF

import org.apache.cassandra.db.filter.NamesQueryFilter; //导入依赖的package包/类
@Test
public void testSliceByNamesCommandOnUUIDTypeSCF() throws Throwable
{
    String keyspaceName = "Keyspace1";
    String cfName = "Super6";
    ByteBuffer superColName = LexicalUUIDType.instance.fromString("a4ed3562-0e8e-4b41-bdfd-c45a2774682d");
    Keyspace keyspace = Keyspace.open(keyspaceName);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
    DecoratedKey key = Util.dk("slice-get-uuid-type");

    // Insert a row with one supercolumn and multiple subcolumns
    putColsSuper(cfs, key, superColName, new BufferCell(cellname("a"), ByteBufferUtil.bytes("A"), 1),
                                         new BufferCell(cellname("b"), ByteBufferUtil.bytes("B"), 1));

    // Get the entire supercolumn like normal
    ColumnFamily cfGet = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName, System.currentTimeMillis()));
    assertEquals(ByteBufferUtil.bytes("A"), cfGet.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("a"))).value());
    assertEquals(ByteBufferUtil.bytes("B"), cfGet.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("b"))).value());

    // Now do the SliceByNamesCommand on the supercolumn, passing both subcolumns in as columns to get
    SortedSet<CellName> sliceColNames = new TreeSet<CellName>(cfs.metadata.comparator);
    sliceColNames.add(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("a")));
    sliceColNames.add(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("b")));
    SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(keyspaceName, key.getKey(), cfName, System.currentTimeMillis(), new NamesQueryFilter(sliceColNames));
    ColumnFamily cfSliced = cmd.getRow(keyspace).cf;

    // Make sure the slice returns the same as the straight get
    assertEquals(ByteBufferUtil.bytes("A"), cfSliced.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("a"))).value());
    assertEquals(ByteBufferUtil.bytes("B"), cfSliced.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("b"))).value());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:31,代码来源:ColumnFamilyStoreTest.java


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