请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CellNames类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: updateDefinition

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated)
{
    AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated);
    if (t == null)
        return false;

    // We need to update this validator ...
    cfm.addOrReplaceColumnDefinition(def.withNewType(t));

    // ... but if it's part of the comparator or key validator, we need to go update those too.
    switch (def.kind)
    {
        case PARTITION_KEY:
            cfm.keyValidator(updateWith(cfm.getKeyValidator(), keyspace, toReplace, updated));
            break;
        case CLUSTERING_COLUMN:
            cfm.comparator = CellNames.fromAbstractType(updateWith(cfm.comparator.asAbstractType(), keyspace, toReplace, updated), cfm.comparator.isDense());
            break;
        default:
            // If it's a collection, we still want to modify the comparator because the collection is aliased in it
            if (def.type instanceof CollectionType)
                cfm.comparator = CellNames.fromAbstractType(updateWith(cfm.comparator.asAbstractType(), keyspace, toReplace, updated), cfm.comparator.isDense());
    }
    return true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:AlterTypeStatement.java


示例2: updateDefinition

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated)
{
    AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated);
    if (t == null)
        return false;

    // We need to update this validator ...
    cfm.addOrReplaceColumnDefinition(def.withNewType(t));

    // ... but if it's part of the comparator or key validator, we need to go update those too.
    switch (def.kind)
    {
        case PARTITION_KEY:
            cfm.keyValidator(updateWith(cfm.getKeyValidator(), keyspace, toReplace, updated));
            break;
        case CLUSTERING_COLUMN:
            cfm.comparator = CellNames.fromAbstractType(updateWith(cfm.comparator.asAbstractType(), keyspace, toReplace, updated), cfm.comparator.isDense());
            break;
    }
    return true;
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:22,代码来源:AlterTypeStatement.java


示例3: retryDummyRead

import org.apache.cassandra.db.composites.CellNames; //导入依赖的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


