Package com.datastax.driver.core

Examples of com.datastax.driver.core.ResultSet


   * @return Value of the counter.
   */
  private long readSchemaIdCounter() {
    // Sanity check that counter value is 1!
    String queryText = String.format("SELECT * FROM %s;", mCounterTable);
    ResultSet resultSet = mAdmin.execute(queryText);
    List<Row> rows = resultSet.all();
    assert(rows.size() == 1);
    Row row = rows.get(0);
    return row.getLong(SCHEMA_COUNTER_COLUMN_VALUE);
  }
View Full Code Here


    // TODO: Obviate this comment by doing all of this in batch.
    // Writes the ID mapping first: if the hash table write fails, we just lost one schema ID.
    // The hash table write must not happen before the ID table write has been persisted.
    // Otherwise, another client may see the hash entry, write cells with the schema ID that cannot
    // be decoded (since the ID mapping has not been written yet).
    final ResultSet resultSet = mAdmin.execute(
        mPreparedStatementWriteIdTable.bind(
            avroEntry.getId(),
            new Date(timestamp),
            ByteBuffer.wrap(entryBytes))
    );
    Preconditions.checkNotNull(resultSet);

    // TODO: Anything here to flush the table or verify that this worked?
    //if (flush) { mSchemaIdTable.flushCommits(); }

    final ResultSet hashResultSet =
        mAdmin.execute(
            mPreparedStatementWriteHashTable.bind(
                ByteBuffer.wrap(avroEntry.getHash().bytes()),
                new Date(timestamp),
                ByteBuffer.wrap(entryBytes))
View Full Code Here

        SCHEMA_COLUMN_VALUE,
        tableName,
        SCHEMA_COLUMN_ID_KEY,
        schemaId,
        SCHEMA_COLUMN_TIME);
    final ResultSet resultSet = mAdmin.execute(queryText);
    final List<Row> rows = resultSet.all();

    if (0 == rows.size()) {
      return null;
    }
View Full Code Here

   * @return Avro schema entry, or null if the schema hash does not exist in the table
   * @throws java.io.IOException on I/O error.
   */
  private SchemaTableEntry loadFromHashTable(BytesKey schemaHash) throws IOException {
    final ByteBuffer tableKey = ByteBuffer.wrap(schemaHash.getBytes());
    final ResultSet resultSet = mAdmin.execute(mPreparedStatementReadHashTable.bind(tableKey));

    final List<Row> rows = resultSet.all();

    if (0 == rows.size()) {
      return null;
    }

View Full Code Here

    admin.execute(updateQuery);

    // TODO: check if below is necessary, or leftover
    // Sanity check that counter value is 1!
    final String selectQuery = String.format("SELECT * FROM %s;", tableName);
    final ResultSet resultSet = admin.execute(selectQuery);
    final List<Row> rows = resultSet.all();
    assert(rows.size() == 1);
    final Row row = rows.get(0);
    final long counterValue = row.getLong(SCHEMA_COUNTER_COLUMN_VALUE);
    assert(0 == counterValue);
  }
View Full Code Here

    final Set<SchemaEntry> entries = new HashSet<SchemaEntry>();
    int hashTableRowCounter = 0;

    // Fetch all of the schemas from the schema hash table (all versions)
    final String queryText = String.format("SELECT * FROM %s;", mSchemaHashTable);
    final ResultSet resultSet = mAdmin.execute(queryText);

    for (Row row : resultSet) {
      hashTableRowCounter += 1;

      // TODO: Not sure how to replicate this check in C*...
 
View Full Code Here

    int idTableRowCounter = 0;
    final Set<SchemaEntry> entries = new HashSet<SchemaEntry>();

    // Fetch all of the schemas from the schema ID table (all versions)
    final String queryText = String.format("SELECT * FROM %s;", mSchemaIdTable);
    final ResultSet resultSet = mAdmin.execute(queryText);

    for (Row row : resultSet) {
      idTableRowCounter += 1;

      // Get the row key, timestamp, and schema for this row.  Use "Unsafe" version of method here
View Full Code Here

    LOG.info(String.format("Creating keyspace %s (if missing) for %s.", keyspace, kijiURI));

    // TODO: Check whether keyspace is > 48 characters long and if so provide Kiji error to user.
    String queryText = "CREATE KEYSPACE IF NOT EXISTS " + keyspace
        + " WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 1}";
    ResultSet resultSet = getSession().execute(queryText);
    LOG.info(resultSet.toString());
    getSession().execute(String.format("USE %s", keyspace));

    // Check that the keyspace actually exists!
    assert(keyspaceExists(keyspace));
View Full Code Here

  public List<String> listTables() throws IOException {
    Preconditions.checkNotNull(mListTablesStatement);


    // Just return a set of in-use tables
    ResultSet resultSet = mAdmin.execute(mListTablesStatement.bind());
    Set<String> keys = new HashSet<String>();

    // This code makes me miss Scala
    for (Row row: resultSet.all()) {
      keys.add(row.getString(QUALIFIER_TABLE));
    }

    List<String> list = new ArrayList<String>();
    list.addAll(keys);
View Full Code Here

  @Override
  public byte[] getValue(String key) throws IOException {
    final State state = mState.get();
    Preconditions.checkState(state == State.OPEN,
        "Cannot get value from SystemTable instance in state %s.", state);
    ResultSet resultSet = mAdmin.execute(mPreparedStatementGetValue.bind(key));

    // Extra the value from the byte buffer, otherwise return this empty buffer
    // TODO: Some additional sanity checks here?
    List<Row> rows = resultSet.all();
    Preconditions.checkArgument(
        rows.size() <= 1, "Expected to get 0 or 1 rows from system table, but got %s.", rows);
    if (rows.size() == 1) {
      Row row = rows.get(0);
      return ByteUtils.toBytes(row.getBytes(VALUE_COLUMN));
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.ResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.