background image
C H A P T E R 1 1
Data Storage and Retrieval
11-12
About Data Storage on Newton Devices
Indexes sort key values in ascending order unless the index spec frame used to
create a particular index specifies descending order.
Begin Keys and End Keys
11
Because index keys are sorted by value, you can improve the speed of an index
query significantly by limiting the range of index key values it tests. One way to do
this is to eliminate from the search any index key values that fall outside specified
minimum or maximum values. For example, you can specify a minimum index key
value used to select the first entry to be tested, causing the query to "skip over" all
lesser-valued index keys. A minimum value used in this way is defined in the query
spec as a
beginKey
value.
Similarly, you can specify a maximum index key value to be used in selecting the
last entry to be tested, causing the query to ignore entries having index keys of
greater value. A maximum value used in this way is defined in the query spec as an
endKey
value.
You can use these optional
beginKey
and
endKey
values together to specify a
subrange of index key values, as shown in Figure 11-3. Note that if an endrange
value is not specified, it is unbounded; for example, if you don't specify an
endKey
value the query result potentially includes all entries through the end of the index.
Figure 11-3
Using
beginKey
and
endKey
values to specify an index subrange
You can also define a special kind of key that is itself excluded from the valid
subrange of index values. These keys are defined as
beginExclKey
and
endExclKey
values in the query spec. Figure 11-4 depicts the use of
beginExclKey
and
endExclKey
values to define the same index subrange
shown in Figure 11-3. Note that you cannot specify both the inclusive and
Ascending key order
Descending key order
beginKey
endKey
subrange of index key values
3 4 5
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна