collocatordb: pmicubed dumper for vr app
diff --git a/Makefile b/Makefile
index ff8a9b0..47c5185 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,9 @@
dumpllr: dumpllr.cc collocatordb.h collocatordb.o Makefile
$(CXX) $(CXXFLAGS) -L. -L/usr/local/lib $@.cc -fopenmp -o$@ collocatordb.o /vol/work/kupietz/rocksdb/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+dumppmicubed: dumppmicubed.cc collocatordb.h collocatordb.o Makefile
+ $(CXX) $(CXXFLAGS) -L. -L/usr/local/lib $@.cc -fopenmp -o$@ collocatordb.o /vol/work/kupietz/rocksdb/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+
c_testcdb: c_testcdb.c collocatordb.h collocatordb.o Makefile
$(CC) $(CFLAGS) -L. -L/usr/local/lib $@.c -o$@ collocatordb.o -std=gnu99 -lstdc++ -lm -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS)
diff --git a/dumppmicubed.cc b/dumppmicubed.cc
new file mode 100644
index 0000000..3482da0
--- /dev/null
+++ b/dumppmicubed.cc
@@ -0,0 +1,44 @@
+#include <typeinfo>
+#include <assert.h>
+#include <memory>
+#include <iostream>
+#include <stdint.h>
+#include "collocatordb.h"
+#include <thread>
+#include <chrono>
+#include <sstream> // for ostringstream
+#include <fstream>
+
+using namespace rocksdb;
+
+
+int main(int argc, char** argv) {
+ const int START=1;
+ const int STOP=300000;
+ uint32_t *array;
+ int done = 0;
+
+ array = (uint32_t *)malloc(STOP * 20 * sizeof(uint32_t));
+ memset(array, 0, STOP * 20 * sizeof(uint32_t));
+ FILE* pFile;
+ CollocatorDB cdb = CollocatorDB(argv[1], true);
+ std::cerr << "Database " << argv[1] << " opened\n";
+ #pragma omp parallel for
+ for(uint32_t i=START; i< STOP; i++) {
+ std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i);
+ int j=0;
+ for (rocksdb::Collocator c : cs) {
+ array[i*20+j] = (uint32_t) c.w2;
+ if(++j >=20)
+ break;
+ }
+ if(done++ % 100 == 0) {
+ std::cerr <<"\r\033[2K"<<std::flush;
+ std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" <<std::flush;
+ }
+ }
+ pFile = fopen("file.binary", "wb");
+ fwrite(array, STOP*20, sizeof(uint32_t), pFile);
+ fclose(pFile);
+ std::cout << std::flush;
+}