Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

KeyRange (Google App Engine API for Java)

Class KeyRange

  • java.lang.Object
  • All Implemented Interfaces:, java.lang.Iterable<Key>

    public final class KeyRange
    extends java.lang.Object
    implements java.lang.Iterable<Key>,
    Represents a range of unique datastore identifiers from getStart().getId() to getEnd().getId() inclusive. If an instance of this class is the result of a call to DatastoreService.allocateIds(), the Keys 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 construct Entities with Keys 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 the Iterators returned by iterator() are not.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructor and Description
      KeyRange(Key parent, java.lang.String kind, long start, long end) 
    • Constructor Detail

      • KeyRange

        public KeyRange(Key parent,
                        java.lang.String kind,
                        long start,
                        long end)
    • Method Detail

      • getStart

        public Key getStart()
        The first Key in the range.
      • getEnd

        public Key getEnd()
        The last Key in the range.
      • getSize

        public long getSize()
        The size of the range.
      • iterator

        public java.util.Iterator<Key> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Key>
      • equals

        public boolean equals(java.lang.Object obj)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object