if (!"COLLATIONS".equals(table)) {
stat2.execute("create table " + table + " as select * from information_schema." + table);
}
}
conn.close();
Compressor compress = new CompressLZF();
int pageSize = Constants.DEFAULT_PAGE_SIZE;
byte[] buff = new byte[pageSize];
byte[] test = new byte[2 * pageSize];
compress.compress(buff, pageSize, test, 0);
for (int j = 0; j < 4; j++) {
long time = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
InputStream in = FileSystem.getInstance("memFS:").openFileInputStream("memFS:compress.h2.db");
int total = 0;
while (true) {
int len = in.read(buff);
if (len < 0) {
break;
}
total += compress.compress(buff, pageSize, test, 0);
}
in.close();
}
System.out.println("compress: " + (System.currentTimeMillis() - time) + " ms");
}
for (int j = 0; j < 4; j++) {
ArrayList<byte[]> comp = New.arrayList();
InputStream in = FileSystem.getInstance("memFS:").openFileInputStream("memFS:compress.h2.db");
while (true) {
int len = in.read(buff);
if (len < 0) {
break;
}
int b = compress.compress(buff, pageSize, test, 0);
byte[] data = new byte[b];
System.arraycopy(test, 0, data, 0, b);
comp.add(data);
}
in.close();
byte[] result = new byte[pageSize];
long time = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
for (int k = 0; k < comp.size(); k++) {
byte[] data = comp.get(k);
compress.expand(data, 0, data.length, result, 0, pageSize);
}
}
System.out.println("expand: " + (System.currentTimeMillis() - time) + " ms");
}
}