Skip to content

Commit

Permalink
Reverse wrong order of parameter names for Java WriteBatchWithIndex#i…
Browse files Browse the repository at this point in the history
…teratorWithBase (#11280)

Summary:
Fix for #11008

`Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase` takes parameters `(… jlong jwbwi_handle, jlong jcf_handle,
    jlong jbase_iterator_handle, jlong jread_opts_handle)` while `WriteBatchWithIndex.java` declares `private native long iteratorWithBase(final long handle, final long baseIteratorHandle,
      final long cfHandle, final long readOptionsHandle)`.

Luckily the only call to `iteratorWithBase` passes the parameters in the correct order for the implementation `(… cfHandle, baseIteratorHandle …)` This type checks because the types are the same (long words).

The code is currently used correctly, it is just extremely misleading. Swap the names of the 2 parameters in the Java method so that the correct usage is clear.

There already exist test methods which call the API correctly and only succeed because of that. These continue to work.

Pull Request resolved: #11280

Reviewed By: cbi42

Differential Revision: D43874798

Pulled By: ajkr

fbshipit-source-id: b59bc930bf579f4e0804f0effd4fb17f4225d60c
  • Loading branch information
alanpaxton authored and facebook-github-bot committed Mar 10, 2023
1 parent 969d4e1 commit fbd603d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions java/src/main/java/org/rocksdb/WriteBatchWithIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ private native static long newWriteBatchWithIndex(
final boolean overwriteKey);
private native long iterator0(final long handle);
private native long iterator1(final long handle, final long cfHandle);
private native long iteratorWithBase(final long handle, final long baseIteratorHandle,
final long cfHandle, final long readOptionsHandle);
private native long iteratorWithBase(final long handle, final long cfHandle,
final long baseIteratorHandle, final long readOptionsHandle);
private native byte[] getFromBatch(final long handle, final long optHandle,
final byte[] key, final int keyLen);
private native byte[] getFromBatch(final long handle, final long optHandle,
Expand Down

0 comments on commit fbd603d

Please sign in to comment.