Skip to content

Commit

Permalink
2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedigerMoeller committed Nov 15, 2014
1 parent fc6a01f commit 16a3130
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 139 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java.util.zip.ZipFile

apply plugin: 'java'
apply plugin: 'maven'
version="2.10"
version="2.12"

targetCompatibility = 1.7
sourceCompatibility = 1.7
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
<version>2.11</version>
<version>2.12</version>

<description>a fast java serialization drop in-replacement + some serialization based utils (Structs, OffHeap Memory)</description>
<url>https://code.google.com/p/fast-serialization/</url>
Expand Down
138 changes: 3 additions & 135 deletions src/main/java/org/nustaq/offheap/OffHeapByteTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Created by ruedi on 29.06.14.
*
* A specialized offheap map [byte[] => long] using a tree structure internally.
* Nodes consist of sparse arrays.
*/
public class OffHeapByteTree {

Expand Down Expand Up @@ -456,141 +459,6 @@ public void dump(long arr) {

}


public static void main(String a[]) {
int klen = 3;
OffHeapByteTree bt = new OffHeapByteTree(klen, 100);

LeftCutStringByteSource kwrap = new LeftCutStringByteSource(null, 0, klen);
String keys[] = { "123","145" };
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
kwrap.setString(key);
long put = bt.put(kwrap, (long) i+1);
if (put != 0)
System.out.println("err " + i + "'" + key + "'" + put);
}
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
kwrap.setString(key);
System.out.println(" i "+key+" "+bt.get(kwrap));
}
dumpBT(bt);
System.out.println();


kwrap.setString(keys[0]);
System.out.println("get "+bt.get(kwrap));
bt.remove(kwrap);
System.out.println("get "+bt.get(kwrap));
dumpBT(bt);
System.out.println();

kwrap.setString(keys[1]);
System.out.println("get "+bt.get(kwrap));
bt.remove(kwrap);
System.out.println("get "+bt.get(kwrap));
dumpBT(bt);
System.out.println();
}

public static void _main(String a[]) {
int klen = 12;
OffHeapByteTree bt = new OffHeapByteTree(klen, 100);

long tim = System.currentTimeMillis();
LeftCutStringByteSource kwrap = new LeftCutStringByteSource(null, 0, klen);
// int MAX = 1000000;
int MAX = 5*1000000;
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
long put = bt.put(kwrap, (long) i);
if ( put != 0 )
System.out.println("err "+i+"'"+key+"'"+put);
}
long dur = System.currentTimeMillis() - tim+1;
System.out.println("PUT need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");
System.out.println(" used MB "+bt.baseOff/1024/1024);
dumpBT(bt);

tim = System.currentTimeMillis();
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
bt.put(kwrap, (long) i);
}
dur = System.currentTimeMillis() - tim+1;
System.out.println("REPUT need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");
System.out.println(" used MB "+bt.baseOff/1024/1024);
dumpBT(bt);

tim = System.currentTimeMillis();
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
long put = bt.get(kwrap);
if ( put != i )
System.out.println("err");
}
dur = System.currentTimeMillis() - tim+1;
System.out.println("GET need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");
System.out.println(" used MB "+bt.baseOff/1024/1024);

for ( int i = 0; i < 5; i++ ) {
System.gc();
System.out.println("mem "+(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/1024/1024+" MB");
}

kwrap.setString("test:99");
System.out.println("rem : " + bt.get(kwrap));
bt.remove(kwrap);
System.out.println(" get: " + bt.get(kwrap));

tim = System.currentTimeMillis();
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
bt.remove(kwrap);
}
dur = System.currentTimeMillis() - tim+1;
System.out.println("DEL need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");
System.out.println(" used MB "+bt.baseOff/1024/1024);
dumpBT(bt);
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
if ( bt.get(kwrap) != 0 )
System.out.println("err");
}
dumpBT(bt);

tim = System.currentTimeMillis();
for ( int i = 1; i < MAX; i++ ) {
String key = "test:"+i;
kwrap.setString(key);
bt.put(kwrap, (long) i);
}
dur = System.currentTimeMillis() - tim+1;
System.out.println("REPUT need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");
System.out.println(" used MB "+bt.baseOff/1024/1024);
dumpBT(bt);

// tim = System.currentTimeMillis();
// for ( int i = 0; i < MAX; i++ ) {
// String key = "test:"+i;
// kwrap.setString(key);
// Long put = bt.remove(kwrap);
// if ( put.longValue() != i )
// System.out.println("err");
// }
// bt.clean();
// System.out.println("ba count " + bacount);
// dur = System.currentTimeMillis() - tim+1;
// System.out.println("REMOVE need "+ dur +" for "+MAX+" recs. "+(MAX/dur)+" per ms ");

}

public static void dumpBT(OffHeapByteTree bt) {
for (int i = 0; i < bt.arrs.length; i++) {
PArray arr = bt.arrs[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public DefaultCoder() {

/**
* will throw an FSTBufferTooSmallException if buffer is too small.
* The required size is part of the exception.
*
*/
public int toByteArray( Object obj, byte result[], int resultOffset, int avaiableSize ) {
output.resetForReUse();
Expand Down

0 comments on commit 16a3130

Please sign in to comment.