本文整理汇总了Java中org.apache.cassandra.cql3.statements.CreateTableStatement类的典型用法代码示例。如果您正苦于以下问题:Java CreateTableStatement类的具体用法?Java CreateTableStatement怎么用?Java CreateTableStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateTableStatement类属于org.apache.cassandra.cql3.statements包,在下文中一共展示了CreateTableStatement类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testParsingCQLOnCompoundedTable
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
@Test
public void testParsingCQLOnCompoundedTable() {
String cql = "CREATE TABLE keyspace1.compressed_bills (" +
" user text," +
" email text," +
" account_id text static," +
" balance int static," +
" expense_id int," +
" item_id int," +
" amount int," +
" name text," +
" PRIMARY KEY ((user, email), expense_id, item_id))";
ParsedStatement stmt = QueryProcessor.parseStatement(cql);
stmt.properties.properties.addProperty(CFProperties.KEYSPACE_NAME, "keyspace1");
stmt.properties.properties.addProperty(CFProperties.PARTITIONER_CLASS,
"org.apache.cassandra.dht.Murmur3Partitioner");
ParsedStatement.Prepared preparedStmt = stmt.prepare();
CFMetaData cfMetaData = ((CreateTableStatement) preparedStmt.statement).getCFMetaData();
Assert.assertEquals(cfMetaData.ksName, "keyspace1");
Assert.assertEquals(cfMetaData.partitioner, Murmur3Partitioner.instance);
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:27,代码来源:TestReadingSSTable21.java
示例2: parseSchema
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
/**
* Get the meta data (column definitions) for the target table.
*
* @param query The CREATE TABLE statement for the table the Json data should be put into.
* @return The table's meta data
*/
private static CFMetaData parseSchema(String query) {
try {
ClientState state = ClientState.forInternalCalls();
ParsedStatement.Prepared prepared = QueryProcessor.getStatement(query, state);
CQLStatement stmt = prepared.statement;
stmt.validate(state);
if (!stmt.getClass().equals(CreateTableStatement.class)) {
throw new IllegalArgumentException("Invalid query, must be a CREATE TABLE statement");
}
return CreateTableStatement.class.cast(stmt).getCFMetaData();
} catch (RequestValidationException | IllegalArgumentException e) {
throw new RuntimeException(e);
}
}
开发者ID:PubGrade,项目名称:Json2SSTable,代码行数:23,代码来源:Json2SSTable.java
示例3: compile
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
@VisibleForTesting
public static CFMetaData compile(String cql, String keyspace)
{
try
{
CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql);
parsed.prepareKeyspace(keyspace);
CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement;
CFMetaData cfm = newSystemMetadata(keyspace, statement.columnFamily(), "", statement.comparator);
statement.applyPropertiesTo(cfm);
return cfm.rebuild();
}
catch (RequestValidationException e)
{
throw new RuntimeException(e);
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:CFMetaData.java
示例4: initializeCfMetaData
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public static CFMetaData initializeCfMetaData(Configuration configuration) {
final String cql = configuration.get(Aegisthus.Feature.CONF_CQL_SCHEMA);
Preconditions.checkNotNull(cql, "Cannot proceed without CQL definition.");
final CreateTableStatement statement = getCreateTableStatement(cql);
try {
final CFMetaData cfMetaData = statement.getCFMetaData();
cfMetaData.rebuild();
return cfMetaData;
} catch (RequestValidationException e) {
// Cannot proceed if an error occurs
throw new RuntimeException("Error initializing CFMetadata from CQL.", e);
}
}
开发者ID:Netflix,项目名称:aegisthus,代码行数:17,代码来源:CFMetadataUtility.java
示例5: cqlStatement
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public final ParsedStatement cqlStatement() throws RecognitionException {
ParsedStatement stmt = null;
CreateTableStatement.RawStatement st9 =null;
try {
// Parser.g:209:5: (st1= selectStatement |st2= insertStatement |st3= updateStatement |st4= batchStatement |st5= deleteStatement |st6= useStatement |st7= truncateStatement |st8= createKeyspaceStatement |st9= createTableStatement |st10= createIndexStatement |st11= dropKeyspaceStatement |st12= dropTableStatement |st13= dropIndexStatement |st14= alterTableStatement |st15= alterKeyspaceStatement |st16= grantPermissionsStatement |st17= revokePermissionsStatement |st18= listPermissionsStatement |st19= createUserStatement |st20= alterUserStatement |st21= dropUserStatement |st22= listUsersStatement |st23= createTriggerStatement |st24= dropTriggerStatement |st25= createTypeStatement |st26= alterTypeStatement |st27= dropTypeStatement |st28= createFunctionStatement |st29= dropFunctionStatement |st30= createAggregateStatement |st31= dropAggregateStatement |st32= createRoleStatement |st33= alterRoleStatement |st34= dropRoleStatement |st35= listRolesStatement |st36= grantRoleStatement |st37= revokeRoleStatement |st38= createMaterializedViewStatement |st39= dropMaterializedViewStatement |st40= alterMaterializedViewStatement )
int alt1=40;
alt1 = dfa1.predict(input);
switch (alt1) {
case 9 :
// Parser.g:217:7: st9= createTableStatement
{
pushFollow(FOLLOW_createTableStatement_in_cqlStatement285);
st9=createTableStatement();
state._fsp--;
stmt = st9;
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return stmt;
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:35,代码来源:Cql_Parser.java
示例6: compile
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public static CFMetaData compile(String cql, String keyspace, IPartitioner partitioner)
{
CFStatement parsed = (CFStatement) QueryProcessor.parseStatement(cql);
parsed.properties.properties.addProperty(CFProperties.KEYSPACE_NAME, keyspace);
CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement;
return statement.metadataBuilder()
.withId(generateLegacyCfId(keyspace, statement.columnFamily()))
.withPartitioner(partitioner)
.build()
.params(statement.params());
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:14,代码来源:CFMetaData.java
示例7: tableFromCQL
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public static CFMetaData tableFromCQL(InputStream source, UUID cfid) throws IOException {
String schema = CharStreams.toString(new InputStreamReader(source, "UTF-8"));
logger.trace("Loading Schema" + schema);
CFStatement statement = (CFStatement) QueryProcessor.parseStatement(schema);
String keyspace = "";
try {
keyspace = statement.keyspace() == null ? "turtles" : statement.keyspace();
} catch (AssertionError e) { // if -ea added we should provide lots of warnings that things probably wont work
logger.warn("Remove '-ea' JVM option when using sstable-tools library");
keyspace = "turtles";
}
statement.prepareKeyspace(keyspace);
if(Schema.instance.getKSMetaData(keyspace) == null) {
Schema.instance.setKeyspaceMetadata(KeyspaceMetadata.create(keyspace, KeyspaceParams.local(), Tables.none(),
Views.none(), getTypes(), Functions.none()));
}
CFMetaData cfm;
if(cfid != null) {
cfm = ((CreateTableStatement) statement.prepare().statement).metadataBuilder().withId(cfid).build();
KeyspaceMetadata prev = Schema.instance.getKSMetaData(keyspace);
List<CFMetaData> tables = Lists.newArrayList(prev.tablesAndViews());
tables.add(cfm);
Schema.instance.setKeyspaceMetadata(prev.withSwapped(Tables.of(tables)));
Schema.instance.load(cfm);
} else {
cfm = ((CreateTableStatement) statement.prepare().statement).getCFMetaData();
}
return cfm;
}
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:30,代码来源:CassandraUtils.java
示例8: doSchema
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public void doSchema(String command) throws Exception {
String path = command.substring(6).trim().replaceAll("\"", "");
if (path.equalsIgnoreCase("off")) {
System.out.println(DISABLING_SCHEMA);
CassandraUtils.cqlOverride = null;
} else if (Strings.isNullOrEmpty(path)) {
if (!Strings.isNullOrEmpty(CassandraUtils.cqlOverride)) {
System.out.printf(USER_DEFINED_SCHEMA, CassandraUtils.cqlOverride);
} else {
System.out.println(NO_USER_DEFINED_SCHEMA);
}
} else {
File schemaFile = new File(path);
if (!schemaFile.exists()) {
System.err.printf(CANNOT_FIND_FILE, schemaFile.getAbsolutePath());
} else {
String cql = new String(Files.readAllBytes(schemaFile.toPath()));
try {
ParsedStatement statement = QueryProcessor.parseStatement(cql);
if (statement instanceof CreateTableStatement.RawStatement) {
CassandraUtils.cqlOverride = cql;
System.out.printf(IMPORTED_SCHEMA, schemaFile.getAbsolutePath());
} else {
System.err.printf(FAILED_TO_IMPORT_SCHEMA, schemaFile.getAbsoluteFile(), "Wrong type of statement, " + statement.getClass());
}
} catch (SyntaxException se) {
System.err.printf(FAILED_TO_IMPORT_SCHEMA, schemaFile.getAbsoluteFile(), se.getMessage());
}
}
}
}
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:34,代码来源:Cqlsh.java
示例9: compile
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
private static CFMetaData compile(String cql, String keyspace)
{
try
{
CreateTableStatement statement = (CreateTableStatement) QueryProcessor.parseStatement(cql).prepare().statement;
CFMetaData cfm = newSystemMetadata(keyspace, statement.columnFamily(), "", statement.comparator, null);
statement.applyPropertiesTo(cfm);
return cfm.rebuild();
}
catch (RequestValidationException e)
{
throw new RuntimeException(e);
}
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:15,代码来源:CFMetaData.java
示例10: compile
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public static CFMetaData compile(String cql, String keyspace)
{
CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql);
parsed.prepareKeyspace(keyspace);
CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed).prepare(Types.none()).statement;
return statement.metadataBuilder()
.withId(generateLegacyCfId(keyspace, statement.columnFamily()))
.build()
.params(statement.params())
.readRepairChance(0.0)
.dcLocalReadRepairChance(0.0)
.gcGraceSeconds(0)
.memtableFlushPeriod((int) TimeUnit.HOURS.toMillis(1));
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:CFMetaData.java
示例11: getTableMetadata
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
private static CFMetaData getTableMetadata(String schema)
{
CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(schema);
// tables with UDTs are currently not supported by CQLSSTableWrite, so we just use Types.none(), for now
// see CASSANDRA-10624 for more details
CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed).prepare(Types.none()).statement;
statement.validate(ClientState.forInternalCalls());
return statement.getCFMetaData();
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:CQLSSTableWriter.java
示例12: createTableStatement
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public final CreateTableStatement.RawStatement createTableStatement() throws RecognitionException {
CreateTableStatement.RawStatement expr = null;
CFName cf =null;
boolean ifNotExists = false;
try {
// Parser.g:656:5: ( K_CREATE K_COLUMNFAMILY ( K_IF K_NOT K_EXISTS )? cf= columnFamilyName cfamDefinition[expr] )
// Parser.g:656:7: K_CREATE K_COLUMNFAMILY ( K_IF K_NOT K_EXISTS )? cf= columnFamilyName cfamDefinition[expr]
{
match(input,K_CREATE,FOLLOW_K_CREATE_in_createTableStatement3883);
match(input,K_COLUMNFAMILY,FOLLOW_K_COLUMNFAMILY_in_createTableStatement3885);
// Parser.g:656:31: ( K_IF K_NOT K_EXISTS )?
int alt70=2;
int LA70_0 = input.LA(1);
if ( (LA70_0==K_IF) ) {
alt70=1;
}
switch (alt70) {
case 1 :
// Parser.g:656:32: K_IF K_NOT K_EXISTS
{
match(input,K_IF,FOLLOW_K_IF_in_createTableStatement3888);
match(input,K_NOT,FOLLOW_K_NOT_in_createTableStatement3890);
match(input,K_EXISTS,FOLLOW_K_EXISTS_in_createTableStatement3892);
ifNotExists = true;
}
break;
}
pushFollow(FOLLOW_columnFamilyName_in_createTableStatement3907);
cf=columnFamilyName();
state._fsp--;
expr = new CreateTableStatement.RawStatement(cf, ifNotExists);
pushFollow(FOLLOW_cfamDefinition_in_createTableStatement3917);
cfamDefinition(expr);
state._fsp--;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return expr;
}
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:53,代码来源:Cql_Parser.java
示例13: getCFMetaData
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
@SuppressWarnings("serial")
@Override
public CFMetaData getCFMetaData(String keyspace, String cfName) {
Pair<String, String> key = Pair.create(keyspace, cfName);
CFMetaData cfm = cfMetaDatas.get(key);
if (cfm == null) {
KeyspaceMetadata ks = metadata.getKeyspace(keyspace);
TableMetadata cf = ks.getTable(cfName);
CFStatement parsed = (CFStatement) QueryProcessor.parseStatement(cf.asCQLQuery());
org.apache.cassandra.schema.KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace);
CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed)
.prepare(ksm != null ? ksm.types : Types.none()).statement;
statement.validate(ClientState.forInternalCalls());
cfm = statement.getCFMetaData();
final Map<ByteBuffer, DroppedColumn> map = new HashMap<>();
Map<ByteBuffer, DroppedColumn> droppedColumns = map;
try {
ResultSet r = session.execute(SELECT_DROPPED_COLUMNS + " WHERE keyspace_name = '" + keyspace
+ "' AND table_name = '" + cfName + '\'');
for (Row row : r) {
String name = row.getString("column_name");
long droppedTime = row.getTimestamp("dropped_time").getTime();
AbstractType<?> type = parse(keyspace, row.getString("type"),
org.apache.cassandra.schema.Types.none());
droppedColumns.put(UTF8Type.instance.decompose(name),
new CFMetaData.DroppedColumn(name, type, droppedTime * 1000));
}
} catch (DriverException e) {
// ignore. Assume we're asking a v2 schema source.
}
if (!ignoreColumns.isEmpty()) {
droppedColumns = new HashMap<ByteBuffer, DroppedColumn>(droppedColumns) {
@Override
public DroppedColumn get(Object key) {
DroppedColumn c = super.get(key);
if (c == null) {
String name = UTF8Type.instance.compose((ByteBuffer) key);
if (ignoreColumns.contains(name)) {
c = new DroppedColumn(name, BytesType.instance, FBUtilities.timestampMicros());
put((ByteBuffer) key, c);
}
}
return c;
}
};
}
cfm.droppedColumns(droppedColumns);
cfMetaDatas.put(key, cfm);
}
return cfm;
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:55,代码来源:BulkLoader.java
示例14: cfamDefinition
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public void cfamDefinition(CreateTableStatement.RawStatement expr) throws RecognitionException { gParser.cfamDefinition(expr); }
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:2,代码来源:CqlParser.java
示例15: pkDef
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public void pkDef(CreateTableStatement.RawStatement expr) throws RecognitionException { gParser.pkDef(expr); }
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:2,代码来源:CqlParser.java
示例16: cfamColumns
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public void cfamColumns(CreateTableStatement.RawStatement expr) throws RecognitionException { gParser.cfamColumns(expr); }
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:2,代码来源:CqlParser.java
示例17: createTableStatement
import org.apache.cassandra.cql3.statements.CreateTableStatement; //导入依赖的package包/类
public CreateTableStatement.RawStatement createTableStatement() throws RecognitionException { return gParser.createTableStatement(); }
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:2,代码来源:CqlParser.java
注:本文中的org.apache.cassandra.cql3.statements.CreateTableStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论