Commit 184c51b
authored
Use a new synthetic _id format for time-series datastreams (#137274)
This pull request follows #136810 and introduces a new format for
documents _id fields in time-series datastreams. In order to test this
new format, the TSDB synthetic terms and postings format
implementations are also changed.
The current _id format is composed of a routing hash, the hashed
value of the _tsid and a timestamp. While it is possible to extract the
routing hash and the timestamp from a document _id value, it is
not possible to extract the original _tsid value.
This is an issue for synthetic _id as the document _id value is not
indexed anymore: instead the synthetic _id is computed at runtime
from the value of the routing hash, _tsid and timestamp. Therefore
we need to be able to extract the routing hash/_tsid/timestamp
values from the _id value and vice-versa.
The format for the synthetic _id in this pull request has been changed to be:
_tsid (variable length)
Long.MAX_VALUE - timestamp (unsigned long on 8 bytes encoded using big endian)
routing hash _ts_routing_hash (4 bytes)
Extracting the values from the _id is then used for routing GETs and DELETEs
requests to the appropriate shard or setting the
_tsid/timestamp/_ts_routing_hash fields in tombstone documents.
Note that in searches, the document _id is built using the existing
TsIdLoader (that has been adjusted).
It is also important that the generated _id can be sorted lexicographically,
as Lucene stops applying doc values updates when it seeks to a term that
is greater than the one used in the soft-update. The ordering of the arrays
of bytes representing the _id must match the ordering of documents in
the segment, and to do that the timestamp value is stored in the array
as Long.MAX_VALUE - timestamp. Docs with higher timestamp are then
sorted first.
The SyntheticIdTermsEnum and SyntheticIdPostingsEnum introduced in
#136810 had to be adjusted for the new _id format. We expect their
implementation to be somewhat slow as it requires several lookups to
work. In a different change we'll add a bloom filter on top of these
enumerations to avoid costly lookups.
Relates #1363041 parent 136677b commit 184c51b
File tree
20 files changed
+1033
-275
lines changed- docs/changelog
- modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams
- server/src
- main/java/org/elasticsearch
- cluster
- metadata
- routing
- common/lucene/uid
- index
- codec
- tsdb
- engine
- mapper
- search
- test/java/org/elasticsearch
- common/lucene/uid
- index
- mapper
- shard
20 files changed
+1033
-275
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 259 additions & 68 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
| 709 | + | |
708 | 710 | | |
709 | 711 | | |
710 | 712 | | |
| |||
754 | 756 | | |
755 | 757 | | |
756 | 758 | | |
757 | | - | |
| 759 | + | |
| 760 | + | |
758 | 761 | | |
759 | 762 | | |
760 | 763 | | |
| |||
815 | 818 | | |
816 | 819 | | |
817 | 820 | | |
| 821 | + | |
818 | 822 | | |
819 | 823 | | |
820 | 824 | | |
| |||
870 | 874 | | |
871 | 875 | | |
872 | 876 | | |
873 | | - | |
| 877 | + | |
| 878 | + | |
874 | 879 | | |
875 | 880 | | |
876 | 881 | | |
| |||
933 | 938 | | |
934 | 939 | | |
935 | 940 | | |
936 | | - | |
| 941 | + | |
| 942 | + | |
937 | 943 | | |
938 | 944 | | |
939 | 945 | | |
| |||
1004 | 1010 | | |
1005 | 1011 | | |
1006 | 1012 | | |
1007 | | - | |
| 1013 | + | |
| 1014 | + | |
1008 | 1015 | | |
1009 | 1016 | | |
1010 | 1017 | | |
| |||
1066 | 1073 | | |
1067 | 1074 | | |
1068 | 1075 | | |
1069 | | - | |
| 1076 | + | |
| 1077 | + | |
1070 | 1078 | | |
1071 | 1079 | | |
1072 | 1080 | | |
| |||
1123 | 1131 | | |
1124 | 1132 | | |
1125 | 1133 | | |
1126 | | - | |
| 1134 | + | |
| 1135 | + | |
1127 | 1136 | | |
1128 | 1137 | | |
1129 | 1138 | | |
| |||
1314 | 1323 | | |
1315 | 1324 | | |
1316 | 1325 | | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1317 | 1333 | | |
1318 | 1334 | | |
1319 | 1335 | | |
| |||
2497 | 2513 | | |
2498 | 2514 | | |
2499 | 2515 | | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
2500 | 2526 | | |
2501 | 2527 | | |
2502 | 2528 | | |
| |||
2546 | 2572 | | |
2547 | 2573 | | |
2548 | 2574 | | |
2549 | | - | |
| 2575 | + | |
| 2576 | + | |
2550 | 2577 | | |
2551 | 2578 | | |
2552 | 2579 | | |
| |||
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| 325 | + | |
324 | 326 | | |
325 | 327 | | |
326 | 328 | | |
| |||
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
| 338 | + | |
336 | 339 | | |
337 | 340 | | |
338 | 341 | | |
| |||
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
424 | 436 | | |
425 | 437 | | |
426 | 438 | | |
| |||
510 | 522 | | |
511 | 523 | | |
512 | 524 | | |
513 | | - | |
514 | 525 | | |
515 | 526 | | |
516 | 527 | | |
| |||
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| |||
Lines changed: 38 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
693 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
694 | 706 | | |
695 | 707 | | |
696 | 708 | | |
| |||
983 | 995 | | |
984 | 996 | | |
985 | 997 | | |
986 | | - | |
| 998 | + | |
987 | 999 | | |
988 | 1000 | | |
989 | 1001 | | |
| |||
1170 | 1182 | | |
1171 | 1183 | | |
1172 | 1184 | | |
1173 | | - | |
1174 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1175 | 1207 | | |
1176 | 1208 | | |
1177 | 1209 | | |
| |||
1907 | 1939 | | |
1908 | 1940 | | |
1909 | 1941 | | |
1910 | | - | |
1911 | | - | |
| 1942 | + | |
| 1943 | + | |
1912 | 1944 | | |
1913 | 1945 | | |
1914 | 1946 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
0 commit comments