Skip to content

Commit

Permalink
Revert "Merge pull request #68 from benalexau/agrona"
Browse files Browse the repository at this point in the history
This reverts commit 14b264a, reversing
changes made to 9a29e34.
  • Loading branch information
krisskross committed Jun 5, 2016
1 parent 14b264a commit a17f85f
Show file tree
Hide file tree
Showing 20 changed files with 760 additions and 732 deletions.
19 changes: 0 additions & 19 deletions lmdbjni-android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,6 @@ limitations under the License.
</configureArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/../lmdbjni/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
19 changes: 0 additions & 19 deletions lmdbjni-linux64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,6 @@ limitations under the License.
</configureArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/../lmdbjni/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
19 changes: 0 additions & 19 deletions lmdbjni-osx64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,6 @@ limitations under the License.
</configureArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/../lmdbjni/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
19 changes: 0 additions & 19 deletions lmdbjni-win64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,6 @@
<packageDirectory>${basedir}/../lmdbjni/target/generated-sources/hawtjni/native-package</packageDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/../lmdbjni/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
69 changes: 0 additions & 69 deletions lmdbjni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
<artifactId>hawtjni-runtime</artifactId>
<version>${hawtjni-version}</version>
</dependency>
<dependency>
<groupId>org.agrona</groupId>
<artifactId>Agrona</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -121,11 +116,6 @@
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.agrona:Agrona:*:*</exclude>
</excludes>
</artifactSet>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
</configuration>
Expand All @@ -138,65 +128,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>uk.co.real-logic</groupId>
<artifactId>sbe-all</artifactId>
</executableDependency>
<mainClass>uk.co.real_logic.sbe.SbeTool</mainClass>
<classpathScope>test</classpathScope>
<systemProperties>
<systemProperty>
<key>sbe.output.dir</key>
<value>${project.build.directory}/generated-sources/java</value>
</systemProperty>
</systemProperties>
<arguments>
<argument>${project.build.testResources[0].directory}/car.xml</argument>
</arguments>
<workingDirectory>${project.build.directory}/generated-sources/java</workingDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>uk.co.real-logic</groupId>
<artifactId>sbe-all</artifactId>
<version>1.4.0-RC4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
57 changes: 31 additions & 26 deletions lmdbjni/src/main/java/org/fusesource/lmdbjni/BufferCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.agrona.MutableDirectBuffer;

import static org.fusesource.lmdbjni.JNI.mdb_strerror;

