Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 55c9e9b

Browse files
committed
Various updates for things renamed in the v2 API.
1 parent 36533b2 commit 55c9e9b

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
`doc/crud.md`) has been migrated to a
3333
[java source file](https://github.com/cloudant/sync-android/blob/2.0.0/doc/CrudSamples.java).
3434

35-
- [NEW] `databaseWithAdvancedAPIs()` getter on `DocumentStore` for specialist advanced use cases.
35+
- [NEW] `advanced()` getter on `DocumentStore` for specialist advanced use cases.
3636
Adds support for creating specific document revisions with history.
3737

3838
- [FIXED] Issue with double encoding of restricted URL characters in credentials when using

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/QueryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class QueryImpl implements Query {
9494
private final SQLDatabaseQueue dbQueue;
9595

9696
/**
97-
* Constructs a new IndexManager which indexes documents in 'datastore'
97+
* Constructs a new {@link Query} which indexes documents in 'datastore'
9898
* @param database The {@link Database} to index
9999
*/
100100
public QueryImpl(Database database, File extensionsLocation, KeyProvider keyProvider) throws IOException, SQLException {

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/documentstore/DatabaseNotificationsMoreTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public void notification_databaseOpenCloseAndThenOpenedAgain_databaseCreatedEven
117117
Assert.assertThat(documentStoreClosed.get(0).dbName, endsWith("test123"));
118118

119119
// After database is closed, when it is opened, the
120-
// DatabaseOpened event should be fired, but the
121-
// DatabaseCreated event should NOT be fired.
120+
// DocumentStoreOpened event should be fired, but the
121+
// DocumentStoreCreated event should NOT be fired.
122122
this.clearAllEventList();
123123
DocumentStore ds1 = DocumentStore.getInstance(new File(datastoreManagerDir, "test123"));
124124
try {

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/query/IndexUpdaterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ public void indexUpdatesPersistFromCreation() throws Exception {
10761076
im.close();
10771077
}
10781078

1079-
// Get a new IndexManager instance and extract its queue
1079+
// Get a new Query instance and extract its queue
10801080
im = new QueryImpl(ds, new File(ds.getPath(), "extensions"), new NullKeyProvider());
10811081
indexManagerDatabaseQueue = TestUtils.getDBQueue(im);
10821082

@@ -1117,7 +1117,7 @@ public void indexUpdatesPersistExistingIndex() throws Exception {
11171117
im.close();
11181118
}
11191119

1120-
// Get a new IndexManager instance and extract its queue
1120+
// Get a new Query instance and extract its queue
11211121
im = new QueryImpl(ds, new File(ds.getPath(), "extensions"), new NullKeyProvider());
11221122
indexManagerDatabaseQueue = TestUtils.getDBQueue(im);
11231123

@@ -1140,7 +1140,7 @@ public void indexUpdatesPersistExistingIndex() throws Exception {
11401140
im.close();
11411141
}
11421142

1143-
// Get a new IndexManager instance and extract its queue
1143+
// Get a new Query instance and extract its queue
11441144
im = new QueryImpl(ds, new File(ds.getPath(), "extensions"), new NullKeyProvider());
11451145
indexManagerDatabaseQueue = TestUtils.getDBQueue(im);
11461146
// Check that the updates are still there

doc/conflicts.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MVCC data-model is used to do this. This page describes how it works.
1010

1111
## Replication
1212

13-
The Sync datastore participates in master-less replication with
13+
The Sync DocumentStore participates in master-less replication with
1414
[Cloudant][cloudant]
1515
or [Apache CouchDB][couch]. What this means is that there is no canonical
1616
copy of the documents in each database. One of the main results of this
@@ -56,17 +56,17 @@ in the tree.
5656
### What are conflicts?
5757

5858
When a document has been replicated to more than one place, it's possible to
59-
edit it concurrently in two places. When the datastores storing the document
59+
edit it concurrently in two places. When the DocumentStores containing the document
6060
then replicate with each other again, they each add their changes to the
6161
document's tree. This causes an extra branch to be added to the tree for
6262
each concurrent set of changes. When this happens, the document is said to be
6363
_conflicted_. This creates multiple current revisions of the document, one for
6464
each of the concurrent changes.
6565

6666
Say we last replicated the document above at the `2-x` revision. We make
67-
two changes locally (`3-x` and `4-x`) and the remote datastore has a single
67+
two changes locally (`3-x` and `4-x`) and the remote DocumentStore has a single
6868
change made to it (`3-y`). On replicating back from the remote, the local
69-
datastore ends up with a document like this:
69+
DocumentStore ends up with a document like this:
7070

7171
```
7272
replicated from remote
@@ -83,7 +83,7 @@ We now have two non-deleted leaf nodes: the document is conflicted.
8383

8484
### The "winning" revision
8585

86-
To make things easier, calling `Datastore#getDocument(...)` returns one of
86+
To make things easier, calling `Database#read(...)` returns one of
8787
the leaf nodes of the branches of the conflicted document. It selects the
8888
node to return in an arbitrary but deterministic way, which means that all
8989
replicas of the database will return the same revision for the document. The
@@ -109,16 +109,16 @@ a helper method to streamline the process of resolving conflicts.
109109

110110
### Finding conflicted documents
111111

112-
There's a method on the `Datastore` interface:
112+
There's a method on the `Database` interface:
113113

114114
```java
115-
Iterator<String> getConflictedDocumentIds();
115+
Iterator<String> getConflictedIds();
116116
```
117117

118118
This method returns an iterator over the document IDs:
119119

120120
```java
121-
for (String docId : datastore.getConflictedDocumentIds()) {
121+
for (String docId : database.getConflictedIds()) {
122122
System.out.println(docId);
123123
}
124124
```
@@ -127,8 +127,8 @@ for (String docId : datastore.getConflictedDocumentIds()) {
127127

128128
Once you've found the list of documents, you need to resolve them. This is
129129
done one-by-one, passing a class able to resolve conflicts and a document
130-
ID to the `resolveConflictsForDocument(String, ConflictResolver)` method
131-
of the `Datastore` interface.
130+
ID to the `resolveConflicts(String, ConflictResolver)` method
131+
of the `Database` interface.
132132

133133
The `ConflictResolver` interface has one method:
134134

@@ -166,7 +166,7 @@ class MergeResolver implements ConflictResolver {
166166
}
167167
```
168168

169-
Conceptually, the `resolveConflictsForDocument` method does the following:
169+
Conceptually, the `resolveConflicts` method does the following:
170170

171171
1. Get all the non-deleted leaf node revisions for the document.
172172

@@ -199,7 +199,7 @@ is no longer conflicted.
199199
200200
All this happens inside a transaction, ensuring consistency.
201201
202-
This resolution can be replicated to the remote document store, bringing
202+
This resolution can be replicated to the remote DocumentStore, bringing
203203
the two databases into a consistent state.
204204
205205
### Simple example
@@ -208,10 +208,10 @@ You could imagine an application running the following method
208208
via a timer to periodically fix up any conflicts:
209209
210210
```java
211-
public void resolveConflicts(Datastore datastore) {
211+
public void resolveConflicts(DocumentStore ds) {
212212
ConflictResolver pickFirst = new PickFirstResolver();
213-
for (String docId : datastore.getConflictedDocumentIds()) {
214-
datastore.resolveConflictsForDocument(docId, pickFirst);
213+
for (String docId : ds.database().getConflictedIds()) {
214+
ds.database().resolveConflicts(docId, pickFirst);
215215
}
216216
}
217217
```

doc/query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ query.put("$or", Arrays.<Object>asList(petClause, andClause));
345345

346346
### Executing queries
347347

348-
To find documents matching a query, use the `IndexManager` object's `find(Map<String, Object> query)` method. This returns an object that can be used in `for ( : )` loops to enumerate over the results.
348+
To find documents matching a query, use the `Query` object's `find(Map<String, Object> query)` method. This returns an object that can be used in `for ( : )` loops to enumerate over the results.
349349

350350
```java
351351
QueryResult result = q.find(query);

doc/replication-policies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ private boolean mIsBound;
330330

331331
Now we add a [`ServiceConnection`](http://developer.android.com/reference/android/content/ServiceConnection.html)
332332
to our [`Activity`](http://developer.android.com/reference/android/app/Activity.html)
333-
to allow us to handle binding and unbinding from our `MyReplicationService`. This enables us to get a reference to the service when we bind to it and add a listener for `replicationComplete` to the [`Service`](http://developer.android.com/reference/android/app/Service.html):
333+
to allow us to handle binding and unbinding from our `MyReplicationService`. This enables us to get a reference to the service when we bind to it and add a listener for `replicationCompleted` to the [`Service`](http://developer.android.com/reference/android/app/Service.html):
334334

335335
```java
336336
private ServiceConnection mConnection = new ServiceConnection() {
@@ -339,7 +339,7 @@ private ServiceConnection mConnection = new ServiceConnection() {
339339
mReplicationService = ((ReplicationService.LocalBinder) service).getService();
340340
mReplicationService.addListener(new ReplicationPolicyManager.SimpleReplicationsCompletedListener() {
341341
@Override
342-
public void replicationComplete(int id) {
342+
public void replicationCompleted(int id) {
343343
// Check if this is the pull replication
344344
if (id == MyReplicationService.PULL_REPLICATION_ID) {
345345
mHandler.post(new Runnable() {

doc/replication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ if (pullReplicator.getState() != Replicator.State.COMPLETE) {
215215
}
216216
```
217217

218-
### Using IndexManager with replication
218+
### Using `Query` with replication
219219

220-
When using IndexManager for querying data, we recommend you update after
220+
When using `Query` for querying data, we recommend you update after
221221
replication completes to avoid a wait for indexing to catch up when the new data
222222
is first queried:
223223

@@ -232,7 +232,7 @@ DocumentStore ds = DocumentStore.getInstance(new File("my_datastore"));
232232
Replicator replicator = ReplicatorBuilder.pull().from(uri).to(ds).build();
233233

234234
// Create a sample index on type field
235-
ds.query().ensureIndexed(Arrays.asList(new FieldSort("fieldName")), "indexName");
235+
ds.query().createJsonIndex(Arrays.asList(new FieldSort("fieldName")), "indexName");
236236

237237
// Use a CountDownLatch to provide a lightweight way to wait for completion
238238
CountDownLatch latch = new CountDownLatch(1);
@@ -247,7 +247,7 @@ if (replicator.getState() != Replicator.State.COMPLETE) {
247247
}
248248

249249
// Ensure all indexes are updated after replication
250-
ds.query().updateAllIndexes();
250+
ds.query().refreshAllIndexes();
251251

252252
```
253253

0 commit comments

Comments
 (0)