Various java cleanup. Convert some anonymous classes to lambdas, remove some unnecessary keywords from some interfaces, fix some documentation issues, etc.
This commit is contained in:
parent
1be6fdf687
commit
157e32fe2e
|
@ -36,15 +36,12 @@ public class Cluster extends DefaultDisposableImpl implements Disposable {
|
|||
protected Cluster(long cPtr, Executor executor) {
|
||||
super(cPtr);
|
||||
this.executor = executor;
|
||||
this.options = new ClusterOptions(new OptionConsumer() {
|
||||
@Override
|
||||
public void setOption(int code, byte[] parameter) {
|
||||
pointerReadLock.lock();
|
||||
try {
|
||||
Cluster_setOption(getPtr(), code, parameter);
|
||||
} finally {
|
||||
pointerReadLock.unlock();
|
||||
}
|
||||
this.options = new ClusterOptions((code, parameter) -> {
|
||||
pointerReadLock.lock();
|
||||
try {
|
||||
Cluster_setOption(getPtr(), code, parameter);
|
||||
} finally {
|
||||
pointerReadLock.unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -80,7 +77,7 @@ public class Cluster extends DefaultDisposableImpl implements Disposable {
|
|||
* successful connection.
|
||||
*/
|
||||
public Database openDatabase(Executor e) throws FDBException {
|
||||
FutureDatabase futureDatabase = null;
|
||||
FutureDatabase futureDatabase;
|
||||
pointerReadLock.lock();
|
||||
try {
|
||||
futureDatabase = new FutureDatabase(Cluster_createDatabase(getPtr(), "DB".getBytes(UTF8)), e);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package com.apple.foundationdb;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -43,7 +42,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
/**
|
||||
* Creates a {@link Transaction} that operates on this {@code Database}.<br>
|
||||
* <br>
|
||||
* Note: Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* <b>Note:</b> Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* option. This is because the Java bindings disallow use of {@code Transaction} objects after
|
||||
* {@link Transaction#onError} is called.
|
||||
*
|
||||
|
|
|
@ -104,7 +104,7 @@ public class LocalityUtil {
|
|||
*/
|
||||
public static CompletableFuture<String[]> getAddressesForKey(Transaction tr, byte[] key) {
|
||||
if (!(tr instanceof FDBTransaction)) {
|
||||
CompletableFuture<String[]> future = new CompletableFuture<String[]>();
|
||||
CompletableFuture<String[]> future = new CompletableFuture<>();
|
||||
future.completeExceptionally(new FDBException("locality_information_unavailable", 1033));
|
||||
return future;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public class LocalityUtil {
|
|||
}
|
||||
}
|
||||
|
||||
static Charset ASCII = Charset.forName("US-ASCII");
|
||||
private static Charset ASCII = Charset.forName("US-ASCII");
|
||||
static byte[] keyServersForKey(byte[] key) {
|
||||
return ByteArrayUtil.join(new byte[] { (byte)255 },
|
||||
"/keyServers/".getBytes(ASCII),
|
||||
|
|
|
@ -33,5 +33,5 @@ public interface OptionConsumer {
|
|||
* @param code the encoded parameter to set
|
||||
* @param parameter the value, the range of which is dependent on the parameter {@code code}
|
||||
*/
|
||||
public void setOption(int code, byte[] parameter);
|
||||
void setOption(int code, byte[] parameter);
|
||||
}
|
||||
|
|
|
@ -270,7 +270,6 @@ class RangeQuery implements AsyncIterable<KeyValue>, Iterable<KeyValue> {
|
|||
// - no more data -or-
|
||||
// - we are already fetching the next block
|
||||
return mainChunkIsTheLast() ?
|
||||
//new ReadyFuture<Boolean>(false, tr.getExecutor()) :
|
||||
CompletableFuture.completedFuture(false) :
|
||||
nextFuture;
|
||||
}
|
||||
|
@ -280,11 +279,6 @@ class RangeQuery implements AsyncIterable<KeyValue>, Iterable<KeyValue> {
|
|||
return onHasNext().join();
|
||||
}
|
||||
|
||||
// moves to the last position in the current chunk
|
||||
/*public synchronized void consumeAll() {
|
||||
index = chunk.values.size() - 1;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public KeyValue next() {
|
||||
CompletableFuture<Boolean> nextFuture;
|
||||
|
@ -326,7 +320,12 @@ class RangeQuery implements AsyncIterable<KeyValue>, Iterable<KeyValue> {
|
|||
|
||||
// If there was no result ready then we need to wait on the future
|
||||
// and return the proper result, throwing if there are no more elements
|
||||
return nextFuture.thenApply(NEXT_MAPPER).join();
|
||||
return nextFuture.thenApply(hasNext -> {
|
||||
if(hasNext) {
|
||||
return next();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -347,14 +346,5 @@ class RangeQuery implements AsyncIterable<KeyValue>, Iterable<KeyValue> {
|
|||
public void dispose() {
|
||||
cancel();
|
||||
}
|
||||
|
||||
private final Function<Boolean, KeyValue> NEXT_MAPPER = new Function<Boolean, KeyValue>() {
|
||||
@Override
|
||||
public KeyValue apply(Boolean o) {
|
||||
if(o)
|
||||
return next();
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,9 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
|
||||
/**
|
||||
* A read-only subset of a FoundationDB {@link Transaction}. This is the interface that
|
||||
* {@code Transaction}'s {@link Transaction#snapshot snapshot} presents.
|
||||
*
|
||||
* {@code Transaction}'s {@link Transaction#snapshot snapshot} presents.<br>
|
||||
* <br>
|
||||
* Note: Client must call {@link Transaction#commit()} and wait on the result on all transactions,
|
||||
* <b>Note:</b> Client must call {@link Transaction#commit()} and wait on the result on all transactions,
|
||||
* even ones that only read. This is done automatically when using the retry loops from
|
||||
* {@link Database#run(Function)}. This is explained more in the intro to {@link Transaction}.
|
||||
*
|
||||
|
@ -42,13 +41,13 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
* When passed to a {@code getRange()} call that takes a {@code limit} parameter,
|
||||
* indicates that the query should return unlimited rows.
|
||||
*/
|
||||
public static final int ROW_LIMIT_UNLIMITED = 0;
|
||||
int ROW_LIMIT_UNLIMITED = 0;
|
||||
|
||||
/**
|
||||
* Gets the version at which the reads for this {@code Transaction} will access the database.
|
||||
* @return the version for database reads
|
||||
*/
|
||||
public CompletableFuture<Long> getReadVersion();
|
||||
CompletableFuture<Long> getReadVersion();
|
||||
|
||||
/**
|
||||
* Gets a value from the database. The call will return {@code null} if the key is not
|
||||
|
@ -59,7 +58,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
* @return a {@code CompletableFuture} which will be set to the value corresponding to
|
||||
* the key or to null if the key does not exist.
|
||||
*/
|
||||
public CompletableFuture<byte[]> get(byte[] key);
|
||||
CompletableFuture<byte[]> get(byte[] key);
|
||||
|
||||
/**
|
||||
* Returns the key referenced by the specified {@code KeySelector}.
|
||||
|
@ -74,7 +73,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a {@code CompletableFuture} which will be set to an absolute database key
|
||||
*/
|
||||
public CompletableFuture<byte[]> getKey(KeySelector selector);
|
||||
CompletableFuture<byte[]> getKey(KeySelector selector);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -89,7 +88,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end);
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -107,7 +106,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -128,7 +127,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -152,7 +151,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -168,7 +167,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end);
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -186,7 +185,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -207,7 +206,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -231,7 +230,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -250,7 +249,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range);
|
||||
AsyncIterable<KeyValue> getRange(Range range);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -271,7 +270,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -295,7 +294,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -322,7 +321,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -330,6 +329,5 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a set of transaction-specific options affecting this {@code Transaction}
|
||||
*/
|
||||
public TransactionOptions options();
|
||||
|
||||
TransactionOptions options();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
* {@code runAsync()} on a {@code Transaction} will simply attempt the operations
|
||||
* without any retry loop.<br>
|
||||
* <br>
|
||||
* Note: Client must call {@link #commit()} and wait on the result on all transactions, even
|
||||
* <b>Note:</b> Client must call {@link #commit()} and wait on the result on all transactions, even
|
||||
* ones that only read. This is done automatically when using the retry loops from
|
||||
* {@link Database#run(Function)}. This is because outstanding reads originating from a
|
||||
* {@code Transaction} will be cancelled when a {@code Transaction} is garbage collected.
|
||||
|
@ -64,9 +64,9 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
* all reads are complete, thereby saving the calling code from this potentially confusing
|
||||
* situation.<br>
|
||||
* <br>
|
||||
* Note: All keys with a first byte of {@code 0xff} are reserved for internal use.<br>
|
||||
* <b>Note:</b> All keys with a first byte of {@code 0xff} are reserved for internal use.<br>
|
||||
* <br>
|
||||
* Note: Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* <b>Note:</b> Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* option. This is because the Java bindings disallow use of {@code Transaction} objects after {@link #onError}
|
||||
* is called.
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* For more information about how to use snapshot reads correctly, see
|
||||
* <a href="/documentation/developer-guide.html#using-snapshot-reads" target="_blank">Using snapshot reads</a>.
|
||||
*/
|
||||
public ReadTransaction snapshot();
|
||||
ReadTransaction snapshot();
|
||||
|
||||
/**
|
||||
* Directly sets the version of the database at which to execute reads. The
|
||||
|
@ -92,7 +92,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @param version the version at which to read from the database
|
||||
*/
|
||||
public void setReadVersion(long version);
|
||||
void setReadVersion(long version);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @param keyBegin the first key in the range (inclusive)
|
||||
* @param keyEnd the ending key for the range (exclusive)
|
||||
*/
|
||||
public void addReadConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
void addReadConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
|
||||
/**
|
||||
* Adds a key to the transaction's read conflict ranges as if you had read
|
||||
|
@ -112,7 +112,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @param key the key to be added to the range
|
||||
*/
|
||||
public void addReadConflictKey(byte[] key);
|
||||
void addReadConflictKey(byte[] key);
|
||||
|
||||
/**
|
||||
* Adds a range of keys to the transaction's write conflict ranges as if you
|
||||
|
@ -122,7 +122,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @param keyBegin the first key in the range (inclusive)
|
||||
* @param keyEnd the ending key for the range (exclusive)
|
||||
*/
|
||||
public void addWriteConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
void addWriteConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
|
||||
/**
|
||||
* Adds a key to the transaction's write conflict ranges as if you had
|
||||
|
@ -131,7 +131,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @param key the key to be added to the range
|
||||
*/
|
||||
public void addWriteConflictKey(byte[] key);
|
||||
void addWriteConflictKey(byte[] key);
|
||||
|
||||
/**
|
||||
* Sets the value for a given key. This will not affect the
|
||||
|
@ -142,7 +142,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void set(byte[] key, byte[] value);
|
||||
void set(byte[] key, byte[] value);
|
||||
|
||||
/**
|
||||
* Clears a given key from the database. This will not affect the
|
||||
|
@ -152,7 +152,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(byte[] key);
|
||||
void clear(byte[] key);
|
||||
|
||||
/**
|
||||
* Clears a range of keys in the database. The upper bound of the range is
|
||||
|
@ -166,7 +166,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(byte[] beginKey, byte[] endKey);
|
||||
void clear(byte[] beginKey, byte[] endKey);
|
||||
|
||||
/**
|
||||
* Clears a range of keys in the database. The upper bound of the range is
|
||||
|
@ -179,7 +179,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(Range range);
|
||||
void clear(Range range);
|
||||
|
||||
/**
|
||||
* Replace with calls to {@link #clear(Range)} with a parameter from a call to
|
||||
|
@ -190,7 +190,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @throws FDBException
|
||||
*/
|
||||
@Deprecated
|
||||
public void clearRangeStartsWith(byte[] prefix);
|
||||
void clearRangeStartsWith(byte[] prefix);
|
||||
|
||||
/**
|
||||
* An atomic operation is a single database command that carries out several
|
||||
|
@ -211,7 +211,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* that are frequently modified. A common example is the use of a key-value
|
||||
* pair as a counter.<br>
|
||||
* <br>
|
||||
* Note: If a transaction uses both an atomic operation and a serializable
|
||||
* <b>Note:</b> If a transaction uses both an atomic operation and a serializable
|
||||
* read on the same key, the benefits of using the atomic operation (for both
|
||||
* conflict checking and performance) are lost.
|
||||
*
|
||||
|
@ -221,7 +221,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @param key the target of the operation
|
||||
* @param param the value with which to modify the key
|
||||
*/
|
||||
public void mutate(MutationType optype, byte[] key, byte[] param);
|
||||
void mutate(MutationType optype, byte[] key, byte[] param);
|
||||
|
||||
/**
|
||||
* Commit this {@code Transaction}. See notes in class description. Consider using
|
||||
|
@ -245,7 +245,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* throw an error code {@code used_during_commit}(2017). In this case, all
|
||||
* subsequent operations on this transaction will throw this error.
|
||||
*/
|
||||
public CompletableFuture<Void> commit();
|
||||
CompletableFuture<Void> commit();
|
||||
|
||||
/**
|
||||
* Gets the version number at which a successful commit modified the database.
|
||||
|
@ -257,7 +257,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @return the database version at which the commit succeeded
|
||||
*/
|
||||
public Long getCommittedVersion();
|
||||
Long getCommittedVersion();
|
||||
|
||||
/**
|
||||
* Returns a future which will contain the versionstamp which was used by any versionstamp
|
||||
|
@ -270,7 +270,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @return a future containing the versionstamp which was used for any versionstamp operations
|
||||
* in this transaction
|
||||
*/
|
||||
public CompletableFuture<byte[]> getVersionstamp();
|
||||
CompletableFuture<byte[]> getVersionstamp();
|
||||
|
||||
/**
|
||||
* Resets a transaction and returns a delayed signal for error recovery. If the error
|
||||
|
@ -287,13 +287,13 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @param e the error caught while executing get()s and set()s on this {@code Transaction}
|
||||
* @return a {@code CompletableFuture} to be set with a reset {@code Transaction} object to retry the transaction
|
||||
*/
|
||||
public CompletableFuture<Transaction> onError(Throwable e);
|
||||
CompletableFuture<Transaction> onError(Throwable e);
|
||||
|
||||
/**
|
||||
* Cancels the {@code Transaction}. All pending and any future uses of the
|
||||
* {@code Transaction} will throw an {@link RuntimeException}.
|
||||
*/
|
||||
public void cancel();
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Creates a watch that will become ready when it reports a change to
|
||||
|
@ -337,7 +337,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* limit defaults to 10,000 and can be modified with a call to
|
||||
* {@link DatabaseOptions#setMaxWatches(long)}.
|
||||
*/
|
||||
public CompletableFuture<Void> watch(byte[] key) throws FDBException;
|
||||
CompletableFuture<Void> watch(byte[] key) throws FDBException;
|
||||
|
||||
/**
|
||||
* Returns the {@link Database} that this {@code Transaction} is interacting
|
||||
|
@ -345,7 +345,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
*
|
||||
* @return the {@link Database} object
|
||||
*/
|
||||
public Database getDatabase();
|
||||
Database getDatabase();
|
||||
|
||||
/**
|
||||
* Run a function once against this {@code Transaction}. This call blocks while
|
||||
|
@ -354,7 +354,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @return the return value of {@code retryable}
|
||||
*/
|
||||
@Override
|
||||
public <T> T run(Function<? super Transaction, T> retryable);
|
||||
<T> T run(Function<? super Transaction, T> retryable);
|
||||
|
||||
/**
|
||||
* Run a function once against this {@code Transaction}. This call returns
|
||||
|
@ -363,7 +363,7 @@ public interface Transaction extends Disposable, ReadTransaction, TransactionCon
|
|||
* @return a {@code CompletableFuture} that will be set to the return value of {@code retryable}
|
||||
*/
|
||||
@Override
|
||||
public <T> CompletableFuture<T> runAsync(
|
||||
<T> CompletableFuture<T> runAsync(
|
||||
Function<? super Transaction, CompletableFuture<T>> retryable);
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public interface AsyncIterable<T> extends Iterable<T> {
|
|||
* @return a handle to be used for non-blocking iteration
|
||||
*/
|
||||
@Override
|
||||
public AsyncIterator<T> iterator();
|
||||
AsyncIterator<T> iterator();
|
||||
|
||||
/**
|
||||
* Asynchronously return the results of this operation as a {@code List}. This is
|
||||
|
@ -47,5 +47,5 @@ public interface AsyncIterable<T> extends Iterable<T> {
|
|||
*
|
||||
* @return a {@code CompletableFuture} that will be set to contents of this operation
|
||||
*/
|
||||
public CompletableFuture<List<T>> asList();
|
||||
CompletableFuture<List<T>> asList();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface AsyncIterator<T> extends Iterator<T>, Disposable {
|
|||
* would return another element without blocking or to {@code false} if there are
|
||||
* no more elements in the sequence.
|
||||
*/
|
||||
public CompletableFuture<Boolean> onHasNext();
|
||||
CompletableFuture<Boolean> onHasNext();
|
||||
|
||||
/**
|
||||
* Blocking call to determine if the sequence contains more elements. This call
|
||||
|
@ -56,7 +56,7 @@ public interface AsyncIterator<T> extends Iterator<T>, Disposable {
|
|||
* otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext();
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Returns the next element in the sequence. This will not block if, since the
|
||||
|
@ -72,17 +72,17 @@ public interface AsyncIterator<T> extends Iterator<T>, Disposable {
|
|||
* @throws NoSuchElementException if the sequence has been exhausted.
|
||||
*/
|
||||
@Override
|
||||
public T next();
|
||||
T next();
|
||||
|
||||
/**
|
||||
* Cancels any outstanding asynchronous work associated with this {@code AsyncIterator}.
|
||||
*/
|
||||
public void cancel();
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Cancel this {@code AsyncIterable} and dispose of associated resources. Equivalent
|
||||
* to calling {@link AsyncIterator#cancel()}.
|
||||
*/
|
||||
@Override
|
||||
public void dispose();
|
||||
void dispose();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class AsyncUtil {
|
|||
try {
|
||||
return func.apply(value);
|
||||
} catch (RuntimeException e) {
|
||||
CompletableFuture<O> future = new CompletableFuture<O>();
|
||||
CompletableFuture<O> future = new CompletableFuture<>();
|
||||
future.completeExceptionally(e);
|
||||
return future;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class AsyncUtil {
|
|||
final CompletableFuture<Void> done;
|
||||
final Executor executor;
|
||||
|
||||
public LoopPartial(Supplier<? extends CompletableFuture<Boolean>> body, Executor executor) {
|
||||
LoopPartial(Supplier<? extends CompletableFuture<Boolean>> body, Executor executor) {
|
||||
this.body = body;
|
||||
this.done = new CompletableFuture<>();
|
||||
this.executor = executor;
|
||||
|
@ -279,12 +279,7 @@ public class AsyncUtil {
|
|||
* @return a newly created {@code CompletableFuture} that is set when {@code task} completes
|
||||
*/
|
||||
public static <V> CompletableFuture<Void> success(CompletableFuture<V> task) {
|
||||
return task.thenApply(new Function<V, Void>() {
|
||||
@Override
|
||||
public Void apply(V o) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return task.thenApply(o -> null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,34 +293,18 @@ public class AsyncUtil {
|
|||
* @return a new {@link CompletableFuture} that is set when {@code task} is ready.
|
||||
*/
|
||||
public static <V> CompletableFuture<Void> whenReady(CompletableFuture<V> task) {
|
||||
return task.thenApply(new Function<V, Void>() {
|
||||
@Override
|
||||
public Void apply(V o) {
|
||||
return null;
|
||||
}
|
||||
}).exceptionally(new Function<Throwable, Void>() {
|
||||
@Override
|
||||
public Void apply(Throwable o) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return task.thenApply(o -> (Void)null)
|
||||
.exceptionally(o -> null);
|
||||
}
|
||||
|
||||
public static <V> CompletableFuture<V> composeExceptionally(CompletableFuture<V> task, Function<Throwable, CompletableFuture<V>> fn) {
|
||||
return task.handle(new BiFunction<V, Throwable, Throwable>() {
|
||||
@Override
|
||||
public Throwable apply(V v, Throwable e) {
|
||||
return e;
|
||||
}
|
||||
}).thenCompose(new Function<Throwable, CompletableFuture<V>>() {
|
||||
@Override
|
||||
public CompletableFuture<V> apply(Throwable e) {
|
||||
if (e != null) {
|
||||
return fn.apply(e);
|
||||
} else {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return task.handle((v,e) -> e)
|
||||
.thenCompose(e -> {
|
||||
if (e != null) {
|
||||
return fn.apply(e);
|
||||
} else {
|
||||
return task;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -338,16 +317,13 @@ public class AsyncUtil {
|
|||
* @return a {@code CompletableFuture} that will be set to the collective result of the tasks
|
||||
*/
|
||||
public static <V> CompletableFuture<List<V>> getAll(final Collection<CompletableFuture<V>> tasks) {
|
||||
return whenAll(tasks).thenApply(new Function<Void, List<V>>() {
|
||||
@Override
|
||||
public List<V> apply(Void o) {
|
||||
List<V> result = new ArrayList<V>();
|
||||
for(CompletableFuture<V> f : tasks) {
|
||||
assert(f.isDone());
|
||||
result.add(f.getNow(null));
|
||||
}
|
||||
return result;
|
||||
return whenAll(tasks).thenApply(unused -> {
|
||||
List<V> result = new ArrayList<>();
|
||||
for(CompletableFuture<V> f : tasks) {
|
||||
assert(f.isDone());
|
||||
result.add(f.getNow(null));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -361,12 +337,7 @@ public class AsyncUtil {
|
|||
* @return a {@code CompletableFuture} that will be set to {@code value} on completion of {@code task}
|
||||
*/
|
||||
public static <V, T> CompletableFuture<V> tag(CompletableFuture<T> task, final V value) {
|
||||
return task.thenApply(new Function<T, V>() {
|
||||
@Override
|
||||
public V apply(T o) {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
return task.thenApply(o -> value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -99,7 +99,7 @@ public class WatchTest {
|
|||
e.execute(cancel);
|
||||
}
|
||||
|
||||
while(a.get() != 2); {
|
||||
while(a.get() != 2) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e1) {
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Cluster extends DefaultDisposableImpl implements Disposable {
|
|||
* successful connection.
|
||||
*/
|
||||
public Database openDatabase(Executor e) throws FDBException {
|
||||
FutureDatabase futureDatabase = null;
|
||||
FutureDatabase futureDatabase;
|
||||
pointerReadLock.lock();
|
||||
try {
|
||||
futureDatabase = new FutureDatabase(Cluster_createDatabase(getPtr(), "DB".getBytes(UTF8)), e);
|
||||
|
|
|
@ -45,13 +45,13 @@ public interface Database extends Disposable, TransactionContext {
|
|||
/**
|
||||
* Creates a {@link Transaction} that operates on this {@code Database}.<br>
|
||||
* <br>
|
||||
* Note: Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* <b>Note:</b> Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* option. This is because the Java bindings disallow use of {@code Transaction} objects after
|
||||
* {@link Transaction#onError} is called.
|
||||
*
|
||||
* @return a newly created {@code Transaction} that reads from and writes to this {@code Database}.
|
||||
*/
|
||||
public Transaction createTransaction();
|
||||
Transaction createTransaction();
|
||||
|
||||
/**
|
||||
* Creates a {@link Transaction} that operates on this {@code Database} with the given {@link Executor}
|
||||
|
@ -60,14 +60,14 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* @param e the {@link Executor} to use when executing asynchronous callbacks for the database
|
||||
* @return a newly created {@code Transaction} that reads from and writes to this {@code Database}.
|
||||
*/
|
||||
public Transaction createTransaction(Executor e);
|
||||
Transaction createTransaction(Executor e);
|
||||
|
||||
/**
|
||||
* Returns a set of options that can be set on a {@code Database}
|
||||
*
|
||||
* @return a set of database-specific options affecting this {@code Database}
|
||||
*/
|
||||
public DatabaseOptions options();
|
||||
DatabaseOptions options();
|
||||
|
||||
/**
|
||||
* Runs a read-only transactional function against this {@code Database} with retry logic.
|
||||
|
@ -81,7 +81,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* this database
|
||||
*/
|
||||
@Override
|
||||
public <T> T read(Function<? super ReadTransaction, T> retryable);
|
||||
<T> T read(Function<? super ReadTransaction, T> retryable);
|
||||
|
||||
/**
|
||||
* Runs a read-only transactional function against this {@code Database} with retry logic. Use
|
||||
|
@ -94,7 +94,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #read(Function)
|
||||
*/
|
||||
public <T> T read(Function<? super ReadTransaction, T> retryable, Executor e);
|
||||
<T> T read(Function<? super ReadTransaction, T> retryable, Executor e);
|
||||
|
||||
/**
|
||||
* Runs a read-only transactional function against this {@code Database} with retry logic. Use
|
||||
|
@ -109,7 +109,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* @see #read(Function)
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> T read(PartialFunction<? super ReadTransaction, T> retryable) throws Exception;
|
||||
<T> T read(PartialFunction<? super ReadTransaction, T> retryable) throws Exception;
|
||||
|
||||
/**
|
||||
* Runs a read-only transactional function against this {@code Database} with retry logic. Use
|
||||
|
@ -125,7 +125,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #read(Function)
|
||||
*/
|
||||
public abstract <T> T read(PartialFunction<? super ReadTransaction, T> retryable, Executor e) throws Exception;
|
||||
<T> T read(PartialFunction<? super ReadTransaction, T> retryable, Executor e) throws Exception;
|
||||
|
||||
/**
|
||||
* Runs a read-only transactional function against this {@code Database} with retry logic.
|
||||
|
@ -143,7 +143,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* this database
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> Future<T> readAsync(
|
||||
<T> Future<T> readAsync(
|
||||
Function<? super ReadTransaction, Future<T>> retryable);
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #readAsync(Function)
|
||||
*/
|
||||
public abstract <T> Future<T> readAsync(
|
||||
<T> Future<T> readAsync(
|
||||
Function<? super ReadTransaction, Future<T>> retryable, Executor e);
|
||||
|
||||
/**
|
||||
|
@ -171,7 +171,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* @see #read(Function)
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> PartialFuture<T> readAsync(
|
||||
<T> PartialFuture<T> readAsync(
|
||||
PartialFunction<? super ReadTransaction, ? extends PartialFuture<T>> retryable);
|
||||
|
||||
/**
|
||||
|
@ -186,7 +186,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #read(Function)
|
||||
*/
|
||||
public abstract <T> PartialFuture<T> readAsync(
|
||||
<T> PartialFuture<T> readAsync(
|
||||
PartialFunction<? super ReadTransaction, ? extends PartialFuture<T>> retryable, Executor e);
|
||||
|
||||
|
||||
|
@ -210,7 +210,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* this database
|
||||
*/
|
||||
@Override
|
||||
public <T> T run(Function<? super Transaction, T> retryable);
|
||||
<T> T run(Function<? super Transaction, T> retryable);
|
||||
|
||||
/**
|
||||
* Runs a transactional function against this {@code Database} with retry logic.
|
||||
|
@ -222,7 +222,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* this database
|
||||
* @param e the {@link Executor} to use for asynchronous callbacks
|
||||
*/
|
||||
public <T> T run(Function<? super Transaction, T> retryable, Executor e);
|
||||
<T> T run(Function<? super Transaction, T> retryable, Executor e);
|
||||
|
||||
/**
|
||||
* Runs a transactional function against this {@code Database} with retry logic. Use
|
||||
|
@ -237,7 +237,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* @see #run(Function)
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> T run(PartialFunction<? super Transaction, T> retryable) throws Exception;
|
||||
<T> T run(PartialFunction<? super Transaction, T> retryable) throws Exception;
|
||||
|
||||
/**
|
||||
* Runs a transactional function against this {@code Database} with retry logic. Use
|
||||
|
@ -253,7 +253,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #run(Function)
|
||||
*/
|
||||
public abstract <T> T run(PartialFunction<? super Transaction, T> retryable, Executor e) throws Exception;
|
||||
<T> T run(PartialFunction<? super Transaction, T> retryable, Executor e) throws Exception;
|
||||
|
||||
/**
|
||||
* Runs a transactional function against this {@code Database} with retry logic.
|
||||
|
@ -279,7 +279,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* this database
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> Future<T> runAsync(
|
||||
<T> Future<T> runAsync(
|
||||
Function<? super Transaction, Future<T>> retryable);
|
||||
|
||||
/**
|
||||
|
@ -293,7 +293,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #run(Function)
|
||||
*/
|
||||
public abstract <T> Future<T> runAsync(
|
||||
<T> Future<T> runAsync(
|
||||
Function<? super Transaction, Future<T>> retryable, Executor e);
|
||||
|
||||
/**
|
||||
|
@ -307,7 +307,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
* @see #run(Function)
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> PartialFuture<T> runAsync(
|
||||
<T> PartialFuture<T> runAsync(
|
||||
PartialFunction<? super Transaction, ? extends PartialFuture<T>> retryable);
|
||||
|
||||
/**
|
||||
|
@ -322,7 +322,7 @@ public interface Database extends Disposable, TransactionContext {
|
|||
*
|
||||
* @see #run(Function)
|
||||
*/
|
||||
public abstract <T> PartialFuture<T> runAsync(
|
||||
<T> PartialFuture<T> runAsync(
|
||||
PartialFunction<? super Transaction, ? extends PartialFuture<T>> retryable, Executor e);
|
||||
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ public class LocalityUtil {
|
|||
}
|
||||
}
|
||||
|
||||
static Charset ASCII = Charset.forName("US-ASCII");
|
||||
private static Charset ASCII = Charset.forName("US-ASCII");
|
||||
static byte[] keyServersForKey(byte[] key) {
|
||||
return ByteArrayUtil.join(new byte[] { (byte)255 },
|
||||
"/keyServers/".getBytes(ASCII),
|
||||
|
|
|
@ -33,5 +33,5 @@ public interface OptionConsumer {
|
|||
* @param code the encoded parameter to set
|
||||
* @param parameter the value, the range of which is dependent on the parameter {@code code}
|
||||
*/
|
||||
public void setOption(int code, byte[] parameter);
|
||||
void setOption(int code, byte[] parameter);
|
||||
}
|
||||
|
|
|
@ -283,11 +283,6 @@ class RangeQuery implements AsyncIterable<KeyValue>, Iterable<KeyValue> {
|
|||
return onHasNext().get();
|
||||
}
|
||||
|
||||
// moves to the last position in the current chunk
|
||||
/*public synchronized void consumeAll() {
|
||||
index = chunk.values.size() - 1;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public KeyValue next() {
|
||||
Future<Boolean> nextFuture;
|
||||
|
|
|
@ -28,10 +28,9 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
|
||||
/**
|
||||
* A read-only subset of a FoundationDB {@link Transaction}. This is the interface that
|
||||
* {@code Transaction}'s {@link Transaction#snapshot snapshot} presents.
|
||||
*
|
||||
* {@code Transaction}'s {@link Transaction#snapshot snapshot} presents.<br>
|
||||
* <br>
|
||||
* Note: Client must call {@link Transaction#commit()} and wait on the result on all transactions,
|
||||
* <b>Note:</b> Client must call {@link Transaction#commit()} and wait on the result on all transactions,
|
||||
* even ones that only read. This is done automatically when using the retry loops from
|
||||
* {@link Database#run(Function)}. This is explained more in the intro to {@link Transaction}.
|
||||
*
|
||||
|
@ -42,13 +41,13 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
* When passed to a {@code getRange()} call that takes a {@code limit} parameter,
|
||||
* indicates that the query should return unlimited rows.
|
||||
*/
|
||||
public static final int ROW_LIMIT_UNLIMITED = 0;
|
||||
int ROW_LIMIT_UNLIMITED = 0;
|
||||
|
||||
/**
|
||||
* Gets the version at which the reads for this {@code Transaction} will access the database.
|
||||
* @return the version for database reads
|
||||
*/
|
||||
public Future<Long> getReadVersion();
|
||||
Future<Long> getReadVersion();
|
||||
|
||||
/**
|
||||
* Gets a value from the database. The call will return {@code null} if the key is not
|
||||
|
@ -59,7 +58,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
* @return a {@code Future} which will be set to the value corresponding to
|
||||
* the key or to null if the key does not exist.
|
||||
*/
|
||||
public Future<byte[]> get(byte[] key);
|
||||
Future<byte[]> get(byte[] key);
|
||||
|
||||
/**
|
||||
* Returns the key referenced by the specified {@code KeySelector}.
|
||||
|
@ -74,7 +73,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a {@code Future} which will be set to an absolute database key
|
||||
*/
|
||||
public Future<byte[]> getKey(KeySelector selector);
|
||||
Future<byte[]> getKey(KeySelector selector);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -89,7 +88,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end);
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -107,7 +106,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -128,7 +127,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -152,7 +151,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -168,7 +167,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end);
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -186,7 +185,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -207,7 +206,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -231,7 +230,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -250,7 +249,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range);
|
||||
AsyncIterable<KeyValue> getRange(Range range);
|
||||
|
||||
/**
|
||||
* Gets an ordered range of keys and values from the database. The begin
|
||||
|
@ -271,7 +270,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit);
|
||||
|
||||
/**
|
||||
|
@ -295,7 +294,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit, boolean reverse);
|
||||
|
||||
/**
|
||||
|
@ -322,7 +321,7 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a handle to access the results of the asynchronous call
|
||||
*/
|
||||
public AsyncIterable<KeyValue> getRange(Range range,
|
||||
AsyncIterable<KeyValue> getRange(Range range,
|
||||
int limit, boolean reverse, StreamingMode mode);
|
||||
|
||||
/**
|
||||
|
@ -330,5 +329,5 @@ public interface ReadTransaction extends ReadTransactionContext {
|
|||
*
|
||||
* @return a set of transaction-specific options affecting this {@code Transaction}
|
||||
*/
|
||||
public TransactionOptions options();
|
||||
TransactionOptions options();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
* {@code runAsync()} on a {@code Transaction} will simply attempt the operations
|
||||
* without any retry loop.<br>
|
||||
* <br>
|
||||
* Note: Client must call {@link #commit()} and wait on the result on all transactions, even
|
||||
* <b>Note:</b> Client must call {@link #commit()} and wait on the result on all transactions, even
|
||||
* ones that only read. This is done automatically when using the retry loops from
|
||||
* {@link Database#run(Function)}. This is because outstanding reads originating from a
|
||||
* {@code Transaction} will be cancelled when a {@code Transaction} is garbage collected.
|
||||
|
@ -67,9 +67,9 @@ import com.apple.foundationdb.tuple.Tuple;
|
|||
* all reads are complete, thereby saving the calling code from this potentially confusing
|
||||
* situation.<br>
|
||||
* <br>
|
||||
* Note: All keys with a first byte of {@code 0xff} are reserved for internal use.<br>
|
||||
* <b>Note:</b> All keys with a first byte of {@code 0xff} are reserved for internal use.<br>
|
||||
* <br>
|
||||
* Note: Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* <b>Note:</b> Java transactions automatically set the {@link TransactionOptions#setUsedDuringCommitProtectionDisable}
|
||||
* option. This is because the Java bindings disallow use of {@code Transaction} objects after {@link #onError}
|
||||
* is called.
|
||||
*/
|
||||
|
@ -84,7 +84,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* For more information about how to use snapshot reads correctly, see
|
||||
* <a href="/documentation/developer-guide.html#using-snapshot-reads" target="_blank">Using snapshot reads</a>.
|
||||
*/
|
||||
public ReadTransaction snapshot();
|
||||
ReadTransaction snapshot();
|
||||
|
||||
/**
|
||||
* Directly sets the version of the database at which to execute reads. The
|
||||
|
@ -95,7 +95,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @param version the version at which to read from the database
|
||||
*/
|
||||
public void setReadVersion(long version);
|
||||
void setReadVersion(long version);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @param keyBegin the first key in the range (inclusive)
|
||||
* @param keyEnd the ending key for the range (exclusive)
|
||||
*/
|
||||
public void addReadConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
void addReadConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
|
||||
/**
|
||||
* Adds a key to the transaction's read conflict ranges as if you had read
|
||||
|
@ -115,7 +115,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @param key the key to be added to the range
|
||||
*/
|
||||
public void addReadConflictKey(byte[] key);
|
||||
void addReadConflictKey(byte[] key);
|
||||
|
||||
/**
|
||||
* Adds a range of keys to the transaction's write conflict ranges as if you
|
||||
|
@ -125,7 +125,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @param keyBegin the first key in the range (inclusive)
|
||||
* @param keyEnd the ending key for the range (exclusive)
|
||||
*/
|
||||
public void addWriteConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
void addWriteConflictRange(byte[] keyBegin, byte[] keyEnd);
|
||||
|
||||
/**
|
||||
* Adds a key to the transaction's write conflict ranges as if you had
|
||||
|
@ -134,7 +134,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @param key the key to be added to the range
|
||||
*/
|
||||
public void addWriteConflictKey(byte[] key);
|
||||
void addWriteConflictKey(byte[] key);
|
||||
|
||||
/**
|
||||
* Sets the value for a given key. This will not affect the
|
||||
|
@ -145,7 +145,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void set(byte[] key, byte[] value);
|
||||
void set(byte[] key, byte[] value);
|
||||
|
||||
/**
|
||||
* Clears a given key from the database. This will not affect the
|
||||
|
@ -155,7 +155,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(byte[] key);
|
||||
void clear(byte[] key);
|
||||
|
||||
/**
|
||||
* Clears a range of keys in the database. The upper bound of the range is
|
||||
|
@ -169,7 +169,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @throws IllegalArgumentException
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(byte[] beginKey, byte[] endKey);
|
||||
void clear(byte[] beginKey, byte[] endKey);
|
||||
|
||||
/**
|
||||
* Clears a range of keys in the database. The upper bound of the range is
|
||||
|
@ -182,7 +182,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @throws FDBException
|
||||
*/
|
||||
public void clear(Range range);
|
||||
void clear(Range range);
|
||||
|
||||
/**
|
||||
* Replace with calls to {@link #clear(Range)} with a parameter from a call to
|
||||
|
@ -193,7 +193,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @throws FDBException
|
||||
*/
|
||||
@Deprecated
|
||||
public void clearRangeStartsWith(byte[] prefix);
|
||||
void clearRangeStartsWith(byte[] prefix);
|
||||
|
||||
/**
|
||||
* An atomic operation is a single database command that carries out several
|
||||
|
@ -214,7 +214,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* that are frequently modified. A common example is the use of a key-value
|
||||
* pair as a counter.<br>
|
||||
* <br>
|
||||
* Note: If a transaction uses both an atomic operation and a serializable
|
||||
* <b>Note:</b> If a transaction uses both an atomic operation and a serializable
|
||||
* read on the same key, the benefits of using the atomic operation (for both
|
||||
* conflict checking and performance) are lost.
|
||||
*
|
||||
|
@ -224,7 +224,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @param key the target of the operation
|
||||
* @param param the value with which to modify the key
|
||||
*/
|
||||
public void mutate(MutationType optype, byte[] key, byte[] param);
|
||||
void mutate(MutationType optype, byte[] key, byte[] param);
|
||||
|
||||
/**
|
||||
* Commit this {@code Transaction}. See notes in class description. Consider using
|
||||
|
@ -248,7 +248,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* throw an error code {@code used_during_commit}(2017). In this case, all
|
||||
* subsequent operations on this transaction will throw this error.
|
||||
*/
|
||||
public Future<Void> commit();
|
||||
Future<Void> commit();
|
||||
|
||||
/**
|
||||
* Gets the version number at which a successful commit modified the database.
|
||||
|
@ -260,7 +260,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @return the database version at which the commit succeeded
|
||||
*/
|
||||
public Long getCommittedVersion();
|
||||
Long getCommittedVersion();
|
||||
|
||||
/**
|
||||
* Returns a future which will contain the versionstamp which was used by any versionstamp
|
||||
|
@ -273,7 +273,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @return a future containing the versionstamp which was used for any versionstamp operations
|
||||
* in this transaction
|
||||
*/
|
||||
public Future<byte[]> getVersionstamp();
|
||||
Future<byte[]> getVersionstamp();
|
||||
|
||||
/**
|
||||
* Resets a transaction and returns a delayed signal for error recovery. If the error
|
||||
|
@ -290,7 +290,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @param e the error caught while executing get()s and set()s on this {@code Transaction}
|
||||
* @return a {@code Future} to be set with a reset {@code Transaction} object to retry the transaction
|
||||
*/
|
||||
public Future<Transaction> onError(RuntimeException e);
|
||||
Future<Transaction> onError(RuntimeException e);
|
||||
|
||||
/**
|
||||
* Resets a transaction and returns a delayed signal for error recovery. If the error
|
||||
|
@ -304,14 +304,14 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @param e the error caught while executing get()s and set()s on this {@code Transaction}
|
||||
* @return a {@code PartialFuture} to be set with a reset {@code Transaction} object to retry the transaction
|
||||
*/
|
||||
public PartialFuture<Transaction> onError(Exception e);
|
||||
PartialFuture<Transaction> onError(Exception e);
|
||||
|
||||
/**
|
||||
* Cancels the {@code Transaction}. All pending and any future uses of the
|
||||
* {@code Transaction} will throw an {@link RuntimeException}.
|
||||
*/
|
||||
@Override
|
||||
public void cancel();
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Creates a watch that will become ready when it reports a change to
|
||||
|
@ -355,7 +355,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* limit defaults to 10,000 and can be modified with a call to
|
||||
* {@link DatabaseOptions#setMaxWatches(long)}.
|
||||
*/
|
||||
public Future<Void> watch(byte[] key) throws FDBException;
|
||||
Future<Void> watch(byte[] key) throws FDBException;
|
||||
|
||||
/**
|
||||
* Returns the {@link Database} that this {@code Transaction} is interacting
|
||||
|
@ -363,7 +363,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
*
|
||||
* @return the {@link Database} object
|
||||
*/
|
||||
public Database getDatabase();
|
||||
Database getDatabase();
|
||||
|
||||
/**
|
||||
* Run a function once against this {@code Transaction}. This call blocks while
|
||||
|
@ -372,7 +372,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @return the return value of {@code retryable}
|
||||
*/
|
||||
@Override
|
||||
public <T> T run(Function<? super Transaction, T> retryable);
|
||||
<T> T run(Function<? super Transaction, T> retryable);
|
||||
|
||||
/**
|
||||
* Run a function once against this {@code Transaction}. This call blocks while
|
||||
|
@ -383,7 +383,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @throws Exception if an error is encountered during execution
|
||||
*/
|
||||
@Override
|
||||
public <T> T run(PartialFunction<? super Transaction, T> retryable)
|
||||
<T> T run(PartialFunction<? super Transaction, T> retryable)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
|
@ -393,7 +393,7 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @return a {@code Future} that will be set to the return value of {@code retryable}
|
||||
*/
|
||||
@Override
|
||||
public <T> Future<T> runAsync(
|
||||
<T> Future<T> runAsync(
|
||||
Function<? super Transaction, Future<T>> retryable);
|
||||
|
||||
/**
|
||||
|
@ -404,6 +404,6 @@ public interface Transaction extends Cancellable, Disposable, ReadTransaction, T
|
|||
* @return a {@code PartialFuture} that will be set to the return value of {@code retryable}
|
||||
*/
|
||||
@Override
|
||||
public <T> PartialFuture<T> runAsync(
|
||||
<T> PartialFuture<T> runAsync(
|
||||
PartialFunction<? super Transaction, ? extends PartialFuture<T>> retryable);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface AsyncIterable<T> extends Iterable<T> {
|
|||
* @return a handle to be used for non-blocking iteration
|
||||
*/
|
||||
@Override
|
||||
public AsyncIterator<T> iterator();
|
||||
AsyncIterator<T> iterator();
|
||||
|
||||
/**
|
||||
* Asynchronously return the results of this operation as a {@code List}. This is
|
||||
|
@ -46,5 +46,5 @@ public interface AsyncIterable<T> extends Iterable<T> {
|
|||
*
|
||||
* @return a {@code Future} that will be set to contents of this operation
|
||||
*/
|
||||
public Future<List<T>> asList();
|
||||
Future<List<T>> asList();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public interface AsyncIterator<T> extends Iterator<T>, Cancellable, Disposable {
|
|||
* would return another element without blocking or to {@code false} if there are
|
||||
* no more elements in the sequence.
|
||||
*/
|
||||
public Future<Boolean> onHasNext();
|
||||
Future<Boolean> onHasNext();
|
||||
|
||||
/**
|
||||
* Blocking call to determine if the sequence contains more elements. This call
|
||||
|
@ -55,7 +55,7 @@ public interface AsyncIterator<T> extends Iterator<T>, Cancellable, Disposable {
|
|||
* otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext();
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Returns the next element in the sequence. This will not block if, since the
|
||||
|
@ -71,18 +71,18 @@ public interface AsyncIterator<T> extends Iterator<T>, Cancellable, Disposable {
|
|||
* @throws NoSuchElementException if the sequence has been exhausted.
|
||||
*/
|
||||
@Override
|
||||
public T next();
|
||||
T next();
|
||||
|
||||
/**
|
||||
* Cancels any outstanding asynchronous work associated with this {@code AsyncIterator}.
|
||||
*/
|
||||
@Override
|
||||
public void cancel();
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Cancel this {@code AsyncIterable} and dispose of associated resources. Equivalent
|
||||
* to calling {@link AsyncIterator#cancel()}.
|
||||
*/
|
||||
@Override
|
||||
public void dispose();
|
||||
void dispose();
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public class AsyncUtil {
|
|||
PartialFuture<Boolean> process;
|
||||
boolean m_cancelled = false;
|
||||
|
||||
public LoopPartial(PartialFunction<Void, ? extends PartialFuture<Boolean>> body) {
|
||||
LoopPartial(PartialFunction<Void, ? extends PartialFuture<Boolean>> body) {
|
||||
this.body = body;
|
||||
this.done = new SettablePartialFuture<Void>();
|
||||
this.done.onCancelled(new Runnable() {
|
||||
|
|
|
@ -106,7 +106,7 @@ public class WatchTest {
|
|||
e.execute(cancel);
|
||||
}
|
||||
|
||||
while(a.get() != 2); {
|
||||
while(a.get() != 2) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e1) {
|
||||
|
|
Loading…
Reference in New Issue