Expand Down Expand Up @@ -121,15 +120,15 @@ public class BufferCursor implements AutoCloseable {
private final ByteBuffer keyByteBuffer;
private ByteBuffer valueByteBuffer;
private final boolean isReadOnly;
private MutableDirectBuffer key;
private MutableDirectBuffer value;
private DirectBuffer key;
private DirectBuffer value;
private boolean keyDatbaseMemoryLocation = false;
private boolean valDatbaseMemoryLocation = false;
private int keyWriteIndex = 0;
private int valWriteIndex = 0;
private boolean validPosition = false;

BufferCursor(Cursor cursor, MutableDirectBuffer key, MutableDirectBuffer value) {
BufferCursor(Cursor cursor, DirectBuffer key, DirectBuffer value) {
this.cursor = cursor;
this.isReadOnly = cursor.isReadOnly();
if (key.byteBuffer() == null) {
Expand All @@ -151,7 +150,7 @@ public class BufferCursor implements AutoCloseable {
}

BufferCursor(Cursor cursor, int maxValueSize) {
this(cursor, Buffers.buffer(), Buffers.buffer(maxValueSize));
this(cursor, new DirectBuffer(), new DirectBuffer(ByteBuffer.allocateDirect(maxValueSize)));
}

/**
Expand Down Expand Up @@ -334,8 +333,10 @@ public void close() {
* previously existing key.
*/
public boolean put() {
MutableDirectBuffer k = (keyWriteIndex != 0) ? Buffers.bufferSlice(key, keyWriteIndex) : key;
MutableDirectBuffer v = (valWriteIndex != 0) ? Buffers.bufferSlice(value, valWriteIndex) : value;
DirectBuffer k = (keyWriteIndex != 0) ?
new DirectBuffer(key.addressOffset(), keyWriteIndex) : key;
DirectBuffer v = (valWriteIndex != 0) ?
new DirectBuffer(value.addressOffset(), valWriteIndex) : value;
keyWriteIndex = 0;
valWriteIndex = 0;
int rc = cursor.put(k, v, Constants.NOOVERWRITE);
Expand All @@ -354,8 +355,10 @@ public boolean put() {
* previously existing key. Also used for adding duplicates.
*/
public boolean overwrite() {
MutableDirectBuffer k = (keyWriteIndex != 0) ? Buffers.bufferSlice(key, keyWriteIndex) : key;
MutableDirectBuffer v = (valWriteIndex != 0) ? Buffers.bufferSlice(value, valWriteIndex) : value;
DirectBuffer k = (keyWriteIndex != 0) ?
new DirectBuffer(key.addressOffset(), keyWriteIndex) : key;
DirectBuffer v = (valWriteIndex != 0) ?
new DirectBuffer(value.addressOffset(), valWriteIndex) : value;
keyWriteIndex = 0;
valWriteIndex = 0;
int rc = cursor.put(k, v, 0);
Expand All @@ -377,8 +380,10 @@ public boolean overwrite() {
* data corruption.
*/
public void append() {
MutableDirectBuffer k = (keyWriteIndex != 0) ? Buffers.bufferSlice(key, keyWriteIndex) : key;
MutableDirectBuffer v = (valWriteIndex != 0) ? Buffers.bufferSlice(value, valWriteIndex) : value;
DirectBuffer k = (keyWriteIndex != 0) ?
new DirectBuffer(key.addressOffset(), keyWriteIndex) : key;
DirectBuffer v = (valWriteIndex != 0) ?
new DirectBuffer(value.addressOffset(), valWriteIndex) : value;
keyWriteIndex = 0;
valWriteIndex = 0;
int rc = cursor.put(k, v, Constants.APPEND);
Expand Down Expand Up @@ -495,7 +500,7 @@ public BufferCursor keyWriteDouble(double data) {
*/
public BufferCursor keyWriteUtf8(ByteString data) {
setSafeKeyMemoryLocation();
Util.putString(this.key, keyWriteIndex, data);
this.key.putString(keyWriteIndex, data);
keyWriteIndex += data.size() + 1;
return this;
}
Expand All @@ -510,7 +515,7 @@ public BufferCursor keyWriteUtf8(ByteString data) {
public BufferCursor keyWriteUtf8(String data) {
setSafeKeyMemoryLocation();
ByteString bytes = new ByteString(data);
Util.putString(this.key, keyWriteIndex, bytes);
this.key.putString(keyWriteIndex, bytes);
keyWriteIndex += bytes.size() + 1;
return this;
}
Expand Down Expand Up @@ -553,7 +558,7 @@ public BufferCursor keyWriteBytes(byte[] data, int offset, int length) {
* @param capacity capacity
* @return this
*/
public BufferCursor keyWrite(MutableDirectBuffer buffer, int capacity) {
public BufferCursor keyWrite(DirectBuffer buffer, int capacity) {
setSafeKeyMemoryLocation();
this.key.putBytes(keyWriteIndex, buffer, 0, capacity);
keyWriteIndex += capacity;
Expand All @@ -563,7 +568,7 @@ public BufferCursor keyWrite(MutableDirectBuffer buffer, int capacity) {
/**
* @see org.fusesource.lmdbjni.BufferCursor#keyWrite(DirectBuffer, int)
*/
public BufferCursor keyWrite(MutableDirectBuffer buffer) {
public BufferCursor keyWrite(DirectBuffer buffer) {
keyWrite(buffer, buffer.capacity());
return this;
}
Expand Down Expand Up @@ -667,7 +672,7 @@ public double keyDouble(int pos) {
*/
public ByteString keyUtf8(int pos) {
checkForValidPosition();
return Util.getString(key, pos);
return this.key.getString(pos);
}

/**
Expand Down Expand Up @@ -698,14 +703,14 @@ public byte[] keyBytes() {
*
* @return underlying buffer
*/
public MutableDirectBuffer keyBuffer() {
public DirectBuffer keyBuffer() {
return key;
}

/**
* @return the key direct buffer at current position.
*/
public MutableDirectBuffer keyDirectBuffer() {
public DirectBuffer keyDirectBuffer() {
checkForValidPosition();
return key;
}
Expand Down Expand Up @@ -850,7 +855,7 @@ public BufferCursor valWriteUtf8(String data) {
setSafeValMemoryLocation();
ByteString bytes = new ByteString(data);
ensureValueWritableBytes(bytes.size() + 1);
Util.putString(this.value, valWriteIndex, bytes);
this.value.putString(valWriteIndex, bytes);
valWriteIndex += bytes.size() + 1;
return this;
}
Expand All @@ -868,7 +873,7 @@ public BufferCursor valWriteUtf8(ByteString data) {
}
setSafeValMemoryLocation();
ensureValueWritableBytes(data.size() + 1);
Util.putString(this.value, valWriteIndex, data);
this.value.putString(valWriteIndex, data);
valWriteIndex += data.size() + 1;
return this;
}
Expand Down Expand Up @@ -922,7 +927,7 @@ public BufferCursor valWriteBytes(byte[] data, int offset, int length) {
* @param length how many bytes to write
* @return this
*/
public BufferCursor valWrite(MutableDirectBuffer buffer, int srcIndex, int length) {
public BufferCursor valWrite(DirectBuffer buffer, int srcIndex, int length) {
if (isReadOnly) {
throw new LMDBException("Read only transaction", LMDBException.EACCES);
}
Expand All @@ -936,14 +941,14 @@ public BufferCursor valWrite(MutableDirectBuffer buffer, int srcIndex, int lengt
/**
* @see org.fusesource.lmdbjni.BufferCursor#valWrite(DirectBuffer, int, int)
*/
public BufferCursor valWrite(MutableDirectBuffer buffer, int length) {
public BufferCursor valWrite(DirectBuffer buffer, int length) {
return valWrite(buffer, 0, length);
}

/**
* @see org.fusesource.lmdbjni.BufferCursor#valWrite(DirectBuffer, int)
*/
public BufferCursor valWrite(MutableDirectBuffer buffer) {
public BufferCursor valWrite(DirectBuffer buffer) {
valWrite(buffer, 0, buffer.capacity());
return this;
}
Expand Down Expand Up @@ -1051,7 +1056,7 @@ public byte[] valBytes() {
*
* @return underlying buffer
*/
public MutableDirectBuffer valBuffer() {
public DirectBuffer valBuffer() {
return value;
}

Expand Down Expand Up @@ -1086,13 +1091,13 @@ public double valDouble(int pos) {
*/
public ByteString valUtf8(int pos) {
checkForValidPosition();
return Util.getString(this.value, pos);
return this.value.getString(pos);
}

/**
* @return the direct buffer at the current position.
*/
public MutableDirectBuffer valDirectBuffer() {
public DirectBuffer valDirectBuffer() {
checkForValidPosition();
return this.value;
}
Expand Down
Loading

0 comments on commit a17f85f

Please sign in to comment.