|
1 | 1 | package com.google.gcloud.datastore; |
2 | 2 |
|
| 3 | +import java.util.Iterator; |
3 | 4 | import java.util.Map; |
4 | 5 |
|
5 | 6 | public interface DatastoreService { |
6 | 7 |
|
7 | | - DatastoreServiceOptions getOptions(); |
| 8 | + interface DatastoreReader { |
| 9 | + |
| 10 | + Map<String, Property<?, ?, ?>> get(Key key); |
| 11 | + |
| 12 | + // return the result in the given order |
| 13 | + Iterator<Map<String, Property<?, ?, ?>>> get(Iterator<Key> key); |
| 14 | + |
| 15 | + // query result item is a tuple of (key, value...) where values may be empty |
| 16 | + //QueryResult runQuery(Query query); |
| 17 | + } |
| 18 | + |
| 19 | + |
| 20 | + interface DatastoreWriter { |
| 21 | + |
| 22 | + Key add(IncompleteKey key, Map<String, Property<?, ?, ?>> values); |
| 23 | + |
| 24 | + void update(Key key , Map<String, Property<?, ?, ?>> values); |
| 25 | + |
| 26 | + Key put(IncompleteKey key, Map<String, Property<?, ?, ?>> values); |
| 27 | + |
| 28 | + void delete(Key key); |
| 29 | + } |
| 30 | + |
| 31 | + |
| 32 | + public interface Transaction extends DatastoreReader, DatastoreWriter { |
| 33 | + |
| 34 | + void commit(); |
8 | 35 |
|
9 | | - CompleteKey put(Key key, Map<String, Property> values); |
| 36 | + void rollback(); |
| 37 | + } |
| 38 | + |
| 39 | + public interface TransactionOptions { |
| 40 | + |
| 41 | + enum IsolationLevel { |
| 42 | + SERIALIZABLE, SNAPSHOT; |
| 43 | + } |
| 44 | + |
| 45 | + IsolationLevel getIsolationLevel(); |
| 46 | + } |
| 47 | + |
| 48 | + public interface Batch extends DatastoreWriter { |
| 49 | + |
| 50 | + @Override |
| 51 | + void add(Key key, Map<String, Property<?, ?, ?>> values); |
| 52 | + |
| 53 | + @Override |
| 54 | + void update(Key key , Map<String, Property<?, ?, ?>> values); |
| 55 | + |
| 56 | + @Override |
| 57 | + void put(Key key, Map<String, Property<?, ?, ?>> values); |
| 58 | + |
| 59 | + void submit(); |
| 60 | + } |
| 61 | + |
| 62 | + public interface BatchOptions { |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + DatastoreServiceOptions getOptions(); |
10 | 67 |
|
11 | | - Map<String, Property> get(CompleteKey key); |
| 68 | + Transaction newTransaction(TransactionOptions tsOptions); |
12 | 69 |
|
13 | | - void delete(CompleteKey... key); |
| 70 | + Batch newBatch(); |
14 | 71 |
|
15 | | - void allocateIds(Key... key); |
| 72 | + P |
16 | 73 |
|
17 | | - // query result item is a tuple of (key, value...) where values may be empty |
18 | | - //QueryResult runQuery(Query query); |
| 74 | + Key allocateId(IncompleteKey key); |
19 | 75 |
|
| 76 | + // results are returned in request order |
| 77 | + Iterator<Key> allocateIds(Iterator<IncompleteKey> key); |
20 | 78 | } |
0 commit comments