java-bindings: Changes per review comments

- Add function to check if DirectBuffer queries are enabled.
- Javadoc comment fixes
- Fix min buffer limits.
This commit is contained in:
Vishesh Yadav 2020-08-27 11:14:58 -07:00
parent b3432c0ce0
commit aa326c030b
3 changed files with 15 additions and 5 deletions

View File

@ -35,7 +35,7 @@ class DirectBufferPool {
// is always greater than the maximum size KV allowed by FDB.
// Current limits is :
// 10kB for key + 100kB for value + 1 int for count + 1 int for more + 2 int for KV size
static public final int MIN_BUFFER_SIZE = (10 + 100) * 1024 + Integer.BYTES * 4;
static public final int MIN_BUFFER_SIZE = (10 + 100) * 1000 + Integer.BYTES * 4;
static private final int DEFAULT_NUM_BUFFERS = 128;
static private final int DEFAULT_BUFFER_SIZE = 1024 * 512;
@ -66,14 +66,14 @@ class DirectBufferPool {
}
/**
* Requests a {@link #DirectByteBuffer} from our pool. Returns null if pool is empty.
* Requests a {@link DirectByteBuffer} from our pool. Returns null if pool is empty.
*/
public synchronized ByteBuffer poll() {
return buffers.poll();
}
/**
* Returns the {@link #DirectByteBuffer} that was borrowed from our pool. This
* Returns the {@link DirectByteBuffer} that was borrowed from our pool. This
* is non-blocking as it was borrowed from this pool.
*/
public synchronized void add(ByteBuffer buffer) {

View File

@ -85,7 +85,7 @@ public class FDB {
private volatile boolean netStarted = false;
private volatile boolean netStopped = false;
volatile boolean warnOnUnclosed = true;
protected boolean enableDirectBufferQueries = false;
private boolean enableDirectBufferQueries = false;
private boolean useShutdownHook = true;
private Thread shutdownHook;
@ -240,6 +240,16 @@ public class FDB {
enableDirectBufferQueries = enabled;
}
/**
* Determines whether getRange() queries can use {@link DirectByteBuffer} from
* {@link DirectBufferPool} to copy results.
*
* @return {@code true} if an enabled has been selected and {@code false} otherwise
*/
public boolean isDirectBufferQueriesEnabled() {
return enableDirectBufferQueries;
}
/**
* Resizes the DirectBufferPool with given parameters, which is used by getRange() requests.
*

View File

@ -373,7 +373,7 @@ class FDBTransaction extends NativeObjectWrapper implements Transaction, OptionC
Transaction_getRange(getPtr(), begin.getKey(), begin.orEqual(), begin.getOffset(),
end.getKey(), end.orEqual(), end.getOffset(), rowLimit, targetBytes,
streamingMode, iteration, isSnapshot, reverse),
FDB.instance().enableDirectBufferQueries, executor);
FDB.instance().isDirectBufferQueriesEnabled(), executor);
} finally {
pointerReadLock.unlock();
}