|
46 | 46 | public class Env extends NativeObject implements Closeable {
|
47 | 47 | private static final Logger log = LoggerFactory.getLogger(Env.class);
|
48 | 48 |
|
| 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 | + |
49 | 57 | private static final String MAIN_DB = "MAIN_DB"; //$NON-NLS-1$
|
50 | 58 |
|
51 | 59 | private Callback keyCmpCallback = null;
|
@@ -80,6 +88,14 @@ public static String version() {
|
80 | 88 | return "" + JNI.MDBX_VERSION_MAJOR + '.' + JNI.MDBX_VERSION_MINOR; //$NON-NLS-1$
|
81 | 89 | }
|
82 | 90 |
|
| 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 | + |
83 | 99 | public static BuildInfo buildInfo() {
|
84 | 100 | MDBX_build_info rc = new MDBX_build_info();
|
85 | 101 |
|
@@ -240,7 +256,14 @@ public void open(String path, int flags) {
|
240 | 256 | * ignored on Windows.
|
241 | 257 | */
|
242 | 258 | 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 | + |
244 | 267 | if (rc != 0) {
|
245 | 268 | close();
|
246 | 269 | }
|
@@ -278,8 +301,8 @@ public void open(String path, EnvConfig config) {
|
278 | 301 | flags |= EnvFlags.WRITEMAP;
|
279 | 302 | }
|
280 | 303 |
|
281 |
| - if (config.isNoTLS()) { |
282 |
| - flags |= EnvFlags.NOTLS; |
| 304 | + if (config.isNoStickyThreads()) { |
| 305 | + flags |= EnvFlags.NOSTICKYTHREADS; |
283 | 306 | }
|
284 | 307 |
|
285 | 308 | if (config.isNoReadAhead()) {
|
@@ -337,16 +360,23 @@ public void open(String path, EnvConfig config) {
|
337 | 360 | setGeometry(config.getMapLower(), config.getMapSize(), config.getMapUpper(), config.getMapGrowth(),
|
338 | 361 | config.getMapShrink(), config.getPageSize());
|
339 | 362 |
|
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 | + |
341 | 371 | if (rc != 0) {
|
342 | 372 | close();
|
343 | 373 | }
|
344 | 374 | else {
|
345 | 375 | mainDb = new Database(this, 1L, MAIN_DB);
|
346 | 376 | }
|
347 | 377 |
|
348 |
| - CursorPoolConfig poolConfig = new CursorPoolConfig(); |
349 |
| - if (config.isUsePooledCursors()) { |
| 378 | + CursorPoolConfig poolConfig = new CursorPoolConfig(); |
| 379 | + if (config.isUsePooledCursors()) { |
350 | 380 | poolConfig.setTimeBetweenEvictionRuns(config.getPooledCursorTimeBetweenEvictionRuns());
|
351 | 381 | poolConfig.setMaxIdlePerKey(config.getPooledCursorMaxIdle());
|
352 | 382 | poolConfig.setSoftMinEvictableIdleTime(config.getPooledCursorMinEvictableIdleTime());
|
@@ -1154,6 +1184,7 @@ public DebugState setupDebug(MdbxLogLevel logLevel, int debugFlags) {
|
1154 | 1184 | return new DebugState(rc);
|
1155 | 1185 | }
|
1156 | 1186 |
|
| 1187 | + |
1157 | 1188 | /**
|
1158 | 1189 | * Method callback for MDBX issued log entries
|
1159 | 1190 | * @param level
|
|
0 commit comments