Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.tidesdb</groupId>
<artifactId>tidesdb-java</artifactId>
<version>0.3.1</version>
<version>0.3.2</version>
<packaging>jar</packaging>

<name>TidesDB Java</name>
Expand Down
7 changes: 5 additions & 2 deletions src/main/c/com_tidesdb_TidesDB.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ JNIEXPORT jlong JNICALL Java_com_tidesdb_TidesDB_nativeOpen(JNIEnv *env, jclass
jint numFlushThreads,
jint numCompactionThreads,
jint logLevel, jlong blockCacheSize,
jlong maxOpenSSTables)
jlong maxOpenSSTables, jboolean logToFile,
jlong logTruncationAt)
{
const char *path = (*env)->GetStringUTFChars(env, dbPath, NULL);
if (path == NULL)
Expand All @@ -91,7 +92,9 @@ JNIEXPORT jlong JNICALL Java_com_tidesdb_TidesDB_nativeOpen(JNIEnv *env, jclass
.num_compaction_threads = numCompactionThreads,
.log_level = (tidesdb_log_level_t)logLevel,
.block_cache_size = (size_t)blockCacheSize,
.max_open_sstables = (size_t)maxOpenSSTables};
.max_open_sstables = (size_t)maxOpenSSTables,
.log_to_file = logToFile ? 1 : 0,
.log_truncation_at = (size_t)logTruncationAt};

tidesdb_t *db = NULL;
int result = tidesdb_open(&config, &db);
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/tidesdb/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Config {
private LogLevel logLevel;
private long blockCacheSize;
private long maxOpenSSTables;
private boolean logToFile;
private long logTruncationAt;

private Config(Builder builder) {
this.dbPath = builder.dbPath;
Expand All @@ -37,6 +39,8 @@ private Config(Builder builder) {
this.logLevel = builder.logLevel;
this.blockCacheSize = builder.blockCacheSize;
this.maxOpenSSTables = builder.maxOpenSSTables;
this.logToFile = builder.logToFile;
this.logTruncationAt = builder.logTruncationAt;
}

/**
Expand All @@ -51,6 +55,8 @@ public static Config defaultConfig() {
.logLevel(LogLevel.INFO)
.blockCacheSize(64 * 1024 * 1024)
.maxOpenSSTables(256)
.logToFile(false)
.logTruncationAt(24 * 1024 * 1024)
.build();
}

Expand Down Expand Up @@ -88,6 +94,14 @@ public long getMaxOpenSSTables() {
return maxOpenSSTables;
}

public boolean isLogToFile() {
return logToFile;
}

public long getLogTruncationAt() {
return logTruncationAt;
}

/**
* Builder for Config.
*/
Expand All @@ -98,6 +112,8 @@ public static class Builder {
private LogLevel logLevel = LogLevel.INFO;
private long blockCacheSize = 64 * 1024 * 1024;
private long maxOpenSSTables = 256;
private boolean logToFile = false;
private long logTruncationAt = 24 * 1024 * 1024;

public Builder dbPath(String dbPath) {
this.dbPath = dbPath;
Expand Down Expand Up @@ -129,6 +145,16 @@ public Builder maxOpenSSTables(long maxOpenSSTables) {
return this;
}

public Builder logToFile(boolean logToFile) {
this.logToFile = logToFile;
return this;
}

public Builder logTruncationAt(long logTruncationAt) {
this.logTruncationAt = logTruncationAt;
return this;
}

public Config build() {
validate();
return new Config(this);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/tidesdb/TidesDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public static TidesDB open(Config config) throws TidesDBException {
config.getNumCompactionThreads(),
config.getLogLevel().getValue(),
config.getBlockCacheSize(),
config.getMaxOpenSSTables()
config.getMaxOpenSSTables(),
config.isLogToFile(),
config.getLogTruncationAt()
);

return new TidesDB(handle);
Expand Down Expand Up @@ -255,7 +257,8 @@ long getNativeHandle() {
}

private static native long nativeOpen(String dbPath, int numFlushThreads, int numCompactionThreads,
int logLevel, long blockCacheSize, long maxOpenSSTables) throws TidesDBException;
int logLevel, long blockCacheSize, long maxOpenSSTables,
boolean logToFile, long logTruncationAt) throws TidesDBException;

private static native void nativeClose(long handle);

Expand Down
Loading