当前位置: 首页>>代码示例>>Java>>正文


Java Row类代码示例

本文整理汇总了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());
}
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:18,代码来源:CassandraViewQuery.java

示例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();
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:19,代码来源:CassandraLoader.java

示例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));
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:19,代码来源:HttpPrimeQueryIntegrationTest.java

示例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");
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:25,代码来源:HttpPrimeQueryIntegrationTest.java

示例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));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:24,代码来源:ConversionIntegrationTests.java

示例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"));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:27,代码来源:CassandraOperationsIntegrationTests.java

示例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;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:24,代码来源:CassandraManager.java

示例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;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:24,代码来源:CassandraManager.java

示例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);
    }
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:17,代码来源:CassandraViewQuery.java

示例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;
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:28,代码来源:GettersInl.java

示例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;
}
 
开发者ID:dev-share,项目名称:database-transform-tool,代码行数:24,代码来源:CassandraFactory.java

示例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;
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:28,代码来源:CassandraUtil.java

示例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;
    });
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:19,代码来源:CassandraLoader.java

示例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();
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:18,代码来源:CassandraLoader.java

示例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();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:23,代码来源:StatefulTestBean.java


注:本文中的com.datastax.driver.core.Row类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。