/** * Execute MultigetSliceQuery with the set of (maxRowCountPerQuery) keys * provided and keep the result in global variable queryResult (List<Rows<K, * N, V>>) * * @param param */ private void runMultigetSliceQuery(final List<K> param) { MultigetSliceQuery<K, N, V> multigetSliceQuery = HFactory .createMultigetSliceQuery(keyspace, keySerializer, nameSerializer, valueSerializer); multigetSliceQuery.setColumnFamily(columnFamily); multigetSliceQuery.setKeys(param); multigetSliceQuery.setRange(start, finish, reversed, maxColumnCount); QueryResult<Rows<K, N, V>> result = multigetSliceQuery.execute(); queryResult.add(result.get()); // Add current query execution time to internal variable // totalExecutionTimeMicro. When parallelism is enabled, this value might not be correct // always due to available system resources and thread implementation totalExecutionTimeMicro.addAndGet(result.getExecutionTimeMicro()); // Add current query execution time to internal variable // totalExecutionTimeNano. When parallelism is enabled, this value might not be correct // always due to available system resources and thread implementation totalExecutionTimeNano.addAndGet(result.getExecutionTimeNano()); //Add host used to the list m_hostsUsed.put(result.getHostUsed().getIp(), result.getHostUsed()); }
@Override public Void call() throws Exception { int rows = 0; rangeSlicesQuery.setColumnFamily(commandArgs.workingColumnFamily); log.debug("Starting SliceCommand"); try { while (rows < commandArgs.getKeysPerThread()) { rows+=commandArgs.batchSize; rangeSlicesQuery.setKeys(String.format("%010d", startKey + rows), ""); rangeSlicesQuery.setRange(null, null, false, commandArgs.columnCount); QueryResult<OrderedRows<String,String,String>> result = rangeSlicesQuery.execute(); LatencyTracker readCount = commandRunner.latencies.get(result.getHostUsed()); readCount.addMicro(result.getExecutionTimeMicro()); rows++; log.info("executed batch of {}. {} of {} complete", new Object[]{commandArgs.batchSize, rows, commandArgs.getKeysPerThread()}); } } catch (Exception e) { log.error("Problem: ", e); } commandRunner.doneSignal.countDown(); log.debug("SliceCommand complete"); return null; }
@Override public Void call() throws Exception { int rows = 0; multigetSliceQuery.setColumnFamily(commandArgs.workingColumnFamily); log.debug("Starting MultigetSliceCommand"); String[] keys = new String[commandArgs.batchSize]; try { while (rows < commandArgs.getKeysPerThread()) { multigetSliceQuery.setRange(null, null, false, commandArgs.columnCount); for (int i = 0; i < commandArgs.batchSize; i++) { keys[i] = String.format("%010d", startKey + rows); rows++; } multigetSliceQuery.setKeys(keys); QueryResult<Rows<String,String,String>> result = multigetSliceQuery.execute(); LatencyTracker readCount = commandRunner.latencies.get(result.getHostUsed()); readCount.addMicro(result.getExecutionTimeMicro()); log.info("executed multiget batch of {}. {} of {} complete", new Object[]{commandArgs.batchSize, rows, commandArgs.getKeysPerThread()}); } } catch (Exception e) { log.error("Problem: ", e); } commandRunner.doneSignal.countDown(); log.debug("MultigetSliceCommand complete"); return null; }
/** * Execute MultigetSliceQuery with the set of (maxRowCountPerQuery) keys * provided and keep the result in global variable queryResult (List<Rows<K, * N, V>>) * * @param param */ private void runMultigetSliceQuery(final List<K> param) { MultigetSliceQuery<K, N, V> multigetSliceQuery = HFactory .createMultigetSliceQuery(keyspace, keySerializer, nameSerializer, valueSerializer); multigetSliceQuery.setColumnFamily(columnFamily); multigetSliceQuery.setKeys(param); multigetSliceQuery.setRange(start, finish, reversed, maxColumnCount); QueryResult<Rows<K, N, V>> result = multigetSliceQuery.execute(); queryResult.add(result.get()); // Add current query execution time to internal variable // totalExecutionTimeMicro. When parallelism is enabled, this value might not be correct // always due to available system resources and thread implementation totalExecutionTimeMicro.addAndGet(result.getExecutionTimeMicro()); // Add current query execution time to internal variable // totalExecutionTimeNano. When parallelism is enabled, this value might not be correct // always due to available system resources and thread implementation totalExecutionTimeNano.addAndGet(result.getExecutionTimeNano()); //Add host used to the list m_hostsUsed.put(result.getHostUsed().getIp(), result.getHostUsed()); }
columnQuery.setColumnFamily("Standard1").setKey("fake_key_0").setName("fake_column_0"); QueryResult<HColumn<String, String>> colResult = columnQuery.execute(); System.out.println("Execution time: " + colResult.getExecutionTimeMicro()); System.out.println("CassandraHost used: " + colResult.getHostUsed()); System.out.println("Query Execute: " + colResult.getQuery());