本文整理汇总了Java中org.apache.cassandra.db.marshal.DecimalType类的典型用法代码示例。如果您正苦于以下问题:Java DecimalType类的具体用法?Java DecimalType怎么用?Java DecimalType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DecimalType类属于org.apache.cassandra.db.marshal包,在下文中一共展示了DecimalType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test2Compare
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
@Test
public void test2Compare()
{
ByteBuffer lowBB = DecimalType.instance.decompose(low);
ByteBuffer low2BB = DecimalType.instance.decompose(low);
ByteBuffer highBB = DecimalType.instance.decompose(high);
assertEquals(-1, DecimalType.instance.compare(lowBB, highBB));
lowBB = DecimalType.instance.decompose(low);
highBB = DecimalType.instance.decompose(high);
assertEquals(1, DecimalType.instance.compare(highBB, lowBB));
lowBB = DecimalType.instance.decompose(low);
assertEquals(0, DecimalType.instance.compare(low2BB, lowBB));
lowBB = DecimalType.instance.decompose(low);
assertEquals(-1, DecimalType.instance.compare(ByteBufferUtil.EMPTY_BYTE_BUFFER, lowBB));
lowBB = DecimalType.instance.decompose(low);
assertEquals(1, DecimalType.instance.compare(lowBB,ByteBufferUtil.EMPTY_BYTE_BUFFER));
assertEquals(0, DecimalType.instance.compare(ByteBufferUtil.EMPTY_BYTE_BUFFER,ByteBufferUtil.EMPTY_BYTE_BUFFER));
}
示例2: test3Sort
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
@Test
public void test3Sort()
{
ByteBuffer zeroBB = DecimalType.instance.decompose(zero);
ByteBuffer minusBB = DecimalType.instance.decompose(minus);
ByteBuffer lowBB = DecimalType.instance.decompose(low);
ByteBuffer highBB = DecimalType.instance.decompose(high);
ByteBuffer[] array = {highBB,minusBB,lowBB,lowBB,zeroBB,minusBB};
// Sort the array of ByteBuffer using a DecimalType comparator
Arrays.sort(array, DecimalType.instance);
// Check that the array is in order
for (int i = 1; i < array.length; i++)
{
BigDecimal i0 = DecimalType.instance.compose(array[i - 1]);
BigDecimal i1 = DecimalType.instance.compose(array[i]);
assertTrue("#" + i, i0.compareTo(i1) <= 0);
}
}
示例3: testEmptiableTypes
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的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));
}
}
示例4: testValidatorClassToKind
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
public void testValidatorClassToKind() {
assertEquals(Kind.validatorClassToKind(null), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(TimeUUIDType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(UTF8Type.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(Int32Type.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(BooleanType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(TimestampType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(DecimalType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(LongType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(DoubleType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(FloatType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(InetAddressType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(IntegerType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(UUIDType.class), Kind.NOT_A_COLLECTION);
assertEquals(Kind.validatorClassToKind(SetType.class), Kind.SET);
assertEquals(Kind.validatorClassToKind(ListType.class), Kind.LIST);
assertEquals(Kind.validatorClassToKind(MapType.class), Kind.MAP);
}
示例5: test1Decompose_compose
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
@Test
public void test1Decompose_compose()
{
ByteBuffer bb = DecimalType.instance.decompose(low);
String string = DecimalType.instance.compose(bb).toPlainString();
// check that the decomposed buffer when re-composed is equal to the initial string.
assertEquals(LOW, string);
// check that a null argument yields an empty byte buffer
bb = DecimalType.instance.decompose(null);
assertEquals(bb, ByteBufferUtil.EMPTY_BYTE_BUFFER);
}
示例6: loadColumnFamilyImpl
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
private void loadColumnFamilyImpl(ColumnFamilyDefinition def) {
String comparatorType = def.getComparatorType();
ColumnType type = ColumnType.ANY_EXCEPT_COMPOSITE;
if(formName(UTF8Type.class, BytesType.class).equals(comparatorType)) {
type = ColumnType.COMPOSITE_STRINGPREFIX;
} else if(formName(IntegerType.class, BytesType.class).equals(comparatorType)) {
type = ColumnType.COMPOSITE_INTEGERPREFIX;
} else if(formName(DecimalType.class, BytesType.class).equals(comparatorType)) {
type = ColumnType.COMPOSITE_DECIMALPREFIX;
}
String keyValidationClass = def.getKeyValidationClass();
StorageTypeEnum keyType = null;
if(UTF8Type.class.getName().equals(keyValidationClass)) {
keyType = StorageTypeEnum.STRING;
} else if(DecimalType.class.getName().equals(keyValidationClass)) {
keyType = StorageTypeEnum.DECIMAL;
} else if(IntegerType.class.getName().equals(keyValidationClass)) {
keyType = StorageTypeEnum.INTEGER;
} else if(BytesType.class.getName().equals(keyValidationClass)) {
keyType = StorageTypeEnum.BYTES;
} else
keyType = StorageTypeEnum.BYTES;
String colFamily = def.getName();
Info info = createInfo(colFamily, type, keyType);
String lowerCaseName = colFamily.toLowerCase();
cfNameToCassandra.put(lowerCaseName, info);
}
示例7: BigDecimals
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
public BigDecimals(String name, GeneratorConfig config)
{
super(DecimalType.instance, config, name, BigDecimal.class);
}
示例8: evaluate
import org.apache.cassandra.db.marshal.DecimalType; //导入依赖的package包/类
public BytesWritable evaluate(Text text) {
return new BytesWritable(
DecimalType.instance.decompose(
new BigDecimal(new String(text.getBytes()))).array());
}