com.google.appengine.api.datastore
Class KeyRange
- java.lang.Object
-
- com.google.appengine.api.datastore.KeyRange
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Iterable<Key>
public final class KeyRange extends java.lang.Object implements java.lang.Iterable<Key>, java.io.Serializable
Represents a range of unique datastore identifiers fromgetStart().getId()
togetEnd().getId()
inclusive. If an instance of this class is the result of a call toDatastoreService.allocateIds()
, theKeys
returned by this instance have been consumed in the datastore's id-space and are guaranteed never to be reused.
This class can be used to constructEntities
withKeys
that have specific id values without fear of the datastore creating new records with those same ids at a later date. This can be helpful as part of a data migration or large bulk upload where you may need to preserve existing ids and relationships between entities.
This class is threadsafe but theIterators
returned byiterator()
are not.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description KeyRange(Key parent, java.lang.String kind, long start, long end)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
equals(java.lang.Object obj)
Key
getEnd()
long
getSize()
Key
getStart()
int
hashCode()
java.util.Iterator<Key>
iterator()
-
-
-
Constructor Detail
-
KeyRange
public KeyRange(Key parent, java.lang.String kind, long start, long end)
-
-
Method Detail
-
getSize
public long getSize()
- Returns:
- The size of the range.
-
iterator
public java.util.Iterator<Key> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Key>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-