當前位置: 首頁>>代碼示例>>Java>>正文


Java Row.getLong方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.Row.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java Row.getLong方法的具體用法?Java Row.getLong怎麽用?Java Row.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.Row的用法示例。


在下文中一共展示了Row.getLong方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getColValue

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
public Object getColValue(Row row, String colName, DataType colType){	
	switch(colType.getName()){
	case VARCHAR: 
		return row.getString(colName);
	case UUID: 
		return row.getUUID(colName);
	case VARINT: 
		return row.getVarint(colName);
	case BIGINT: 
		return row.getLong(colName);
	case INT: 
		return row.getInt(colName);
	case FLOAT: 
		return row.getFloat(colName);	
	case DOUBLE: 
		return row.getDouble(colName);
	case BOOLEAN: 
		return row.getBool(colName);
	case MAP: 
		return row.getMap(colName, String.class, String.class);
	default: 
		return null;
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:25,代碼來源:MusicDataStore.java

示例2: 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

示例3: 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

示例4: getValue

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
private Object getValue(Row musicRow, String colname) {
	ColumnDefinitions cdef = musicRow.getColumnDefinitions();
	String type = cdef.getType(colname).getName().toString().toUpperCase();
	switch (type) {
	case "BIGINT":
		return musicRow.getLong(colname);
	case "BOOLEAN":
		return musicRow.getBool(colname);
	case "BLOB":
		return musicRow.getBytes(colname);
	case "DOUBLE":
		return musicRow.getDouble(colname);
	case "INT":
		return musicRow.getInt(colname);
	case "TIMESTAMP":
		return musicRow.getTimestamp(colname);
	default:
		logger.error("UNEXPECTED COLUMN TYPE: columname="+colname+", columntype="+type);
		// fall thru
	case "VARCHAR":
		return musicRow.getString(colname);
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:24,代碼來源:CassandraMixin.java

示例5: readRow

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
private Object readRow(final Row row, final String name, final DataType colType) {
		switch (colType.getName()) {
		case BIGINT:
			return row.getLong(name);
		case BOOLEAN:
			return row.getBool(name);
		case DOUBLE:
			return row.getDouble(name);
		case FLOAT:
			return row.getFloat(name);
		case INT:
			return row.getInt(name);
		case MAP:
			return row.getMap(name, String.class, String.class);
		case UUID:
			return row.getUUID(name);
		case TEXT:
		case VARCHAR:
			return row.getString(name);
		case VARINT:
			return row.getVarint(name);
// These are not supported right now....
// ASCII
// BLOB
// COUNTER
// CUSTOM
// DECIMAL
// INET
// LIST
// SET
// TIMESTAMP
// TIMEUUID
// TUPLE
// UDT
		default:
			return null;
		}
	}
 
開發者ID:att,項目名稱:music,代碼行數:39,代碼來源:MusicClient.java

示例6: load

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
@Override
public Data load(Data data, Row row) {
	data.id = row.getUUID(0);
	data.ticket = row.getUUID(1);
	data.user = row.getString(2);
	data.approver = row.getString(3);
	data.type = row.getString(4);
	data.status = row.getString(5);
	data.memo = row.getString(6);
	data.operation = row.getString(7);
	if(row.getColumnDefinitions().size()>8) {
		// Rows reported in MicroSeconds
		data.updated = new Date(row.getLong(8)/1000);
	}
	return data;
}
 
開發者ID:att,項目名稱:AAF,代碼行數:17,代碼來源:ApprovalDAO.java

示例7: marshalRow

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
protected IndexCreatedEvent marshalRow(Row row)
{
    if (row == null)
    {
        return null;
    }
    //look up index here
    Index index = new Index();
    index.setName(row.getString(Columns.INDEX_NAME));
    index.setTable(row.getString(Columns.DATABASE), row.getString(Columns.TABLE));
    Index toUse;
    try
    {
        toUse = indexRepo.read(index.getId());
    } catch (ItemNotFoundException e)//this should only happen in tests that do not have full test data established; errors will be evident if this happens in the actual app
    {
        toUse = index;
    }
    IndexCreatedEvent i = new IndexCreatedEvent(row.getUUID(Columns.ID), row.getDate(Columns.STARTED_AT), row.getDate(Columns.UPDATED_AT), toUse, row.getLong(Columns.TOTAL_RECORDS), row.getLong(Columns.RECORDS_COMPLETED));
    i.setFatalError(row.getString(Columns.FATAL_ERROR));
    i.setErrors(row.getList(Columns.ERRORS, String.class));
    i.calculateValues();
    return i;
}
 
開發者ID:PearsonEducation,項目名稱:Docussandra,代碼行數:25,代碼來源:IndexStatusRepositoryImpl.java

示例8: count

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
/**
 * Count.
 *
 * @param tableName the table name
 * @return the long
 * @throws Exception the exception
 */
public static long count( String tableName ) throws Exception {
	long cnt = -1;
	try {
		String selectCount = String.format("SELECT COUNT(*) FROM %s; ", tableName);
		logger.debug("selectCount={}",selectCount);
		ResultSet rs = execute(selectCount);
		Row row = rs.one();
		if( row != null ) {
			cnt = row.getLong(0);
		}

	} catch( Exception e ) {
		logger.error(e.getLocalizedMessage(), e);
		throw e;
	}
	return cnt;
}
 
開發者ID:petezybrick,項目名稱:iote2e,代碼行數:25,代碼來源:CassandraBaseDao.java

示例9: count

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
/**
 * Count.
 *
 * @param tableName the table name
 * @return the long
 * @throws Exception the exception
 */
public long count( String tableName ) throws Exception {
	long cnt = -1;
	try {
		String selectCount = String.format("SELECT COUNT(*) FROM %s", tableName);
		logger.debug("selectCount={}",selectCount);
		long before = System.currentTimeMillis();
		ResultSet rs = execute(selectCount);
		Row row = rs.one();
		if( row != null ) {
			cnt = row.getLong(0);
		}
		logger.info(">>> elapsed {}",(System.currentTimeMillis()-before));

	} catch( Exception e ) {
		logger.error(e.getLocalizedMessage(), e);
		throw e;
	}
	return cnt;
}
 
開發者ID:petezybrick,項目名稱:iote2e,代碼行數:27,代碼來源:LearnCassandra.java

示例10: testQueryPositionalParamSimple

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
@Test
public void testQueryPositionalParamSimple() 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.makeNativeQueryWithPositionalParams(
          "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");
  // Extra Param
  set =
      HttpTestUtil.makeNativeQueryWithPositionalParams(
          "SELECT table FROM foo WHERE c1=?", contactPoint, "c1", "extraParam");
  assertThat(set.all().size()).isEqualTo(0);
  // Wrong Param
  set =
      HttpTestUtil.makeNativeQueryWithPositionalParams(
          "SELECT table FROM foo WHERE ci1=?", contactPoint, "d1");
  assertThat(set.all().size()).isEqualTo(0);
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:35,代碼來源:HttpPrimeQueryIntegrationTest.java

示例11: testBoundStatementNamed

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
@Test
public void testBoundStatementNamed() throws Exception {
  HashMap<String, String> paramTypes = new HashMap<>();
  paramTypes.put("id", "bigint");
  paramTypes.put("id2", "bigint");
  HashMap<String, Object> params = new HashMap<>();
  params.put("id", new Long(1));
  params.put("id2", new Long(2));
  RequestPrime prime =
      HttpTestUtil.createSimpleParameterizedQuery(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", params, paramTypes);

  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = (RequestPrime) om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);
  Map<String, Long> values = ImmutableMap.<String, Long>of("id", new Long(1), "id2", new Long(2));
  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set =
      HttpTestUtil.makeNativeBoundQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  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));
  Map<String, String> values2 = ImmutableMap.<String, String>of("id", "1", "id2", "2");
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:31,代碼來源:HttpPrimeQueryIntegrationTest.java

示例12: getIdByKey

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
/**
 * Get entity id by entity key.
 *
 * @param key    the entity key
 * @param tenant tenant name
 * @return entity id
 */
public Long getIdByKey(String key, String tenant) {
    Select select = QueryBuilder.select(ENTITY_ID_COL).from(tenant, TABLE_KEY_ID);
    select.where(eq(ENTITY_KEY_COL, key));
    ResultSet resultSet = session.execute(select);
    Row row = resultSet.one();
    return  row == null ? null : row.getLong(ENTITY_ID_COL);
}
 
開發者ID:xm-online,項目名稱:xm-ms-timeline,代碼行數:15,代碼來源:EntityMappingRepository.java

示例13: getLongValue

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
private Long getLongValue(Row row) {
    if (aggregation == Aggregation.MIN || aggregation == Aggregation.MAX
            || aggregation == Aggregation.SUM || aggregation == Aggregation.AVG) {
        return row.getLong(LONG_POS);
    } else {
        return null;
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:9,代碼來源:AggregatePartitionsFunction.java

示例14: convertResultToTsKvEntry

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
private TsKvEntry convertResultToTsKvEntry(String key, Row row) {
    if (row != null) {
        long ts = row.getLong(ModelConstants.TS_COLUMN);
        return new BasicTsKvEntry(ts, toKvEntry(row, key));
    } else {
        return new BasicTsKvEntry(System.currentTimeMillis(), new StringDataEntry(key, null));
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:9,代碼來源:CassandraBaseTimeseriesDao.java

示例15: getTokenRanges

import com.datastax.driver.core.Row; //導入方法依賴的package包/類
/**
 * Gets the list of token ranges that a table occupies on a give Cassandra node.
 *
 * <p>NB: This method is compatible with Cassandra 2.1.5 and greater.
 */
private static List<TokenRange> getTokenRanges(Cluster cluster, String keyspace, String table) {
  try (Session session = cluster.newSession()) {
    ResultSet resultSet =
        session.execute(
            "SELECT range_start, range_end, partitions_count, mean_partition_size FROM "
                + "system.size_estimates WHERE keyspace_name = ? AND table_name = ?",
            keyspace,
            table);

    ArrayList<TokenRange> tokenRanges = new ArrayList<>();
    for (Row row : resultSet) {
      TokenRange tokenRange =
          new TokenRange(
              row.getLong("partitions_count"),
              row.getLong("mean_partition_size"),
              row.getLong("range_start"),
              row.getLong("range_end"));
      tokenRanges.add(tokenRange);
    }
    // The table may not contain the estimates yet
    // or have partitions_count and mean_partition_size fields = 0
    // if the data was just inserted and the amount of data in the table was small.
    // This is very common situation during tests,
    // when we insert a few rows and immediately query them.
    // However, for tiny data sets the lack of size estimates is not a problem at all,
    // because we don't want to split tiny data anyways.
    // Therefore, we're not issuing a warning if the result set was empty
    // or mean_partition_size and partitions_count = 0.
    return tokenRanges;
  }
}
 
開發者ID:apache,項目名稱:beam,代碼行數:37,代碼來源:CassandraServiceImpl.java


注:本文中的com.datastax.driver.core.Row.getLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。