65 lines
2.2 KiB
Java
65 lines
2.2 KiB
Java
package org.warp.jcwdb.ann.exampleimpl;
|
|
|
|
import org.warp.jcwdb.ann.DBDBObjectList;
|
|
import org.warp.jcwdb.ann.JCWDatabase;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Paths;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
long t0 = System.currentTimeMillis();
|
|
JCWDatabase db = new JCWDatabase(Paths.get("N:\\TimedTemp\\database_temp.db"), Paths.get("N:\\TimedTemp\\database_temp.idx"));
|
|
db.registerClass(Class1.class, 0);
|
|
db.registerClass(Class2.class, 1);
|
|
Class2 class1 = db.loadRoot(Class2.class);
|
|
long t1 = System.currentTimeMillis();
|
|
System.err.println("Loading took " + (t1-t0)/1000d + " seconds");
|
|
t0 = System.currentTimeMillis();
|
|
System.err.println("[MAIN] class1="+class1);
|
|
class1.value1 = "ciaoooooooooooooooooooooo";
|
|
class1.value2 = 3;
|
|
class1.value5 = 5;
|
|
System.err.println("[MAIN] value3="+class1.getValue3());
|
|
class1.setValue3("Ciao 3");
|
|
System.err.println("[MAIN] value3="+class1.getValue3());
|
|
|
|
System.err.println("[MAIN] propString="+class1.getValueStr());
|
|
class1.setValueStr("Ciao String");
|
|
System.err.println("[MAIN] propString="+class1.getValueStr());
|
|
|
|
System.err.println("[MAIN] getValue4="+class1.getValue4());
|
|
t1 = System.currentTimeMillis();
|
|
System.err.println("Post-loading took " + (t1-t0)/1000d + " seconds");
|
|
t0 = System.currentTimeMillis();
|
|
for (int i = 0; i < 200; i++) {
|
|
Class1 nested;
|
|
if ((nested = class1.getValue4()) == null) {
|
|
//System.err.println("[MAIN] Created nested class");
|
|
class1.setValue4(nested = new Class1(db));
|
|
}
|
|
nested.getValue3();
|
|
//System.err.println("[MAIN] value4="+class1.getValue4());
|
|
//System.err.println("[MAIN] nested value3="+nested.getValue3());
|
|
nested.setValue3("Ciao nested 3");
|
|
//System.err.println("[MAIN] nested value3=" + class1.getValue4().getValue3());
|
|
}
|
|
t1 = System.currentTimeMillis();
|
|
System.err.println("Took " + (t1-t0)/1000d + " seconds");
|
|
|
|
|
|
/*
|
|
if (class1.value4 == null) {
|
|
class1.value4 = new DBDBObjectList<>(db, 100, Class1.class);
|
|
}
|
|
for (int i = 0; i < 15; i++) {
|
|
Class1 c1 = new Class1(db);
|
|
c1.value1 = "" + i;
|
|
c1.value2 = i;
|
|
c1.setValueStr("" + i);
|
|
class1.value4.add(c1);
|
|
}*/
|
|
class1.value4 = new Class1(db);
|
|
}
|
|
} |