On Mar 9, 5:13 pm, Robert Kluin <[email protected]> wrote:
> Matt,
>   db.get(key_list) does return entities in the same order as key_list.
>

Perhaps in Python, but not in Java. The following test asserts the
order is independent of the input order, and prints:

[Kind(1), Kind(2)]
[Kind(1), Kind(2)]
class java.util.HashMap
class java.util.HashMap

It is not surprising that the return order is different from the input
order, since the implementation is a HashMap.

public void testBulkGetKeyOrder() throws Exception {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();

        Key k1 = ds.put(new Entity("Kind"));
        Key k2 = ds.put(new Entity("Kind"));

        Map<Key,Entity> map_a = ds.get(Arrays.asList(k1, k2));
        List<Key> keys_a = new ArrayList<Key>(map_a.keySet());

        Map<Key,Entity> map_b = ds.get(Arrays.asList(k2, k1));
        List<Key> keys_b = new ArrayList<Key>(map_b.keySet());

        // expect key order to be the same, no matter what order we requested
it
        assertEquals(keys_a, keys_b);

        System.out.println(keys_a);
        System.out.println(keys_b);

        System.out.println(map_a.getClass());
        System.out.println(map_b.getClass());
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to