本文整理汇总了Java中org.apache.cassandra.db.marshal.AsciiType类的典型用法代码示例。如果您正苦于以下问题:Java AsciiType类的具体用法?Java AsciiType怎么用?Java AsciiType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsciiType类属于org.apache.cassandra.db.marshal包,在下文中一共展示了AsciiType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newPlacement
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@Override
public Placement newPlacement(String placement) throws ConnectionException {
String[] parsed = PlacementUtil.parsePlacement(placement);
String keyspaceName = parsed[0];
String cfPrefix = parsed[1];
CassandraKeyspace keyspace = _keyspaceMap.get(keyspaceName);
if (keyspace == null) {
throw new UnknownPlacementException(format(
"Placement string refers to unknown or non-local Cassandra keyspace: %s", keyspaceName), placement);
}
KeyspaceDefinition keyspaceDef = keyspace.getAstyanaxKeyspace().describeKeyspace();
ColumnFamily<ByteBuffer,Composite> columnFamily = getColumnFamily(keyspaceDef, cfPrefix, "blob", placement,
new SpecificCompositeSerializer(CompositeType.getInstance(Arrays.<AbstractType<?>>asList(
AsciiType.instance, IntegerType.instance))));
return new BlobPlacement(placement, keyspace, columnFamily);
}
示例2: getByteBuffer
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
/**
* Returns the typed value, serialized to a ByteBuffer.
*
* @return a ByteBuffer of the value.
* @throws InvalidRequestException if unable to coerce the string to its type.
*/
public ByteBuffer getByteBuffer() throws InvalidRequestException
{
switch (type)
{
case STRING:
return AsciiType.instance.fromString(text);
case INTEGER:
return IntegerType.instance.fromString(text);
case UUID:
// we specifically want the Lexical class here, not "UUIDType," because we're supposed to have
// a uuid-shaped string here, and UUIDType also accepts integer or date strings (and turns them into version 1 uuids).
return LexicalUUIDType.instance.fromString(text);
case FLOAT:
return FloatType.instance.fromString(text);
}
// FIXME: handle scenario that should never happen
return null;
}
示例3: testAsciiKeyValidator
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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"));
}
示例4: testEmptyVariableLengthTypes
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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));
}
}
示例5: defineSchema
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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);
}
示例6: defineSchema
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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();
}
示例7: apply
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@Override
public boolean apply(Mutation mutation)
{
for (PartitionUpdate update : mutation.getPartitionUpdates())
{
for (Row row : update)
if (row.clustering().size() > 0 &&
AsciiType.instance.compose(row.clustering().get(0)).startsWith(CELLNAME))
{
for (Cell cell : row.cells())
{
hash = hash(hash, cell.value());
++cells;
}
}
}
return true;
}
示例8: defineSchema
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE,
KeyspaceParams.simple(1),
CFMetaData.Builder.create(KEYSPACE, CF1, true, false, false)
.addPartitionKey("pk", AsciiType.instance)
.addClusteringColumn("ck", AsciiType.instance)
.addRegularColumn("val", AsciiType.instance)
.build(),
CFMetaData.Builder.create(KEYSPACE, CF2, true, false, false)
.addPartitionKey("pk", AsciiType.instance)
.addClusteringColumn("ck", AsciiType.instance)
.addRegularColumn("val", AsciiType.instance)
.build());
}
示例9: defineSchema
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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,
KeyspaceParams.simple(1),
SchemaLoader.denseCFMD(KEYSPACE1, CF_DENSE1)
.compaction(CompactionParams.scts(compactionOptions)),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1)
.compaction(CompactionParams.scts(compactionOptions)),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD4),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER1, AsciiType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER5, AsciiType.instance),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPERGC, AsciiType.instance)
.gcGraceSeconds(0));
}
示例10: defineSchema
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws Exception
{
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3),
CFMetaData.Builder.create(KEYSPACE1, CF_STANDARDCOMPOSITE2)
.addPartitionKey("key", AsciiType.instance)
.addClusteringColumn("name", AsciiType.instance)
.addClusteringColumn("int", IntegerType.instance)
.addRegularColumn("val", AsciiType.instance).build(),
SchemaLoader.counterCFMD(KEYSPACE1, CF_COUNTER1));
}
示例11: testAsciiKeyValidator
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的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"));
}
示例12: init
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
/**
* Initialization. Creates target directory if needed and establishes
* the writer
*
* @throws Exception if a problem occurs
*/
public void init() throws Exception {
File directory = new File(this.directory);
if (!directory.exists()) {
directory.mkdir();
}
try {
//TODO set parameter for null
writer = new SSTableSimpleUnsortedWriter(directory, null, keyspace,
columnFamily, AsciiType.instance, null, bufferSize);
} catch (Throwable t) {
throw new KettleException(
"Failed to create SSTableSimpleUnsortedWriter", t);
}
}
示例13: getByteBuffer
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
/**
* Returns the typed value, serialized to a ByteBuffer.
*
* @return a ByteBuffer of the value.
* @throws InvalidRequestException if unable to coerce the string to its type.
*/
public ByteBuffer getByteBuffer() throws InvalidRequestException
{
switch (type)
{
case STRING:
return AsciiType.instance.fromString(text);
case INTEGER:
return IntegerType.instance.fromString(text);
case UUID:
// we specifically want the Lexical class here, not "UUIDType," because we're supposed to have
// a uuid-shaped string here, and UUIDType also accepts integer or date strings (and turns them into version 1 uuids).
return LexicalUUIDType.instance.fromString(text);
case FLOAT:
return FloatType.instance.fromString(text);
}
// FIXME: handle scenario that should never happen
return null;
}
示例14: testThriftConversion
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@Test
public void testThriftConversion() throws Exception
{
CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
.setComment("Test comment")
.setColumn_metadata(columnDefs)
.setKeyspace(KEYSPACE)
.setName(COLUMN_FAMILY);
// convert Thrift to CFMetaData
CFMetaData cfMetaData = CFMetaData.fromThrift(cfDef);
CfDef thriftCfDef = new CfDef();
thriftCfDef.keyspace = KEYSPACE;
thriftCfDef.name = COLUMN_FAMILY;
thriftCfDef.default_validation_class = cfDef.default_validation_class;
thriftCfDef.comment = cfDef.comment;
thriftCfDef.column_metadata = new ArrayList<ColumnDef>();
for (ColumnDef columnDef : columnDefs)
{
ColumnDef c = new ColumnDef();
c.name = ByteBufferUtil.clone(columnDef.name);
c.validation_class = columnDef.getValidation_class();
c.index_name = columnDef.getIndex_name();
c.index_type = IndexType.KEYS;
thriftCfDef.column_metadata.add(c);
}
CfDef converted = cfMetaData.toThrift();
assertEquals(thriftCfDef.keyspace, converted.keyspace);
assertEquals(thriftCfDef.name, converted.name);
assertEquals(thriftCfDef.default_validation_class, converted.default_validation_class);
assertEquals(thriftCfDef.comment, converted.comment);
assertEquals(new HashSet<>(thriftCfDef.column_metadata), new HashSet<>(converted.column_metadata));
}
示例15: testThriftConversion
import org.apache.cassandra.db.marshal.AsciiType; //导入依赖的package包/类
@Test
public void testThriftConversion() throws Exception
{
CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
.setComment("Test comment")
.setColumn_metadata(columnDefs)
.setKeyspace(KEYSPACE)
.setName(COLUMN_FAMILY);
// convert Thrift to CFMetaData
CFMetaData cfMetaData = CFMetaData.fromThrift(cfDef);
CfDef thriftCfDef = new CfDef();
thriftCfDef.keyspace = KEYSPACE;
thriftCfDef.name = COLUMN_FAMILY;
thriftCfDef.default_validation_class = cfDef.default_validation_class;
thriftCfDef.comment = cfDef.comment;
thriftCfDef.column_metadata = new ArrayList<ColumnDef>();
for (ColumnDef columnDef : columnDefs)
{
ColumnDef c = new ColumnDef();
c.name = ByteBufferUtil.clone(columnDef.name);
c.validation_class = columnDef.getValidation_class();
c.index_name = columnDef.getIndex_name();
c.index_type = IndexType.KEYS;
thriftCfDef.column_metadata.add(c);
}
CfDef converted = cfMetaData.toThrift();
assertEquals(thriftCfDef.keyspace, converted.keyspace);
assertEquals(thriftCfDef.name, converted.name);
assertEquals(thriftCfDef.default_validation_class, converted.default_validation_class);
assertEquals(thriftCfDef.comment, converted.comment);
assertEquals(thriftCfDef.column_metadata, converted.column_metadata);
}