Generates a map of TSUIDs to get requests given the tag permutations. If all salts is enabled, each TSUID will have Const.SALT_BUCKETS() number of entries. Otherwise each TSUID will have one row key. @param tagv_compounds The permutations of tag key and value combinations to search for. @param base_
(final List<byte[][]> tagv_compounds,
final List<Long> base_time_list)
| 1099 | * @return A non-null map of TSUIDs to lists of get requests to send to HBase. |
| 1100 | */ |
| 1101 | @VisibleForTesting |
| 1102 | ByteMap<ByteMap<List<GetRequest>>> prepareRequestsNoMeta(final List<byte[][]> tagv_compounds, |
| 1103 | final List<Long> base_time_list) { |
| 1104 | |
| 1105 | final int row_size = (Const.SALT_WIDTH() + tsdb.metrics.width() |
| 1106 | + Const.TIMESTAMP_BYTES |
| 1107 | + (tsdb.tag_names.width() * tags.get(0).size()) |
| 1108 | + (tsdb.tag_values.width() * tags.get(0).size())); |
| 1109 | |
| 1110 | final ByteMap<List<GetRequest>> tsuid_rows = new ByteMap<List<GetRequest>>(); |
| 1111 | for (final byte[][] tagvs : tagv_compounds) { |
| 1112 | // TSUID's don't have salts |
| 1113 | // TODO: we reallly don't have to allocate tsuid's here. |
| 1114 | // we can use the row_key array to fetch the tsuid. |
| 1115 | // This will just double the memory utilization per time series. |
| 1116 | final byte[] tsuid = new byte[tsdb.metrics.width() |
| 1117 | + (tags.get(0).size() * tsdb.tag_names.width()) |
| 1118 | + tags.get(0).size() * tsdb.tag_values.width()]; |
| 1119 | final byte[] row_key = new byte[row_size]; |
| 1120 | |
| 1121 | // metric |
| 1122 | System.arraycopy(metric, 0, row_key, Const.SALT_WIDTH(), tsdb.metrics.width()); |
| 1123 | System.arraycopy(metric, 0, tsuid, 0, tsdb.metrics.width()); |
| 1124 | |
| 1125 | final List<GetRequest> rows = |
| 1126 | new ArrayList<GetRequest>(base_time_list.size()); |
| 1127 | |
| 1128 | // copy tagks and tagvs to the row key |
| 1129 | int tag_index = 0; |
| 1130 | int row_key_copy_offset = Const.SALT_WIDTH() + tsdb.metrics.width() |
| 1131 | + Const.TIMESTAMP_BYTES; |
| 1132 | int tsuid_copy_offset = tsdb.metrics.width(); |
| 1133 | for (Map.Entry<byte[], byte[][]> tag : tags.get(0)) { |
| 1134 | // tagk |
| 1135 | byte[] tagk = tag.getKey(); |
| 1136 | System.arraycopy(tagk, 0, row_key, row_key_copy_offset, tsdb.tag_names.width()); |
| 1137 | System.arraycopy(tagk, 0, tsuid, tsuid_copy_offset, tsdb.tag_names.width()); |
| 1138 | row_key_copy_offset += tsdb.tag_names.width(); |
| 1139 | tsuid_copy_offset += tsdb.tag_names.width(); |
| 1140 | |
| 1141 | // tagv |
| 1142 | System.arraycopy(tagvs[tag_index], 0, row_key, row_key_copy_offset, |
| 1143 | tsdb.tag_values.width()); |
| 1144 | System.arraycopy(tagvs[tag_index], 0, tsuid, tsuid_copy_offset, |
| 1145 | tsdb.tag_values.width()); |
| 1146 | row_key_copy_offset += tsdb.tag_values.width(); |
| 1147 | tsuid_copy_offset += tsdb.tag_values.width(); |
| 1148 | |
| 1149 | // move to the next tag |
| 1150 | ++tag_index; |
| 1151 | } |
| 1152 | |
| 1153 | // iterate for each timestamp, making a copy of the key and tweaking it's |
| 1154 | // timestamp. |
| 1155 | for (final long row_base_time : base_time_list) { |
| 1156 | final byte[] key_copy = Arrays.copyOf(row_key, row_key.length); |
| 1157 | |
| 1158 | // base time |