Skip to content

Commit

Permalink
java/syncbase: Add default options for runInBatch
Browse files Browse the repository at this point in the history
We missed one of these. The rest of the options all have a default
version that doesn't require the options parameter.

Closes vanadium/issues#1377

Change-Id: I9024dd2cbb053107e8a284f6774aa80760dc1792
  • Loading branch information
afandria committed Jul 1, 2016
1 parent a9afb39 commit 8b2d6c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion syncbase/src/main/java/io/v/syncbase/Collection.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void run(BatchDatabase db) {
if (mDatabaseHandle instanceof BatchDatabase) {
op.run((BatchDatabase) mDatabaseHandle);
} else {
((Database) mDatabaseHandle).runInBatch(op, new Database.BatchOptions());
((Database) mDatabaseHandle).runInBatch(op);
}
}
}
11 changes: 11 additions & 0 deletions syncbase/src/main/java/io/v/syncbase/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@ public void run(io.v.syncbase.core.BatchDatabase batchDatabase) {
}, opts.toCore());
}

/**
* Runs the given operation in a batch, managing retries and commit/abort. Writable batches are
* committed, retrying if commit fails due to a concurrent batch. Read-only batches are aborted.
* Uses the default BatchOptions.
*
* @param op the operation to run
*/
public void runInBatch(final BatchOperation op) throws VError {
runInBatch(op, new BatchOptions());
}

/**
* Creates a new batch. Instead of calling this function directly, clients are encouraged to use
* the {@code runInBatch} helper function, which detects "concurrent batch" errors and handles
Expand Down
2 changes: 1 addition & 1 deletion syncbase/src/main/java/io/v/syncbase/Syncgroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ public void run(BatchDatabase db) {
}
}
}
}, new Database.BatchOptions());
});
}
}
2 changes: 1 addition & 1 deletion syncbase/src/test/java/io/v/syncbase/SyncbaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void run(BatchDatabase db) {
fail(vError.toString());
}
}
}, new Database.BatchOptions());
});
assertEquals(db.collection("c").get("foo", Integer.class), Integer.valueOf(10));
}

Expand Down

0 comments on commit 8b2d6c0

Please sign in to comment.