Tables now support multiple ranged keys. These work in the same way as single range key lookups work, except that each subsequent range lookup only works on a subset of available rows as determined by what the preceding range key lookup value is.
Table Contents:
RangeKey1 |
RangeKey2 |
Data |
5 |
2010 |
a |
5 |
2015 |
b |
10 |
2020 |
c |
10 |
2025 |
d |
Above we have a simple table that makes use of two range keys. Range keys are applied in the order they are listed in the table definition (top to bottom).
Ranged Table Look-ups:
LookUp |
RangeKey1 |
RangeKey2 |
Result |
1 |
[Up] 5 |
[Up] 2000 |
a |
2 |
[Up] 5 |
[Up] 2016 |
(None) |
3 |
[Down] 15 |
[Up] 2000 |
c |
4 |
[Down] 15 |
[Down] 2015 |
(None) |
5 |
[Down] 15 |
[Down] 2025 |
d |
Above are a few examples of what results are obtained, when different range key values are used.
1.Ranging up on RangeKey1 with a value of 5 filters the available rows for RangeKey2 to the 2 rows that have the value of 5 for RangeKey1. From there, ranging up on RangeKey2 with a value of 2000 yields 2010. Using the keys of 5 and 2010 returns a value of 'a'.
2.Here again we start with range up on RangeKey1 with a value of 5, leaving only the first 2 rows available in the subset. Ranging up on RangeKey2 with a value of 2016 yields no value (despite the fact we have a row that has 2020 as its RangeKey2 value), since the highest value in the row subset from the first range key is 2015, hence this lookup returns no value.
3.Ranging down with 15 on RangeKey1 filters the available rows to the bottom two rows (with RangeKey1 value of 10), ranging up RangeKey2 with the value of 2000 yields 2020 (instead of 2010 because we're no longer considering the two rows with 2010 and 2015). Using the keys 10 and 2020, the lookup returns the value 'c'.
4.Range down with 15 on RangeKey1, then down with 2015 on RangeKey2 yields no result, since the lowest RangeKey2 value from the subset is 2020.
5.Range down with 15 on RangeKey1, then down with 2025 on RangeKey2 - straightforward result of 'd'.