Apple Newton Utilities Guide de l'utilisateur Page 472

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 942
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 471
CHAPTER 11
Data Storage and Retrieval
11-40 Using Newton Data Storage Objects
particular slot, the soup must be indexed on that slot. For example, the following
example of a query returns a cursor to all soup entries that have a
name slot. The
cursor sorts the entries according to the value of this slot. As rst returned by the
query, the cursor points to the rst entry in index order.
// mySoup is a valid soup indexed on the 'name slot
nameCursor:= mySoup:Query({indexPath:'name});
You can also use the cursor method GoToKey to go directly to the rst entry
holding a specied name or value in an indexed slot. For examples of the use of
this method, see “Moving the Cursor” beginning on page 11-55.
Using
beginKey and endKey values to limit your search can improve query
performance signicantly. The following example is an index query that uses
a
beginKey value and an endKey value to return entries for which
(11 entry.number 27 ).
// mySoup is indexed on the 'number slot
local numCursor := mySoup:Query({indexPath: 'number,
beginKey: 11,
endKey: 27});
The index on the number slot potentially includes all entries that have a number
slot. The index sorts entries on their index key values; unless otherwise specied,
the default index order is ascending. Thus, the query can use a
beginKey value of
11 to skip over entries holding a value less than 11 in the number slot. The test
can be concluded quickly by specifying a maximum value beyond which the cursor
generated by this query does not proceed. In this case, the
endKey value species
that the query result does not include entries having values greater than
27 in the
number slot. When multiple entries hold a specified endrange value, all of them
are included in the result of a query that species that endrange value; for example,
if multiple entries in the
mySoup soup hold the value 27 in their number slot, the
previous example includes all of these entries in its result.
The
beginKey specication evaluates to a value that occupies a unique position in
the sorted index data for the soup. If no entry is associated with this value, the
cursor is positioned at the next valid entry in index order. For example, if the
mySoup
soup in the previous code fragment does not contain an entry having a
number slot
that holds the value
11, the next valid entry in index order is the rst entry in the
range over which the cursor iterates.
Similarly, the
endKey specication evaluates to a value that occupies a unique
position in the sorted index data for the soup. If no entry is associated with this
value, the cursor stops on the rst valid entry in index order before the
endKey
value. For example, if the
mySoup soup in the previous code fragment does not
contain an entry having a
number slot that holds the value 27, the last valid entry
Vue de la page 471
1 2 ... 467 468 469 470 471 472 473 474 475 476 477 ... 941 942

Commentaires sur ces manuels

Pas de commentaire