Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customized terarkzip default options/options.cc modification. problem as mentioned #247

Open
vipsland opened this issue Sep 7, 2022 · 4 comments

Comments

@vipsland
Copy link

vipsland commented Sep 7, 2022

i've edited options/options.cc with error below. can anyone pls help? coz i got the code to make all request defaulting to use terarkzip coz my NON-C++ language binding for rocksdb doesn't have the terarkzip option binding.

pls help. thx

/*
ColumnFamilyOptions::ColumnFamilyOptions()
    : compression(Snappy_Supported() ? kSnappyCompression : kNoCompression),
      table_factory(
          std::shared_ptr<TableFactory>(new BlockBasedTableFactory())) {}
//
*/

ColumnFamilyOptions::ColumnFamilyOptions()
    : compression(Snappy_Supported() ? kSnappyCompression : kNoCompression),
      table_factory(
          std::shared_ptr<TableFactory>(new BlockBasedTableFactory())) {
  TerarkZipTableOptions tzt_options;
  tzt_options.localTempDir = "/tmp";
  tzt_options.indexNestLevel = 3;
  tzt_options.sampleRatio = 0.01;
  tzt_options.terarkZipMinLevel = 2; // Start using TerarkZipTable from level 2
  // reset table...
  table_factory.reset(NewTerarkZipTableFactory(tzt_options, table_factory));
}
[ 88%] Built target terarkdb
[ 88%] Building CXX object CMakeFiles/table_reader_bench.dir/table/table_reader_bench.cc.o
[ 89%] Building CXX object CMakeFiles/cache_bench.dir/cache/cache_bench.cc.o
[ 89%] Building CXX object CMakeFiles/range_del_aggregator_bench.dir/db/range_del_aggregator_bench.cc.o
[ 90%] Building CXX object CMakeFiles/memtablerep_bench.dir/memtable/memtablerep_bench.cc.o
[ 90%] Linking CXX executable cache_bench
[ 91%] Linking CXX executable range_del_aggregator_bench
/usr/bin/ld: [ 91%] Linking CXX executable memtablerep_bench
libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:132: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
/usr/bin/ld: [ 92%] Linking CXX executable table_reader_bench
libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:132: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
/usr/bin/ld: collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/cache_bench.dir/build.make:108: cache_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:293: CMakeFiles/cache_bench.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:132: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/range_del_aggregator_bench.dir/build.make:108: range_del_aggregator_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:363: CMakeFiles/range_del_aggregator_bench.dir/all] Error 2
/usr/bin/ld: libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:132: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/memtablerep_bench.dir/build.make:108: memtablerep_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:328: CMakeFiles/memtablerep_bench.dir/all] Error 2
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/table_reader_bench.dir/build.make:108: table_reader_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:398: CMakeFiles/table_reader_bench.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
@vipsland vipsland changed the title customized terarkzip default options/options.cc modification. pls help customized terarkzip default options/options.cc modification. problem as mentioned Sep 7, 2022
@yapple
Copy link
Collaborator

yapple commented Sep 7, 2022

add header try again
#include "table/terark_zip_table.h"

@vipsland
Copy link
Author

vipsland commented Sep 7, 2022

i did but i get...

[ 91%] Linking CXX executable range_del_aggregator_bench
[ 91%] Linking CXX executable memtablerep_bench
[ 92%] Linking CXX executable table_reader_bench
/usr/bin/ld: /usr/bin/ld: libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:131: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:131: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/cache_bench.dir/build.make:108: cache_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:293: CMakeFiles/cache_bench.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/range_del_aggregator_bench.dir/build.make:108: range_del_aggregator_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:363: CMakeFiles/range_del_aggregator_bench.dir/all] Error 2
/usr/bin/ld: collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/memtablerep_bench.dir/build.make:108: memtablerep_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:328: CMakeFiles/memtablerep_bench.dir/all] Error 2
libterarkdb.a(options.cc.o): in function `terarkdb::ColumnFamilyOptions::ColumnFamilyOptions()':
/usr/local/src/src/terarkdb/options/options.cc:131: undefined reference to `terarkdb::NewTerarkZipTableFactory(terarkdb::TerarkZipTableOptions const&, std::shared_ptr<terarkdb::TableFactory>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/table_reader_bench.dir/build.make:108: table_reader_bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:398: CMakeFiles/table_reader_bench.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

@yapple
Copy link
Collaborator

yapple commented Sep 8, 2022

#include
#include "rocksdb/db.h"
#include "rocksdb/options.h"
#include "rocksdb/table.h"
#include "table/terark_zip_table.h"

rocksdb::DB* db;
rocksdb::Options options;

// Your db options here
options.create_if_missing = true;
options.wal_bytes_per_sync = 32768;
options.bytes_per_sync = 32768;

// TerarkZipTable need a fallback options because you can indicate which LSM level you want to start using TerarkZipTable
// For example, by setting tzt_options.terarkZipMinLevel = 2, TerarkDB will use your fallback Table on level 0 and 1.
std::shared_ptrrocksdb::TableFactory table_factory;
rocksdb::BlockBasedTableOptions blockbased_options;
blockbased_options.block_size = 8ULL << 10;
table_factory.reset(NewBlockBasedTableFactory(blockbased_options));

rocksdb::TerarkZipTableOptions tzt_options;
// TerarkZipTable requires a temp directory other than data directory, a slow device is acceptable
tzt_options.localTempDir = "/tmp";
tzt_options.indexNestLevel = 3;
tzt_options.sampleRatio = 0.01;
tzt_options.terarkZipMinLevel = 2; // Start using TerarkZipTable from level 2

table_factory.reset(
rocksdb::NewTerarkZipTableFactory(tzt_options, table_factory));

options.table_factory = table_factory;

// Open DB
auto status = rocksdb::DB::Open(options, "/tmp/testdb2", &db);

// Operations
std::string value;
auto s = db->Put(rocksdb::WriteOptions(), "key1", "value1");
s = db->Get(rocksdb::ReadOptions(), "key1", &value);
assert(s.ok());
assert("value1" == value);

s = db->Delete(rocksdb::WriteOptions(), "key1");
assert(s.ok());

is this your need?

@vipsland
Copy link
Author

vipsland commented Sep 8, 2022

no, i mean i'm ediitng this file directly
https://github.com/bytedance/terarkdb/blob/dev.1.4/options/options.cc

how to force it to use terarkzip as default? (doing so to make my language binding easier. no need to write binding)

the code i shown is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant