本文整理汇总了Java中com.datastax.driver.core.BoundStatement类的典型用法代码示例。如果您正苦于以下问题:Java BoundStatement类的具体用法?Java BoundStatement怎么用?Java BoundStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoundStatement类属于com.datastax.driver.core包,在下文中一共展示了BoundStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertiesValueById
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
@Override
public Response getPropertiesValueById(String keyspaceName, String tableName, String id,
String... properties) {
long startTime = System.currentTimeMillis();
ProjectLogger.log("Cassandra Service getPropertiesValueById method started at ==" + startTime,
LoggerEnum.PERF_LOG);
Response response = new Response();
try {
String selectQuery = CassandraUtil.getSelectStatement(keyspaceName, tableName, properties);
PreparedStatement statement = connectionManager.getSession(keyspaceName).prepare(selectQuery);
BoundStatement boundStatement = new BoundStatement(statement);
ResultSet results =
connectionManager.getSession(keyspaceName).execute(boundStatement.bind(id));
response = CassandraUtil.createResponse(results);
} catch (Exception e) {
ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + tableName + " : " + e.getMessage(), e);
throw new ProjectCommonException(ResponseCode.SERVER_ERROR.getErrorCode(),
ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
ProjectLogger.log("Cassandra Service getPropertiesValueById method end at ==" + stopTime
+ " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
return response;
}
示例2: getBoundStatementInsert
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementInsert
* @param userid
* @param devicetoken
* @param authcode
* @param accesstoken
* @param refreshtoken
* @param ttl
* @return Insert Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementInsert (
Object userid,
Object devicetoken,
Object authcode,
Object accesstoken,
Object refreshtoken,
Object ttl) throws Exception {
return
this.getQuery(kInsertName).getBoundStatement(
userid,
devicetoken,
authcode,
accesstoken,
refreshtoken,
ttl);
}
示例3: bindKeyValue
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* Binds Ignite cache key and value object to {@link PreparedStatement}.
*
* @param statement statement to which key and value object should be bind.
* @param key key object.
* @param val value object.
* @return statement with bounded key and value.
*/
public BoundStatement bindKeyValue(PreparedStatement statement, Object key, Object val) {
KeyPersistenceSettings keySettings = persistenceSettings.getKeyPersistenceSettings();
Object[] keyValues = getBindingValues(keySettings.getStrategy(),
keySettings.getSerializer(), keySettings.getFields(), key);
ValuePersistenceSettings valSettings = persistenceSettings.getValuePersistenceSettings();
Object[] valValues = getBindingValues(valSettings.getStrategy(),
valSettings.getSerializer(), valSettings.getFields(), val);
Object[] values = new Object[keyValues.length + valValues.length];
int i = 0;
for (Object keyVal : keyValues) {
values[i] = keyVal;
i++;
}
for (Object valVal : valValues) {
values[i] = valVal;
i++;
}
return statement.bind(values);
}
示例4: getBoundStatementInsert
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementInsert
* @param airportcode
* @param latitude
* @param longitude
* @param continent
* @param continentcode
* @param country
* @param countrycode
* @param city
* @param populationinmillions
* @param addedyearmonthday
* @return Insert Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementInsert (
Object airportcode,
Object latitude,
Object longitude,
Object continent,
Object continentcode,
Object country,
Object countrycode,
Object city,
Object populationinmillions,
Object addedyearmonthday) throws Exception {
return
this.getQuery(kInsertName).getBoundStatement(
airportcode,
latitude,
longitude,
continent,
continentcode,
country,
countrycode,
city,
populationinmillions,
addedyearmonthday);
}
示例5: getBoundStatementInsert
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementInsert
* @param email
* @param password
* @param userid
* @return Insert Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementInsert (
Object email,
Object password,
Object userid) throws Exception {
return
this.getQuery(kInsertName).getBoundStatement(
email,
password,
userid);
}
示例6: getBoundStatementSelectTopSmallerThanOrEqualLimit
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementSelectTopSmallerThanOrEqualLimit
* @param yearmonthdaycountrycode
* @param rank
* @return SelectTopSmallerThanOrEqualLimit Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementSelectTopSmallerThanOrEqualLimit (
Object yearmonthdaycountrycode,
Object rank) throws Exception {
return
this.getQuery(kSelectTopSmallerThanOrEqualLimitName).getBoundStatement(
yearmonthdaycountrycode,
rank);
}
示例7: getBoundStatementSelectTopSmallerThanOrEqualLimit
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementSelectTopSmallerThanOrEqualLimit
* @param yearweekgridid
* @param rank
* @return SelectTopSmallerThanOrEqualLimit Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementSelectTopSmallerThanOrEqualLimit (
Object yearweekgridid,
Object rank) throws Exception {
return
this.getQuery(kSelectTopSmallerThanOrEqualLimitName).getBoundStatement(
yearweekgridid,
rank);
}
示例8: getBoundStatementDelete
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementDelete
* @param postid
* @param userid
* @return Delete Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementDelete (
Object postid,
Object userid) throws Exception {
return
this.getQuery(kDeleteName).getBoundStatement(
postid,
userid);
}
示例9: insertMulti
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
@Override
public Status insertMulti(List<TsPoint> points) {
long costTime = 0L;
if (points != null) {
Cluster cluster = null;
try {
// cluster = Cluster.builder().addContactPoint(CASSADRA_URL).build();
// Session session = cluster.connect(KEY_SPACE_NAME);
Session session = SessionManager.getSession();
BatchStatement batch = new BatchStatement();
PreparedStatement ps = session.prepare(
"INSERT INTO " + TABLE_NAME + "(timestamp,device_code,sensor_code,value) VALUES(?,?,?,?)");
for (TsPoint point : points) {
BoundStatement bs = ps.bind(new Date(point.getTimestamp()), point.getDeviceCode(),
point.getSensorCode(), Double.parseDouble(point.getValue().toString()));
batch.add(bs);
}
long startTime = System.nanoTime();
session.execute(batch);
long endTime = System.nanoTime();
costTime = endTime - startTime;
batch.clear();
// session.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cluster != null)
cluster.close();
}
}
// System.out.println("costTime=" + costTime);
return Status.OK(costTime);
}
示例10: getBoundStatementSelectAfter
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementSelectAfter
* @param yearmonthdayhourcontroller
* @param logtime
* @return SelectAfter Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementSelectAfter (
Object yearmonthdayhourcontroller,
Object logtime) throws Exception {
return
this.getQuery(kSelectAfterName).getBoundStatement(
yearmonthdayhourcontroller,
logtime);
}
示例11: request
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* Override to change what data from the statement are parsed into the span representing it. By
* default, this sets the span name to the lower-camel case type name and tags {@link
* CassandraTraceKeys#CASSANDRA_KEYSPACE} and {@link CassandraTraceKeys#CASSANDRA_QUERY} for bound
* statements.
*
* <p>If you only want to change the span name, you can override {@link #spanName(Statement)}
* instead.
*
* @see #spanName(Statement)
*/
public void request(Statement statement, SpanCustomizer customizer) {
customizer.name(spanName(statement));
String keyspace = statement.getKeyspace();
if (keyspace != null) {
customizer.tag(CassandraTraceKeys.CASSANDRA_KEYSPACE, statement.getKeyspace());
}
if (statement instanceof BoundStatement) {
customizer.tag(CassandraTraceKeys.CASSANDRA_QUERY,
((BoundStatement) statement).preparedStatement().getQueryString());
}
}
示例12: getBoundStatementInsert
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementInsert
* @param postid
* @param userid
* @param commenttime
* @return Insert Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementInsert (
Object postid,
Object userid,
Object commenttime) throws Exception {
return
this.getQuery(kInsertName).getBoundStatement(
postid,
userid,
commenttime);
}
示例13: getBoundStatementInsert
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementInsert
* @param messageid
* @param message
* @return Insert Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementInsert (
Object messageid,
Object message) throws Exception {
return
this.getQuery(kInsertName).getBoundStatement(
messageid,
message);
}
示例14: getBoundStatementDelete
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
/**
* getBoundStatementDelete
* @param userid
* @param devicetoken
* @return Delete Query in the form of
* a BoundStatement ready for execution or to be added to
* a BatchStatement
* @throws Exception
*/
public BoundStatement getBoundStatementDelete (
Object userid,
Object devicetoken) throws Exception {
return
this.getQuery(kDeleteName).getBoundStatement(
userid,
devicetoken);
}
示例15: execute
import com.datastax.driver.core.BoundStatement; //导入依赖的package包/类
void execute(Function<Session, BoundStatement> statement) {
try (Cluster cluster = Cluster.builder()
.addContactPointsWithPorts(Collections.singleton(cassandra.contactPoint()))
.build(); Session session = cluster.connect()) {
session.execute(statement.apply(session));
}
}