本文整理汇总了Java中org.apache.cassandra.db.marshal.BytesType类的典型用法代码示例。如果您正苦于以下问题:Java BytesType类的具体用法?Java BytesType怎么用?Java BytesType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BytesType类属于org.apache.cassandra.db.marshal包,在下文中一共展示了BytesType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parsedValue
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的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: makeFromBlobFunction
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
final String name = "blobas" + toType.asCQL3Type();
return new AbstractFunction(name, toType, BytesType.instance)
{
public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException
{
ByteBuffer val = parameters.get(0);
try
{
if (val != null)
toType.validate(val);
return val;
}
catch (MarshalException e)
{
throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
}
}
};
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:BytesConversionFcts.java
示例3: Writer
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
protected Writer(int keysToSave)
{
if (keysToSave >= getKeySet().size())
keys = getKeySet();
else
keys = hotKeySet(keysToSave);
OperationType type;
if (cacheType == CacheService.CacheType.KEY_CACHE)
type = OperationType.KEY_CACHE_SAVE;
else if (cacheType == CacheService.CacheType.ROW_CACHE)
type = OperationType.ROW_CACHE_SAVE;
else if (cacheType == CacheService.CacheType.COUNTER_CACHE)
type = OperationType.COUNTER_CACHE_SAVE;
else
type = OperationType.UNKNOWN;
info = new CompactionInfo(CFMetaData.denseCFMetaData(Keyspace.SYSTEM_KS, cacheType.toString(), BytesType.instance),
type,
0,
keys.size(),
"keys");
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:AutoSavingCache.java
示例4: testAsciiKeyValidator
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@Test
public void testAsciiKeyValidator() throws IOException, ParseException
{
File tempSS = tempSSTableFile("Keyspace1", "AsciiKeys");
ColumnFamily cfamily = ArrayBackedSortedColumns.factory.create("Keyspace1", "AsciiKeys");
SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2, ActiveRepairService.UNREPAIRED_SSTABLE);
// Add a row
cfamily.addColumn(column("column", "value", 1L));
writer.append(Util.dk("key", AsciiType.instance), cfamily);
SSTableReader reader = writer.closeAndOpenReader();
// Export to JSON and verify
File tempJson = File.createTempFile("CFWithAsciiKeys", ".json");
SSTableExport.export(reader,
new PrintStream(tempJson.getPath()),
new String[0],
CFMetaData.sparseCFMetaData("Keyspace1", "AsciiKeys", BytesType.instance));
JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
assertEquals(1, json.size());
JSONObject row = (JSONObject)json.get(0);
// check row key
assertEquals("key", row.get("key"));
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:SSTableExportTest.java
示例5: Writer
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
protected Writer(int keysToSave)
{
if (keysToSave >= getKeySet().size())
keys = getKeySet();
else
keys = hotKeySet(keysToSave);
OperationType type;
if (cacheType == CacheService.CacheType.KEY_CACHE)
type = OperationType.KEY_CACHE_SAVE;
else if (cacheType == CacheService.CacheType.ROW_CACHE)
type = OperationType.ROW_CACHE_SAVE;
else
type = OperationType.UNKNOWN;
info = new CompactionInfo(new CFMetaData(Keyspace.SYSTEM_KS, cacheType.toString(), ColumnFamilyType.Standard, BytesType.instance, null),
type,
0,
keys.size(),
"keys");
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:AutoSavingCache.java
示例6: parsedValue
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的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
示例7: makeFromBlobFunction
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
final String name = "blobas" + toType.asCQL3Type();
return new NativeScalarFunction(name, toType, BytesType.instance)
{
public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
{
ByteBuffer val = parameters.get(0);
try
{
if (val != null)
toType.validate(val);
return val;
}
catch (MarshalException e)
{
throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
}
}
};
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:BytesConversionFcts.java
示例8: forKeyCache
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
public static SerializationHeader forKeyCache(CFMetaData metadata)
{
// We don't save type information in the key cache (we could change
// that but it's easier right now), so instead we simply use BytesType
// for both serialization and deserialization. Note that we also only
// serializer clustering prefixes in the key cache, so only the clusteringTypes
// really matter.
int size = metadata.clusteringColumns().size();
List<AbstractType<?>> clusteringTypes = new ArrayList<>(size);
for (int i = 0; i < size; i++)
clusteringTypes.add(BytesType.instance);
return new SerializationHeader(false,
BytesType.instance,
clusteringTypes,
PartitionColumns.NONE,
EncodingStats.NO_STATS,
Collections.<ByteBuffer, AbstractType<?>>emptyMap());
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:SerializationHeader.java
示例9: testEmptyVariableLengthTypes
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@Test
public void testEmptyVariableLengthTypes()
{
AbstractType<?>[] types = new AbstractType<?>[]{
AsciiType.instance,
BytesType.instance,
UTF8Type.instance,
new UFTestCustomType()
};
for (AbstractType<?> type : types)
{
Assert.assertFalse("type " + type.getClass().getName(),
UDHelper.isNullOrEmpty(type, ByteBufferUtil.EMPTY_BYTE_BUFFER));
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:UDHelperTest.java
示例10: testNonTextComparator
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@Test // test for CASSANDRA-8178
public void testNonTextComparator() throws Throwable
{
ColumnDef column = new ColumnDef();
column.setName(bytes(42))
.setValidation_class(UTF8Type.instance.toString());
CfDef cf = new CfDef("thriftcompat", "JdbcInteger");
cf.setColumn_type("Standard")
.setComparator_type(Int32Type.instance.toString())
.setDefault_validation_class(UTF8Type.instance.toString())
.setKey_validation_class(BytesType.instance.toString())
.setColumn_metadata(Collections.singletonList(column));
SchemaLoader.createKeyspace("thriftcompat", KeyspaceParams.simple(1), ThriftConversion.fromThrift(cf));
// the comparator is IntegerType, and there is a column named 42 with a UTF8Type validation type
execute("INSERT INTO \"thriftcompat\".\"JdbcInteger\" (key, \"42\") VALUES (0x00000001, 'abc')");
execute("UPDATE \"thriftcompat\".\"JdbcInteger\" SET \"42\" = 'abc' WHERE key = 0x00000001");
execute("DELETE \"42\" FROM \"thriftcompat\".\"JdbcInteger\" WHERE key = 0x00000000");
UntypedResultSet results = execute("SELECT key, \"42\" FROM \"thriftcompat\".\"JdbcInteger\"");
assertEquals(1, results.size());
UntypedResultSet.Row row = results.iterator().next();
assertEquals(ByteBufferUtil.bytes(1), row.getBytes("key"));
assertEquals("abc", row.getString("42"));
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:ThriftCompatibilityTest.java
示例11: testComparisonMethod
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@Test
public void testComparisonMethod()
{
ThreadLocalRandom random = ThreadLocalRandom.current();
byte[] commonBytes = new byte[10];
byte[] aBytes = new byte[16];
byte[] bBytes = new byte[16];
for (int i = 0 ; i < 100000 ; i++)
{
int commonLength = random.nextInt(0, 10);
random.nextBytes(commonBytes);
random.nextBytes(aBytes);
random.nextBytes(bBytes);
System.arraycopy(commonBytes, 0, aBytes, 0, commonLength);
System.arraycopy(commonBytes, 0, bBytes, 0, commonLength);
int aLength = random.nextInt(commonLength, 16);
int bLength = random.nextInt(commonLength, 16);
ColumnIdentifier a = new ColumnIdentifier(ByteBuffer.wrap(aBytes, 0, aLength), BytesType.instance);
ColumnIdentifier b = new ColumnIdentifier(ByteBuffer.wrap(bBytes, 0, bLength), BytesType.instance);
Assert.assertEquals("" + i, compareResult(a.compareTo(b)), compareResult(ByteBufferUtil.compareUnsigned(a.bytes, b.bytes)));
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:ColumnIdentifierTest.java
示例12: defineSchema
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
CFMetaData cfMetadata = CFMetaData.Builder.create(KEYSPACE1, CF_STANDARD)
.addPartitionKey("key", BytesType.instance)
.addClusteringColumn("col1", AsciiType.instance)
.addRegularColumn("c1", AsciiType.instance)
.addRegularColumn("c2", AsciiType.instance)
.addRegularColumn("one", AsciiType.instance)
.addRegularColumn("two", AsciiType.instance)
.build();
CFMetaData cfMetaData2 = CFMetaData.Builder.create(KEYSPACE1, CF_COLLECTION)
.addPartitionKey("k", ByteType.instance)
.addRegularColumn("m", MapType.getInstance(IntegerType.instance, IntegerType.instance, true))
.build();
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
cfMetadata, cfMetaData2);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:DataResolverTest.java
示例13: defineSchema
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
new Random().nextBytes(entropy);
DatabaseDescriptor.setCommitLogCompression(new ParameterizedClass("LZ4Compressor", ImmutableMap.of()));
DatabaseDescriptor.setCommitLogSegmentSize(1);
DatabaseDescriptor.setCommitLogSync(CommitLogSync.periodic);
DatabaseDescriptor.setCommitLogSyncPeriod(10 * 1000);
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, STANDARD2, 0, AsciiType.instance, BytesType.instance));
CompactionManager.instance.disableAutoCompaction();
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:CommitLogSegmentManagerTest.java
示例14: makeFromBlobFunction
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
final String name = "blobas" + toType.asCQL3Type();
return new NativeFunction(name, toType, BytesType.instance)
{
public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException
{
ByteBuffer val = parameters.get(0);
try
{
if (val != null)
toType.validate(val);
return val;
}
catch (MarshalException e)
{
throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
}
}
};
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:BytesConversionFcts.java
示例15: defineSchema
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Map<String, String> compactionOptions = new HashMap<>();
compactionOptions.put("tombstone_compaction_interval", "1");
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
SimpleStrategy.class,
KSMetaData.optsWithRF(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1).compactionStrategyOptions(compactionOptions),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD4),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER1, LongType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER5, BytesType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPERGC, BytesType.instance).gcGraceSeconds(0));
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:18,代码来源:CompactionsTest.java
示例16: defineSchema
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
SchemaLoader.prepareServer();
AbstractType<?> compositeMaxMin = CompositeType.getInstance(Arrays.asList(new AbstractType<?>[]{BytesType.instance, IntegerType.instance}));
SchemaLoader.createKeyspace(KEYSPACE1,
SimpleStrategy.class,
KSMetaData.optsWithRF(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARDLONG),
CFMetaData.denseCFMetaData(KEYSPACE1, CF_STANDARDCOMPOSITE2, compositeMaxMin));
SchemaLoader.createKeyspace(KEYSPACE2,
SimpleStrategy.class,
KSMetaData.optsWithRF(1),
SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD3));
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:18,代码来源:KeyspaceTest.java
示例17: testAsciiKeyValidator
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
@Test
public void testAsciiKeyValidator() throws IOException, ParseException
{
File tempSS = tempSSTableFile(KEYSPACE1, "AsciiKeys");
ColumnFamily cfamily = ArrayBackedSortedColumns.factory.create(KEYSPACE1, "AsciiKeys");
SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2, ActiveRepairService.UNREPAIRED_SSTABLE);
// Add a row
cfamily.addColumn(column("column", "value", 1L));
writer.append(Util.dk("key", AsciiType.instance), cfamily);
SSTableReader reader = writer.closeAndOpenReader();
// Export to JSON and verify
File tempJson = File.createTempFile("CFWithAsciiKeys", ".json");
SSTableExport.export(reader,
new PrintStream(tempJson.getPath()),
new String[0],
CFMetaData.sparseCFMetaData(KEYSPACE1, "AsciiKeys", BytesType.instance));
JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
assertEquals(1, json.size());
JSONObject row = (JSONObject)json.get(0);
// check row key
assertEquals("key", row.get("key"));
}
开发者ID:daidong,项目名称:GraphTrek,代码行数:27,代码来源:SSTableExportTest.java
示例18: defineSchema
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的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
示例19: testAddAllInternal
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
private void testAddAllInternal(boolean reversed)
{
ISortedColumns map = ArrayBackedSortedColumns.factory().create(BytesType.instance, reversed);
ISortedColumns map2 = ArrayBackedSortedColumns.factory().create(BytesType.instance, reversed);
int[] values1 = new int[]{ 1, 3, 5, 6 };
int[] values2 = new int[]{ 2, 4, 5, 6 };
for (int i = 0; i < values1.length; ++i)
map.addColumn(new Column(ByteBufferUtil.bytes(values1[reversed ? values1.length - 1 - i : i])), HeapAllocator.instance);
for (int i = 0; i < values2.length; ++i)
map2.addColumn(new Column(ByteBufferUtil.bytes(values2[reversed ? values2.length - 1 - i : i])), HeapAllocator.instance);
map2.addAll(map, HeapAllocator.instance, Functions.<IColumn>identity());
Iterator<IColumn> iter = map2.iterator();
assertEquals("1st column", 1, iter.next().name().getInt(0));
assertEquals("2nd column", 2, iter.next().name().getInt(0));
assertEquals("3rd column", 3, iter.next().name().getInt(0));
assertEquals("4st column", 4, iter.next().name().getInt(0));
assertEquals("5st column", 5, iter.next().name().getInt(0));
assertEquals("6st column", 6, iter.next().name().getInt(0));
}
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:25,代码来源:ArrayBackedSortedColumnsTest.java
示例20: testGetCollectionInternal
import org.apache.cassandra.db.marshal.BytesType; //导入依赖的package包/类
private void testGetCollectionInternal(boolean reversed)
{
ISortedColumns map = ArrayBackedSortedColumns.factory().create(BytesType.instance, reversed);
int[] values = new int[]{ 1, 2, 3, 5, 9 };
List<IColumn> sorted = new ArrayList<IColumn>();
for (int v : values)
sorted.add(new Column(ByteBufferUtil.bytes(v)));
List<IColumn> reverseSorted = new ArrayList<IColumn>(sorted);
Collections.reverse(reverseSorted);
for (int i = 0; i < values.length; ++i)
map.addColumn(new Column(ByteBufferUtil.bytes(values[reversed ? values.length - 1 - i : i])), HeapAllocator.instance);
assertSame(sorted, map.getSortedColumns());
assertSame(reverseSorted, map.getReverseSortedColumns());
}
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:18,代码来源:ArrayBackedSortedColumnsTest.java
注:本文中的org.apache.cassandra.db.marshal.BytesType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论