示例4: unthriftifySuper

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private List<Cell> unthriftifySuper(SuperColumn super_column)
{
    List<Cell> cells = new ArrayList<Cell>(super_column.columns.size());
    for (org.apache.cassandra.thrift.Column column : super_column.columns)
    {
        Cell c = unthriftifySimple(column);
        cells.add(c.withUpdatedName(CellNames.simpleDense(CompositeType.build(super_column.name, c.name().toByteBuffer()))));
    }
    return cells;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:ColumnFamilyRecordReader.java


示例5: unthriftifySuperCounter

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private List<Cell> unthriftifySuperCounter(CounterSuperColumn super_column)
{
    List<Cell> cells = new ArrayList<Cell>(super_column.columns.size());
    for (CounterColumn column : super_column.columns)
    {
        Cell c = unthriftifyCounter(column);
        cells.add(c.withUpdatedName(CellNames.simpleDense(CompositeType.build(super_column.name, c.name().toByteBuffer()))));
    }
    return cells;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:ColumnFamilyRecordReader.java


示例6: getNext

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
/** get next row */
public Tuple getNext() throws IOException
{
    try
    {
        // load the next pair
        if (!reader.nextKeyValue())
            return null;

        CfInfo cfInfo = getCfInfo(loadSignature);
        CfDef cfDef = cfInfo.cfDef;
        Row row = reader.getCurrentValue();
        Tuple tuple = TupleFactory.getInstance().newTuple(cfDef.column_metadata.size());
        Iterator<ColumnDef> itera = cfDef.column_metadata.iterator();
        int i = 0;
        while (itera.hasNext())
        {
            ColumnDef cdef = itera.next();
            ByteBuffer columnValue = row.getBytesUnsafe(ByteBufferUtil.string(cdef.name.duplicate()));
            if (columnValue != null)
            {
                Cell cell = new BufferCell(CellNames.simpleDense(cdef.name), columnValue);
                AbstractType<?> validator = getValidatorMap(cfDef).get(cdef.name);
                setTupleValue(tuple, i, cqlColumnToObj(cell, cfDef), validator);
            }
            else
                tuple.set(i, null);
            i++;
        }
        return tuple;
    }
    catch (InterruptedException e)
    {
        throw new IOException(e.getMessage());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:37,代码来源:CqlNativeStorage.java


示例7: toString

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
@Override
public String toString()
{
    StringBuilder sb = new StringBuilder("ColumnFamily(");
    sb.append(metadata.cfName);

    if (isMarkedForDelete())
        sb.append(" -").append(deletionInfo()).append("-");

    sb.append(" [").append(CellNames.getColumnsString(getComparator(), this)).append("])");
    return sb.toString();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:ColumnFamily.java


示例8: getWriteData

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
public List<IMutation> getWriteData()
{
    List<IMutation> rms = new LinkedList<IMutation>();
    Mutation rm = new Mutation(keyspaceName, ByteBufferUtil.bytes("key1"));
    rm.addCounter(cfname, CellNames.simpleDense(ByteBufferUtil.bytes("Column1")), 42);
    rms.add(new CounterMutation(rm, ConsistencyLevel.ONE));
    return rms;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:AntiEntropyServiceCounterTest.java


示例9: createCF

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private ColumnFamily createCF(int nbCol)
{
    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(createMetadata());
    for (int i = 0; i < nbCol; i++)
        cf.addColumn(CellNames.simpleDense(bb(i)), bb(i), 0);
    return cf;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:AbstractQueryPagerTest.java


示例10: test64kColumn

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
@Test
public void test64kColumn()
{
    // a byte buffer more than 64k
    ByteBuffer buffer = ByteBuffer.allocate(1024 * 65);
    buffer.clear();

    //read more than 64k
    for (int i=0; i<1024*64/4 + 1; i++)
        buffer.putInt(0);

    // for read
    buffer.flip();
    Cell cell = new BufferCell(CellNames.simpleDense(ByteBufferUtil.bytes("test")), buffer, 0);

    SecondaryIndexCellSizeTest.MockRowIndex mockRowIndex = new SecondaryIndexCellSizeTest.MockRowIndex();
    SecondaryIndexCellSizeTest.MockColumnIndex mockColumnIndex = new SecondaryIndexCellSizeTest.MockColumnIndex();

    assertTrue(mockRowIndex.validate(cell));
    assertFalse(mockColumnIndex.validate(cell));

    // test less than 64k value
    buffer.flip();
    buffer.clear();
    buffer.putInt(20);
    buffer.flip();

    assertTrue(mockRowIndex.validate(cell));
    assertTrue(mockColumnIndex.validate(cell));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:31,代码来源:SecondaryIndexCellSizeTest.java


示例11: putColsSuper

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private static void putColsSuper(ColumnFamilyStore cfs, DecoratedKey key, ByteBuffer scfName, Cell... cols) throws Throwable
{
    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(cfs.keyspace.getName(), cfs.name);
    for (Cell col : cols)
        cf.addColumn(col.withUpdatedName(CellNames.compositeDense(scfName, col.name().toByteBuffer())));
    Mutation rm = new Mutation(cfs.keyspace.getName(), key.getKey(), cf);
    rm.apply();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:ColumnFamilyStoreTest.java


示例12: testSliceByNamesCommandOnUUIDTypeSCF

import org.apache.cassandra.db.composites.CellNames; //导入依赖的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


示例13: putColsSuper

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
private static void putColsSuper(ColumnFamilyStore cfs, DecoratedKey key, ByteBuffer scfName, Cell... cols) throws Throwable
{
    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(cfs.keyspace.getName(), cfs.name);
    for (Cell col : cols)
        cf.addColumn(col.withUpdatedName(CellNames.compositeDense(scfName, col.name().toByteBuffer())));
    Mutation rm = new Mutation(cfs.keyspace.getName(), key.getKey(), cf);
    rm.applyUnsafe();
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:9,代码来源:ColumnFamilyStoreTest.java


示例14: testSliceByNamesCommandOnUUIDTypeSCF

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
@Test
public void testSliceByNamesCommandOnUUIDTypeSCF() throws Throwable
{
    String keyspaceName = KEYSPACE1;
    String cfName = CF_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:daidong,项目名称:GraphTrek,代码行数:31,代码来源:ColumnFamilyStoreTest.java


示例15: toString

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
@Override
public String toString()
{
    StringBuilder sb = new StringBuilder("ColumnFamily(");
    sb.append(metadata == null ? "<anonymous>" : metadata.cfName);

    if (isMarkedForDelete())
        sb.append(" -").append(deletionInfo()).append("-");

    sb.append(" [").append(CellNames.getColumnsString(getComparator(), this)).append("])");
    return sb.toString();
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:13,代码来源:ColumnFamily.java


示例16: test64kColumn

import org.apache.cassandra.db.composites.CellNames; //导入依赖的package包/类
@Test
public void test64kColumn()
{
    // a byte buffer more than 64k
    ByteBuffer buffer = ByteBuffer.allocate(1024 * 65);
    buffer.clear();

    //read more than 64k
    for (int i=0; i<1024*64/4 + 1; i++)
        buffer.putInt(0);

    // for read
    buffer.flip();
    Cell cell = new Cell(CellNames.simpleDense(ByteBufferUtil.bytes("test")), buffer, 0);

    SecondaryIndexCellSizeTest.MockRowIndex mockRowIndex = new SecondaryIndexCellSizeTest.MockRowIndex();
    SecondaryIndexCellSizeTest.MockColumnIndex mockColumnIndex = new SecondaryIndexCellSizeTest.MockColumnIndex();

    assertTrue(mockRowIndex.validate(cell));
    assertFalse(mockColumnIndex.validate(cell));

    // test less than 64k value
    buffer.flip();
    buffer.clear();
    buffer.putInt(20);
    buffer.flip();

    assertTrue(mockRowIndex.validate(cell));
    assertTrue(mockColumnIndex.validate(cell));
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:31,代码来源:SecondaryIndexCellSizeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap