Tabnine Logo
com.datastax.driver.core
Code IndexAdd Tabnine to your IDE (free)

How to use com.datastax.driver.core

Best Java code snippets using com.datastax.driver.core (Showing top 20 results out of 1,728)

origin: apache/flink

/**
 * Opens a Session and executes the query.
 *
 * @param ignored because parameter is not parallelizable.
 * @throws IOException
 */
@Override
public void open(InputSplit ignored) throws IOException {
  this.session = cluster.connect();
  this.resultSet = session.execute(query);
}
origin: prestodb/presto

@Override
public boolean advanceNextPosition()
{
  if (!rs.isExhausted()) {
    currentRow = rs.one();
    count++;
    return true;
  }
  return false;
}
origin: prestodb/presto

  @Override
  public boolean isNull(int i)
  {
    return currentRow.isNull(i);
  }
}
origin: prestodb/presto

@Override
public VersionNumber getCassandraVersion()
{
  ResultSet result = executeWithSession(session -> session.execute("select release_version from system.local"));
  Row versionRow = result.one();
  if (versionRow == null) {
    throw new PrestoException(CASSANDRA_VERSION_ERROR, "The cluster version is not available. " +
        "Please make sure that the Cassandra cluster is up and running, " +
        "and that the contact points are specified correctly.");
  }
  return VersionNumber.parse(versionRow.getString("release_version"));
}
origin: apache/flink

  @Override
  protected Cluster buildCluster(Cluster.Builder builder) {
    return builder.addContactPoint(host).withPort(port).build();
  }
};
origin: prestodb/presto

  public TestHost(InetSocketAddress address)
  {
    super(address, new ConvictionPolicy.DefaultConvictionPolicy.Factory(), Cluster.builder().addContactPoints("localhost").build().manager);
  }
}
origin: prestodb/presto

private void checkSizeEstimatesTableExist()
{
  KeyspaceMetadata keyspaceMetadata = executeWithSession(session -> session.getCluster().getMetadata().getKeyspace(SYSTEM));
  checkState(keyspaceMetadata != null, "system keyspace metadata must not be null");
  TableMetadata table = keyspaceMetadata.getTable(SIZE_ESTIMATES);
  if (table == null) {
    throw new PrestoException(NOT_SUPPORTED, "Cassandra versions prior to 2.1.5 are not supported");
  }
}
origin: prestodb/presto

@Override
public List<String> getCaseSensitiveSchemaNames()
{
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  List<KeyspaceMetadata> keyspaces = executeWithSession(session -> session.getCluster().getMetadata().getKeyspaces());
  for (KeyspaceMetadata meta : keyspaces) {
    builder.add(meta.getName());
  }
  return builder.build();
}
origin: prestodb/presto

@Override
public Set<Host> getReplicas(String caseSensitiveSchemaName, TokenRange tokenRange)
{
  requireNonNull(caseSensitiveSchemaName, "keyspace is null");
  requireNonNull(tokenRange, "tokenRange is null");
  return executeWithSession(session ->
      session.getCluster().getMetadata().getReplicas(validSchemaName(caseSensitiveSchemaName), tokenRange));
}
origin: prestodb/presto

@Override
public Set<TokenRange> getTokenRanges()
{
  return executeWithSession(session -> session.getCluster().getMetadata().getTokenRanges());
}
origin: prestodb/presto

@Override
public String getPartitioner()
{
  return executeWithSession(session -> session.getCluster().getMetadata().getPartitioner());
}
origin: apache/flink

@Override
protected Session createSession() {
  return cluster.connect(keyspace);
}
origin: apache/flink

@Override
public ListenableFuture<ResultSet> send(IN value) {
  Object[] fields = extract(value);
  return session.executeAsync(ps.bind(fields));
}
origin: prestodb/presto

@Override
public synchronized void close()
{
  closed = true;
  if (delegate != null) {
    delegate.close();
    delegate = null;
  }
}
origin: apache/flink

  @Override
  public OUT nextRecord(OUT reuse) throws IOException {
    final Row item = resultSet.one();
    for (int i = 0; i < reuse.getArity(); i++) {
      reuse.setField(item.getObject(i), i);
    }
    return reuse;
  }
}
origin: prestodb/presto

@Override
public boolean getBoolean(int i)
{
  return currentRow.getBool(i);
}
origin: prestodb/presto

  public static Row createSingleStringRow(String value, int protocolVersion)
  {
    ColumnDefinitions definitions = new ColumnDefinitions(new Definition[] {new Definition("keyspace", "table", "column", DataType.ascii())}, CodecRegistry.DEFAULT_INSTANCE);
    ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8));
    return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion), ImmutableList.of(data));
  }
}
origin: apache/flink

@Override
public boolean reachedEnd() throws IOException {
  return resultSet.isExhausted();
}
origin: stackoverflow.com

 // based on the above keyspace, we would change the cluster and session as follows:
Cluster cluster = Cluster.builder()
 .addContactPoints(serverIP)
 .build();
Session session = cluster.connect("myfirstcassandradb");

String cqlStatement = "CREATE TABLE users (" + 
           " user_name varchar PRIMARY KEY," + 
           " password varchar " + 
           ");";

session.execute(cqlStatement);
origin: prestodb/presto

@Override
public Set<Host> getReplicas(String caseSensitiveSchemaName, ByteBuffer partitionKey)
{
  requireNonNull(caseSensitiveSchemaName, "keyspace is null");
  requireNonNull(partitionKey, "partitionKey is null");
  return executeWithSession(session ->
      session.getCluster().getMetadata().getReplicas(validSchemaName(caseSensitiveSchemaName), partitionKey));
}
com.datastax.driver.core

Most used classes

  • Session
    A session holds connections to a Cassandra cluster, allowing it to be queried. Each session maintain
  • Cluster
    Information and known state of a Cassandra cluster. This is the main entry point of the driver. A si
  • Cluster$Builder
    Helper class to build Cluster instances.
  • Row
    A CQL Row returned in a ResultSet. The values of a CQL Row can be retrieved by either index (index s
  • ResultSet
    The result of a query.The retrieval of the rows of a ResultSet is generally paged (a first page of r
  • QueryBuilder,
  • PreparedStatement,
  • KeyspaceMetadata,
  • Select,
  • Insert,
  • BoundStatement,
  • Select$Selection,
  • DataType,
  • BatchStatement,
  • Configuration,
  • Select$Builder,
  • Select$Where,
  • Host,
  • TableMetadata
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now