Skip to content

Commit d93cde5

Browse files
author
Sylvain Lebresne
committed
Initial commit; tentative and incomplete skeleton of an API
0 parents  commit d93cde5

9 files changed

Lines changed: 470 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.datastax.driver.core;
2+
3+
/**
4+
* Authentication information to connect to a Cassandra node.
5+
*
6+
* TODO (and define what this is in particular)
7+
*/
8+
public class AuthInfo {
9+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.datastax.driver.core;
2+
3+
public class BoundStatement {
4+
5+
/**
6+
* Returns the prepared statement on which this BoundStatement is based.
7+
*
8+
* @return the prepared statement on which this BoundStatement is based.
9+
*/
10+
public PreparedStatement preparedStatement() {
11+
return null;
12+
}
13+
14+
/**
15+
* Returns whether all variables have been bound to values in thi
16+
* BoundStatement.
17+
*
18+
* @return whether all variables are bound.
19+
*/
20+
public boolean ready() {
21+
return false;
22+
}
23+
24+
public BoundStatement bind(Object... values) {
25+
return null;
26+
}
27+
28+
public BoundStatement setBool(int i, boolean v) {
29+
return null;
30+
}
31+
32+
public BoundStatement setBool(String name, boolean v) {
33+
return null;
34+
}
35+
36+
public BoundStatement setInt(int i, int v) {
37+
return null;
38+
}
39+
40+
public BoundStatement setInt(String name, int v) {
41+
return null;
42+
}
43+
44+
// ...
45+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.datastax.driver.core;
2+
3+
import java.util.Date;
4+
5+
/**
6+
* A CQL Row returned in a {@link ResultSet}.
7+
*/
8+
public class CQLRow {
9+
10+
/**
11+
* The columns contains in this CQLRow.
12+
*
13+
* @return the columns contained in this CQLRow.
14+
*/
15+
public Columns columns() {
16+
return null;
17+
}
18+
19+
public boolean getBool(int i) {
20+
return false;
21+
}
22+
23+
public boolean getBool(String name) {
24+
return false;
25+
}
26+
27+
public int getInt(int i) {
28+
return 0;
29+
}
30+
31+
public int getInt(String name) {
32+
return 0;
33+
}
34+
35+
public long getLong(int i) {
36+
return 0;
37+
}
38+
39+
public long getLong(String name) {
40+
return 0;
41+
}
42+
43+
public Date getDate(int i) {
44+
return null;
45+
}
46+
47+
public Date getDate(String name) {
48+
return null;
49+
}
50+
51+
// ...
52+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.datastax.driver.core;
2+
3+
/**
4+
* Informations and known state of a Cassandra cluster.
5+
* <p>
6+
* This is the main entry point of the driver. A simple example of access to a
7+
* Cassandra cluster would be:
8+
* <code>
9+
* Cluster cluster = Cluster.Builder().addContactPoint("192.168.0.1").build();
10+
* Session session = cluster.connect("db1");
11+
*
12+
* for (CQLRow row : session.execute("SELECT * FROM table1"))
13+
* // do something ...
14+
* </code>
15+
* <p>
16+
* A cluster object maintains a permanent connection to one of the cluster node
17+
* that it uses solely to maintain informations on the state and current
18+
* topology of the cluster. Using the connection, the driver will discover all
19+
* the nodes composing the cluster as well as new nodes joining the cluster.
20+
* You can disable that connection through the disableStateConnection() method.
21+
* This is however discouraged as it means queries will only ever be executed
22+
* against node set as contact point. If you want to limit the number of nodes
23+
* to which this driver connects to, prefer maxConnectedNode().
24+
*/
25+
public class Cluster {
26+
27+
/**
28+
* Creates a new session on this cluster.
29+
*
30+
* @return a new session on this cluster sets to no keyspace.
31+
*/
32+
public Session connect() {
33+
return null;
34+
}
35+
36+
/**
37+
* Creates a new session on this cluster.
38+
*
39+
* @param authInfo The authorisation credentials to use to connect to
40+
* Cassandra nodes.
41+
* @return a new session on this cluster sets to no keyspace.
42+
*/
43+
public Session connect(AuthInfo authInfo) {
44+
return null;
45+
}
46+
47+
/**
48+
* Creates a new session on this cluster and sets a keyspace to use.
49+
*
50+
* @param keyspaceName The name of the keyspace to use for the created
51+
* <code>Session</code>. This can be later changed using {@link Session#use}.
52+
* @return a new session on this cluster sets to keyspace
53+
* <code>keyspaceName</code>.
54+
*/
55+
public Session connect(String keyspace) {
56+
return null;
57+
}
58+
59+
/**
60+
* Creates a new session on this cluster and sets a keyspace to use.
61+
*
62+
* @param authInfo The authorisation credentials to use to connect to
63+
* Cassandra nodes.
64+
* @return a new session on this cluster sets to keyspace
65+
* <code>keyspaceName</code>.
66+
*/
67+
public Session connect(String keyspace, AuthInfo authInfo) {
68+
return null;
69+
}
70+
71+
public class Builder {
72+
// TODO
73+
}
74+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.datastax.driver.core;
2+
3+
/**
4+
* Metadata describing the columns returned in a {@link ResultSet} or a
5+
* {@link PreparedStatement}.
6+
*/
7+
public class Columns {
8+
9+
/**
10+
* Returns the number of columns described by this <code>Columns</code>
11+
* instance.
12+
*
13+
* @return the number of columns described by this metadata.
14+
*/
15+
public int count() {
16+
return 0;
17+
}
18+
19+
/**
20+
* Returns the name of the <code>i</code>th column in this metadata.
21+
*
22+
* @return the name of the <code>i</code>th column in this metadata.
23+
*/
24+
public String name(int i) {
25+
return null;
26+
}
27+
28+
/**
29+
* Returns the type of the <code>i</code>th column in this metadata.
30+
*
31+
* @return the type of the <code>i</code>th column in this metadata.
32+
*/
33+
public DataType type(int i) {
34+
return null;
35+
}
36+
37+
/**
38+
* Returns the type of column <code>name</code> in this metadata.
39+
*
40+
* @return the type of column <code>name</code> in this metadata.
41+
*/
42+
public DataType type(String name) {
43+
return null;
44+
}
45+
46+
/**
47+
* Returns the keyspace of the <code>i</code>th column in this metadata.
48+
*
49+
* @return the keyspace of the <code>i</code>th column in this metadata.
50+
*/
51+
public String keyspace(int i) {
52+
return null;
53+
}
54+
55+
/**
56+
* Returns the keyspace of column <code>name</code> in this metadata.
57+
*
58+
* @return the keyspace of column <code>name</code> in this metadata.
59+
*/
60+
public String keyspace(String name) {
61+
return null;
62+
}
63+
64+
/**
65+
* Returns the table of the <code>i</code>th column in this metadata.
66+
*
67+
* @return the table of the <code>i</code>th column in this metadata.
68+
*/
69+
public String table(int i) {
70+
return null;
71+
}
72+
73+
/**
74+
* Returns the table of column <code>name</code> in this metadata.
75+
*
76+
* @return the table of column <code>name</code> in this metadata.
77+
*/
78+
public String table(String name) {
79+
return null;
80+
}
81+
82+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.datastax.driver.core;
2+
3+
/**
4+
* Supported data types for columns.
5+
*/
6+
public class DataType {
7+
// TODO
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.datastax.driver.core;
2+
3+
/**
4+
* Represents a prepared statement, a query with bound variables that has been
5+
* prepared (pre-parsed) by the database.
6+
* <p>
7+
* A prepared statement can be executed once concrete values has been provided
8+
* for the bound variables. The pair of a prepared statement and values for its
9+
* bound variables is a BoundStatement and can be executed by
10+
* {@link Session#executePrepared}.
11+
*/
12+
public class PreparedStatement {
13+
14+
public Columns variables() {
15+
return null;
16+
}
17+
18+
public BoundStatement bind(Object... values) {
19+
return null;
20+
}
21+
22+
public BoundStatement newBoundStatement() {
23+
return null;
24+
}
25+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.datastax.driver.core;
2+
3+
import java.util.Iterator;
4+
import java.util.List;
5+
6+
/**
7+
* The result of a query.
8+
*/
9+
public class ResultSet implements Iterable<CQLRow> {
10+
11+
/**
12+
* The columns returned in this ResultSet.
13+
*
14+
* @return the columns returned in this ResultSet.
15+
*/
16+
public Columns columns() {
17+
return null;
18+
}
19+
20+
/**
21+
* Test whether this ResultSet has more results.
22+
*
23+
* @return whether this ResultSet has more results.
24+
*/
25+
public boolean isExhausted() {
26+
return true;
27+
}
28+
29+
/**
30+
* Returns the the next result from this ResultSet.
31+
*
32+
* @return the next row in this resultSet or null if this ResultSet is
33+
* exhausted.
34+
*/
35+
public CQLRow fetchOne() {
36+
return null;
37+
}
38+
39+
/**
40+
* Returns all the remaining rows in this ResultSet as a list.
41+
*
42+
* @return a list containing the remaining results of this ResultSet. The
43+
* returned list is empty if and only the ResultSet is exhausted.
44+
*/
45+
public List<CQLRow> fetchAll() {
46+
return null;
47+
}
48+
49+
/**
50+
* An iterator over the rows contained in this ResultSet.
51+
*
52+
* The {@link Iterator.next iterator next()} method is equivalent to
53+
* calling {@link fetchOne}. So this iterator will consume results from
54+
* this ResultSet and after a full iteration, the ResultSet will be empty.
55+
*
56+
* The returned iterator does not support the {@link Iterato.remove} method.
57+
*
58+
* @return an iterator that will consume and return the remaining rows of
59+
* this ResultSet.
60+
*/
61+
public Iterator<CQLRow> iterator() {
62+
return null;
63+
}
64+
}

0 commit comments

Comments
 (0)