本文整理匯總了Java中com.datastax.driver.core.Row類的典型用法代碼示例。如果您正苦於以下問題:Java Row類的具體用法?Java Row怎麽用?Java Row使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Row類屬於com.datastax.driver.core包,在下文中一共展示了Row類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queryByOpId
import com.datastax.driver.core.Row; //導入依賴的package包/類
@Override
public List<E> queryByOpId(String opId) throws EventStoreException {
Select select = QueryBuilder.select(CassandraEventRecorder.ENTITY_ID).from(tableName);
select.where(QueryBuilder.eq(CassandraEventRecorder.OP_ID, opId));
List<Row> entityEventDatas = cassandraSession.execute(select, PagingIterable::all);
Map<String, E> resultList = new HashMap<>();
for (Row entityEvent : entityEventDatas) {
String entityId = entityEvent.getString(CassandraEventRecorder.ENTITY_ID);
if (!resultList.containsKey(entityId)) {
E value = queryEntity(entityId);
if (value != null)
resultList.put(entityId, value);
}
}
return new ArrayList<>(resultList.values());
}
示例2: getValueGroupChange
import com.datastax.driver.core.Row; //導入依賴的package包/類
private Set<ValueGroupChange> getValueGroupChange(final Row row) {
final String type = row.getString("vgchangetype");
if (type != null && Type.valueOf(type) != Type.NONE) {
final ValueGroup group =
new ValueGroup(row.getUUID("vgid"), row.getString("vgname"),
row.getList("vgdrivers", String.class),
new DateRange(row.get("vgstart", Instant.class), row.get("vgend", Instant.class)));
final String driver = row.getString("vgdrivername");
if (driver != null && !driver.isEmpty()) {
group.setNewRuleData(driver, row.getList("vgrulecodes", UUID.class));
}
return Collections.singleton(new ValueGroupChange(Type.valueOf(type), group));
}
return Collections.emptySet();
}
示例3: testQueryPrimeSimple
import com.datastax.driver.core.Row; //導入依賴的package包/類
@Test
public void testQueryPrimeSimple() throws Exception {
RequestPrime prime = HttpTestUtil.createSimplePrimedQuery("Select * FROM TABLE2");
HttpTestResponse response = server.prime(prime);
assertNotNull(response);
RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
assertThat(responseQuery).isEqualTo(prime);
String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
ResultSet set = HttpTestUtil.makeNativeQuery("Select * FROM TABLE2", contactPoint);
List<Row> results = set.all();
assertThat(1).isEqualTo(results.size());
Row row1 = results.get(0);
String column1 = row1.getString("column1");
assertThat(column1).isEqualTo("column1");
Long column2 = row1.getLong("column2");
assertThat(column2).isEqualTo(new Long(2));
}
示例4: testBoundStatementPositional
import com.datastax.driver.core.Row; //導入依賴的package包/類
@Test
public void testBoundStatementPositional() throws Exception {
HashMap<String, String> paramTypes = new HashMap<>();
paramTypes.put("c1", "ascii");
HashMap<String, Object> params = new HashMap<>();
params.put("c1", "c1");
RequestPrime prime =
HttpTestUtil.createSimpleParameterizedQuery(
"SELECT table FROM foo WHERE c1=?", params, paramTypes);
HttpTestResponse response = server.prime(prime);
assertNotNull(response);
RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
assertThat(responseQuery).isEqualTo(prime);
String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
ResultSet set =
HttpTestUtil.makeNativeBoundQueryWithPositionalParam(
"SELECT table FROM foo WHERE c1=?", contactPoint, "c1");
List<Row> results = set.all();
assertThat(1).isEqualTo(results.size());
Row row1 = results.get(0);
String column1 = row1.getString("column1");
assertThat(column1).isEqualTo("column1");
Long column2 = row1.getLong("column2");
}
示例5: shouldCreateAddressbook
import com.datastax.driver.core.Row; //導入依賴的package包/類
/**
* Creates and stores a new {@link Addressbook} inside of Cassandra. {@link Contact} classes are converted using the
* custom {@link example.springdata.cassandra.convert.ConverterConfiguration.PersonWriteConverter}.
*/
@Test
public void shouldCreateAddressbook() {
Addressbook addressbook = new Addressbook();
addressbook.setId("private");
addressbook.setMe(new Contact("Walter", "White"));
addressbook.setFriends(Arrays.asList(new Contact("Jesse", "Pinkman"), new Contact("Saul", "Goodman")));
operations.insert(addressbook);
Row row = operations.selectOne(QueryBuilder.select().from("addressbook"), Row.class);
assertThat(row, is(notNullValue()));
assertThat(row.getString("id"), is(equalTo("private")));
assertThat(row.getString("me"), containsString("\"firstname\":\"Walter\""));
assertThat(row.getList("friends", String.class), hasSize(2));
}
示例6: selectProjections
import com.datastax.driver.core.Row; //導入依賴的package包/類
/**
* {@link CassandraTemplate} allows selection of projections on template-level. All basic data types including
* {@link Row} can be selected.
*/
@Test
@SuppressWarnings("unchecked")
public void selectProjections() {
User user = new User();
user.setId(42L);
user.setUsername("heisenberg");
user.setFirstname("Walter");
user.setLastname("White");
template.insert(user);
Long id = template.selectOne(QueryBuilder.select("user_id").from("users"), Long.class);
assertThat(id, is(user.getId()));
Row row = template.selectOne(QueryBuilder.select("user_id").from("users"), Row.class);
assertThat(row.getLong(0), is(user.getId()));
Map<String, Object> map = template.selectOne(QueryBuilder.select().from("users"), Map.class);
assertThat(map, hasEntry("user_id", user.getId()));
assertThat(map, hasEntry("fname", "Walter"));
}
示例7: downloadPackage
import com.datastax.driver.core.Row; //導入依賴的package包/類
@Override
public DataPackage downloadPackage(long packageID) {
DataPackage dataPack = new DataPackage();
try {
Session session;
Cluster cluster;
cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
session = cluster.connect();
Statement statement = QueryBuilder.select()
.all()
.from(DATABASE, MAIN_TABLE)
.where(eq(COL_ID, packageID));
ResultSet results = session.execute(statement);
for(Row row : results) {
dataPack.setId(row.getLong(COL_ID));
dataPack.setDescription(row.getString(COL_DESC));
dataPack.setData(row.getBytes(COL_DATA).array());
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return dataPack;
}
示例8: listPackages
import com.datastax.driver.core.Row; //導入依賴的package包/類
@Override
public List<DataPackage> listPackages() {
List<DataPackage> dataPacks = new ArrayList<>();
try {
Session session;
Cluster cluster;
cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
session = cluster.connect();
Statement statement = QueryBuilder.select()
.all()
.from(DATABASE, MAIN_TABLE);
ResultSet results = session.execute(statement);
for(Row row : results) {
DataPackage dataPack = new DataPackage();
dataPack.setId(row.getLong(COL_ID));
dataPack.setDescription(row.getString(COL_DESC));
dataPacks.add(dataPack);
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return dataPacks;
}
示例9: convertToEntityEvent
import com.datastax.driver.core.Row; //導入依賴的package包/類
static EntityEvent convertToEntityEvent(Row entityEventData) {
EventKey eventKey = new EventKey(entityEventData.getString(CassandraEventRecorder.ENTITY_ID), entityEventData.getInt(CassandraEventRecorder.VERSION));
String opId = entityEventData.getString(CassandraEventRecorder.OP_ID);
String eventData = entityEventData.getString(CassandraEventRecorder.EVENT_DATA);
// ObjectNode jsonNode = (ObjectNode) objectMapper.readTree(eventData);
/* for (String indexedField : indexedFields) {
if (entityEventData.getColumnDefinitions().contains(indexedField))
jsonNode.put(indexedField, entityEventData.getString(indexedField));
}*/
return new EntityEvent(eventKey, opId,
entityEventData.getTimestamp(CassandraEventRecorder.OP_DATE),
entityEventData.getString(CassandraEventRecorder.EVENT_TYPE),
EventState.valueOf(entityEventData.getString(CassandraEventRecorder.STATUS)),
entityEventData.getString(CassandraEventRecorder.AUDIT_INFO),
eventData);
}
示例10: getUserLastGeoCoordinates
import com.datastax.driver.core.Row; //導入依賴的package包/類
/**
* getUserLastGeoCoordinates
* @param userId
* @return user's last geo coordinates and null if it doesn't exist
* @throws Exception
*/
public static GeoCoordinates getUserLastGeoCoordinates (
UUID userId) throws Exception {
ResultSet resultSet =
UsersInfo.i().executeSyncSelectLastLocation(userId);
if (resultSet.isExhausted() == false) {
Row row = resultSet.one();
double latitude =
row.getDouble(UsersInfo.kLastLatitudeColumnName);
double longitude =
row.getDouble(UsersInfo.kLastLongitudeColumnName);
return new GeoCoordinates(latitude, longitude);
} else {
return null;
}
}
示例11: queryTables
import com.datastax.driver.core.Row; //導入依賴的package包/類
/**
* 描述: 查詢數據庫表名[未實現]
* 時間: 2017年11月15日 上午11:29:59
* @author yi.zhang
* @return 返回表
*/
@Deprecated
public List<String> queryTables(){
try {
List<String> tables = new ArrayList<String>();
String useQuery = "describe tables";
ResultSet rs = session.execute(useQuery);
for (Row row : rs.all()) {
String table = row.getString(1);
tables.add(table);
}
return tables;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例12: createResponse
import com.datastax.driver.core.Row; //導入依賴的package包/類
/**
* @desc This method is used for creating response from the resultset i.e return map
* <String,Object> or map<columnName,columnValue>
* @param results ResultSet
* @return Response Response
*/
public static Response createResponse(ResultSet results) {
Response response = new Response();
List<Row> rows = results.all();
Map<String, Object> map = null;
List<Map<String, Object>> responseList = new ArrayList<>();
String str = results.getColumnDefinitions().toString().substring(8,
results.getColumnDefinitions().toString().length() - 1);
String[] keyArray = str.split("\\), ");
for (Row row : rows) {
map = new HashMap<>();
for (int i = 0; i < keyArray.length; i++) {
int pos = keyArray[i].indexOf(Constants.OPEN_BRACE);
String column = instance.getProperty(keyArray[i].substring(0, pos).trim());
map.put(column, row.getObject(column));
}
responseList.add(map);
}
ProjectLogger.log(responseList.toString());
response.put(Constants.RESPONSE, responseList);
return response;
}
示例13: getValueGroupsForRuleSet
import com.datastax.driver.core.Row; //導入依賴的package包/類
private Set<ValueGroup> getValueGroupsForRuleSet(final String ruleSetName) {
return EhSupport.propagateFn(() -> {
final ResultSet resultSet = this.session.execute(CQL_GET_VALUE_GROUPS_FOR_RULESET, ruleSetName);
final Set<ValueGroup> groups = ConcurrentHashMap.newKeySet();
for (final Row row : resultSet) {
final UUID id = row.getUUID(0);
final String name = row.getString(1);
final List<String> drivers = row.getList(2, String.class);
final DateRange range = new DateRange(row.get(3, Instant.class), row.get(4, Instant.class));
final ValueGroup group = new ValueGroup(id, name, drivers, range);
groups.add(group);
}
return groups;
});
}
示例14: getRuleChangeForChange
import com.datastax.driver.core.Row; //導入依賴的package包/類
private Set<RuleChange> getRuleChangeForChange(final Row row) {
final String type = row.getString("rulechangetype");
if (type != null && Type.valueOf(type) != Type.NONE) {
final Builder<RuleBuilder, DecisionTreeRule> ruleBuilder = RuleBuilder.creator()
.with(RuleBuilder::input, row.getList("ruledrivers", String.class))
.with(RuleBuilder::output, row.getList("ruleoutputs", String.class))
.with(RuleBuilder::setId, row.getUUID("ruleid"))
.with(RuleBuilder::setCode, row.getUUID("rulecode"))
.with(RuleBuilder::start, row.get("rulestart", Instant.class))
.with(RuleBuilder::end, row.get("ruleend", Instant.class));
final DecisionTreeRule rule = ruleBuilder.build();
return Collections.singleton(new RuleChange(Type.valueOf(type), rule));
}
return Collections.emptySet();
}
示例15: asyncQuery
import com.datastax.driver.core.Row; //導入依賴的package包/類
public Row asyncQuery() {
openConnection();
try {
session.execute("CREATE TABLE employee (lastname varchar primary key, firstname varchar, age int, city varchar, email varchar)");
session.execute("INSERT INTO employee (lastname, firstname, age, city, email) VALUES ('Smith','Leanne', 30, 'Boston', '[email protected]')");
session.execute("update employee set age = 36 where lastname = 'Smith'");
// Select and show the change
try {
ResultSetFuture results = session.executeAsync("select * from employee where lastname='Smith'");
return results.get().one();
} catch( Throwable exception) {
throw new RuntimeException("could not get executeAsync result for some reason", exception);
}
} finally {
try {
session.execute("DROP TABLE employee");
} catch (Throwable ignore) {
}
closeConnection();
}
}