本文整理汇总了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());
}
}
示例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();
}
示例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());
}
}
示例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));
}
}
示例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));
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}