Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jak lvové bijem o mříže, jak lvové v kleci jatí, my bychom vzhůru k nebesům a jsme zde Zemí spjatí. Nám zdá se, z hvězd že vane hlas: "Nuž pojďte, páni, blíže, jen trochu blíže, hrdobci, jimž hrouda nohy víže!" My přijdem! Odpusť, matičko, již jsi nám, Země, malá, my blesk k myšlénkám spřaháme a noha parou cvalá. My přijdem! Duch náš roste v výš a tepny touhou bijí, zimniční touhou po světech div srdce nerozbijí! My přijdem blíž, my přijdem blíž, my světů dožijeme, my bijem o mříž, ducha lvi, a my ji rozbijeme!
- Loading branch information
0 parents
commit 4efa487
Showing
32 changed files
with
9,908 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
JDBM4 provides HashMap and TreeMap backed by disk storage. It is fast and easy to use embedded Java database. | ||
|
||
Currently there is only early development version. There is not even user friendly API yet. | ||
Only ConcurrentHashMap is implemented. To test it use following code: | ||
|
||
import net.kotek.jdbm.*; | ||
RecordStore db = new RecordStoreCache("filename",true); | ||
HashMap2 map = new HashMap2(db,0L); | ||
//do something with map | ||
db.close() | ||
|
||
To reopen map you need to save its rootRecid between sessions: | ||
|
||
long rootRecid = map.rootRecid; //save this number somewhere | ||
//restart JVM or whatever, and latter reopen map: | ||
RecordStore db = new RecordStoreCache("filename",true); | ||
HashMap2 map = new HashMap2(db,rootRecid); | ||
//do something with map, it is populated with previous data | ||
db.close() | ||
|
||
|
||
What works (or should) | ||
|
||
* low level RecordStorage (basically Map<long,byte[]>) | ||
* serializers for most `java.lang.*` and `java.util.*` classes | ||
* Hard Reference Cache with autoclear on memory low | ||
* Full thread safety | ||
* Concurrent scalability should be nearly linear with number of cores (even writes) | ||
* All writes are done in background thread | ||
|
||
What is not there yet | ||
|
||
* Transactions | ||
* Weak/Soft/MRU cache | ||
* POJO serialization | ||
* TreeMap aka BTree | ||
* Friendly interface (DB & DBMaker) | ||
* Max record size is currently 64KB. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>net.kotek.jdbm</groupId> | ||
<artifactId>jdbm</artifactId> | ||
<version>4.0-SNAPSHOT</version> | ||
|
||
|
||
<developers> | ||
<developer> | ||
<name>Jan Kotek</name> | ||
<id>jan</id> | ||
</developer> | ||
</developers> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache 2</name> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.2</version> | ||
<type>jar</type> | ||
<scope>test</scope> | ||
<optional>false</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<target>1.5</target> | ||
<source>1.5</source> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>2.5</version> | ||
<configuration> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.1.2</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jar</goal> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- uncomment to enable proguard (strip down jar)--> | ||
<!-- | ||
<plugin> | ||
<groupId>com.pyx4me</groupId> | ||
<artifactId>proguard-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>proguard</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<options> | ||
<option>-allowaccessmodification</option> | ||
<option>-keep public class * { public *; public static *; }</option> | ||
</options> | ||
<libs> | ||
<lib>${java.home}/lib/rt.jar</lib> | ||
<lib>${java.home}/lib/jce.jar</lib> | ||
</libs> | ||
</configuration> | ||
</plugin> | ||
--> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.kotek.jdbm; | ||
|
||
/** | ||
* Compiler Configuration. | ||
* Static final booleans to enable/disable features you want. | ||
* Compiler and dead code elimination will take care of removing unwanted features from bytecode. | ||
*/ | ||
interface CC { | ||
|
||
/** | ||
* Compile with assertions. | ||
*/ | ||
boolean ASSERT = true; | ||
|
||
/** | ||
* Compile without trace logging statements (Logger.debug and Logger.trace) | ||
*/ | ||
boolean TRACE = true; | ||
|
||
/** | ||
* JDBM has some long running acceptance tests. For daily development it makes sense to skip those. | ||
* This flag controls whatever all tests are run. | ||
*/ | ||
boolean FULL_TEST = false; | ||
|
||
|
||
|
||
short STORE_FORMAT_VERSION = 10000 + 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package net.kotek.jdbm; | ||
|
||
import java.io.DataInput; | ||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* Wraps ByteBuffer and provides DataInput | ||
*/ | ||
public class DataInput2 implements DataInput { | ||
|
||
ByteBuffer buf; | ||
int pos; | ||
|
||
public DataInput2(final ByteBuffer buf, final int pos) { | ||
this.buf = buf; | ||
this.pos = pos; | ||
} | ||
|
||
@Override | ||
public void readFully(byte[] b) throws IOException { | ||
readFully(b, 0, b.length); | ||
} | ||
|
||
@Override | ||
public void readFully(byte[] b, int off, int len) throws IOException { | ||
//naive, but only thread safe way | ||
//TODO investigate | ||
for(int i=off;i<off+len;i++){ | ||
b[i] = readByte(); | ||
} | ||
} | ||
|
||
@Override | ||
public int skipBytes(final int n) throws IOException { | ||
pos +=n; | ||
return n; | ||
} | ||
|
||
@Override | ||
public boolean readBoolean() throws IOException { | ||
return buf.get(pos++) ==1; | ||
} | ||
|
||
@Override | ||
public byte readByte() throws IOException { | ||
return buf.get(pos++); | ||
} | ||
|
||
@Override | ||
public int readUnsignedByte() throws IOException { | ||
return buf.get(pos++)& 0xff; | ||
} | ||
|
||
@Override | ||
public short readShort() throws IOException { | ||
final short ret = buf.getShort(pos); | ||
pos+=2; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public int readUnsignedShort() throws IOException { | ||
return (((int) (buf.get(pos++) & 0xff) << 8) | | ||
((int) (buf.get(pos++) & 0xff))); | ||
} | ||
|
||
@Override | ||
public char readChar() throws IOException { | ||
return (char) readInt(); | ||
} | ||
|
||
@Override | ||
public int readInt() throws IOException { | ||
final int ret = buf.getInt(pos); | ||
pos+=4; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public long readLong() throws IOException { | ||
final long ret = buf.getLong(pos); | ||
pos+=8; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public float readFloat() throws IOException { | ||
final float ret = buf.getFloat(pos); | ||
pos+=4; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public double readDouble() throws IOException { | ||
final double ret = buf.getDouble(pos); | ||
pos+=8; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public String readLine() throws IOException { | ||
return readUTF(); | ||
} | ||
|
||
@Override | ||
public String readUTF() throws IOException { | ||
return SerializerBase.deserializeString(this); | ||
} | ||
} |
Oops, something went wrong.
4efa487
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for changing the package name from org.apache.jdbm to net.kotek.jdbm between version 3 and 4?
4efa487
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.