/** * Drops table using cql3. * * @param tableInfo * the table info * @throws Exception * the exception */ private void dropTableUsingCql(TableInfo tableInfo) throws Exception { CQLTranslator translator = new CQLTranslator(); StringBuilder dropQuery = new StringBuilder("drop table "); translator.ensureCase(dropQuery, tableInfo.getTableName(), false); KunderaCoreUtils.printQuery(dropQuery.toString(), showQuery); cassandra_client.execute_cql3_query(ByteBuffer.wrap(dropQuery.toString().getBytes()), Compression.NONE, ConsistencyLevel.ONE); }
cassandra_client.execute_cql3_query( ByteBuffer.wrap(queries.get(embeddableKey).getBytes(Constants.CHARSET_UTF8)), Compression.NONE, ConsistencyLevel.ONE);
@Override public CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { ByteBuffer queryBytes = ByteBuffer.wrap(cqlQuery.toString().getBytes(StandardCharsets.UTF_8)); return executeHandlingExceptions(() -> client.execute_cql3_query(queryBytes, compression, consistency)); }
CQLTranslator translator = new CQLTranslator(); String query = "insert into \"PERSON\" (key,\"PERSON_NAME\",\"AGE\") values ('1','Amry','10' )"; CassandraCli.client.execute_cql3_query(ByteBuffer.wrap(query.getBytes()), Compression.NONE, ConsistencyLevel.ONE);
cassandra_client.execute_cql3_query(ByteBuffer.wrap(replacedWithindexName.getBytes()), Compression.NONE, ConsistencyLevel.ONE);
cassandra_client.execute_cql3_query(ByteBuffer.wrap(addColumnQuery.toString().getBytes()), Compression.NONE, ConsistencyLevel.ONE);
CQLTranslator translator = new CQLTranslator(); String query = "insert into \"PERSON\" (\"personId\",\"PERSON_NAME\",\"AGE\") values ('1','Amry',10 )"; CassandraCli.client.execute_cql3_query(ByteBuffer.wrap(query.getBytes()), Compression.NONE, ConsistencyLevel.ONE); entityManager.refresh(o1);
client.execute_cql3_query(ByteBufferUtil.bytes("create table \"PRIMARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"NAME\" text)"), org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY); client.execute_cql3_query(ByteBufferUtil.bytes("create table \"SECONDARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"AGE\" int)"), org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);
getClient().execute_cql3_query(ByteBuffer.wrap(cqlQuery.getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE);
getClient().execute_cql3_query(ByteBuffer.wrap(cqlQuery.getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE);
client.execute_cql3_query(ByteBufferUtil .bytes("create table \"SECONDARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"AGE\" int)"), org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);
/** * showSchema Alters column type of an existing column. * * @param tableInfo * the table info * @param translator * the translator * @param column * the column * @throws Exception * the exception */ private void alterColumnType(TableInfo tableInfo, CQLTranslator translator, ColumnInfo column) throws Exception { StringBuilder alterColumnTypeQuery = new StringBuilder("ALTER TABLE "); translator.ensureCase(alterColumnTypeQuery, tableInfo.getTableName(), false); alterColumnTypeQuery.append(" ALTER "); translator.ensureCase(alterColumnTypeQuery, column.getColumnName(), false); alterColumnTypeQuery.append(" TYPE " + translator.getCQLType(CassandraValidationClassMapper.getValidationClass(column.getType(), isCql3Enabled(tableInfo)))); cassandra_client.execute_cql3_query(ByteBuffer.wrap(alterColumnTypeQuery.toString().getBytes()), Compression.NONE, ConsistencyLevel.ONE); KunderaCoreUtils.printQuery(alterColumnTypeQuery.toString(), showQuery); }
/** * Execute. * * @param <T> * the generic type * @param query * the query * @param connection * the connection * @return the t */ public <T> T execute(final String query, Object connection) { try { org.apache.cassandra.thrift.Cassandra.Client conn = (org.apache.cassandra.thrift.Cassandra.Client) connection; conn.set_cql_version(CassandraConstants.CQL_VERSION_3_0); KunderaCoreUtils.printQuery(query, showQuery); return (T) conn.execute_cql3_query(ByteBuffer.wrap(query.getBytes(Constants.CHARSET_UTF8)), Compression.NONE, getConsistencyLevel()); } catch (Exception e) { log.error("Error while executing query {}", query); throw new KunderaException(e); } }
/** * CompositeUserDataType * * @throws java.lang.Exception */ @After public void tearDown() throws Exception { try { emf.close(); CassandraCli.client.execute_cql3_query(ByteBuffer.wrap("use \"KunderaExamples\"".getBytes()), Compression.NONE, ConsistencyLevel.ONE); CassandraCli.client.execute_cql3_query(ByteBuffer.wrap("truncate \"CompositeUser\"".getBytes()), Compression.NONE, ConsistencyLevel.ONE); } finally { CassandraCli.dropKeySpace("KunderaExamples"); } }
/** * Sets the up. * * @throws Exception * the exception */ @Before public void setUp() throws Exception { CassandraCli.cassandraSetUp(); CassandraCli.dropKeySpace(schema); String nativeSql = "CREATE KEYSPACE \"" + schema + "\" with replication = {'class':'SimpleStrategy', 'replication_factor':1}"; CassandraCli.getClient().execute_cql3_query(ByteBuffer.wrap(nativeSql.getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE); emf = getEntityManagerFactory(); }
/** * Creates the keyspace. */ private static void createKeyspace() { try { CassandraCli .getClient() .execute_cql3_query( ByteBuffer.wrap("CREATE KEYSPACE \"sparktest\" WITH replication = {'class':'SimpleStrategy','replication_factor':3}" .getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE); } catch (Exception e) { } } }
/** * CompositeUserDataType. * * @throws Exception * the exception */ @After public void tearDown() throws Exception { emf.close(); CassandraCli.client.execute_cql3_query(ByteBuffer.wrap("use \"CompositeCassandra\"".getBytes()), Compression.NONE, ConsistencyLevel.ONE); CassandraCli.client.execute_cql3_query(ByteBuffer.wrap("truncate \"CompositeUser\"".getBytes()), Compression.NONE, ConsistencyLevel.ONE); CassandraCli.dropKeySpace("CompositeCassandra"); }
/** * Sets the up. * * @throws Exception * the exception */ @Before public void setUp() throws Exception { CassandraCli.cassandraSetUp(); CassandraCli.dropKeySpace(schema); String nativeSql = "CREATE KEYSPACE \"" + schema + "\" with replication = {'class':'SimpleStrategy', 'replication_factor':1}"; CassandraCli.getClient().execute_cql3_query(ByteBuffer.wrap(nativeSql.getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE); emf = getEntityManagerFactory(); }
private void createKeyspace() { try { CassandraCli .getClient() .execute_cql3_query( ByteBuffer.wrap("CREATE KEYSPACE \"KunderaExamples\" WITH replication = {'class':'SimpleStrategy','replication_factor':3}" .getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE); } catch (Exception e) { } }
private void createKeyspace() { try { CassandraCli .getClient() .execute_cql3_query( ByteBuffer.wrap("CREATE KEYSPACE \"KunderaExamples\" WITH replication = {'class':'SimpleStrategy','replication_factor':3}" .getBytes("UTF-8")), Compression.NONE, ConsistencyLevel.ONE); } catch (Exception e) { } }