MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / prepareConcurrentMultiGetTasks

Method prepareConcurrentMultiGetTasks

src/core/MultiGetQuery.java:659–748  ·  view source on GitHub ↗

Compiles the list of TSUIDs and GetRequests to send to execute against storage. Each batch will only have requests for one salt, i.e a batch will not have requests with multiple salts.

()

Source from the content-addressed store, hash-verified

657 * will not have requests with multiple salts.
658 */
659 @VisibleForTesting
660 void prepareConcurrentMultiGetTasks() {
661 multi_get_wait_cnt = 0;
662 prepare_multi_get_start_time = DateTime.currentTimeMillis();
663
664
665 final List<Long> row_base_time_list;
666 if (RollupQuery.isValidQuery(rollup_query)) {
667 row_base_time_list = prepareRowBaseTimesRollup();
668 } else {
669 row_base_time_list = prepareRowBaseTimes();
670 }
671
672 int next_concurrency_index = 0;
673 List<GetRequest> gets_to_prepare = new ArrayList<GetRequest>(batch_size);
674 Set<byte[]> tsuids = new ByteSet();
675
676 final ByteMap<ByteMap<List<GetRequest>>> all_tsuids_gets;
677 if (multiget_no_meta) {
678 // prepare the tagvs combinations and base time list
679
680 final List<byte[][]> tagv_compinations = prepareAllTagvCompounds();
681 all_tsuids_gets = prepareRequestsNoMeta(tagv_compinations, row_base_time_list);
682 } else {
683 all_tsuids_gets = prepareRequests(row_base_time_list, tags);
684
685 }
686 // Iterate over all salts
687 for (final Entry<byte[], ByteMap<List<GetRequest>>> salts_entry : all_tsuids_gets.entrySet()) {
688 if (gets_to_prepare.size() > 0) { // if we have any gets_to_prepare for previous salt, create a
689 // request out of it.
690 final MultiGetTask task = new MultiGetTask(tsuids, gets_to_prepare);
691 final List<MultiGetTask> mulget_task_list =
692 multi_get_tasks.get((next_concurrency_index++) % concurrency_multi_get);
693 mulget_task_list.add(task);
694 ++multi_get_wait_cnt;
695 multi_get_num_get_requests = multi_get_num_get_requests + gets_to_prepare.size();
696 gets_to_prepare = new ArrayList<GetRequest>(batch_size);
697 tsuids = new ByteSet();
698 }
699 byte[] curr_salt = salts_entry.getKey();
700 // Iterate over all tsuid's in curr_salt and add them to gets_to_prepare
701 for (final Entry<byte[], List<GetRequest>> gets_entry : salts_entry.getValue()) {
702 byte[] tsuid = gets_entry.getKey();
703
704 for (GetRequest request : gets_entry.getValue()) {
705 if (gets_to_prepare.size() >= batch_size) { // close batch and create a MultiGetTask
706 final MultiGetTask task = new MultiGetTask(tsuids, gets_to_prepare);
707 final List<MultiGetTask> mulget_task_list =
708 multi_get_tasks.get((next_concurrency_index++) % concurrency_multi_get);
709 mulget_task_list.add(task);
710 ++multi_get_wait_cnt;
711 multi_get_num_get_requests = multi_get_num_get_requests + gets_to_prepare.size();
712 if (LOG.isDebugEnabled()) {
713 LOG.debug("Finished preparing MultiGetRequest with " + gets_to_prepare.size() + " requests for salt " + curr_salt +
714 " for tsuid " + Bytes.pretty(tsuid));
715 }
716 // prepare a new task list and tsuids

Calls 13

currentTimeMillisMethod · 0.95
isValidQueryMethod · 0.95
prepareRowBaseTimesMethod · 0.95
prepareRequestsNoMetaMethod · 0.95
prepareRequestsMethod · 0.95
addMethod · 0.95
sizeMethod · 0.65
getMethod · 0.45
addMethod · 0.45
getKeyMethod · 0.45