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


Java CounterColumnType类代码示例

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


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

示例1: parsedValue

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException
{
    if (validator instanceof ReversedType<?>)
        validator = ((ReversedType<?>) validator).baseType;
    try
    {
        // BytesType doesn't want it's input prefixed by '0x'.
        if (type == Type.HEX && validator instanceof BytesType)
            return validator.fromString(text.substring(2));
        if (validator instanceof CounterColumnType)
            return LongType.instance.fromString(text);
        return validator.fromString(text);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:Constants.java

示例2: prepare

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
public Operation prepare(CFDefinition.Name receiver) throws InvalidRequestException
{
    Term v = value.prepare(receiver);

    if (receiver.type instanceof CounterColumnType)
        throw new InvalidRequestException(String.format("Cannot set the value of counter column %s (counters can only be incremented/decremented, not set)", receiver));

    if (!(receiver.type instanceof CollectionType))
        return new Constants.Setter(receiver.kind == CFDefinition.Name.Kind.VALUE_ALIAS ? null : receiver.name, v);

    switch (((CollectionType)receiver.type).kind)
    {
        case LIST:
            return new Lists.Setter(receiver.name, v);
        case SET:
            return new Sets.Setter(receiver.name, v);
        case MAP:
            return new Maps.Setter(receiver.name, v);
    }
    throw new AssertionError();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:Operation.java

示例3: parsedValue

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException
{
    if (validator instanceof ReversedType<?>)
        validator = ((ReversedType<?>) validator).baseType;
    try
    {
        if (type == Type.HEX)
            // Note that validator could be BytesType, but it could also be a custom type, so
            // we hardcode BytesType (rather than using 'validator') in the call below.
            // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring.
            return BytesType.instance.fromString(text.substring(2));

        if (validator instanceof CounterColumnType)
            return LongType.instance.fromString(text);
        return validator.fromString(text);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:Constants.java

示例4: testEmptiableTypes

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@Test
public void testEmptiableTypes()
{
    AbstractType<?>[] types = new AbstractType<?>[]{
                                                   BooleanType.instance,
                                                   CounterColumnType.instance,
                                                   DateType.instance,
                                                   DecimalType.instance,
                                                   DoubleType.instance,
                                                   FloatType.instance,
                                                   InetAddressType.instance,
                                                   Int32Type.instance,
                                                   IntegerType.instance,
                                                   LongType.instance,
                                                   TimestampType.instance,
                                                   TimeUUIDType.instance,
                                                   UUIDType.instance
    };

    for (AbstractType<?> type : types)
    {
        Assert.assertTrue(type.getClass().getSimpleName(), UDHelper.isNullOrEmpty(type, ByteBufferUtil.EMPTY_BYTE_BUFFER));
        Assert.assertTrue("reversed " + type.getClass().getSimpleName(),
                          UDHelper.isNullOrEmpty(ReversedType.getInstance(type), ByteBufferUtil.EMPTY_BYTE_BUFFER));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:UDHelperTest.java

示例5: defineSchema

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws Exception
{
    SchemaLoader.prepareServer();
    StorageService.instance.initServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance).defaultValidator(CounterColumnType.instance),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_STANDARDINT, IntegerType.instance),
                                SchemaLoader.indexCFMD(KEYSPACE1, CF_INDEX, true));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1));
    SchemaLoader.createKeyspace(KEYSPACE_CACHEKEY,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD2),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHEKEY, CF_STANDARD3));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:StreamingTransferTest.java

示例6: prepare

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
public Operation prepare(String keyspace, ColumnDefinition receiver) throws InvalidRequestException
{
    Term v = value.prepare(keyspace, receiver);

    if (receiver.type instanceof CounterColumnType)
        throw new InvalidRequestException(String.format("Cannot set the value of counter column %s (counters can only be incremented/decremented, not set)", receiver));

    if (!(receiver.type instanceof CollectionType))
        return new Constants.Setter(receiver, v);

    switch (((CollectionType)receiver.type).kind)
    {
        case LIST:
            return new Lists.Setter(receiver, v);
        case SET:
            return new Sets.Setter(receiver, v);
        case MAP:
            return new Maps.Setter(receiver, v);
    }
    throw new AssertionError();
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:22,代码来源:Operation.java

示例7: maybeCreateColumnFamily

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
private void maybeCreateColumnFamily(RequiresColumnFamily rcf) {
  try {
    CFMetaData cfMetaData;
    if ( rcf.isCounter() ) {
      cfMetaData = new CFMetaData(rcf.ksName(), rcf.cfName(),
                    ColumnFamilyType.Standard, TypeParser.parse(rcf.comparator()), null)
              .replicateOnWrite(false).defaultValidator(CounterColumnType.instance);
    } else {
      cfMetaData = new CFMetaData(rcf.ksName(), rcf.cfName(),
                    ColumnFamilyType.Standard, TypeParser.parse(rcf.comparator()), null);
    }
    MigrationManager.announceNewColumnFamily(cfMetaData);
  } catch(AlreadyExistsException aee) {
    logger.info("CF already exists for " + rcf.cfName());
    maybeTruncateSafely(rcf);
  } catch (Exception ex) {
    throw new RuntimeException("Could not create CF for: " + rcf.cfName(), ex);
  }
}
 
开发者ID:Netflix,项目名称:staash,代码行数:20,代码来源:CassandraRunner.java

示例8: metadataBuilder

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
public CFMetaData.Builder metadataBuilder()
{
    CFMetaData.Builder builder = CFMetaData.Builder.create(keyspace(), columnFamily(), isDense, isCompound, hasCounters);
    builder.withId(id);
    for (int i = 0; i < keyAliases.size(); i++)
        builder.addPartitionKey(keyAliases.get(i), keyTypes.get(i));
    for (int i = 0; i < columnAliases.size(); i++)
        builder.addClusteringColumn(columnAliases.get(i), clusteringTypes.get(i));

    boolean isStaticCompact = !isDense && !isCompound;
    for (Map.Entry<ColumnIdentifier, AbstractType> entry : columns.entrySet())
    {
        ColumnIdentifier name = entry.getKey();
        // Note that for "static" no-clustering compact storage we use static for the defined columns
        if (staticColumns.contains(name) || isStaticCompact)
            builder.addStaticColumn(name, entry.getValue());
        else
            builder.addRegularColumn(name, entry.getValue());
    }

    boolean isCompactTable = isDense || !isCompound;
    if (isCompactTable)
    {
        CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(builder.usedColumnNames());
        // Compact tables always have a clustering and a single regular value.
        if (isStaticCompact)
        {
            builder.addClusteringColumn(names.defaultClusteringName(), UTF8Type.instance);
            builder.addRegularColumn(names.defaultCompactValueName(), hasCounters ? CounterColumnType.instance : BytesType.instance);
        }
        else if (isDense && !builder.hasRegulars())
        {
            // Even for dense, we might not have our regular column if it wasn't part of the declaration. If
            // that's the case, add it but with a specific EmptyType so we can recognize that case later
            builder.addRegularColumn(names.defaultCompactValueName(), EmptyType.instance);
        }
    }

    return builder;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:41,代码来源:CreateTableStatement.java

示例9: getTopLevelColumns

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

示例10: getTopLevelColumns

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

示例11: getTopLevelColumns

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
public ColumnFamily getTopLevelColumns(boolean copyOnHeap)
{
	//@daidong Most of the time, we run collectAllData() function.
    return filter.filter instanceof NamesQueryFilter
           && cfs.metadata.getDefaultValidator() != CounterColumnType.instance
           ? collectTimeOrderedData(copyOnHeap)
           : collectAllData(copyOnHeap);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:9,代码来源:CollationController.java

示例12: defineSchema

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
                            SimpleStrategy.class,
                            KSMetaData.optsWithRF(1),
                            SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
                            CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance)
                                      .defaultValidator(CounterColumnType.instance));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:12,代码来源:EncodedStreamsTest.java

示例13: defineSchema

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER1, BytesType.instance)
                                          .defaultValidator(CounterColumnType.instance));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:12,代码来源:ColumnFamilyTest.java

示例14: defineSchema

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.loadSchema();
    SchemaLoader.createKeyspace(KEYSPACE,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE, CF),
                                SchemaLoader.standardCFMD(KEYSPACE, CF2),
                                SchemaLoader.standardCFMD(KEYSPACE, CF3),
                                CFMetaData.denseCFMetaData(KEYSPACE, COUNTER_CF, BytesType.instance).defaultValidator(CounterColumnType.instance),
                                SchemaLoader.standardCFMD(KEYSPACE, CF_UUID).keyValidator(UUIDType.instance));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:14,代码来源:ScrubTest.java

示例15: defineSchema

import org.apache.cassandra.db.marshal.CounterColumnType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER1, BytesType.instance).defaultValidator(CounterColumnType.instance));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD3));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:15,代码来源:RecoveryManagerTest.java


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