Skip to content
Open
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down
4 changes: 2 additions & 2 deletions rocksdbjni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
package org.fusesource.rocksdbjni;

import org.fusesource.rocksdbjni.internal.*;

import org.iq80.leveldb.*;

import java.io.*;
import java.net.URL;
import java.util.List;
import java.util.concurrent.Callable;

/**
Expand Down Expand Up @@ -91,18 +93,16 @@ static private class OptionsResourceHolder {
NativeComparator comparator=null;
NativeLogger logger=null;
NativeOptions options;


public void init(Options value) {

options = new NativeOptions();
options.blockRestartInterval(value.blockRestartInterval());
options.blockSize(value.blockSize());
options.createIfMissing(value.createIfMissing());
options.errorIfExists(value.errorIfExists());
options.maxOpenFiles(value.maxOpenFiles());
options.paranoidChecks(value.paranoidChecks());
options.writeBufferSize(value.writeBufferSize());

switch(value.compressionType()) {
case NONE:
options.compression(NativeCompressionType.kNoCompression);
Expand All @@ -127,18 +127,24 @@ public String name() {
};
options.comparator(comparator);
}

final Logger userLogger = value.logger();
if(userLogger!=null) {


logger = new NativeLogger() {

@Override
public void log(String message) {

userLogger.log(message);

}
};

options.infoLog(logger);
}

}
public void close() {
if(comparator!=null){
Expand All @@ -165,6 +171,22 @@ public DB open(File path, Options options) throws IOException {
}
return new JniDB(db, holder.comparator, holder.logger);
}

public DB openForReadOnly(File path, Options options) throws IOException {
NativeDB db=null;
OptionsResourceHolder holder = new OptionsResourceHolder();
try {
holder.init(options);
db = NativeDB.openforReadOnly(holder.options, path);
} finally {
// if we could not open up the DB, then clean up the
// other allocated native resouces..
if(db==null) {
holder.close();
}
}
return new JniDB(db, holder.comparator, holder.logger);
}

public void destroy(File path, Options options) throws IOException {
OptionsResourceHolder holder = new OptionsResourceHolder();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2018, FuseSource Corp. All rights reserved.
*
* http://fusesource.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of FuseSource Corp. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.fusesource.rocksdbjni.internal;

import org.fusesource.rocksdbjni.internal.NativeComparator.ComparatorJNI;
import org.iq80.leveldb.ColumnFamilyHandle;

public class JniColumnFamilyHandle implements ColumnFamilyHandle

{
private NativeColumnFamilyHandle handle=new NativeColumnFamilyHandle();



static {
NativeDB.LIBRARY.load();
}

public JniColumnFamilyHandle(NativeColumnFamilyHandle handle) {
this.handle=handle;
}

public JniColumnFamilyHandle() {
}

@Override
public long getId() {
long id = handle.getID();
return id;
}

@Override
public ComparatorJNI getComparator() {
ComparatorJNI comparator= handle.getComparator();
return comparator;
}

@Override
public long getDescriptor(NativeDescriptor descript) {
long descriptor= handle.getDescriptor(descript);
return descriptor;
}

@Override
public String get1Name() {
String result=handle.getName();
return result;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2018, FuseSource Corp. All rights reserved.
*
* http://fusesource.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of FuseSource Corp. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.fusesource.rocksdbjni.internal;

public class JniColumnFamilyOptions {

private long writeBufferSize;


public long writeBufferSize()
{
return writeBufferSize;
}

public JniColumnFamilyOptions writeBufferSize(long writeBufferSize)
{
this.writeBufferSize = writeBufferSize;
return this;
}

private int level0_file_num_compaction_trigger=4;

private boolean disable_auto_compactions = false;

public JniColumnFamilyOptions level0_file_num_compaction_trigger(int value) {
this.level0_file_num_compaction_trigger = value;
return this;
}

public int level0_file_num_compaction_trigger() {
return level0_file_num_compaction_trigger;
}

public JniColumnFamilyOptions disable_auto_compactions(boolean value) {
this.disable_auto_compactions = value;
return this;
}

public boolean disable_auto_compactions() {
return disable_auto_compactions;
}


}
Loading