Skip to content

Commit e3e4870

Browse files
committed
Upgrade to version 0.13.3
1 parent a97721e commit e3e4870

16 files changed

+1995
-266
lines changed

mdbxjni/src/main/java/com/castortech/mdbxjni/CursorOp.java

+38
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,52 @@ public enum CursorOp {
114114

115115
/** Position at first key-value pair greater than or equal to specified,
116116
* return both key and data, and the return code depends on a exact match.
117+
*
118+
* For non DUPSORT-ed collections this work the same to \ref MDBX_SET_RANGE,
119+
* but returns \ref MDBX_SUCCESS if key found exactly or
120+
* \ref MDBX_RESULT_TRUE if greater key was found.
121+
*
122+
* For DUPSORT-ed a data value is taken into account for duplicates,
123+
* i.e. for a pairs/tuples of a key and an each data value of duplicates.
124+
* Returns \ref MDBX_SUCCESS if key-value pair found exactly or
125+
* \ref MDBX_RESULT_TRUE if the next pair was returned.
117126
*/
118127
SET_LOWERBOUND(MDBX_SET_LOWERBOUND),
119128

120129
/** Positions cursor at first key-value pair greater than specified,
121130
* return both key and data, and the return code depends on whether a
122131
* upper-bound was found.
132+
*
133+
* For non DUPSORT-ed collections this work like \ref MDBX_SET_RANGE,
134+
* but returns \ref MDBX_SUCCESS if the greater key was found or
135+
* \ref MDBX_NOTFOUND otherwise.
136+
*
137+
* For DUPSORT-ed a data value is taken into account for duplicates,
138+
* i.e. for a pairs/tuples of a key and an each data value of duplicates.
139+
* Returns \ref MDBX_SUCCESS if the greater pair was returned or
140+
* \ref MDBX_NOTFOUND otherwise.
123141
*/
124142
SET_UPPERBOUND(MDBX_SET_UPPERBOUND),
143+
144+
/* Doubtless cursor positioning at a specified key. */
145+
TO_KEY_LESSER_THAN(MDBX_TO_KEY_LESSER_THAN),
146+
TO_KEY_LESSER_OR_EQUAL(MDBX_TO_KEY_LESSER_OR_EQUAL),
147+
TO_KEY_EQUAL(MDBX_TO_KEY_EQUAL),
148+
TO_KEY_GREATER_OR_EQUAL(MDBX_TO_KEY_GREATER_OR_EQUAL),
149+
TO_KEY_GREATER_THAN(MDBX_TO_KEY_GREATER_THAN),
150+
151+
/* Doubtless cursor positioning at a specified key-value pair for dupsort/multi-value hives. */
152+
TO_EXACT_KEY_VALUE_LESSER_THAN(MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN),
153+
TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL(MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL),
154+
TO_EXACT_KEY_VALUE_EQUAL(MDBX_TO_EXACT_KEY_VALUE_EQUAL),
155+
TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL(MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL),
156+
TO_EXACT_KEY_VALUE_GREATER_THAN(MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN),
157+
158+
TO_PAIR_LESSER_THAN(MDBX_TO_PAIR_LESSER_THAN),
159+
TO_PAIR_LESSER_OR_EQUAL(MDBX_TO_PAIR_LESSER_OR_EQUAL),
160+
TO_PAIR_EQUAL(MDBX_TO_PAIR_EQUAL),
161+
TO_PAIR_GREATER_OR_EQUAL(MDBX_TO_PAIR_GREATER_OR_EQUAL),
162+
TO_PAIR_GREATER_THAN(MDBX_TO_PAIR_GREATER_THAN),
125163
;
126164

127165
private final int value;

mdbxjni/src/main/java/com/castortech/mdbxjni/CursorState.java

+23-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.castortech.mdbxjni;
22

3-
import static com.castortech.mdbxjni.JNIIntern.*;
4-
53
import java.util.ArrayList;
64
import java.util.Collection;
75
import java.util.List;
@@ -20,29 +18,29 @@ public CursorState(short rawResult) {
2018

2119
public Collection<CursorStateFlags> getCursorStateFlags() {
2220
List<CursorStateFlags> csFlags = new ArrayList<>();
23-
int flgsInt = flags.intValue();
24-
25-
if (flgsInt == 0) {
26-
csFlags.add(CursorStateFlags.NONE);
27-
}
28-
if ((flgsInt & C_INITIALIZED) == C_INITIALIZED) {
29-
csFlags.add(CursorStateFlags.INITIALIZED);
30-
}
31-
if ((flgsInt & C_EOF) == C_EOF) {
32-
csFlags.add(CursorStateFlags.EOF);
33-
}
34-
if ((flgsInt & C_SUB) == C_SUB) {
35-
csFlags.add(CursorStateFlags.SUB);
36-
}
37-
if ((flgsInt & C_DEL) == C_DEL) {
38-
csFlags.add(CursorStateFlags.DEL);
39-
}
40-
if ((flgsInt & C_UNTRACK) == C_UNTRACK) {
41-
csFlags.add(CursorStateFlags.UNTRACK);
42-
}
43-
if ((flgsInt & C_GCU) == C_GCU) {
44-
csFlags.add(CursorStateFlags.GCU);
45-
}
21+
// int flgsInt = flags.intValue();
22+
//
23+
// if (flgsInt == 0) {
24+
// csFlags.add(CursorStateFlags.NONE);
25+
// }
26+
// if ((flgsInt & C_INITIALIZED) == C_INITIALIZED) {
27+
// csFlags.add(CursorStateFlags.INITIALIZED);
28+
// }
29+
// if ((flgsInt & C_EOF) == C_EOF) {
30+
// csFlags.add(CursorStateFlags.EOF);
31+
// }
32+
// if ((flgsInt & C_SUB) == C_SUB) {
33+
// csFlags.add(CursorStateFlags.SUB);
34+
// }
35+
// if ((flgsInt & C_DEL) == C_DEL) {
36+
// csFlags.add(CursorStateFlags.DEL);
37+
// }
38+
// if ((flgsInt & C_UNTRACK) == C_UNTRACK) {
39+
// csFlags.add(CursorStateFlags.UNTRACK);
40+
// }
41+
// if ((flgsInt & C_GCU) == C_GCU) {
42+
// csFlags.add(CursorStateFlags.GCU);
43+
// }
4644
return csFlags;
4745
}
4846

mdbxjni/src/main/java/com/castortech/mdbxjni/CursorStateFlags.java

+17-19
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package com.castortech.mdbxjni;
1919

20-
import static com.castortech.mdbxjni.JNIIntern.*;
21-
2220
/**
2321
* Cursor state flags.
2422
*
@@ -28,23 +26,23 @@ public enum CursorStateFlags {
2826
/** None */
2927
NONE(0),
3028

31-
/** cursor has been initialized and is valid */
32-
INITIALIZED(C_INITIALIZED),
33-
34-
/** No more data */
35-
EOF(C_EOF),
36-
37-
/** Cursor is a sub-cursor */
38-
SUB(C_SUB),
39-
40-
/** last op was a cursor_del */
41-
DEL(C_DEL),
42-
43-
/** Un-track cursor when closing */
44-
UNTRACK(C_UNTRACK),
45-
46-
/** Preparing for a GC update is in progress, so you can take pages from GC even for FREE_DBI */
47-
GCU(C_GCU),
29+
// /** cursor has been initialized and is valid */
30+
// INITIALIZED(C_INITIALIZED),
31+
//
32+
// /** No more data */
33+
// EOF(C_EOF),
34+
//
35+
// /** Cursor is a sub-cursor */
36+
// SUB(C_SUB),
37+
//
38+
// /** last op was a cursor_del */
39+
// DEL(C_DEL),
40+
//
41+
// /** Un-track cursor when closing */
42+
// UNTRACK(C_UNTRACK),
43+
//
44+
// /** Preparing for a GC update is in progress, so you can take pages from GC even for FREE_DBI */
45+
// GCU(C_GCU),
4846
;
4947

5048
private final int value;

mdbxjni/src/main/java/com/castortech/mdbxjni/Env.java

+37-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
public class Env extends NativeObject implements Closeable {
4747
private static final Logger log = LoggerFactory.getLogger(Env.class);
4848

49+
public static final boolean IS_WINDOWS = isWindows();
50+
51+
@SuppressWarnings("nls")
52+
static private boolean isWindows() {
53+
String name = System.getProperty("os.name").toLowerCase().trim();
54+
return name.startsWith("win");
55+
}
56+
4957
private static final String MAIN_DB = "MAIN_DB"; //$NON-NLS-1$
5058

5159
private Callback keyCmpCallback = null;
@@ -80,6 +88,14 @@ public static String version() {
8088
return "" + JNI.MDBX_VERSION_MAJOR + '.' + JNI.MDBX_VERSION_MINOR; //$NON-NLS-1$
8189
}
8290

91+
public static VersionInfo versionInfo() {
92+
MDBX_version_info rc = new MDBX_version_info();
93+
94+
NativeBuffer buffer = NativeBuffer.create(JNI.SIZEOF_VERSIONINFO);
95+
// mdbx_build();
96+
return new VersionInfo(rc);
97+
}
98+
8399
public static BuildInfo buildInfo() {
84100
MDBX_build_info rc = new MDBX_build_info();
85101

@@ -240,7 +256,14 @@ public void open(String path, int flags) {
240256
* ignored on Windows.
241257
*/
242258
public void open(String path, int flags, int mode) {
243-
int rc = mdbx_env_open(pointer(), path, flags, mode);
259+
int rc;
260+
if (IS_WINDOWS) {
261+
rc = mdbx_env_openW(pointer(), path, flags, mode);
262+
}
263+
else {
264+
rc = mdbx_env_open(pointer(), path, flags, mode);
265+
}
266+
244267
if (rc != 0) {
245268
close();
246269
}
@@ -278,8 +301,8 @@ public void open(String path, EnvConfig config) {
278301
flags |= EnvFlags.WRITEMAP;
279302
}
280303

281-
if (config.isNoTLS()) {
282-
flags |= EnvFlags.NOTLS;
304+
if (config.isNoStickyThreads()) {
305+
flags |= EnvFlags.NOSTICKYTHREADS;
283306
}
284307

285308
if (config.isNoReadAhead()) {
@@ -337,16 +360,23 @@ public void open(String path, EnvConfig config) {
337360
setGeometry(config.getMapLower(), config.getMapSize(), config.getMapUpper(), config.getMapGrowth(),
338361
config.getMapShrink(), config.getPageSize());
339362

340-
int rc = mdbx_env_open(pointer(), path, flags, config.getMode());
363+
int rc;
364+
if (IS_WINDOWS) {
365+
rc = mdbx_env_openW(pointer(), path, flags, config.getMode());
366+
}
367+
else {
368+
rc = mdbx_env_open(pointer(), path, flags, config.getMode());
369+
}
370+
341371
if (rc != 0) {
342372
close();
343373
}
344374
else {
345375
mainDb = new Database(this, 1L, MAIN_DB);
346376
}
347377

348-
CursorPoolConfig poolConfig = new CursorPoolConfig();
349-
if (config.isUsePooledCursors()) {
378+
CursorPoolConfig poolConfig = new CursorPoolConfig();
379+
if (config.isUsePooledCursors()) {
350380
poolConfig.setTimeBetweenEvictionRuns(config.getPooledCursorTimeBetweenEvictionRuns());
351381
poolConfig.setMaxIdlePerKey(config.getPooledCursorMaxIdle());
352382
poolConfig.setSoftMinEvictableIdleTime(config.getPooledCursorMinEvictableIdleTime());
@@ -1154,6 +1184,7 @@ public DebugState setupDebug(MdbxLogLevel logLevel, int debugFlags) {
11541184
return new DebugState(rc);
11551185
}
11561186

1187+
11571188
/**
11581189
* Method callback for MDBX issued log entries
11591190
* @param level

mdbxjni/src/main/java/com/castortech/mdbxjni/EnvConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void setMapAsync(boolean mapAsync) {
194194
this.mapAsync = mapAsync;
195195
}
196196

197-
public boolean isNoTLS() {
197+
public boolean isNoStickyThreads() {
198198
return noTLS;
199199
}
200200

mdbxjni/src/main/java/com/castortech/mdbxjni/EnvFlags.java

+35-18
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,48 @@
2121
import static com.castortech.mdbxjni.JNI.*;
2222

2323
/**
24+
* @see JNI#MDBX_ENV_DEFAULTS
2425
* @author Alain Picard
2526
*/
2627
public class EnvFlags {
2728
//====================================================//
2829
// Environment Flags
2930
//====================================================//
30-
public static final int ENVDEFAULTS = MDBX_ENV_DEFAULTS;
31-
public static final int VALIDATION = MDBX_VALIDATION ;
32-
public static final int NOSUBDIR = MDBX_NOSUBDIR ;
33-
public static final int RDONLY = MDBX_RDONLY ;
34-
public static final int EXCLUSIVE = MDBX_EXCLUSIVE ;
35-
public static final int ACCEDE = MDBX_ACCEDE ;
36-
public static final int WRITEMAP = MDBX_WRITEMAP ;
37-
public static final int NOTLS = MDBX_NOTLS ;
38-
public static final int NORDAHEAD = MDBX_NORDAHEAD ;
39-
public static final int NOMEMINIT = MDBX_NOMEMINIT ;
31+
public static final int ENVDEFAULTS = MDBX_ENV_DEFAULTS ;
32+
/** @see JNI#MDBX_VALIDATION*/
33+
public static final int VALIDATION = MDBX_VALIDATION ;
34+
/** @see JNI#MDBX_NOSUBDIR*/
35+
public static final int NOSUBDIR = MDBX_NOSUBDIR ;
36+
/** @see JNI#MDBX_RDONLY*/
37+
public static final int RDONLY = MDBX_RDONLY ;
38+
/** @see JNI#MDBX_EXCLUSIVE*/
39+
public static final int EXCLUSIVE = MDBX_EXCLUSIVE ;
40+
/** @see JNI#MDBX_ACCEDE*/
41+
public static final int ACCEDE = MDBX_ACCEDE ;
42+
/** @see JNI#MDBX_WRITEMAP*/
43+
public static final int WRITEMAP = MDBX_WRITEMAP ;
44+
/** @see JNI#MDBX_NOSTICKYTHREADS*/
45+
public static final int NOSTICKYTHREADS = MDBX_NOSTICKYTHREADS;
46+
/** @see JNI#MDBX_NORDAHEAD*/
47+
public static final int NORDAHEAD = MDBX_NORDAHEAD ;
48+
/** @see JNI#MDBX_NOMEMINIT*/
49+
public static final int NOMEMINIT = MDBX_NOMEMINIT ;
4050
/** @see JNI#MDBX_COALESCE */
41-
public static final int COALESCE = MDBX_COALESCE ;
51+
@Deprecated
52+
public static final int COALESCE = MDBX_COALESCE ;
4253
/** @see JNI#MDBX_LIFORECLAIM */
43-
public static final int LIFORECLAIM = MDBX_LIFORECLAIM ;
54+
public static final int LIFORECLAIM = MDBX_LIFORECLAIM ;
4455
/** @see JNI#MDBX_PAGEPERTURB */
45-
public static final int PAGEPERTURB = MDBX_PAGEPERTURB ;
46-
public static final int SYNCDURABLE = MDBX_SYNC_DURABLE;
47-
public static final int NOMETASYNC = MDBX_NOMETASYNC ;
48-
public static final int SAFENOSYNC = MDBX_SAFE_NOSYNC ;
49-
public static final int MAPASYNC = MDBX_MAPASYNC ;
50-
public static final int UTTERLY_NOSYNC = MDBX_UTTERLY_NOSYNC;
56+
public static final int PAGEPERTURB = MDBX_PAGEPERTURB ;
57+
/** @see JNI#MDBX_SYNC_DURABLE */
58+
public static final int SYNCDURABLE = MDBX_SYNC_DURABLE ;
59+
/** @see JNI#MDBX_NOMETASYNC */
60+
public static final int NOMETASYNC = MDBX_NOMETASYNC ;
61+
/** @see JNI#MDBX_SAFE_NOSYNC */
62+
public static final int SAFENOSYNC = MDBX_SAFE_NOSYNC ;
63+
/** @see JNI#MDBX_MAPASYNC */
64+
@Deprecated
65+
public static final int MAPASYNC = MDBX_MAPASYNC ;
66+
/** @see JNI#MDBX_UTTERLY_NOSYNC */
67+
public static final int UTTERLY_NOSYNC = MDBX_UTTERLY_NOSYNC ;
5168
}

mdbxjni/src/main/java/com/castortech/mdbxjni/EnvOptions.java

+21-15
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ public class EnvOptions {
2727
//====================================================//
2828
// Environment Options
2929
//====================================================//
30-
public static final int OPT_MAX_DBS = MDBX_opt_max_db ;
31-
public static final int OPT_MAX_READERS = MDBX_opt_max_readers ;
32-
public static final int OPT_SYNC_BYTES = MDBX_opt_sync_bytes ;
33-
public static final int OPT_SYNC_PERIOD = MDBX_opt_sync_period ;
34-
public static final int OPT_RP_ARG_LIMIT = MDBX_opt_rp_augment_limit ;
35-
public static final int OPT_LOOSE_LIMIT = MDBX_opt_loose_limit ;
36-
public static final int OPT_DB_RESERVE_LIMIT = MDBX_opt_dp_reserve_limit ;
37-
public static final int OPT_TXN_DP_LIMIT = MDBX_opt_txn_dp_limit ;
38-
public static final int OPT_TXN_DP_INITIAL = MDBX_opt_txn_dp_initial ;
39-
public static final int OPT_SPILL_MAX_DENOM = MDBX_opt_spill_max_denominator;
40-
public static final int OPT_SPILL_MIN_DENOM = MDBX_opt_spill_min_denominator;
41-
public static final int OPT_SPILL_P4C_DENOM = MDBX_opt_spill_parent4child_denominator;
42-
public static final int OPT_MERGE_THRESH_PERC = MDBX_opt_merge_threshold_16dot16_percent;
43-
public static final int OPT_WRTIE_THRU_THRESH = MDBX_opt_writethrough_threshold;
44-
public static final int OPT_PREFAULT_WRITE_ENABLE = MDBX_opt_prefault_write_enable;
30+
public static final int OPT_MAX_DBS = MDBX_opt_max_db ;
31+
public static final int OPT_MAX_READERS = MDBX_opt_max_readers ;
32+
public static final int OPT_SYNC_BYTES = MDBX_opt_sync_bytes ;
33+
public static final int OPT_SYNC_PERIOD = MDBX_opt_sync_period ;
34+
public static final int OPT_RP_ARG_LIMIT = MDBX_opt_rp_augment_limit ;
35+
public static final int OPT_LOOSE_LIMIT = MDBX_opt_loose_limit ;
36+
public static final int OPT_DB_RESERVE_LIMIT = MDBX_opt_dp_reserve_limit ;
37+
public static final int OPT_TXN_DP_LIMIT = MDBX_opt_txn_dp_limit ;
38+
public static final int OPT_TXN_DP_INITIAL = MDBX_opt_txn_dp_initial ;
39+
public static final int OPT_SPILL_MAX_DENOM = MDBX_opt_spill_max_denominator ;
40+
public static final int OPT_SPILL_MIN_DENOM = MDBX_opt_spill_min_denominator ;
41+
public static final int OPT_SPILL_P4C_DENOM = MDBX_opt_spill_parent4child_denominator ;
42+
public static final int OPT_MERGE_THRESH_PERC = MDBX_opt_merge_threshold_16dot16_percent;
43+
public static final int OPT_WRTIE_THRU_THRESH = MDBX_opt_writethrough_threshold ;
44+
public static final int OPT_PREFAULT_WRITE_ENABLE = MDBX_opt_prefault_write_enable ;
45+
public static final int OPT_GC_TIME_LIMIT = MDBX_opt_gc_time_limit ;
46+
public static final int OPT_PREFER_WAF_INSTEADOF_BALANCE = MDBX_opt_prefer_waf_insteadof_balance ;
47+
public static final int OPT_SUBPAGE_LIMIT = MDBX_opt_subpage_limit ;
48+
public static final int OPT_SUBPAGE_ROOM_THRESHOLD = MDBX_opt_subpage_room_threshold ;
49+
public static final int OPT_SUBPAGE_RESERVE_PREREQ = MDBX_opt_subpage_reserve_prereq ;
50+
public static final int OPT_SUBPAGE_RESERVE_LIMIT = MDBX_opt_subpage_reserve_limit ;
4551
}

mdbxjni/src/main/java/com/castortech/mdbxjni/Global.java

+8
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ public long getMaxTxnSize(long pageSize) {
2525
return mdbx_limits_txnsize_max(pageSize);
2626
}
2727

28+
public long getMinKeySize(int flags) {
29+
return mdbx_limits_keysize_min(flags);
30+
}
31+
2832
public long getMaxKeySize(long pageSize, int flags) {
2933
return mdbx_limits_keysize_max(pageSize, flags);
3034
}
3135

36+
public long getMinValSize(int flags) {
37+
return mdbx_limits_valsize_min(flags);
38+
}
39+
3240
public long getMaxValSize(long pageSize, int flags) {
3341
return mdbx_limits_valsize_max(pageSize, flags);
3442
}

0 commit comments

Comments
 (0)