├── .gitignore ├── ChangeLog ├── LICENSE ├── Makefile ├── README.md ├── TODO ├── api ├── README.md ├── cpp │ ├── Doxyfile │ ├── Makefile │ ├── README.md │ ├── SSDB.h │ ├── SSDB_impl.cpp │ ├── SSDB_impl.h │ ├── demo.cpp │ └── hello-ssdb.cpp ├── cpy │ ├── SSDB.cpy │ └── demo.cpy ├── php │ ├── SSDB.php │ ├── demo.php │ └── perf.php └── python │ ├── SSDB.py │ └── demo.py ├── build.sh ├── deps ├── cpy │ ├── Eval.g │ ├── Eval.py │ ├── Expr.g │ ├── ExprLexer.py │ ├── ExprParser.py │ ├── Makefile │ ├── Readme.txt │ ├── antlr3 │ │ ├── __init__.py │ │ ├── compat.py │ │ ├── constants.py │ │ ├── dfa.py │ │ ├── dottreegen.py │ │ ├── exceptions.py │ │ ├── extras.py │ │ ├── main.py │ │ ├── recognizers.py │ │ ├── streams.py │ │ ├── tokens.py │ │ ├── tree.py │ │ └── treewizard.py │ ├── cpy │ ├── cpy.bat │ ├── cpy.py │ ├── engine.py │ └── samples │ │ ├── class.cpy │ │ ├── extends.cpy │ │ ├── foreach.cpy │ │ ├── function.cpy │ │ ├── hello.cpy │ │ ├── list.cpy │ │ ├── object.cpy │ │ ├── simple_client.cpy │ │ ├── simple_server.cpy │ │ ├── stdin.cpy │ │ └── test.cpy ├── jemalloc-3.3.1 │ ├── .gitignore │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile.in │ ├── README │ ├── VERSION │ ├── autogen.sh │ ├── bin │ │ ├── jemalloc.sh.in │ │ └── pprof │ ├── config.guess │ ├── config.stamp.in │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── doc │ │ ├── html.xsl │ │ ├── html.xsl.in │ │ ├── jemalloc.3 │ │ ├── jemalloc.html │ │ ├── jemalloc.xml │ │ ├── jemalloc.xml.in │ │ ├── manpages.xsl │ │ ├── manpages.xsl.in │ │ └── stylesheet.xsl │ ├── include │ │ ├── jemalloc │ │ │ ├── internal │ │ │ │ ├── arena.h │ │ │ │ ├── atomic.h │ │ │ │ ├── base.h │ │ │ │ ├── bitmap.h │ │ │ │ ├── chunk.h │ │ │ │ ├── chunk_dss.h │ │ │ │ ├── chunk_mmap.h │ │ │ │ ├── ckh.h │ │ │ │ ├── ctl.h │ │ │ │ ├── extent.h │ │ │ │ ├── hash.h │ │ │ │ ├── huge.h │ │ │ │ ├── jemalloc_internal.h.in │ │ │ │ ├── mb.h │ │ │ │ ├── mutex.h │ │ │ │ ├── private_namespace.h │ │ │ │ ├── prng.h │ │ │ │ ├── prof.h │ │ │ │ ├── ql.h │ │ │ │ ├── qr.h │ │ │ │ ├── quarantine.h │ │ │ │ ├── rb.h │ │ │ │ ├── rtree.h │ │ │ │ ├── size_classes.sh │ │ │ │ ├── stats.h │ │ │ │ ├── tcache.h │ │ │ │ ├── tsd.h │ │ │ │ └── util.h │ │ │ ├── jemalloc.h.in │ │ │ └── jemalloc_defs.h.in │ │ └── msvc_compat │ │ │ ├── inttypes.h │ │ │ ├── stdbool.h │ │ │ ├── stdint.h │ │ │ └── strings.h │ ├── install-sh │ ├── src │ │ ├── arena.c │ │ ├── atomic.c │ │ ├── base.c │ │ ├── bitmap.c │ │ ├── chunk.c │ │ ├── chunk_dss.c │ │ ├── chunk_mmap.c │ │ ├── ckh.c │ │ ├── ctl.c │ │ ├── extent.c │ │ ├── hash.c │ │ ├── huge.c │ │ ├── jemalloc.c │ │ ├── mb.c │ │ ├── mutex.c │ │ ├── prof.c │ │ ├── quarantine.c │ │ ├── rtree.c │ │ ├── stats.c │ │ ├── tcache.c │ │ ├── tsd.c │ │ ├── util.c │ │ └── zone.c │ └── test │ │ ├── ALLOCM_ARENA.c │ │ ├── ALLOCM_ARENA.exp │ │ ├── aligned_alloc.c │ │ ├── aligned_alloc.exp │ │ ├── allocated.c │ │ ├── allocated.exp │ │ ├── allocm.c │ │ ├── allocm.exp │ │ ├── bitmap.c │ │ ├── bitmap.exp │ │ ├── jemalloc_test.h.in │ │ ├── mremap.c │ │ ├── mremap.exp │ │ ├── posix_memalign.c │ │ ├── posix_memalign.exp │ │ ├── rallocm.c │ │ ├── rallocm.exp │ │ ├── thread_arena.c │ │ ├── thread_arena.exp │ │ ├── thread_tcache_enabled.c │ │ └── thread_tcache_enabled.exp ├── rocksdb-master │ ├── .arcconfig │ ├── .clang-format │ ├── .gitignore │ ├── .travis.yml │ ├── CONTRIBUTING.md │ ├── HISTORY.md │ ├── INSTALL.md │ ├── LICENSE │ ├── Makefile │ ├── PATENTS │ ├── README.md │ ├── ROCKSDB_LITE.md │ ├── build_tools │ │ ├── build_detect_platform │ │ ├── build_detect_version │ │ ├── fbcode.clang31.sh │ │ ├── fbcode.gcc471.sh │ │ ├── fbcode.gcc481.sh │ │ ├── format-diff.sh │ │ ├── mac-install-gflags.sh │ │ ├── make_new_version.sh │ │ ├── regression_build_test.sh │ │ └── valgrind_test.sh │ ├── coverage │ │ ├── coverage_test.sh │ │ └── parse_gcov_output.py │ ├── db │ │ ├── builder.cc │ │ ├── builder.h │ │ ├── c.cc │ │ ├── c_test.c │ │ ├── column_family.cc │ │ ├── column_family.h │ │ ├── column_family_test.cc │ │ ├── compaction.cc │ │ ├── compaction.h │ │ ├── compaction_picker.cc │ │ ├── compaction_picker.h │ │ ├── corruption_test.cc │ │ ├── db_bench.cc │ │ ├── db_filesnapshot.cc │ │ ├── db_impl.cc │ │ ├── db_impl.h │ │ ├── db_impl_debug.cc │ │ ├── db_impl_readonly.cc │ │ ├── db_impl_readonly.h │ │ ├── db_iter.cc │ │ ├── db_iter.h │ │ ├── db_iter_test.cc │ │ ├── db_test.cc │ │ ├── dbformat.cc │ │ ├── dbformat.h │ │ ├── dbformat_test.cc │ │ ├── deletefile_test.cc │ │ ├── file_indexer.cc │ │ ├── file_indexer.h │ │ ├── file_indexer_test.cc │ │ ├── filename.cc │ │ ├── filename.h │ │ ├── filename_test.cc │ │ ├── forward_iterator.cc │ │ ├── forward_iterator.h │ │ ├── internal_stats.cc │ │ ├── internal_stats.h │ │ ├── log_and_apply_bench.cc │ │ ├── log_format.h │ │ ├── log_reader.cc │ │ ├── log_reader.h │ │ ├── log_test.cc │ │ ├── log_writer.cc │ │ ├── log_writer.h │ │ ├── memtable.cc │ │ ├── memtable.h │ │ ├── memtable_list.cc │ │ ├── memtable_list.h │ │ ├── merge_context.h │ │ ├── merge_helper.cc │ │ ├── merge_helper.h │ │ ├── merge_operator.cc │ │ ├── merge_test.cc │ │ ├── perf_context_test.cc │ │ ├── plain_table_db_test.cc │ │ ├── prefix_test.cc │ │ ├── repair.cc │ │ ├── simple_table_db_test.cc │ │ ├── skiplist.h │ │ ├── skiplist_test.cc │ │ ├── snapshot.h │ │ ├── table_cache.cc │ │ ├── table_cache.h │ │ ├── table_properties_collector.cc │ │ ├── table_properties_collector.h │ │ ├── table_properties_collector_test.cc │ │ ├── tailing_iter.cc │ │ ├── tailing_iter.h │ │ ├── transaction_log_impl.cc │ │ ├── transaction_log_impl.h │ │ ├── version_edit.cc │ │ ├── version_edit.h │ │ ├── version_edit_test.cc │ │ ├── version_set.cc │ │ ├── version_set.h │ │ ├── version_set_test.cc │ │ ├── write_batch.cc │ │ ├── write_batch_internal.h │ │ └── write_batch_test.cc │ ├── doc │ │ ├── doc.css │ │ ├── index.html │ │ ├── log_format.txt │ │ ├── rockslogo.jpg │ │ └── rockslogo.png │ ├── examples │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.md │ │ ├── column_families_example.cc │ │ └── simple_example.cc │ ├── hdfs │ │ ├── README │ │ ├── env_hdfs.h │ │ └── setup.sh │ ├── helpers │ │ └── memenv │ │ │ ├── memenv.cc │ │ │ └── memenv_test.cc │ ├── include │ │ ├── rocksdb │ │ │ ├── c.h │ │ │ ├── cache.h │ │ │ ├── compaction_filter.h │ │ │ ├── comparator.h │ │ │ ├── db.h │ │ │ ├── env.h │ │ │ ├── filter_policy.h │ │ │ ├── flush_block_policy.h │ │ │ ├── iostats_context.h │ │ │ ├── iterator.h │ │ │ ├── ldb_tool.h │ │ │ ├── memtablerep.h │ │ │ ├── merge_operator.h │ │ │ ├── options.h │ │ │ ├── perf_context.h │ │ │ ├── rate_limiter.h │ │ │ ├── slice.h │ │ │ ├── slice_transform.h │ │ │ ├── statistics.h │ │ │ ├── status.h │ │ │ ├── table.h │ │ │ ├── table_properties.h │ │ │ ├── transaction_log.h │ │ │ ├── types.h │ │ │ ├── universal_compaction.h │ │ │ ├── utilities │ │ │ │ ├── backupable_db.h │ │ │ │ ├── db_ttl.h │ │ │ │ ├── document_db.h │ │ │ │ ├── geo_db.h │ │ │ │ ├── json_document.h │ │ │ │ ├── spatial_db.h │ │ │ │ ├── stackable_db.h │ │ │ │ └── utility_db.h │ │ │ ├── version.h │ │ │ └── write_batch.h │ │ └── utilities │ │ │ ├── backupable_db.h │ │ │ ├── db_ttl.h │ │ │ ├── document_db.h │ │ │ ├── geo_db.h │ │ │ ├── json_document.h │ │ │ ├── stackable_db.h │ │ │ └── utility_db.h │ ├── java │ │ ├── HISTORY-JAVA.md │ │ ├── Makefile │ │ ├── RocksDBSample.java │ │ ├── jdb_bench.sh │ │ ├── org │ │ │ └── rocksdb │ │ │ │ ├── BackupableDB.java │ │ │ │ ├── BackupableDBOptions.java │ │ │ │ ├── BloomFilter.java │ │ │ │ ├── CompactionStyle.java │ │ │ │ ├── CompressionType.java │ │ │ │ ├── Filter.java │ │ │ │ ├── HashLinkedListMemTableConfig.java │ │ │ │ ├── HashSkipListMemTableConfig.java │ │ │ │ ├── HistogramData.java │ │ │ │ ├── HistogramType.java │ │ │ │ ├── MemTableConfig.java │ │ │ │ ├── Options.java │ │ │ │ ├── PlainTableConfig.java │ │ │ │ ├── ReadOptions.java │ │ │ │ ├── RestoreBackupableDB.java │ │ │ │ ├── RestoreOptions.java │ │ │ │ ├── RocksDB.java │ │ │ │ ├── RocksDBException.java │ │ │ │ ├── RocksEnv.java │ │ │ │ ├── RocksIterator.java │ │ │ │ ├── RocksObject.java │ │ │ │ ├── SkipListMemTableConfig.java │ │ │ │ ├── Statistics.java │ │ │ │ ├── StatisticsCollector.java │ │ │ │ ├── StatisticsCollectorCallback.java │ │ │ │ ├── StatsCollectorInput.java │ │ │ │ ├── TableFormatConfig.java │ │ │ │ ├── TickerType.java │ │ │ │ ├── VectorMemTableConfig.java │ │ │ │ ├── WriteBatch.java │ │ │ │ ├── WriteBatchTest.java │ │ │ │ ├── WriteOptions.java │ │ │ │ ├── benchmark │ │ │ │ └── DbBenchmark.java │ │ │ │ ├── test │ │ │ │ ├── BackupableDBTest.java │ │ │ │ ├── OptionsTest.java │ │ │ │ ├── ReadOptionsTest.java │ │ │ │ ├── StatisticsCollectorTest.java │ │ │ │ └── StatsCallbackMock.java │ │ │ │ └── util │ │ │ │ ├── Environment.java │ │ │ │ └── SizeUnit.java │ │ └── rocksjni │ │ │ ├── backupablejni.cc │ │ │ ├── env.cc │ │ │ ├── filter.cc │ │ │ ├── iterator.cc │ │ │ ├── memtablejni.cc │ │ │ ├── options.cc │ │ │ ├── portal.h │ │ │ ├── restorejni.cc │ │ │ ├── rocksjni.cc │ │ │ ├── statistics.cc │ │ │ ├── table.cc │ │ │ └── write_batch.cc │ ├── linters │ │ ├── __phutil_library_init__.php │ │ ├── __phutil_library_map__.php │ │ ├── cpp_linter │ │ │ ├── ArcanistCpplintLinter.php │ │ │ ├── FbcodeCppLinter.php │ │ │ ├── PfffCppLinter.php │ │ │ └── cpplint.py │ │ └── lint_engine │ │ │ └── FacebookFbcodeLintEngine.php │ ├── port │ │ ├── README │ │ ├── atomic_pointer.h │ │ ├── likely.h │ │ ├── port.h │ │ ├── port_example.h │ │ ├── port_posix.cc │ │ ├── port_posix.h │ │ ├── stack_trace.cc │ │ ├── stack_trace.h │ │ └── win │ │ │ └── stdint.h │ ├── table │ │ ├── adaptive_table_factory.cc │ │ ├── adaptive_table_factory.h │ │ ├── block.cc │ │ ├── block.h │ │ ├── block_based_table_builder.cc │ │ ├── block_based_table_builder.h │ │ ├── block_based_table_factory.cc │ │ ├── block_based_table_factory.h │ │ ├── block_based_table_reader.cc │ │ ├── block_based_table_reader.h │ │ ├── block_builder.cc │ │ ├── block_builder.h │ │ ├── block_hash_index.cc │ │ ├── block_hash_index.h │ │ ├── block_hash_index_test.cc │ │ ├── block_prefix_index.cc │ │ ├── block_prefix_index.h │ │ ├── block_test.cc │ │ ├── bloom_block.cc │ │ ├── bloom_block.h │ │ ├── cuckoo_table_builder.cc │ │ ├── cuckoo_table_builder.h │ │ ├── cuckoo_table_builder_test.cc │ │ ├── cuckoo_table_factory.h │ │ ├── cuckoo_table_reader.cc │ │ ├── cuckoo_table_reader.h │ │ ├── cuckoo_table_reader_test.cc │ │ ├── filter_block.cc │ │ ├── filter_block.h │ │ ├── filter_block_test.cc │ │ ├── flush_block_policy.cc │ │ ├── format.cc │ │ ├── format.h │ │ ├── iter_heap.h │ │ ├── iterator.cc │ │ ├── iterator_wrapper.h │ │ ├── merger.cc │ │ ├── merger.h │ │ ├── meta_blocks.cc │ │ ├── meta_blocks.h │ │ ├── plain_table_builder.cc │ │ ├── plain_table_builder.h │ │ ├── plain_table_factory.cc │ │ ├── plain_table_factory.h │ │ ├── plain_table_index.cc │ │ ├── plain_table_index.h │ │ ├── plain_table_key_coding.cc │ │ ├── plain_table_key_coding.h │ │ ├── plain_table_reader.cc │ │ ├── plain_table_reader.h │ │ ├── table_builder.h │ │ ├── table_properties.cc │ │ ├── table_reader.h │ │ ├── table_reader_bench.cc │ │ ├── table_test.cc │ │ ├── two_level_iterator.cc │ │ └── two_level_iterator.h │ ├── third-party │ │ └── rapidjson │ │ │ ├── document.h │ │ │ ├── filestream.h │ │ │ ├── internal │ │ │ ├── pow10.h │ │ │ ├── stack.h │ │ │ └── strfunc.h │ │ │ ├── license.txt │ │ │ ├── prettywriter.h │ │ │ ├── rapidjson.h │ │ │ ├── reader.h │ │ │ ├── stringbuffer.h │ │ │ └── writer.h │ ├── tools │ │ ├── auto_sanity_test.sh │ │ ├── blob_store_bench.cc │ │ ├── db_crashtest.py │ │ ├── db_crashtest2.py │ │ ├── db_repl_stress.cc │ │ ├── db_sanity_test.cc │ │ ├── db_stress.cc │ │ ├── ldb.cc │ │ ├── ldb_test.py │ │ ├── reduce_levels_test.cc │ │ └── sst_dump.cc │ ├── util │ │ ├── arena.cc │ │ ├── arena.h │ │ ├── arena_test.cc │ │ ├── auto_roll_logger.cc │ │ ├── auto_roll_logger.h │ │ ├── auto_roll_logger_test.cc │ │ ├── autovector.h │ │ ├── autovector_test.cc │ │ ├── benchharness.cc │ │ ├── benchharness.h │ │ ├── benchharness_test.cc │ │ ├── blob_store.cc │ │ ├── blob_store.h │ │ ├── blob_store_test.cc │ │ ├── bloom.cc │ │ ├── bloom_test.cc │ │ ├── build_version.h │ │ ├── cache.cc │ │ ├── cache_test.cc │ │ ├── coding.cc │ │ ├── coding.h │ │ ├── coding_test.cc │ │ ├── comparator.cc │ │ ├── crc32c.cc │ │ ├── crc32c.h │ │ ├── crc32c_test.cc │ │ ├── dynamic_bloom.cc │ │ ├── dynamic_bloom.h │ │ ├── dynamic_bloom_test.cc │ │ ├── env.cc │ │ ├── env_hdfs.cc │ │ ├── env_posix.cc │ │ ├── env_test.cc │ │ ├── filelock_test.cc │ │ ├── filter_policy.cc │ │ ├── hash.cc │ │ ├── hash.h │ │ ├── hash_cuckoo_rep.cc │ │ ├── hash_cuckoo_rep.h │ │ ├── hash_linklist_rep.cc │ │ ├── hash_linklist_rep.h │ │ ├── hash_skiplist_rep.cc │ │ ├── hash_skiplist_rep.h │ │ ├── histogram.cc │ │ ├── histogram.h │ │ ├── histogram_test.cc │ │ ├── iostats_context.cc │ │ ├── iostats_context_imp.h │ │ ├── ldb_cmd.cc │ │ ├── ldb_cmd.h │ │ ├── ldb_cmd_execute_result.h │ │ ├── ldb_tool.cc │ │ ├── log_buffer.cc │ │ ├── log_buffer.h │ │ ├── log_write_bench.cc │ │ ├── logging.cc │ │ ├── logging.h │ │ ├── manual_compaction_test.cc │ │ ├── murmurhash.cc │ │ ├── murmurhash.h │ │ ├── mutexlock.h │ │ ├── options.cc │ │ ├── options_builder.cc │ │ ├── options_test.cc │ │ ├── perf_context.cc │ │ ├── perf_context_imp.h │ │ ├── posix_logger.h │ │ ├── random.h │ │ ├── rate_limiter.cc │ │ ├── rate_limiter.h │ │ ├── rate_limiter_test.cc │ │ ├── signal_test.cc │ │ ├── skiplistrep.cc │ │ ├── slice.cc │ │ ├── statistics.cc │ │ ├── statistics.h │ │ ├── status.cc │ │ ├── stl_wrappers.h │ │ ├── stop_watch.h │ │ ├── string_util.cc │ │ ├── string_util.h │ │ ├── sync_point.cc │ │ ├── sync_point.h │ │ ├── testharness.cc │ │ ├── testharness.h │ │ ├── testutil.cc │ │ ├── testutil.h │ │ ├── thread_local.cc │ │ ├── thread_local.h │ │ ├── thread_local_test.cc │ │ ├── vectorrep.cc │ │ ├── xxhash.cc │ │ └── xxhash.h │ └── utilities │ │ ├── backupable │ │ ├── backupable_db.cc │ │ └── backupable_db_test.cc │ │ ├── document │ │ ├── document_db.cc │ │ ├── document_db_test.cc │ │ ├── json_document.cc │ │ └── json_document_test.cc │ │ ├── geodb │ │ ├── geodb_impl.cc │ │ ├── geodb_impl.h │ │ └── geodb_test.cc │ │ ├── merge_operators.h │ │ ├── merge_operators │ │ ├── put.cc │ │ ├── string_append │ │ │ ├── stringappend.cc │ │ │ ├── stringappend.h │ │ │ ├── stringappend2.cc │ │ │ ├── stringappend2.h │ │ │ └── stringappend_test.cc │ │ └── uint64add.cc │ │ ├── redis │ │ ├── README │ │ ├── redis_list_exception.h │ │ ├── redis_list_iterator.h │ │ ├── redis_lists.cc │ │ ├── redis_lists.h │ │ └── redis_lists_test.cc │ │ ├── spatialdb │ │ ├── spatial_db.cc │ │ ├── spatial_db_test.cc │ │ └── utils.h │ │ └── ttl │ │ ├── db_ttl_impl.cc │ │ ├── db_ttl_impl.h │ │ └── ttl_test.cc └── snappy-1.1.0 │ ├── .gitignore │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── aclocal.m4 │ ├── autogen.sh │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── depcomp │ ├── format_description.txt │ ├── framing_format.txt │ ├── install-sh │ ├── ltmain.sh │ ├── m4 │ └── gtest.m4 │ ├── missing │ ├── snappy-c.cc │ ├── snappy-c.h │ ├── snappy-internal.h │ ├── snappy-sinksource.cc │ ├── snappy-sinksource.h │ ├── snappy-stubs-internal.cc │ ├── snappy-stubs-internal.h │ ├── snappy-stubs-public.h │ ├── snappy-stubs-public.h.in │ ├── snappy-test.cc │ ├── snappy-test.h │ ├── snappy.cc │ ├── snappy.h │ └── snappy_unittest.cc ├── src ├── Makefile ├── backend_dump.cpp ├── backend_dump.h ├── backend_sync.cpp ├── backend_sync.h ├── binlog.cpp ├── binlog.h ├── include.h ├── iterator.cpp ├── iterator.h ├── link.cpp ├── link.h ├── link_redis.cpp ├── link_redis.h ├── proc_hash.cpp ├── proc_kv.cpp ├── proc_queue.cpp ├── proc_zset.cpp ├── serv.cpp ├── serv.h ├── slave.cpp ├── slave.h ├── ssdb-server.cpp ├── ssdb.cpp ├── ssdb.h ├── t_hash.cpp ├── t_hash.h ├── t_kv.cpp ├── t_kv.h ├── t_queue.cpp ├── t_queue.h ├── t_zset.cpp ├── t_zset.h ├── ttl.cpp ├── ttl.h ├── util │ ├── Makefile │ ├── bytes.cpp │ ├── bytes.h │ ├── config.cpp │ ├── config.h │ ├── daemon.h │ ├── fde.cpp │ ├── fde.h │ ├── fde_epoll.cpp │ ├── fde_select.cpp │ ├── file.h │ ├── ip_filter.h │ ├── log.cpp │ ├── log.h │ ├── sorted_set.cpp │ ├── sorted_set.h │ ├── strings.h │ ├── test_sorted_set.cpp │ └── thread.h └── version.h ├── ssdb.conf ├── ssdb_slave.conf ├── tools ├── Makefile ├── leveldb-import.cpp ├── redis-import.php ├── ssdb-bench.cpp ├── ssdb-cli ├── ssdb-cli.cpy ├── ssdb-dump.cpp ├── ssdb-ins.sh ├── ssdb-repair.cpp ├── ssdb.sh └── unittest.php └── version /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *.class 4 | .DS_Store 5 | *.pyc 6 | var/* 7 | var_slave/* 8 | dev_ssdb.conf 9 | *.swp 10 | *_cpy_* 11 | ssdb-server 12 | tools/ssdb-dump 13 | tools/ssdb-bench 14 | tools/ssdb-repair 15 | tools/leveldb-import 16 | _pack 17 | build_config.mk 18 | log.txt 19 | log_slave.txt 20 | api/cpp/demo 21 | api/cpp/hello-ssdb 22 | api/cpp/test 23 | api/cpp/html 24 | api/php/a.php 25 | api/php/c.php 26 | api/java/Test.java 27 | src/util/test_sorted_set 28 | deps/rocksdb-master/include/leveldb 29 | deps/rocksdb-master/include/rocksdb/rocksdb 30 | 31 | 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 SSDB Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the SSDB nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX=/usr/local/ssdb 2 | 3 | $(shell sh build.sh 1>&2) 4 | include build_config.mk 5 | 6 | all: 7 | chmod u+x deps/cpy/cpy 8 | chmod u+x tools/ssdb-cli 9 | cd "${LEVELDB_PATH}"; ${MAKE} static_lib 10 | cd src/util; ${MAKE} 11 | cd src; ${MAKE} 12 | cd tools; ${MAKE} 13 | 14 | install: 15 | mkdir -p ${PREFIX} 16 | mkdir -p ${PREFIX}/_cpy_ 17 | mkdir -p ${PREFIX}/deps 18 | mkdir -p ${PREFIX}/var 19 | mkdir -p ${PREFIX}/var_slave 20 | cp ssdb-server ssdb.conf ssdb_slave.conf ${PREFIX} 21 | cp -r api ${PREFIX} 22 | cp -r \ 23 | tools/ssdb-bench tools/ssdb-cli \ 24 | tools/ssdb-cli.cpy tools/ssdb-dump \ 25 | tools/ssdb-ins.sh tools/unittest.php \ 26 | ${PREFIX} 27 | cp -r deps/cpy ${PREFIX}/deps 28 | chmod ugo+rwx ${PREFIX} 29 | chmod -R ugo+rw ${PREFIX} 30 | rm -f ${PREFIX}/Makefile 31 | 32 | clean: 33 | rm -f *.exe.stackdump 34 | rm -rf api/cpy/_cpy_ 35 | rm -f api/python/SSDB.pyc 36 | rm -rf db_test 37 | cd deps/cpy; ${MAKE} clean 38 | cd src/util; ${MAKE} clean 39 | cd src; ${MAKE} clean 40 | cd tools; ${MAKE} clean 41 | 42 | clean_all: clean 43 | cd "${LEVELDB_PATH}"; ${MAKE} clean 44 | rm -f ${JEMALLOC_PATH}/Makefile 45 | rm -f ${SNAPPY_PATH}/Makefile 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ssdb-rocks 2 | ========== 3 | 4 | [ssdb](https://github.com/ideawu/ssdb) with rocksdb 5 | 6 | [ssdb.io](http://ssdb.io/) 7 | 8 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * add ping command 2 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | See https://github.com/ssdb 2 | -------------------------------------------------------------------------------- /api/cpp/Makefile: -------------------------------------------------------------------------------- 1 | include ../../build_config.mk 2 | 3 | all: lib 4 | ${CXX} -o demo demo.cpp libssdb.a 5 | ${CXX} -o hello-ssdb hello-ssdb.cpp libssdb.a 6 | 7 | lib: SSDB.h SSDB_impl.h SSDB_impl.cpp 8 | ${CXX} -I../../src ${CFLAGS} -c SSDB_impl.cpp 9 | ar -cru libssdb.a\ 10 | SSDB_impl.o\ 11 | ../../src/util/bytes.o\ 12 | ../../src/util/log.o\ 13 | ../../src/link.o 14 | 15 | clean: 16 | rm -f demo hello-ssdb libssdb.a SSDB_impl.o 17 | -------------------------------------------------------------------------------- /api/cpp/README.md: -------------------------------------------------------------------------------- 1 | SSDB C++ API Documentation {#mainpage} 2 | ============ 3 | 4 | @author: [ideawu](http://www.ideawu.com/) 5 | 6 | ## Build the static library(libssdb.a) 7 | 8 | Download the SSDB source code from [github](https://github.com/ideawu/ssdb). 9 | 10 | make 11 | cd api/cpp 12 | make 13 | 14 | The shell commands above will compile the C++ API codes, and generate a `libssdb.a` file. 15 | 16 | ## Sample code 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "SSDB.h" 23 | 24 | int main(int argc, char **argv){ 25 | const char *ip = (argc >= 2)? argv[1] : "127.0.0.1"; 26 | int port = (argc >= 3)? atoi(argv[2]) : 8888; 27 | 28 | ssdb::Client *client = ssdb::Client::connect(ip, port); 29 | if(client == NULL){ 30 | printf("fail to connect to server!\n"); 31 | return 0; 32 | } 33 | 34 | ssdb::Status s; 35 | s = client->set("k", "hello ssdb!"); 36 | if(s.ok()){ 37 | printf("k = hello ssdb!\n"); 38 | }else{ 39 | printf("error!\n"); 40 | } 41 | 42 | delete client; 43 | return 0; 44 | } 45 | 46 | Save the codes above into a file named `hello-ssdb.cpp`. 47 | 48 | ## Compile sample code 49 | 50 | If you are under the directory `api/cpp`, compile it like this 51 | 52 | g++ -o hello-ssdb hello-ssdb.cpp libssdb.a 53 | ./hello-ssdb 54 | 55 | Before you run `hello-ssdb`, you have to start ssdb-server with the default configuration. The output would be like 56 | 57 | k = hello ssdb! 58 | 59 | Connect to ssdb-server with `ssdb-cli`, to verify the key `k` is stored with the value "hello ssdb!". 60 | 61 | If your `hello-ssdb.cpp` file is not under the directory `api/cpp`, you will compile it like this 62 | 63 | g++ -o hello-ssdb -I hello-ssdb.cpp /libssdb.a 64 | 65 | -------------------------------------------------------------------------------- /api/cpp/hello-ssdb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "SSDB.h" 6 | 7 | int main(int argc, char **argv){ 8 | const char *ip = (argc >= 2)? argv[1] : "127.0.0.1"; 9 | int port = (argc >= 3)? atoi(argv[2]) : 8888; 10 | 11 | ssdb::Client *client = ssdb::Client::connect(ip, port); 12 | if(client == NULL){ 13 | printf("fail to connect to server!\n"); 14 | return 0; 15 | } 16 | 17 | ssdb::Status s; 18 | s = client->set("k", "hello ssdb!"); 19 | if(s.ok()){ 20 | printf("k = hello ssdb!\n"); 21 | }else{ 22 | printf("error!\n"); 23 | } 24 | std::string val; 25 | s = client->get("k", &val); 26 | printf("length: %d\n", (int)val.size()); 27 | 28 | delete client; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /api/cpy/demo.cpy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012, ideawu 3 | * All rights reserved. 4 | * @author: ideawu 5 | * @link: http://www.ideawu.com/ 6 | * 7 | * SSDB cpy API demo. 8 | */ 9 | 10 | import SSDB.SSDB; 11 | 12 | try{ 13 | ssdb = new SSDB('127.0.0.1', 8888); 14 | }catch(Exception e){ 15 | print e; 16 | sys.exit(0); 17 | } 18 | 19 | print(ssdb.request('set', ['test', '123'])); 20 | print(ssdb.request('get', ['test'])); 21 | print(ssdb.request('incr', ['test', '1'])); 22 | print(ssdb.request('decr', ['test', '1'])); 23 | print(ssdb.request('scan', ['a', 'z', 10])); 24 | print(ssdb.request('rscan', ['z', 'a', 10])); 25 | print(ssdb.request('keys', ['a', 'z', 10])); 26 | print(ssdb.request('del', ['test'])); 27 | print(ssdb.request('get', ['test'])); 28 | print "\n"; 29 | print(ssdb.request('zset', ['test', 'a', 20])); 30 | print(ssdb.request('zget', ['test', 'a'])); 31 | print(ssdb.request('zincr', ['test', 'a', 20])); 32 | print(ssdb.request('zdecr', ['test', 'a', 20])); 33 | print(ssdb.request('zscan', ['test', 'a', 0, 100, 10])); 34 | print(ssdb.request('zrscan', ['test', 'a', 100, 0, 10])); 35 | print(ssdb.request('zkeys', ['test', 'a', 0, 100, 10])); 36 | print(ssdb.request('zdel', ['test', 'a'])); 37 | print(ssdb.request('zget', ['test', 'a'])); 38 | print "\n"; 39 | print(ssdb.request('hset', ['test', 'a', 20])); 40 | print(ssdb.request('hget', ['test', 'a'])); 41 | print(ssdb.request('hincr', ['test', 'a', 20])); 42 | print(ssdb.request('hdecr', ['test', 'a', 20])); 43 | print(ssdb.request('hscan', ['test', '0', 'z', 10])); 44 | print(ssdb.request('hrscan', ['test', 'z', '0', 10])); 45 | print(ssdb.request('hkeys', ['test', '0', 'z', 10])); 46 | print(ssdb.request('hdel', ['test', 'a'])); 47 | print(ssdb.request('hget', ['test', 'a'])); 48 | print "\n"; 49 | -------------------------------------------------------------------------------- /api/php/perf.php: -------------------------------------------------------------------------------- 1 | set('key', $str); 9 | 10 | 11 | $keys = array( 12 | 'seq' => array(), 13 | ); 14 | for($i=0; $i<1000; $i++){ 15 | $key = sprintf('%010s', $i); 16 | $keys['seq'][] = $key; 17 | } 18 | 19 | $REQUESTS = 1000; 20 | $stime = 0; 21 | $etime = 0; 22 | 23 | 24 | start(); 25 | foreach($keys['seq'] as $key){ 26 | $resp = $ssdb->set($key, $str); 27 | } 28 | output('writeseq'); 29 | 30 | $ks = $keys['seq']; 31 | shuffle($ks); 32 | start(); 33 | foreach($ks as $key){ 34 | $resp = $ssdb->set($key, $str); 35 | } 36 | output('writerand'); 37 | 38 | start(); 39 | foreach($keys['seq'] as $key){ 40 | $resp = $ssdb->get($key); 41 | if(strlen($resp) != $DATA_LEN){ 42 | echo "$key ERROR!\n"; 43 | die(); 44 | } 45 | } 46 | output('readseq'); 47 | 48 | 49 | $ks = $keys['seq']; 50 | shuffle($ks); 51 | start(); 52 | foreach($ks as $key){ 53 | $resp = $ssdb->get($key); 54 | if(strlen($resp) != $DATA_LEN){ 55 | echo "$key ERROR!\n"; 56 | die(); 57 | } 58 | } 59 | output('readrand'); 60 | 61 | 62 | 63 | 64 | function start(){ 65 | global $stime, $etime, $DATA_LEN, $REQUESTS; 66 | $stime = microtime(1); 67 | } 68 | 69 | function output($op){ 70 | global $stime, $etime, $DATA_LEN, $REQUESTS; 71 | $etime = microtime(1); 72 | $time_consumed = $etime - $stime; 73 | $tpr = $time_consumed/$REQUESTS * 1000; 74 | $sps = ($REQUESTS * $DATA_LEN)/$time_consumed/1024/1024; 75 | printf("%-10s: %8s ms/op %10.1f MB/s\n", $op, number_format($tpr, 3), $sps);// . "ms/op\n"; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /api/python/demo.py: -------------------------------------------------------------------------------- 1 | # encoding=utf-8 2 | # Generated by cpy 3 | # 2013-01-26 21:04:47.984000 4 | import os, sys 5 | from sys import stdin, stdout 6 | 7 | from SSDB import SSDB 8 | try: 9 | pass 10 | ssdb = SSDB('127.0.0.1', 8888) 11 | except Exception , e: 12 | pass 13 | print e 14 | sys.exit(0) 15 | print ssdb.request('set', ['test', '123']) 16 | print ssdb.request('get', ['test']) 17 | print ssdb.request('incr', ['test', '1']) 18 | print ssdb.request('decr', ['test', '1']) 19 | print ssdb.request('scan', ['a', 'z', 10]) 20 | print ssdb.request('rscan', ['z', 'a', 10]) 21 | print ssdb.request('keys', ['a', 'z', 10]) 22 | print ssdb.request('del', ['test']) 23 | print ssdb.request('get', ['test']) 24 | print "\n" 25 | print ssdb.request('zset', ['test', 'a', 20]) 26 | print ssdb.request('zget', ['test', 'a']) 27 | print ssdb.request('zincr', ['test', 'a', 20]) 28 | print ssdb.request('zdecr', ['test', 'a', 20]) 29 | print ssdb.request('zscan', ['test', 'a', 0, 100, 10]) 30 | print ssdb.request('zrscan', ['test', 'a', 100, 0, 10]) 31 | print ssdb.request('zkeys', ['test', 'a', 0, 100, 10]) 32 | print ssdb.request('zdel', ['test', 'a']) 33 | print ssdb.request('zget', ['test', 'a']) 34 | print "\n" 35 | print ssdb.request('hset', ['test', 'a', 20]) 36 | print ssdb.request('hget', ['test', 'a']) 37 | print ssdb.request('hincr', ['test', 'a', 20]) 38 | print ssdb.request('hdecr', ['test', 'a', 20]) 39 | print ssdb.request('hscan', ['test', '0', 'z', 10]) 40 | print ssdb.request('hrscan', ['test', 'z', '0', 10]) 41 | print ssdb.request('hkeys', ['test', '0', 'z', 10]) 42 | print ssdb.request('hdel', ['test', 'a']) 43 | print ssdb.request('hget', ['test', 'a']) 44 | print "\n" 45 | -------------------------------------------------------------------------------- /deps/cpy/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: antlr test 3 | 4 | antlr: 5 | java -jar ../antlr-3.4-complete.jar Expr.g Eval.g 6 | 7 | lexer: 8 | java -jar ../antlr-3.4-complete.jar Expr.g 9 | python test_lexer.py test.cpy 10 | 11 | test: 12 | python cpy.py test.cpy 13 | 14 | run: 15 | python a.py 16 | 17 | clean: 18 | rm -rf _cpy_ 19 | rm -f *.pyc 20 | rm -f antlr3/*.pyc 21 | -------------------------------------------------------------------------------- /deps/cpy/Readme.txt: -------------------------------------------------------------------------------- 1 | ********************************************** 2 | * Author: ideawu 3 | * Link: http://www.ideawu.net/ 4 | * Cpy - Cpy provides you a way to write Python 5 | * codes in C syntax! 6 | ********************************************** 7 | 8 | * Run the samples 9 | $ ./cpy samples/hello.cpy 10 | 11 | * Compile Antlr grammar files 12 | $ make antlr 13 | -------------------------------------------------------------------------------- /deps/cpy/antlr3/compat.py: -------------------------------------------------------------------------------- 1 | """Compatibility stuff""" 2 | 3 | # begin[licence] 4 | # 5 | # [The "BSD licence"] 6 | # Copyright (c) 2005-2008 Terence Parr 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions 11 | # are met: 12 | # 1. Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 2. Redistributions in binary form must reproduce the above copyright 15 | # notice, this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # 3. The name of the author may not be used to endorse or promote products 18 | # derived from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | # end[licence] 32 | 33 | try: 34 | set = set 35 | frozenset = frozenset 36 | except NameError: 37 | from sets import Set as set, ImmutableSet as frozenset 38 | 39 | 40 | try: 41 | reversed = reversed 42 | except NameError: 43 | def reversed(l): 44 | l = l[:] 45 | l.reverse() 46 | return l 47 | 48 | 49 | -------------------------------------------------------------------------------- /deps/cpy/antlr3/extras.py: -------------------------------------------------------------------------------- 1 | """ @package antlr3.dottreegenerator 2 | @brief ANTLR3 runtime package, tree module 3 | 4 | This module contains all support classes for AST construction and tree parsers. 5 | 6 | """ 7 | 8 | # begin[licence] 9 | # 10 | # [The "BSD licence"] 11 | # Copyright (c) 2005-2008 Terence Parr 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions 16 | # are met: 17 | # 1. Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # 2. Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in the 21 | # documentation and/or other materials provided with the distribution. 22 | # 3. The name of the author may not be used to endorse or promote products 23 | # derived from this software without specific prior written permission. 24 | # 25 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | # end[licence] 37 | 38 | # lot's of docstrings are missing, don't complain for now... 39 | # pylint: disable-msg=C0111 40 | 41 | from treewizard import TreeWizard 42 | 43 | try: 44 | from antlr3.dottreegen import toDOT 45 | except ImportError, exc: 46 | def toDOT(*args, **kwargs): 47 | raise exc 48 | -------------------------------------------------------------------------------- /deps/cpy/cpy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DIR=`dirname $0` 4 | python $DIR/cpy.py $@ 5 | -------------------------------------------------------------------------------- /deps/cpy/cpy.bat: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | python %~dp0cpy.py %1 %2 %3 %4 %5 %6 %7 %8 %9 4 | -------------------------------------------------------------------------------- /deps/cpy/cpy.py: -------------------------------------------------------------------------------- 1 | # encoding=utf-8 2 | ################################# 3 | # Author: ideawu 4 | # Link: http://www.ideawu.net/ 5 | ################################# 6 | 7 | import sys, os 8 | import signal 9 | def __sigint__(n, f): 10 | sys.exit(0) 11 | signal.signal(signal.SIGINT, __sigint__); 12 | 13 | def usage(): 14 | print ('Cpy - A C-like scripting language.') 15 | print ('Copyright (c) 2012 ideawu.com') 16 | print ('') 17 | print ('Usage:') 18 | print (' cpy source_file') 19 | 20 | # 不然管道时报错 21 | reload(sys) 22 | sys.setdefaultencoding('utf-8') 23 | 24 | from engine import CpyEngine 25 | cpy = CpyEngine() 26 | 27 | if len(sys.argv) < 2: 28 | usage() 29 | sys.exit(0) 30 | 31 | is_compile = False; 32 | if sys.argv[1] == '-c': 33 | is_compile = True 34 | if len(sys.argv) >= 3: 35 | srcfile = sys.argv[2] 36 | else: 37 | usage() 38 | sys.exit(0) 39 | else: 40 | srcfile = sys.argv[1] 41 | 42 | if not srcfile.endswith('.cpy'): 43 | srcfile += '.cpy' 44 | if not os.path.exists(srcfile): 45 | print ("File not found!: " + srcfile) 46 | sys.exit(0) 47 | 48 | base_dir, tail = os.path.split(srcfile) 49 | if len(base_dir) == 0: 50 | base_dir = '.' 51 | 52 | dstfile = cpy.compile(srcfile, base_dir, base_dir + '/_cpy_') 53 | sys.path.append(os.path.dirname(dstfile)) 54 | 55 | #print ('-----') 56 | #print (''.join(open(dstfile, 'r').readlines())) 57 | #print ('-----') 58 | 59 | dstfile = os.path.abspath(dstfile) 60 | os.chdir(base_dir); 61 | if not is_compile: 62 | sys.argv = sys.argv[1 :] 63 | sys.path.insert(0, os.path.dirname(dstfile)) 64 | try: 65 | execfile(dstfile) 66 | except Exception,e: 67 | import traceback 68 | sys.stderr.write(traceback.format_exc()) 69 | pass 70 | -------------------------------------------------------------------------------- /deps/cpy/samples/class.cpy: -------------------------------------------------------------------------------- 1 | class A{ 2 | public a = 0; 3 | public static s = 1; 4 | 5 | function init(a){ 6 | this.a = a; 7 | print 'A init', a; 8 | } 9 | 10 | function f(a, b=1){ 11 | return a + b; 12 | } 13 | } 14 | 15 | print A.s; // 1 16 | a = new A(1); // A init 1 17 | print a.f(1, 2); 18 | -------------------------------------------------------------------------------- /deps/cpy/samples/extends.cpy: -------------------------------------------------------------------------------- 1 | class A{ 2 | function f(){ 3 | print 'A.f'; 4 | } 5 | } 6 | class B extends A{ 7 | function g(){ 8 | print "B.g"; 9 | } 10 | } 11 | 12 | b = new B(); 13 | b.f(); 14 | b.g(); 15 | -------------------------------------------------------------------------------- /deps/cpy/samples/foreach.cpy: -------------------------------------------------------------------------------- 1 | 2 | arr = [10, 11, 12]; 3 | foreach(arr as k=>v){ 4 | print k, v; 5 | } 6 | 7 | # output: # 8 | 9 | d = { 10 | 'a': 1, 11 | 'b': 2, 12 | 'c': 3, 13 | }; 14 | 15 | foreach(d as k=>v){ 16 | print k, v; 17 | } 18 | -------------------------------------------------------------------------------- /deps/cpy/samples/function.cpy: -------------------------------------------------------------------------------- 1 | 2 | function f(a, b=1){ 3 | return a + b; 4 | } 5 | 6 | print f(1); 7 | print f(1, 2); 8 | 9 | -------------------------------------------------------------------------------- /deps/cpy/samples/hello.cpy: -------------------------------------------------------------------------------- 1 | 2 | printf("Hello World!\n"); 3 | -------------------------------------------------------------------------------- /deps/cpy/samples/list.cpy: -------------------------------------------------------------------------------- 1 | a = []; // empty array 2 | a.append(1); 3 | a.append(2); 4 | print a[0]; // output: 1 5 | print a; // output: [1, 2] 6 | 7 | a = [1, 2]; 8 | print a; 9 | -------------------------------------------------------------------------------- /deps/cpy/samples/object.cpy: -------------------------------------------------------------------------------- 1 | 2 | a = {}; // empty dictionary 3 | a['x'] = [1, 2]; 4 | a['y'] = [3, 4]; 5 | foreach(a as k=>v1, v2){ 6 | printf('%s: %d, %d\n', k, v1, v2); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /deps/cpy/samples/simple_client.cpy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/cpy/samples/simple_client.cpy -------------------------------------------------------------------------------- /deps/cpy/samples/simple_server.cpy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/cpy/samples/simple_server.cpy -------------------------------------------------------------------------------- /deps/cpy/samples/stdin.cpy: -------------------------------------------------------------------------------- 1 | 2 | 3 | print "input 'q' to quit:"; 4 | 5 | while(true){ 6 | printf("> "); 7 | line = stdin.readline(); 8 | line = line.strip().lower(); 9 | if(line == 'q'){ 10 | print "bye."; 11 | break; 12 | }else{ 13 | print 'your input:', repr(line); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /deps/cpy/samples/test.cpy: -------------------------------------------------------------------------------- 1 | a = {}; // empty dictionary 2 | a['x'] = 1; 3 | a['y'] = 2; 4 | foreach(a as k,v){ 5 | print k, v; 6 | } 7 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | bin/jemalloc\.sh 3 | Makefile 4 | config.log 5 | config.stamp 6 | config.status 7 | lib/ 8 | include/jemalloc/internal/jemalloc_internal.h 9 | include/jemalloc/internal/size_classes.h 10 | include/jemalloc/jemalloc.h 11 | include/jemalloc/jemalloc_defs.h 12 | test/jemalloc_test.h 13 | 14 | 15 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/COPYING: -------------------------------------------------------------------------------- 1 | Unless otherwise specified, files in the jemalloc source distribution are 2 | subject to the following license: 3 | -------------------------------------------------------------------------------- 4 | Copyright (C) 2002-2013 Jason Evans . 5 | All rights reserved. 6 | Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved. 7 | Copyright (C) 2009-2013 Facebook, Inc. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 1. Redistributions of source code must retain the above copyright notice(s), 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice(s), 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/README: -------------------------------------------------------------------------------- 1 | jemalloc is a general-purpose scalable concurrent malloc(3) implementation. 2 | This distribution is a "portable" implementation that currently targets 3 | FreeBSD, Linux, Apple OS X, and MinGW. jemalloc is included as the default 4 | allocator in the FreeBSD and NetBSD operating systems, and it is used by the 5 | Mozilla Firefox web browser on Microsoft Windows-related platforms. Depending 6 | on your needs, one of the other divergent versions may suit your needs better 7 | than this distribution. 8 | 9 | The COPYING file contains copyright and licensing information. 10 | 11 | The INSTALL file contains information on how to configure, build, and install 12 | jemalloc. 13 | 14 | The ChangeLog file contains a brief summary of changes for each release. 15 | 16 | URL: http://www.canonware.com/jemalloc/ 17 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/VERSION: -------------------------------------------------------------------------------- 1 | 3.3.1-0-g9ef9d9e8c271cdf14f664b871a8f98c827714784 2 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/config.stamp.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/jemalloc-3.3.1/config.stamp.in -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/html.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/jemalloc.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/jemalloc-3.3.1/doc/jemalloc.html -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/manpages.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | "" 6 | 7 | 8 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/jemalloc/internal/base.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | void *base_alloc(size_t size); 13 | void *base_calloc(size_t number, size_t size); 14 | extent_node_t *base_node_alloc(void); 15 | void base_node_dealloc(extent_node_t *node); 16 | bool base_boot(void); 17 | void base_prefork(void); 18 | void base_postfork_parent(void); 19 | void base_postfork_child(void); 20 | 21 | #endif /* JEMALLOC_H_EXTERNS */ 22 | /******************************************************************************/ 23 | #ifdef JEMALLOC_H_INLINES 24 | 25 | #endif /* JEMALLOC_H_INLINES */ 26 | /******************************************************************************/ 27 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/jemalloc/internal/chunk_dss.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef enum { 5 | dss_prec_disabled = 0, 6 | dss_prec_primary = 1, 7 | dss_prec_secondary = 2, 8 | 9 | dss_prec_limit = 3 10 | } dss_prec_t ; 11 | #define DSS_PREC_DEFAULT dss_prec_secondary 12 | #define DSS_DEFAULT "secondary" 13 | 14 | #endif /* JEMALLOC_H_TYPES */ 15 | /******************************************************************************/ 16 | #ifdef JEMALLOC_H_STRUCTS 17 | 18 | extern const char *dss_prec_names[]; 19 | 20 | #endif /* JEMALLOC_H_STRUCTS */ 21 | /******************************************************************************/ 22 | #ifdef JEMALLOC_H_EXTERNS 23 | 24 | dss_prec_t chunk_dss_prec_get(void); 25 | bool chunk_dss_prec_set(dss_prec_t dss_prec); 26 | void *chunk_alloc_dss(size_t size, size_t alignment, bool *zero); 27 | bool chunk_in_dss(void *chunk); 28 | bool chunk_dss_boot(void); 29 | void chunk_dss_prefork(void); 30 | void chunk_dss_postfork_parent(void); 31 | void chunk_dss_postfork_child(void); 32 | 33 | #endif /* JEMALLOC_H_EXTERNS */ 34 | /******************************************************************************/ 35 | #ifdef JEMALLOC_H_INLINES 36 | 37 | #endif /* JEMALLOC_H_INLINES */ 38 | /******************************************************************************/ 39 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/jemalloc/internal/chunk_mmap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | bool pages_purge(void *addr, size_t length); 13 | 14 | void *chunk_alloc_mmap(size_t size, size_t alignment, bool *zero); 15 | bool chunk_dealloc_mmap(void *chunk, size_t size); 16 | 17 | #endif /* JEMALLOC_H_EXTERNS */ 18 | /******************************************************************************/ 19 | #ifdef JEMALLOC_H_INLINES 20 | 21 | #endif /* JEMALLOC_H_INLINES */ 22 | /******************************************************************************/ 23 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/jemalloc/internal/extent.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct extent_node_s extent_node_t; 5 | 6 | #endif /* JEMALLOC_H_TYPES */ 7 | /******************************************************************************/ 8 | #ifdef JEMALLOC_H_STRUCTS 9 | 10 | /* Tree of extents. */ 11 | struct extent_node_s { 12 | /* Linkage for the size/address-ordered tree. */ 13 | rb_node(extent_node_t) link_szad; 14 | 15 | /* Linkage for the address-ordered tree. */ 16 | rb_node(extent_node_t) link_ad; 17 | 18 | /* Profile counters, used for huge objects. */ 19 | prof_ctx_t *prof_ctx; 20 | 21 | /* Pointer to the extent that this tree node is responsible for. */ 22 | void *addr; 23 | 24 | /* Total region size. */ 25 | size_t size; 26 | 27 | /* True if zero-filled; used by chunk recycling code. */ 28 | bool zeroed; 29 | }; 30 | typedef rb_tree(extent_node_t) extent_tree_t; 31 | 32 | #endif /* JEMALLOC_H_STRUCTS */ 33 | /******************************************************************************/ 34 | #ifdef JEMALLOC_H_EXTERNS 35 | 36 | rb_proto(, extent_tree_szad_, extent_tree_t, extent_node_t) 37 | 38 | rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t) 39 | 40 | #endif /* JEMALLOC_H_EXTERNS */ 41 | /******************************************************************************/ 42 | #ifdef JEMALLOC_H_INLINES 43 | 44 | #endif /* JEMALLOC_H_INLINES */ 45 | /******************************************************************************/ 46 | 47 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/jemalloc/internal/huge.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | /* Huge allocation statistics. */ 13 | extern uint64_t huge_nmalloc; 14 | extern uint64_t huge_ndalloc; 15 | extern size_t huge_allocated; 16 | 17 | /* Protects chunk-related data structures. */ 18 | extern malloc_mutex_t huge_mtx; 19 | 20 | void *huge_malloc(size_t size, bool zero); 21 | void *huge_palloc(size_t size, size_t alignment, bool zero); 22 | void *huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size, 23 | size_t extra); 24 | void *huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra, 25 | size_t alignment, bool zero, bool try_tcache_dalloc); 26 | void huge_dalloc(void *ptr, bool unmap); 27 | size_t huge_salloc(const void *ptr); 28 | prof_ctx_t *huge_prof_ctx_get(const void *ptr); 29 | void huge_prof_ctx_set(const void *ptr, prof_ctx_t *ctx); 30 | bool huge_boot(void); 31 | void huge_prefork(void); 32 | void huge_postfork_parent(void); 33 | void huge_postfork_child(void); 34 | 35 | #endif /* JEMALLOC_H_EXTERNS */ 36 | /******************************************************************************/ 37 | #ifdef JEMALLOC_H_INLINES 38 | 39 | #endif /* JEMALLOC_H_INLINES */ 40 | /******************************************************************************/ 41 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/msvc_compat/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | typedef BOOL _Bool; 9 | 10 | #define bool _Bool 11 | #define true 1 12 | #define false 0 13 | 14 | #define __bool_true_false_are_defined 1 15 | 16 | #endif /* stdbool_h */ 17 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/include/msvc_compat/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef strings_h 2 | #define strings_h 3 | 4 | /* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided 5 | * for both */ 6 | #include 7 | #pragma intrinsic(_BitScanForward) 8 | static __forceinline int ffsl(long x) 9 | { 10 | unsigned long i; 11 | 12 | if (_BitScanForward(&i, x)) 13 | return (i + 1); 14 | return (0); 15 | } 16 | 17 | static __forceinline int ffs(int x) 18 | { 19 | 20 | return (ffsl(x)); 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/src/atomic.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_ATOMIC_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/src/extent.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_EXTENT_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | /******************************************************************************/ 5 | 6 | static inline int 7 | extent_szad_comp(extent_node_t *a, extent_node_t *b) 8 | { 9 | int ret; 10 | size_t a_size = a->size; 11 | size_t b_size = b->size; 12 | 13 | ret = (a_size > b_size) - (a_size < b_size); 14 | if (ret == 0) { 15 | uintptr_t a_addr = (uintptr_t)a->addr; 16 | uintptr_t b_addr = (uintptr_t)b->addr; 17 | 18 | ret = (a_addr > b_addr) - (a_addr < b_addr); 19 | } 20 | 21 | return (ret); 22 | } 23 | 24 | /* Generate red-black tree functions. */ 25 | rb_gen(, extent_tree_szad_, extent_tree_t, extent_node_t, link_szad, 26 | extent_szad_comp) 27 | 28 | static inline int 29 | extent_ad_comp(extent_node_t *a, extent_node_t *b) 30 | { 31 | uintptr_t a_addr = (uintptr_t)a->addr; 32 | uintptr_t b_addr = (uintptr_t)b->addr; 33 | 34 | return ((a_addr > b_addr) - (a_addr < b_addr)); 35 | } 36 | 37 | /* Generate red-black tree functions. */ 38 | rb_gen(, extent_tree_ad_, extent_tree_t, extent_node_t, link_ad, 39 | extent_ad_comp) 40 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/src/mb.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MB_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/src/rtree.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_RTREE_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | rtree_t * 5 | rtree_new(unsigned bits) 6 | { 7 | rtree_t *ret; 8 | unsigned bits_per_level, height, i; 9 | 10 | bits_per_level = ffs(pow2_ceil((RTREE_NODESIZE / sizeof(void *)))) - 1; 11 | height = bits / bits_per_level; 12 | if (height * bits_per_level != bits) 13 | height++; 14 | assert(height * bits_per_level >= bits); 15 | 16 | ret = (rtree_t*)base_alloc(offsetof(rtree_t, level2bits) + 17 | (sizeof(unsigned) * height)); 18 | if (ret == NULL) 19 | return (NULL); 20 | memset(ret, 0, offsetof(rtree_t, level2bits) + (sizeof(unsigned) * 21 | height)); 22 | 23 | if (malloc_mutex_init(&ret->mutex)) { 24 | /* Leak the rtree. */ 25 | return (NULL); 26 | } 27 | ret->height = height; 28 | if (bits_per_level * height > bits) 29 | ret->level2bits[0] = bits % bits_per_level; 30 | else 31 | ret->level2bits[0] = bits_per_level; 32 | for (i = 1; i < height; i++) 33 | ret->level2bits[i] = bits_per_level; 34 | 35 | ret->root = (void**)base_alloc(sizeof(void *) << ret->level2bits[0]); 36 | if (ret->root == NULL) { 37 | /* 38 | * We leak the rtree here, since there's no generic base 39 | * deallocation. 40 | */ 41 | return (NULL); 42 | } 43 | memset(ret->root, 0, sizeof(void *) << ret->level2bits[0]); 44 | 45 | return (ret); 46 | } 47 | 48 | void 49 | rtree_prefork(rtree_t *rtree) 50 | { 51 | 52 | malloc_mutex_prefork(&rtree->mutex); 53 | } 54 | 55 | void 56 | rtree_postfork_parent(rtree_t *rtree) 57 | { 58 | 59 | malloc_mutex_postfork_parent(&rtree->mutex); 60 | } 61 | 62 | void 63 | rtree_postfork_child(rtree_t *rtree) 64 | { 65 | 66 | malloc_mutex_postfork_child(&rtree->mutex); 67 | } 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/ALLOCM_ARENA.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define NTHREADS 10 5 | 6 | void * 7 | je_thread_start(void *arg) 8 | { 9 | unsigned thread_ind = (unsigned)(uintptr_t)arg; 10 | unsigned arena_ind; 11 | int r; 12 | void *p; 13 | size_t rsz, sz; 14 | 15 | sz = sizeof(arena_ind); 16 | if (mallctl("arenas.extend", &arena_ind, &sz, NULL, 0) 17 | != 0) { 18 | malloc_printf("Error in arenas.extend\n"); 19 | abort(); 20 | } 21 | 22 | if (thread_ind % 4 != 3) { 23 | size_t mib[3]; 24 | size_t miblen = sizeof(mib) / sizeof(size_t); 25 | const char *dss_precs[] = {"disabled", "primary", "secondary"}; 26 | const char *dss = dss_precs[thread_ind % 4]; 27 | if (mallctlnametomib("arena.0.dss", mib, &miblen) != 0) { 28 | malloc_printf("Error in mallctlnametomib()\n"); 29 | abort(); 30 | } 31 | mib[1] = arena_ind; 32 | if (mallctlbymib(mib, miblen, NULL, NULL, (void *)&dss, 33 | sizeof(const char *))) { 34 | malloc_printf("Error in mallctlbymib()\n"); 35 | abort(); 36 | } 37 | } 38 | 39 | r = allocm(&p, &rsz, 1, ALLOCM_ARENA(arena_ind)); 40 | if (r != ALLOCM_SUCCESS) { 41 | malloc_printf("Unexpected allocm() error\n"); 42 | abort(); 43 | } 44 | dallocm(p, 0); 45 | 46 | return (NULL); 47 | } 48 | 49 | int 50 | main(void) 51 | { 52 | je_thread_t threads[NTHREADS]; 53 | unsigned i; 54 | 55 | malloc_printf("Test begin\n"); 56 | 57 | for (i = 0; i < NTHREADS; i++) { 58 | je_thread_create(&threads[i], je_thread_start, 59 | (void *)(uintptr_t)i); 60 | } 61 | 62 | for (i = 0; i < NTHREADS; i++) 63 | je_thread_join(threads[i], NULL); 64 | 65 | malloc_printf("Test end\n"); 66 | return (0); 67 | } 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/ALLOCM_ARENA.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/aligned_alloc.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/allocated.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/allocm.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/bitmap.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/jemalloc_test.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * This header should be included by tests, rather than directly including 3 | * jemalloc/jemalloc.h, because --with-install-suffix may cause the header to 4 | * have a different name. 5 | */ 6 | #include "jemalloc/jemalloc@install_suffix@.h" 7 | #include "jemalloc/internal/jemalloc_internal.h" 8 | 9 | /* Abstraction layer for threading in tests */ 10 | #ifdef _WIN32 11 | #include 12 | 13 | typedef HANDLE je_thread_t; 14 | 15 | void 16 | je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg) 17 | { 18 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 19 | *thread = CreateThread(NULL, 0, routine, arg, 0, NULL); 20 | if (*thread == NULL) { 21 | malloc_printf("Error in CreateThread()\n"); 22 | exit(1); 23 | } 24 | } 25 | 26 | void 27 | je_thread_join(je_thread_t thread, void **ret) 28 | { 29 | WaitForSingleObject(thread, INFINITE); 30 | } 31 | 32 | #else 33 | #include 34 | 35 | typedef pthread_t je_thread_t; 36 | 37 | void 38 | je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg) 39 | { 40 | 41 | if (pthread_create(thread, NULL, proc, arg) != 0) { 42 | malloc_printf("Error in pthread_create()\n"); 43 | exit(1); 44 | } 45 | } 46 | 47 | void 48 | je_thread_join(je_thread_t thread, void **ret) 49 | { 50 | 51 | pthread_join(thread, ret); 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/mremap.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | int 5 | main(void) 6 | { 7 | int ret, err; 8 | size_t sz, lg_chunk, chunksize, i; 9 | char *p, *q; 10 | 11 | malloc_printf("Test begin\n"); 12 | 13 | sz = sizeof(lg_chunk); 14 | if ((err = mallctl("opt.lg_chunk", &lg_chunk, &sz, NULL, 0))) { 15 | assert(err != ENOENT); 16 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 17 | strerror(err)); 18 | ret = 1; 19 | goto label_return; 20 | } 21 | chunksize = ((size_t)1U) << lg_chunk; 22 | 23 | p = (char *)malloc(chunksize); 24 | if (p == NULL) { 25 | malloc_printf("malloc(%zu) --> %p\n", chunksize, p); 26 | ret = 1; 27 | goto label_return; 28 | } 29 | memset(p, 'a', chunksize); 30 | 31 | q = (char *)realloc(p, chunksize * 2); 32 | if (q == NULL) { 33 | malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize * 2, 34 | q); 35 | ret = 1; 36 | goto label_return; 37 | } 38 | for (i = 0; i < chunksize; i++) { 39 | assert(q[i] == 'a'); 40 | } 41 | 42 | p = q; 43 | 44 | q = (char *)realloc(p, chunksize); 45 | if (q == NULL) { 46 | malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize, q); 47 | ret = 1; 48 | goto label_return; 49 | } 50 | for (i = 0; i < chunksize; i++) { 51 | assert(q[i] == 'a'); 52 | } 53 | 54 | free(q); 55 | 56 | ret = 0; 57 | label_return: 58 | malloc_printf("Test end\n"); 59 | return (ret); 60 | } 61 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/mremap.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/posix_memalign.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/rallocm.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/thread_arena.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define NTHREADS 10 5 | 6 | void * 7 | je_thread_start(void *arg) 8 | { 9 | unsigned main_arena_ind = *(unsigned *)arg; 10 | void *p; 11 | unsigned arena_ind; 12 | size_t size; 13 | int err; 14 | 15 | p = malloc(1); 16 | if (p == NULL) { 17 | malloc_printf("%s(): Error in malloc()\n", __func__); 18 | return (void *)1; 19 | } 20 | free(p); 21 | 22 | size = sizeof(arena_ind); 23 | if ((err = mallctl("thread.arena", &arena_ind, &size, &main_arena_ind, 24 | sizeof(main_arena_ind)))) { 25 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 26 | strerror(err)); 27 | return (void *)1; 28 | } 29 | 30 | size = sizeof(arena_ind); 31 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 32 | 0))) { 33 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 34 | strerror(err)); 35 | return (void *)1; 36 | } 37 | assert(arena_ind == main_arena_ind); 38 | 39 | return (NULL); 40 | } 41 | 42 | int 43 | main(void) 44 | { 45 | int ret = 0; 46 | void *p; 47 | unsigned arena_ind; 48 | size_t size; 49 | int err; 50 | je_thread_t threads[NTHREADS]; 51 | unsigned i; 52 | 53 | malloc_printf("Test begin\n"); 54 | 55 | p = malloc(1); 56 | if (p == NULL) { 57 | malloc_printf("%s(): Error in malloc()\n", __func__); 58 | ret = 1; 59 | goto label_return; 60 | } 61 | 62 | size = sizeof(arena_ind); 63 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) { 64 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 65 | strerror(err)); 66 | ret = 1; 67 | goto label_return; 68 | } 69 | 70 | for (i = 0; i < NTHREADS; i++) { 71 | je_thread_create(&threads[i], je_thread_start, 72 | (void *)&arena_ind); 73 | } 74 | 75 | for (i = 0; i < NTHREADS; i++) 76 | je_thread_join(threads[i], (void *)&ret); 77 | 78 | label_return: 79 | malloc_printf("Test end\n"); 80 | return (ret); 81 | } 82 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/thread_arena.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.3.1/test/thread_tcache_enabled.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/rocksdb-master/.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "project_id" : "rocksdb", 3 | "conduit_uri" : "https://reviews.facebook.net/", 4 | "copyright_holder" : "Facebook", 5 | "load" : [ 6 | "linters" 7 | ], 8 | "lint.engine" : "FacebookFbcodeLintEngine", 9 | "lint.engine.single.linter" : "FbcodeCppLinter" 10 | } 11 | -------------------------------------------------------------------------------- /deps/rocksdb-master/.clang-format: -------------------------------------------------------------------------------- 1 | # Complete list of style options can be found at: 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | --- 4 | BasedOnStyle: Google 5 | ... 6 | -------------------------------------------------------------------------------- /deps/rocksdb-master/.gitignore: -------------------------------------------------------------------------------- 1 | TARGETS 2 | build_config.mk 3 | 4 | *.a 5 | *.arc 6 | *.d 7 | *.dylib* 8 | *.gcda 9 | *.gcno 10 | *.o 11 | *.so 12 | *.so.* 13 | *_test 14 | *_bench 15 | *_stress 16 | *.out 17 | *.class 18 | *.jar 19 | *.*jnilib* 20 | *.d-e 21 | *.o-* 22 | *.swp 23 | 24 | ldb 25 | manifest_dump 26 | sst_dump 27 | util/build_version.cc 28 | build_tools/VALGRIND_LOGS/ 29 | coverage/COVERAGE_REPORT 30 | .gdbhistory 31 | .phutil_module_cache 32 | tags 33 | java/*.log 34 | java/include/org_rocksdb_*.h 35 | -------------------------------------------------------------------------------- /deps/rocksdb-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | before_install: 4 | # As of this writing (10 May 2014) the Travis build environment is Ubuntu 12.04, 5 | # which needs the following ugly dependency incantations to build RocksDB: 6 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 7 | - sudo apt-get update -qq 8 | - sudo apt-get install -y -qq gcc-4.8 g++-4.8 zlib1g-dev libbz2-dev libsnappy-dev libjemalloc-dev 9 | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 10 | - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 11 | - wget https://gflags.googlecode.com/files/libgflags0_2.0-1_amd64.deb 12 | - sudo dpkg -i libgflags0_2.0-1_amd64.deb 13 | - wget https://gflags.googlecode.com/files/libgflags-dev_2.0-1_amd64.deb 14 | - sudo dpkg -i libgflags-dev_2.0-1_amd64.deb 15 | # Lousy hack to disable use and testing of fallocate, which doesn't behave quite 16 | # as EnvPosixTest::AllocateTest expects within the Travis OpenVZ environment. 17 | - sed -i "s/fallocate(/HACK_NO_fallocate(/" build_tools/build_detect_platform 18 | script: make check -j8 19 | notifications: 20 | email: false 21 | -------------------------------------------------------------------------------- /deps/rocksdb-master/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to RocksDB 2 | 3 | ## Contributor License Agreement ("CLA") 4 | 5 | In order to accept your pull request, we need you to submit a CLA. You 6 | only need to do this once, so if you've done this for another Facebook 7 | open source project, you're good to go. If you are submitting a pull 8 | request for the first time, just let us know that you have completed 9 | the CLA and we can cross-check with your GitHub username. 10 | 11 | Complete your CLA here: 12 | 13 | If you prefer to sign a paper copy, we can send you a PDF. Send us an 14 | e-mail or create a new github issue to request the CLA in PDF format. 15 | 16 | ## License 17 | 18 | By contributing to RocksDB, you agree that your contributions will be 19 | licensed under the [BSD License](LICENSE). 20 | -------------------------------------------------------------------------------- /deps/rocksdb-master/LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For rocksdb software 4 | 5 | Copyright (c) 2014, Facebook, Inc. 6 | All rights reserved. 7 | --------------------------------------------------------------------- 8 | 9 | Copyright (c) 2011 The LevelDB Authors. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above 18 | copyright notice, this list of conditions and the following disclaimer 19 | in the documentation and/or other materials provided with the 20 | distribution. 21 | * Neither the name of Google Inc. nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /deps/rocksdb-master/PATENTS: -------------------------------------------------------------------------------- 1 | Additional Grant of Patent Rights 2 | 3 | “Software” means the rocksdb software distributed by Facebook, Inc. 4 | 5 | Facebook hereby grants you a perpetual, worldwide, royalty-free, 6 | non-exclusive, irrevocable (subject to the termination provision below) 7 | license under any rights in any patent claims owned by Facebook, to make, 8 | have made, use, sell, offer to sell, import, and otherwise transfer the 9 | Software. For avoidance of doubt, no license is granted under Facebook’s 10 | rights in any patent claims that are infringed by (i) modifications to the 11 | Software made by you or a third party, or (ii) the Software in combination 12 | with any software or other technology provided by you or a third party. 13 | 14 | The license granted hereunder will terminate, automatically and without 15 | notice, for anyone that makes any claim (including by filing any lawsuit, 16 | assertion or other action) alleging (a) direct, indirect, or contributory 17 | infringement or inducement to infringe any patent: (i) by Facebook or any 18 | of its subsidiaries or affiliates, whether or not such claim is related 19 | to the Software, (ii) by any party if such claim arises in whole or in 20 | part from any software, product or service of Facebook or any of its 21 | subsidiaries or affiliates, whether or not such claim is related to the 22 | Software, or (iii) by any party relating to the Software; or (b) that 23 | any right in any patent claim of Facebook is invalid or unenforceable. 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/README.md: -------------------------------------------------------------------------------- 1 | ## RocksDB: A Persistent Key-Value Store for Flash and RAM Storage 2 | 3 | [![Build Status](https://travis-ci.org/facebook/rocksdb.svg?branch=master)](https://travis-ci.org/facebook/rocksdb) 4 | 5 | RocksDB is developed and maintained by Facebook Database Engineering Team. 6 | It is built on on earlier work on LevelDB by Sanjay Ghemawat (sanjay@google.com) 7 | and Jeff Dean (jeff@google.com) 8 | 9 | This code is a library that forms the core building block for a fast 10 | key value server, especially suited for storing data on flash drives. 11 | It has a Log-Structured-Merge-Database (LSM) design with flexible tradeoffs 12 | between Write-Amplification-Factor (WAF), Read-Amplification-Factor (RAF) 13 | and Space-Amplification-Factor (SAF). It has multi-threaded compactions, 14 | making it specially suitable for storing multiple terabytes of data in a 15 | single database. 16 | 17 | Start with example usage here: https://github.com/facebook/rocksdb/tree/master/examples 18 | 19 | See the [github wiki](https://github.com/facebook/rocksdb/wiki) for more explanation. 20 | 21 | The public interface is in `include/`. Callers should not include or 22 | rely on the details of any other header files in this package. Those 23 | internal APIs may be changed without warning. 24 | 25 | Design discussions are conducted in https://www.facebook.com/groups/rocksdb.dev/ 26 | -------------------------------------------------------------------------------- /deps/rocksdb-master/ROCKSDB_LITE.md: -------------------------------------------------------------------------------- 1 | # RocksDBLite 2 | 3 | RocksDBLite is a project focused on mobile use cases, which don't need a lot of fancy things we've built for server workloads and they are very sensitive to binary size. For that reason, we added a compile flag ROCKSDB_LITE that comments out a lot of the nonessential code and keeps the binary lean. 4 | 5 | Some examples of the features disabled by ROCKSDB_LITE: 6 | * compiled-in support for LDB tool 7 | * No backupable DB 8 | * No support for replication (which we provide in form of TrasactionalIterator) 9 | * No advanced monitoring tools 10 | * No special-purpose memtables that are highly optimized for specific use cases 11 | 12 | When adding a new big feature to RocksDB, please add ROCKSDB_LITE compile guard if: 13 | * Nobody from mobile really needs your feature, 14 | * Your feature is adding a lot of weight to the binary. 15 | 16 | Don't add ROCKSDB_LITE compile guard if: 17 | * It would introduce a lot of code complexity. Compile guards make code harder to read. It's a trade-off. 18 | * Your feature is not adding a lot of weight. 19 | 20 | If unsure, ask. :) 21 | -------------------------------------------------------------------------------- /deps/rocksdb-master/build_tools/build_detect_version: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Record the version of the source that we are compiling. 4 | # We keep a record of the git revision in util/version.cc. This source file 5 | # is then built as a regular source file as part of the compilation process. 6 | # One can run "strings executable_filename | grep _build_" to find the version of 7 | # the source that we used to build the executable file. 8 | 9 | OUTFILE="$PWD/util/build_version.cc" 10 | 11 | GIT_SHA="" 12 | if command -v git >/dev/null 2>&1; then 13 | GIT_SHA=$(git rev-parse HEAD 2>/dev/null) 14 | fi 15 | 16 | cat > "${OUTFILE}" <> ~/.bash_profile 19 | echo 'export CPATH+=":/usr/local/include"' >> ~/.bash_profile 20 | 21 | echo "" 22 | echo "-----------------------------------------------------------------------------" 23 | echo "| Installation Completed |" 24 | echo "-----------------------------------------------------------------------------" 25 | echo "Please run \`. ~/.bash_profile\` to be able to compile with gflags" 26 | -------------------------------------------------------------------------------- /deps/rocksdb-master/build_tools/make_new_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2013, Facebook, Inc. All rights reserved. 3 | # This source code is licensed under the BSD-style license found in the 4 | # LICENSE file in the root directory of this source tree. An additional grant 5 | # of patent rights can be found in the PATENTS file in the same directory. 6 | 7 | set -e 8 | if [ -z "$GIT" ] 9 | then 10 | GIT="git" 11 | fi 12 | 13 | # Print out the colored progress info so that it can be brainlessly 14 | # distinguished by users. 15 | function title() { 16 | echo -e "\033[1;32m$*\033[0m" 17 | } 18 | 19 | usage="Create new RocksDB version and prepare it for the release process\n" 20 | usage+="USAGE: ./make_new_version.sh " 21 | 22 | # -- Pre-check 23 | if [[ $# < 1 ]]; then 24 | echo -e $usage 25 | exit 1 26 | fi 27 | 28 | ROCKSDB_VERSION=$1 29 | 30 | GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` 31 | echo $GIT_BRANCH 32 | 33 | if [ $GIT_BRANCH != "master" ]; then 34 | echo "Error: Current branch is '$GIT_BRANCH', Please switch to master branch." 35 | exit 1 36 | fi 37 | 38 | title "Adding new tag for this release ..." 39 | BRANCH="$ROCKSDB_VERSION.fb" 40 | $GIT co -b $BRANCH 41 | 42 | # Setting up the proxy for remote repo access 43 | title "Pushing new branch to remote repo ..." 44 | git push origin --set-upstream $BRANCH 45 | 46 | title "Branch $BRANCH is pushed to github;" 47 | -------------------------------------------------------------------------------- /deps/rocksdb-master/build_tools/valgrind_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #A shell script for Jenknis to run valgrind on rocksdb tests 3 | #Returns 0 on success when there are no failed tests 4 | 5 | VALGRIND_DIR=build_tools/VALGRIND_LOGS 6 | make clean 7 | make -j$(nproc) valgrind_check 8 | NUM_FAILED_TESTS=$((`wc -l $VALGRIND_DIR/valgrind_failed_tests | awk '{print $1}'` - 1)) 9 | if [ $NUM_FAILED_TESTS -lt 1 ]; then 10 | echo No tests have valgrind errors 11 | exit 0 12 | else 13 | cat $VALGRIND_DIR/valgrind_failed_tests 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /deps/rocksdb-master/db/log_format.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | // 10 | // Log format information shared by reader and writer. 11 | // See ../doc/log_format.txt for more detail. 12 | 13 | #pragma once 14 | namespace rocksdb { 15 | namespace log { 16 | 17 | enum RecordType { 18 | // Zero is reserved for preallocated files 19 | kZeroType = 0, 20 | kFullType = 1, 21 | 22 | // For fragments 23 | kFirstType = 2, 24 | kMiddleType = 3, 25 | kLastType = 4 26 | }; 27 | static const int kMaxRecordType = kLastType; 28 | 29 | static const unsigned int kBlockSize = 32768; 30 | 31 | // Header is checksum (4 bytes), type (1 byte), length (2 bytes). 32 | static const int kHeaderSize = 4 + 1 + 2; 33 | 34 | } // namespace log 35 | } // namespace rocksdb 36 | -------------------------------------------------------------------------------- /deps/rocksdb-master/db/log_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #pragma once 11 | #include 12 | #include 13 | #include "db/log_format.h" 14 | #include "rocksdb/slice.h" 15 | #include "rocksdb/status.h" 16 | 17 | namespace rocksdb { 18 | 19 | class WritableFile; 20 | 21 | using std::unique_ptr; 22 | 23 | namespace log { 24 | 25 | class Writer { 26 | public: 27 | // Create a writer that will append data to "*dest". 28 | // "*dest" must be initially empty. 29 | // "*dest" must remain live while this Writer is in use. 30 | explicit Writer(unique_ptr&& dest); 31 | ~Writer(); 32 | 33 | Status AddRecord(const Slice& slice); 34 | 35 | WritableFile* file() { return dest_.get(); } 36 | const WritableFile* file() const { return dest_.get(); } 37 | 38 | private: 39 | unique_ptr dest_; 40 | int block_offset_; // Current offset in block 41 | 42 | // crc32c values for all supported record types. These are 43 | // pre-computed to reduce the overhead of computing the crc of the 44 | // record type stored in the header. 45 | uint32_t type_crc_[kMaxRecordType + 1]; 46 | 47 | Status EmitPhysicalRecord(RecordType type, const char* ptr, size_t length); 48 | 49 | // No copying allowed 50 | Writer(const Writer&); 51 | void operator=(const Writer&); 52 | }; 53 | 54 | } // namespace log 55 | } // namespace rocksdb 56 | -------------------------------------------------------------------------------- /deps/rocksdb-master/doc/doc.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-left: 0.5in; 3 | margin-right: 0.5in; 4 | background: white; 5 | color: black; 6 | } 7 | 8 | h1 { 9 | margin-left: -0.2in; 10 | font-size: 14pt; 11 | } 12 | h2 { 13 | margin-left: -0in; 14 | font-size: 12pt; 15 | } 16 | h3 { 17 | margin-left: -0in; 18 | } 19 | h4 { 20 | margin-left: -0in; 21 | } 22 | hr { 23 | margin-left: -0in; 24 | } 25 | 26 | /* Definition lists: definition term bold */ 27 | dt { 28 | font-weight: bold; 29 | } 30 | 31 | address { 32 | text-align: center; 33 | } 34 | code,samp,var { 35 | color: blue; 36 | } 37 | kbd { 38 | color: #600000; 39 | } 40 | div.note p { 41 | float: right; 42 | width: 3in; 43 | margin-right: 0%; 44 | padding: 1px; 45 | border: 2px solid #6060a0; 46 | background-color: #fffff0; 47 | } 48 | 49 | ul { 50 | margin-top: -0em; 51 | margin-bottom: -0em; 52 | } 53 | 54 | ol { 55 | margin-top: -0em; 56 | margin-bottom: -0em; 57 | } 58 | 59 | UL.nobullets { 60 | list-style-type: none; 61 | list-style-image: none; 62 | margin-left: -1em; 63 | } 64 | 65 | p { 66 | margin: 1em 0 1em 0; 67 | padding: 0 0 0 0; 68 | } 69 | 70 | pre { 71 | line-height: 1.3em; 72 | padding: 0.4em 0 0.8em 0; 73 | margin: 0 0 0 0; 74 | border: 0 0 0 0; 75 | color: blue; 76 | } 77 | 78 | .datatable { 79 | margin-left: auto; 80 | margin-right: auto; 81 | margin-top: 2em; 82 | margin-bottom: 2em; 83 | border: 1px solid; 84 | } 85 | 86 | .datatable td,th { 87 | padding: 0 0.5em 0 0.5em; 88 | text-align: right; 89 | } 90 | -------------------------------------------------------------------------------- /deps/rocksdb-master/doc/rockslogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/rocksdb-master/doc/rockslogo.jpg -------------------------------------------------------------------------------- /deps/rocksdb-master/doc/rockslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/ssdb-rocks/a3cbb322cafb2f493252829c608e2239df98c9ac/deps/rocksdb-master/doc/rockslogo.png -------------------------------------------------------------------------------- /deps/rocksdb-master/examples/.gitignore: -------------------------------------------------------------------------------- 1 | column_families_example 2 | simple_example 3 | -------------------------------------------------------------------------------- /deps/rocksdb-master/examples/Makefile: -------------------------------------------------------------------------------- 1 | include ../build_config.mk 2 | 3 | all: simple_example column_families_example 4 | 5 | simple_example: simple_example.cc 6 | $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++11 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) 7 | 8 | column_families_example: column_families_example.cc 9 | $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++11 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) 10 | -------------------------------------------------------------------------------- /deps/rocksdb-master/examples/README.md: -------------------------------------------------------------------------------- 1 | Compile RocksDB first by executing `make static_lib` in parent dir 2 | -------------------------------------------------------------------------------- /deps/rocksdb-master/examples/simple_example.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | #include 6 | #include 7 | 8 | #include "rocksdb/db.h" 9 | #include "rocksdb/slice.h" 10 | #include "rocksdb/options.h" 11 | 12 | using namespace rocksdb; 13 | 14 | std::string kDBPath = "/tmp/rocksdb_simple_example"; 15 | 16 | int main() { 17 | DB* db; 18 | Options options; 19 | // Optimize RocksDB. This is the easiest way to get RocksDB to perform well 20 | options.IncreaseParallelism(); 21 | options.OptimizeLevelStyleCompaction(); 22 | // create the DB if it's not already present 23 | options.create_if_missing = true; 24 | 25 | // open DB 26 | Status s = DB::Open(options, kDBPath, &db); 27 | assert(s.ok()); 28 | 29 | // Put key-value 30 | s = db->Put(WriteOptions(), "key", "value"); 31 | assert(s.ok()); 32 | std::string value; 33 | // get value 34 | s = db->Get(ReadOptions(), "key", &value); 35 | assert(s.ok()); 36 | assert(value == "value"); 37 | 38 | delete db; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /deps/rocksdb-master/hdfs/README: -------------------------------------------------------------------------------- 1 | This directory contains the hdfs extensions needed to make rocksdb store 2 | files in HDFS. 3 | 4 | It has been compiled and testing against CDH 4.4 (2.0.0+1475-1.cdh4.4.0.p0.23~precise-cdh4.4.0). 5 | 6 | The configuration assumes that packages libhdfs0, libhdfs0-dev are 7 | installed which basically means that hdfs.h is in /usr/include and libhdfs in /usr/lib 8 | 9 | The env_hdfs.h file defines the rocksdb objects that are needed to talk to an 10 | underlying filesystem. 11 | 12 | If you want to compile rocksdb with hdfs support, please set the following 13 | enviroment variables appropriately (also defined in setup.sh for convenience) 14 | USE_HDFS=1 15 | JAVA_HOME=/usr/local/jdk-6u22-64 16 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/jdk-6u22-64/jre/lib/amd64/server:/usr/local/jdk-6u22-64/jre/lib/amd64/:./snappy/libs 17 | make clean all db_bench 18 | 19 | To run dbbench, 20 | set CLASSPATH to include your hadoop distribution 21 | db_bench --hdfs="hdfs://hbaseudbperf001.snc1.facebook.com:9000" 22 | 23 | 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/hdfs/setup.sh: -------------------------------------------------------------------------------- 1 | export USE_HDFS=1 2 | export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/server:$JAVA_HOME/jre/lib/amd64:/usr/lib/hadoop/lib/native 3 | 4 | export CLASSPATH= 5 | for f in `find /usr/lib/hadoop-hdfs | grep jar`; do export CLASSPATH=$CLASSPATH:$f; done 6 | for f in `find /usr/lib/hadoop | grep jar`; do export CLASSPATH=$CLASSPATH:$f; done 7 | for f in `find /usr/lib/hadoop/client | grep jar`; do export CLASSPATH=$CLASSPATH:$f; done 8 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/flush_block_policy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace rocksdb { 11 | 12 | class Slice; 13 | class BlockBuilder; 14 | struct Options; 15 | 16 | // FlushBlockPolicy provides a configurable way to determine when to flush a 17 | // block in the block based tables, 18 | class FlushBlockPolicy { 19 | public: 20 | // Keep track of the key/value sequences and return the boolean value to 21 | // determine if table builder should flush current data block. 22 | virtual bool Update(const Slice& key, 23 | const Slice& value) = 0; 24 | 25 | virtual ~FlushBlockPolicy() { } 26 | }; 27 | 28 | class FlushBlockPolicyFactory { 29 | public: 30 | // Return the name of the flush block policy. 31 | virtual const char* Name() const = 0; 32 | 33 | // Return a new block flush policy that flushes data blocks by data size. 34 | // FlushBlockPolicy may need to access the metadata of the data block 35 | // builder to determine when to flush the blocks. 36 | // 37 | // Callers must delete the result after any database that is using the 38 | // result has been closed. 39 | virtual FlushBlockPolicy* NewFlushBlockPolicy( 40 | const Options& options, const BlockBuilder& data_block_builder) const = 0; 41 | 42 | virtual ~FlushBlockPolicyFactory() { } 43 | }; 44 | 45 | class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory { 46 | public: 47 | FlushBlockBySizePolicyFactory() {} 48 | 49 | virtual const char* Name() const override { 50 | return "FlushBlockBySizePolicyFactory"; 51 | } 52 | 53 | virtual FlushBlockPolicy* NewFlushBlockPolicy( 54 | const Options& options, 55 | const BlockBuilder& data_block_builder) const override; 56 | }; 57 | 58 | } // rocksdb 59 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/iostats_context.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #ifndef INCLUDE_ROCKSDB_IOSTATS_CONTEXT_H_ 7 | #define INCLUDE_ROCKSDB_IOSTATS_CONTEXT_H_ 8 | 9 | #include 10 | #include 11 | 12 | // A thread local context for gathering io-stats efficiently and transparently. 13 | namespace rocksdb { 14 | 15 | struct IOStatsContext { 16 | // reset all io-stats counter to zero 17 | void Reset(); 18 | 19 | std::string ToString() const; 20 | 21 | // the thread pool id 22 | uint64_t thread_pool_id; 23 | 24 | // number of bytes that has been written. 25 | uint64_t bytes_written; 26 | // number of bytes that has been read. 27 | uint64_t bytes_read; 28 | }; 29 | 30 | extern __thread IOStatsContext iostats_context; 31 | 32 | } // namespace rocksdb 33 | 34 | #endif // INCLUDE_ROCKSDB_IOSTATS_CONTEXT_H_ 35 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/ldb_tool.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | #ifndef ROCKSDB_LITE 6 | #pragma once 7 | #include 8 | #include "rocksdb/options.h" 9 | 10 | namespace rocksdb { 11 | 12 | // An interface for converting a slice to a readable string 13 | class SliceFormatter { 14 | public: 15 | virtual ~SliceFormatter() {} 16 | virtual std::string Format(const Slice& s) const = 0; 17 | }; 18 | 19 | // Options for customizing ldb tool (beyond the DB Options) 20 | struct LDBOptions { 21 | // Create LDBOptions with default values for all fields 22 | LDBOptions(); 23 | 24 | // Key formatter that converts a slice to a readable string. 25 | // Default: Slice::ToString() 26 | std::shared_ptr key_formatter; 27 | }; 28 | 29 | class LDBTool { 30 | public: 31 | void Run(int argc, char** argv, Options db_options= Options(), 32 | const LDBOptions& ldb_options = LDBOptions()); 33 | }; 34 | 35 | } // namespace rocksdb 36 | 37 | #endif // ROCKSDB_LITE 38 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/slice_transform.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // Copyright (c) 2012 The LevelDB Authors. All rights reserved. 6 | // Use of this source code is governed by a BSD-style license that can be 7 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 8 | // 9 | // Class for specifying user-defined functions which perform a 10 | // transformation on a slice. It is not required that every slice 11 | // belong to the domain and/or range of a function. Subclasses should 12 | // define InDomain and InRange to determine which slices are in either 13 | // of these sets respectively. 14 | 15 | #ifndef STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_ 16 | #define STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_ 17 | 18 | #include 19 | 20 | namespace rocksdb { 21 | 22 | class Slice; 23 | 24 | class SliceTransform { 25 | public: 26 | virtual ~SliceTransform() {}; 27 | 28 | // Return the name of this transformation. 29 | virtual const char* Name() const = 0; 30 | 31 | // transform a src in domain to a dst in the range 32 | virtual Slice Transform(const Slice& src) const = 0; 33 | 34 | // determine whether this is a valid src upon the function applies 35 | virtual bool InDomain(const Slice& src) const = 0; 36 | 37 | // determine whether dst=Transform(src) for some src 38 | virtual bool InRange(const Slice& dst) const = 0; 39 | }; 40 | 41 | extern const SliceTransform* NewFixedPrefixTransform(size_t prefix_len); 42 | 43 | extern const SliceTransform* NewNoopTransform(); 44 | 45 | } 46 | 47 | #endif // STORAGE_ROCKSDB_INCLUDE_SLICE_TRANSFORM_H_ 48 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/types.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #ifndef STORAGE_ROCKSDB_INCLUDE_TYPES_H_ 7 | #define STORAGE_ROCKSDB_INCLUDE_TYPES_H_ 8 | 9 | #include 10 | 11 | namespace rocksdb { 12 | 13 | // Define all public custom types here. 14 | 15 | // Represents a sequence number in a WAL file. 16 | typedef uint64_t SequenceNumber; 17 | 18 | } // namespace rocksdb 19 | 20 | #endif // STORAGE_ROCKSDB_INCLUDE_TYPES_H_ 21 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/utilities/utility_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #pragma once 6 | #ifndef ROCKSDB_LITE 7 | #include 8 | #include 9 | 10 | #include "rocksdb/utilities/stackable_db.h" 11 | #include "rocksdb/utilities/db_ttl.h" 12 | #include "rocksdb/db.h" 13 | 14 | namespace rocksdb { 15 | 16 | // Please don't use this class. It's deprecated 17 | class UtilityDB { 18 | public: 19 | // This function is here only for backwards compatibility. Please use the 20 | // functions defined in DBWithTTl (rocksdb/utilities/db_ttl.h) 21 | // (deprecated) 22 | __attribute__((deprecated)) static Status OpenTtlDB(const Options& options, 23 | const std::string& name, 24 | StackableDB** dbptr, 25 | int32_t ttl = 0, 26 | bool read_only = false); 27 | }; 28 | 29 | } // namespace rocksdb 30 | #endif // ROCKSDB_LITE 31 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/rocksdb/version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | #pragma once 6 | 7 | // Also update Makefile if you change these 8 | #define ROCKSDB_MAJOR 3 9 | #define ROCKSDB_MINOR 4 10 | #define ROCKSDB_PATCH 0 11 | 12 | // Do not use these. We made the mistake of declaring macros starting with 13 | // double underscore. Now we have to live with our choice. We'll deprecate these 14 | // at some point 15 | #define __ROCKSDB_MAJOR__ ROCKSDB_MAJOR 16 | #define __ROCKSDB_MINOR__ ROCKSDB_MINOR 17 | #define __ROCKSDB_PATCH__ ROCKSDB_PATCH 18 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/backupable_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #pragma once 11 | #warning This file was moved to rocksdb/utilities/backupable_db.h 12 | #include "rocksdb/utilities/backupable_db.h" 13 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/db_ttl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | #warning This file was moved to rocksdb/utilities/db_ttl.h 8 | #include "rocksdb/utilities/db_ttl.h" 9 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/document_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | #warning This file was moved to rocksdb/utilities/document_db.h 8 | #include "rocksdb/utilities/document_db.h" 9 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/geo_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | #warning This file was moved to rocksdb/utilities/geo_db.h 8 | #include "rocksdb/utilities/geo_db.h" 9 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/json_document.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | #pragma once 6 | #warning This file was moved to rocksdb/utilities/json_document.h 7 | #include "rocksdb/utilities/json_document.h" 8 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/stackable_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #pragma once 6 | #warning This file was moved to rocksdb/utilities/stackable_db.h 7 | #include "rocksdb/utilities/stackable_db.h" 8 | -------------------------------------------------------------------------------- /deps/rocksdb-master/include/utilities/utility_db.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #pragma once 6 | #warning This file was moved to rocksdb/utilities/utility_db.h 7 | #include "rocksdb/utilities/utility_db.h" 8 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/Makefile: -------------------------------------------------------------------------------- 1 | NATIVE_JAVA_CLASSES = org.rocksdb.RocksDB org.rocksdb.Options org.rocksdb.WriteBatch org.rocksdb.WriteBatchInternal org.rocksdb.WriteBatchTest org.rocksdb.WriteOptions org.rocksdb.BackupableDB org.rocksdb.BackupableDBOptions org.rocksdb.Statistics org.rocksdb.RocksIterator org.rocksdb.VectorMemTableConfig org.rocksdb.SkipListMemTableConfig org.rocksdb.HashLinkedListMemTableConfig org.rocksdb.HashSkipListMemTableConfig org.rocksdb.PlainTableConfig org.rocksdb.ReadOptions org.rocksdb.Filter org.rocksdb.BloomFilter org.rocksdb.RestoreOptions org.rocksdb.RestoreBackupableDB org.rocksdb.RocksEnv 2 | 3 | NATIVE_INCLUDE = ./include 4 | ROCKSDB_JAR = rocksdbjni.jar 5 | 6 | clean: 7 | -find . -name "*.class" -exec rm {} \; 8 | -find . -name "hs*.log" -exec rm {} \; 9 | rm -f $(ROCKSDB_JAR) 10 | 11 | java: 12 | javac org/rocksdb/util/*.java org/rocksdb/*.java 13 | @cp ../HISTORY.md ./HISTORY-CPP.md 14 | @rm -f ./HISTORY-CPP.md 15 | javah -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_CLASSES) 16 | 17 | sample: java 18 | javac -cp $(ROCKSDB_JAR) RocksDBSample.java 19 | @rm -rf /tmp/rocksdbjni 20 | @rm -rf /tmp/rocksdbjni_not_found 21 | java -ea -Djava.library.path=.:../ -cp ".:./*" -Xcheck:jni RocksDBSample /tmp/rocksdbjni 22 | @rm -rf /tmp/rocksdbjni 23 | @rm -rf /tmp/rocksdbjni_not_found 24 | 25 | test: java 26 | javac org/rocksdb/test/*.java 27 | java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.WriteBatchTest 28 | java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.BackupableDBTest 29 | java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.OptionsTest 30 | java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ReadOptionsTest 31 | java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.StatisticsCollectorTest 32 | 33 | db_bench: java 34 | javac org/rocksdb/benchmark/*.java 35 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/jdb_bench.sh: -------------------------------------------------------------------------------- 1 | java -server -d64 -XX:NewSize=4m -XX:+AggressiveOpts -Djava.library.path=.:../ -cp "rocksdbjni.jar:.:./*" org.rocksdb.benchmark.DbBenchmark $@ 2 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/BloomFilter.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * This class creates a new filter policy that uses a bloom filter 10 | * with approximately the specified number of bits per key. 11 | * A good value for bitsPerKey is 10, which yields a filter 12 | * with ~ 1% false positive rate. 13 | * 14 | * Default value of bits per key is 10. 15 | */ 16 | public class BloomFilter extends Filter { 17 | private static final int DEFAULT_BITS_PER_KEY = 10; 18 | private final int bitsPerKey_; 19 | 20 | public BloomFilter() { 21 | this(DEFAULT_BITS_PER_KEY); 22 | } 23 | 24 | public BloomFilter(int bitsPerKey) { 25 | super(); 26 | bitsPerKey_ = bitsPerKey; 27 | 28 | createNewFilter(); 29 | } 30 | 31 | @Override 32 | protected void createNewFilter() { 33 | createNewFilter0(bitsPerKey_); 34 | } 35 | 36 | private native void createNewFilter0(int bitsKeyKey); 37 | } 38 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/CompactionStyle.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | public enum CompactionStyle { 9 | LEVEL((byte) 0), 10 | UNIVERSAL((byte) 1), 11 | FIFO((byte) 2); 12 | 13 | private final byte value_; 14 | 15 | private CompactionStyle(byte value) { 16 | value_ = value; 17 | } 18 | 19 | public byte getValue() { 20 | return value_; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/CompressionType.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | public enum CompressionType { 9 | NO_COMPRESSION((byte) 0), 10 | SNAPPY_COMPRESSION((byte) 1), 11 | ZLIB_COMPRESSION((byte) 2), 12 | BZLIB2_COMPRESSION((byte) 3), 13 | LZ4_COMPRESSION((byte) 4), 14 | LZ4HC_COMPRESSION((byte) 5); 15 | 16 | private final byte value_; 17 | 18 | private CompressionType(byte value) { 19 | value_ = value; 20 | } 21 | 22 | public byte getValue() { 23 | return value_; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/Filter.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * Filters are stored in rocksdb and are consulted automatically 10 | * by rocksdb to decide whether or not to read some 11 | * information from disk. In many cases, a filter can cut down the 12 | * number of disk seeks form a handful to a single disk seek per 13 | * DB::Get() call. 14 | */ 15 | public abstract class Filter extends RocksObject { 16 | protected abstract void createNewFilter(); 17 | 18 | /** 19 | * Deletes underlying C++ filter pointer. 20 | * 21 | * Note that this function should be called only after all 22 | * RocksDB instances referencing the filter are closed. 23 | * Otherwise an undefined behavior will occur. 24 | */ 25 | @Override protected void disposeInternal() { 26 | assert(isInitialized()); 27 | disposeInternal(nativeHandle_); 28 | } 29 | 30 | private native void disposeInternal(long handle); 31 | } 32 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/HashLinkedListMemTableConfig.java: -------------------------------------------------------------------------------- 1 | package org.rocksdb; 2 | 3 | /** 4 | * The config for hash linked list memtable representation 5 | * Such memtable contains a fix-sized array of buckets, where 6 | * each bucket points to a sorted singly-linked 7 | * list (or null if the bucket is empty). 8 | * 9 | * Note that since this mem-table representation relies on the 10 | * key prefix, it is required to invoke one of the usePrefixExtractor 11 | * functions to specify how to extract key prefix given a key. 12 | * If proper prefix-extractor is not set, then RocksDB will 13 | * use the default memtable representation (SkipList) instead 14 | * and post a warning in the LOG. 15 | */ 16 | public class HashLinkedListMemTableConfig extends MemTableConfig { 17 | public static final long DEFAULT_BUCKET_COUNT = 50000; 18 | 19 | public HashLinkedListMemTableConfig() { 20 | bucketCount_ = DEFAULT_BUCKET_COUNT; 21 | } 22 | 23 | /** 24 | * Set the number of buckets in the fixed-size array used 25 | * in the hash linked-list mem-table. 26 | * 27 | * @param count the number of hash buckets. 28 | * @return the reference to the current HashLinkedListMemTableConfig. 29 | */ 30 | public HashLinkedListMemTableConfig setBucketCount(long count) { 31 | bucketCount_ = count; 32 | return this; 33 | } 34 | 35 | /** 36 | * Returns the number of buckets that will be used in the memtable 37 | * created based on this config. 38 | * 39 | * @return the number of buckets 40 | */ 41 | public long bucketCount() { 42 | return bucketCount_; 43 | } 44 | 45 | @Override protected long newMemTableFactoryHandle() { 46 | return newMemTableFactoryHandle(bucketCount_); 47 | } 48 | 49 | private native long newMemTableFactoryHandle(long bucketCount); 50 | 51 | private long bucketCount_; 52 | } 53 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/HistogramData.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | public class HistogramData { 9 | private final double median_; 10 | private final double percentile95_; 11 | private final double percentile99_; 12 | private final double average_; 13 | private final double standardDeviation_; 14 | 15 | public HistogramData(double median, double percentile95, 16 | double percentile99, double average, double standardDeviation) { 17 | median_ = median; 18 | percentile95_ = percentile95; 19 | percentile99_ = percentile99; 20 | average_ = average; 21 | standardDeviation_ = standardDeviation; 22 | } 23 | 24 | public double getMedian() { 25 | return median_; 26 | } 27 | 28 | public double getPercentile95() { 29 | return percentile95_; 30 | } 31 | 32 | public double getPercentile99() { 33 | return percentile99_; 34 | } 35 | 36 | public double getAverage() { 37 | return average_; 38 | } 39 | 40 | public double getStandardDeviation() { 41 | return standardDeviation_; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/HistogramType.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | public enum HistogramType { 9 | DB_GET(0), 10 | DB_WRITE(1), 11 | COMPACTION_TIME(2), 12 | TABLE_SYNC_MICROS(3), 13 | COMPACTION_OUTFILE_SYNC_MICROS(4), 14 | WAL_FILE_SYNC_MICROS(5), 15 | MANIFEST_FILE_SYNC_MICROS(6), 16 | // TIME SPENT IN IO DURING TABLE OPEN 17 | TABLE_OPEN_IO_MICROS(7), 18 | DB_MULTIGET(8), 19 | READ_BLOCK_COMPACTION_MICROS(9), 20 | READ_BLOCK_GET_MICROS(10), 21 | WRITE_RAW_BLOCK_MICROS(11), 22 | 23 | STALL_L0_SLOWDOWN_COUNT(12), 24 | STALL_MEMTABLE_COMPACTION_COUNT(13), 25 | STALL_L0_NUM_FILES_COUNT(14), 26 | HARD_RATE_LIMIT_DELAY_COUNT(15), 27 | SOFT_RATE_LIMIT_DELAY_COUNT(16), 28 | NUM_FILES_IN_SINGLE_COMPACTION(17); 29 | 30 | private final int value_; 31 | 32 | private HistogramType(int value) { 33 | value_ = value; 34 | } 35 | 36 | public int getValue() { 37 | return value_; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/MemTableConfig.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | package org.rocksdb; 6 | 7 | /** 8 | * MemTableConfig is used to config the internal mem-table of a RocksDB. 9 | * It is required for each memtable to have one such sub-class to allow 10 | * Java developers to use it. 11 | * 12 | * To make a RocksDB to use a specific MemTable format, its associated 13 | * MemTableConfig should be properly set and passed into Options 14 | * via Options.setMemTableFactory() and open the db using that Options. 15 | * 16 | * @see Options 17 | */ 18 | public abstract class MemTableConfig { 19 | /** 20 | * This function should only be called by Options.setMemTableConfig(), 21 | * which will create a c++ shared-pointer to the c++ MemTableRepFactory 22 | * that associated with the Java MemTableConfig. 23 | * 24 | * @see Options.setMemTableFactory() 25 | */ 26 | abstract protected long newMemTableFactoryHandle(); 27 | } 28 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/RestoreOptions.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * RestoreOptions to control the behavior of restore. 10 | * 11 | * Note that dispose() must be called before this instance become out-of-scope 12 | * to release the allocated memory in c++. 13 | * 14 | * @param If true, restore won't overwrite the existing log files in wal_dir. It 15 | * will also move all log files from archive directory to wal_dir. Use this 16 | * option in combination with BackupableDBOptions::backup_log_files = false 17 | * for persisting in-memory databases. 18 | * Default: false 19 | */ 20 | public class RestoreOptions extends RocksObject { 21 | public RestoreOptions(boolean keepLogFiles) { 22 | super(); 23 | nativeHandle_ = newRestoreOptions(keepLogFiles); 24 | } 25 | 26 | /** 27 | * Release the memory allocated for the current instance 28 | * in the c++ side. 29 | */ 30 | @Override public synchronized void disposeInternal() { 31 | assert(isInitialized()); 32 | dispose(nativeHandle_); 33 | } 34 | 35 | private native long newRestoreOptions(boolean keepLogFiles); 36 | private native void dispose(long handle); 37 | } 38 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/RocksDBException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | import java.util.*; 9 | 10 | /** 11 | * A RocksDBException encapsulates the error of an operation. This exception 12 | * type is used to describe an internal error from the c++ rocksdb library. 13 | */ 14 | public class RocksDBException extends Exception { 15 | /** 16 | * The private construct used by a set of public static factory method. 17 | * 18 | * @param msg the specified error message. 19 | */ 20 | public RocksDBException(String msg) { 21 | super(msg); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/SkipListMemTableConfig.java: -------------------------------------------------------------------------------- 1 | package org.rocksdb; 2 | 3 | /** 4 | * The config for skip-list memtable representation. 5 | */ 6 | public class SkipListMemTableConfig extends MemTableConfig { 7 | public SkipListMemTableConfig() { 8 | } 9 | 10 | @Override protected long newMemTableFactoryHandle() { 11 | return newMemTableFactoryHandle0(); 12 | } 13 | 14 | private native long newMemTableFactoryHandle0(); 15 | } 16 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/Statistics.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * Statistics to analyze the performance of a db. Pointer for statistics object 10 | * is managed by Options class. 11 | */ 12 | public class Statistics { 13 | 14 | private final long statsHandle_; 15 | 16 | public Statistics(long statsHandle) { 17 | statsHandle_ = statsHandle; 18 | } 19 | 20 | public long getTickerCount(TickerType tickerType) { 21 | assert(isInitialized()); 22 | return getTickerCount0(tickerType.getValue(), statsHandle_); 23 | } 24 | 25 | public HistogramData geHistogramData(HistogramType histogramType) { 26 | assert(isInitialized()); 27 | HistogramData hist = geHistogramData0( 28 | histogramType.getValue(), statsHandle_); 29 | return hist; 30 | } 31 | 32 | private boolean isInitialized() { 33 | return (statsHandle_ != 0); 34 | } 35 | 36 | private native long getTickerCount0(int tickerType, long handle); 37 | private native HistogramData geHistogramData0(int histogramType, long handle); 38 | } 39 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/StatisticsCollectorCallback.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * Callback interface provided to StatisticsCollector. 10 | * 11 | * Thread safety: 12 | * StatisticsCollector doesn't make any guarantees about thread safety. 13 | * If the same reference of StatisticsCollectorCallback is passed to multiple 14 | * StatisticsCollector references, then its the responsibility of the 15 | * user to make StatisticsCollectorCallback's implementation thread-safe. 16 | * 17 | * @param tickerType 18 | * @param tickerCount 19 | */ 20 | public interface StatisticsCollectorCallback { 21 | /** 22 | * Callback function to get ticker values. 23 | * @param tickerType Ticker type. 24 | * @param tickerCount Value of ticker type. 25 | */ 26 | void tickerCallback(TickerType tickerType, long tickerCount); 27 | 28 | /** 29 | * Callback function to get histogram values. 30 | * @param histType Histogram type. 31 | * @param histData Histogram data. 32 | */ 33 | void histogramCallback(HistogramType histType, HistogramData histData); 34 | } 35 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/StatsCollectorInput.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb; 7 | 8 | /** 9 | * Contains all information necessary to collect statistics from one instance 10 | * of DB statistics. 11 | */ 12 | public class StatsCollectorInput { 13 | private final Statistics _statistics; 14 | private final StatisticsCollectorCallback _statsCallback; 15 | 16 | /** 17 | * Constructor for StatsCollectorInput. 18 | * 19 | * @param statistics Reference of DB statistics. 20 | * @param statsCallback Reference of statistics callback interface. 21 | */ 22 | public StatsCollectorInput(Statistics statistics, 23 | StatisticsCollectorCallback statsCallback) { 24 | _statistics = statistics; 25 | _statsCallback = statsCallback; 26 | } 27 | 28 | public Statistics getStatistics() { 29 | return _statistics; 30 | } 31 | 32 | public StatisticsCollectorCallback getCallback() { 33 | return _statsCallback; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/TableFormatConfig.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | package org.rocksdb; 6 | 7 | /** 8 | * TableFormatConfig is used to config the internal Table format of a RocksDB. 9 | * To make a RocksDB to use a specific Table format, its associated 10 | * TableFormatConfig should be properly set and passed into Options via 11 | * Options.setTableFormatConfig() and open the db using that Options. 12 | */ 13 | public abstract class TableFormatConfig { 14 | /** 15 | * This function should only be called by Options.setTableFormatConfig(), 16 | * which will create a c++ shared-pointer to the c++ TableFactory 17 | * that associated with the Java TableFormatConfig. 18 | */ 19 | abstract protected long newTableFactoryHandle(); 20 | } 21 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/VectorMemTableConfig.java: -------------------------------------------------------------------------------- 1 | package org.rocksdb; 2 | 3 | /** 4 | * The config for vector memtable representation. 5 | */ 6 | public class VectorMemTableConfig extends MemTableConfig { 7 | public static final int DEFAULT_RESERVED_SIZE = 0; 8 | public VectorMemTableConfig() { 9 | reservedSize_ = DEFAULT_RESERVED_SIZE; 10 | } 11 | 12 | /** 13 | * Set the initial size of the vector that will be used 14 | * by the memtable created based on this config. 15 | * 16 | * @param size the initial size of the vector. 17 | * @return the reference to the current config. 18 | */ 19 | public VectorMemTableConfig setReservedSize(int size) { 20 | reservedSize_ = size; 21 | return this; 22 | } 23 | 24 | /** 25 | * Returns the initial size of the vector used by the memtable 26 | * created based on this config. 27 | * 28 | * @return the initial size of the vector. 29 | */ 30 | public int reservedSize() { 31 | return reservedSize_; 32 | } 33 | 34 | @Override protected long newMemTableFactoryHandle() { 35 | return newMemTableFactoryHandle(reservedSize_); 36 | } 37 | 38 | private native long newMemTableFactoryHandle(long reservedSize); 39 | private int reservedSize_; 40 | } 41 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/test/ReadOptionsTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb.test; 7 | 8 | import java.util.Random; 9 | import org.rocksdb.RocksDB; 10 | import org.rocksdb.ReadOptions; 11 | 12 | public class ReadOptionsTest { 13 | static { 14 | RocksDB.loadLibrary(); 15 | } 16 | public static void main(String[] args) { 17 | ReadOptions opt = new ReadOptions(); 18 | Random rand = new Random(); 19 | { // VerifyChecksums test 20 | boolean boolValue = rand.nextBoolean(); 21 | opt.setVerifyChecksums(boolValue); 22 | assert(opt.verifyChecksums() == boolValue); 23 | } 24 | 25 | { // FillCache test 26 | boolean boolValue = rand.nextBoolean(); 27 | opt.setFillCache(boolValue); 28 | assert(opt.fillCache() == boolValue); 29 | } 30 | 31 | { // Tailing test 32 | boolean boolValue = rand.nextBoolean(); 33 | opt.setTailing(boolValue); 34 | assert(opt.tailing() == boolValue); 35 | } 36 | 37 | opt.dispose(); 38 | System.out.println("Passed ReadOptionsTest"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/test/StatisticsCollectorTest.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb.test; 7 | 8 | import java.util.Collections; 9 | import org.rocksdb.*; 10 | 11 | public class StatisticsCollectorTest { 12 | static final String db_path = "/tmp/backupablejni_db"; 13 | static { 14 | RocksDB.loadLibrary(); 15 | } 16 | 17 | public static void main(String[] args) 18 | throws InterruptedException, RocksDBException { 19 | Options opt = new Options().createStatistics().setCreateIfMissing(true); 20 | Statistics stats = opt.statisticsPtr(); 21 | 22 | RocksDB db = RocksDB.open(db_path); 23 | 24 | StatsCallbackMock callback = new StatsCallbackMock(); 25 | StatsCollectorInput statsInput = new StatsCollectorInput(stats, callback); 26 | 27 | StatisticsCollector statsCollector = new StatisticsCollector( 28 | Collections.singletonList(statsInput), 100); 29 | statsCollector.start(); 30 | 31 | Thread.sleep(1000); 32 | 33 | assert(callback.tickerCallbackCount > 0); 34 | assert(callback.histCallbackCount > 0); 35 | 36 | statsCollector.shutDown(1000); 37 | 38 | db.close(); 39 | opt.dispose(); 40 | 41 | System.out.println("Stats collector test passed.!"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/test/StatsCallbackMock.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb.test; 7 | 8 | import org.rocksdb.*; 9 | 10 | public class StatsCallbackMock implements StatisticsCollectorCallback { 11 | public int tickerCallbackCount = 0; 12 | public int histCallbackCount = 0; 13 | 14 | public void tickerCallback(TickerType tickerType, long tickerCount) { 15 | tickerCallbackCount++; 16 | } 17 | 18 | public void histogramCallback(HistogramType histType, 19 | HistogramData histData) { 20 | histCallbackCount++; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/util/Environment.java: -------------------------------------------------------------------------------- 1 | package org.rocksdb.util; 2 | 3 | public class Environment { 4 | private static String OS = System.getProperty("os.name").toLowerCase(); 5 | 6 | public static boolean isWindows() { 7 | return (OS.indexOf("win") >= 0); 8 | } 9 | 10 | public static boolean isMac() { 11 | return (OS.indexOf("mac") >= 0); 12 | } 13 | 14 | public static boolean isUnix() { 15 | return (OS.indexOf("nix") >= 0 || 16 | OS.indexOf("nux") >= 0 || 17 | OS.indexOf("aix") >= 0); 18 | } 19 | 20 | public static String getSharedLibraryName(String name) { 21 | if (isUnix()) { 22 | return String.format("lib%s.so", name); 23 | } else if (isMac()) { 24 | return String.format("lib%s.dylib", name); 25 | } 26 | throw new UnsupportedOperationException(); 27 | } 28 | 29 | public static String getJniLibraryName(String name) { 30 | if (isUnix()) { 31 | return String.format("lib%s.so", name); 32 | } else if (isMac()) { 33 | return String.format("lib%s.jnilib", name); 34 | } 35 | throw new UnsupportedOperationException(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/org/rocksdb/util/SizeUnit.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | package org.rocksdb.util; 7 | 8 | public class SizeUnit { 9 | public static final long KB = 1024L; 10 | public static final long MB = KB * KB; 11 | public static final long GB = KB * MB; 12 | public static final long TB = KB * GB; 13 | public static final long PB = KB * TB; 14 | 15 | private SizeUnit() {} 16 | } 17 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/rocksjni/filter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // This file implements the "bridge" between Java and C++ for 7 | // rocksdb::FilterPolicy. 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "include/org_rocksdb_Filter.h" 15 | #include "include/org_rocksdb_BloomFilter.h" 16 | #include "rocksjni/portal.h" 17 | #include "rocksdb/filter_policy.h" 18 | 19 | /* 20 | * Class: org_rocksdb_BloomFilter 21 | * Method: createNewFilter0 22 | * Signature: (I)V 23 | */ 24 | void Java_org_rocksdb_BloomFilter_createNewFilter0( 25 | JNIEnv* env, jobject jobj, jint bits_per_key) { 26 | const rocksdb::FilterPolicy* fp = rocksdb::NewBloomFilterPolicy(bits_per_key); 27 | rocksdb::FilterJni::setHandle(env, jobj, fp); 28 | } 29 | 30 | /* 31 | * Class: org_rocksdb_Filter 32 | * Method: disposeInternal 33 | * Signature: (J)V 34 | */ 35 | void Java_org_rocksdb_Filter_disposeInternal( 36 | JNIEnv* env, jobject jobj, jlong handle) { 37 | delete reinterpret_cast(handle); 38 | } 39 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/rocksjni/statistics.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // This file implements the "bridge" between Java and C++ and enables 7 | // calling c++ rocksdb::Statistics methods from Java side. 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "include/org_rocksdb_Statistics.h" 14 | #include "rocksjni/portal.h" 15 | #include "rocksdb/statistics.h" 16 | 17 | /* 18 | * Class: org_rocksdb_Statistics 19 | * Method: getTickerCount0 20 | * Signature: (IJ)J 21 | */ 22 | jlong Java_org_rocksdb_Statistics_getTickerCount0( 23 | JNIEnv* env, jobject jobj, int tickerType, jlong handle) { 24 | auto st = reinterpret_cast(handle); 25 | assert(st != nullptr); 26 | 27 | return st->getTickerCount(static_cast(tickerType)); 28 | } 29 | 30 | /* 31 | * Class: org_rocksdb_Statistics 32 | * Method: geHistogramData0 33 | * Signature: (IJ)Lorg/rocksdb/HistogramData; 34 | */ 35 | jobject Java_org_rocksdb_Statistics_geHistogramData0( 36 | JNIEnv* env, jobject jobj, int histogramType, jlong handle) { 37 | auto st = reinterpret_cast(handle); 38 | assert(st != nullptr); 39 | 40 | rocksdb::HistogramData data; 41 | st->histogramData(static_cast(histogramType), 42 | &data); 43 | 44 | // Don't reuse class pointer 45 | jclass jclazz = env->FindClass("org/rocksdb/HistogramData"); 46 | jmethodID mid = rocksdb::HistogramDataJni::getConstructorMethodId( 47 | env, jclazz); 48 | return env->NewObject(jclazz, mid, data.median, data.percentile95, 49 | data.percentile99, data.average, data.standard_deviation); 50 | } 51 | -------------------------------------------------------------------------------- /deps/rocksdb-master/java/rocksjni/table.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // This file implements the "bridge" between Java and C++ for rocksdb::Options. 7 | 8 | #include 9 | #include "include/org_rocksdb_PlainTableConfig.h" 10 | #include "rocksdb/table.h" 11 | 12 | /* 13 | * Class: org_rocksdb_PlainTableConfig 14 | * Method: newTableFactoryHandle 15 | * Signature: (IIDI)J 16 | */ 17 | jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle( 18 | JNIEnv* env, jobject jobj, jint jkey_size, jint jbloom_bits_per_key, 19 | jdouble jhash_table_ratio, jint jindex_sparseness) { 20 | rocksdb::PlainTableOptions options = rocksdb::PlainTableOptions(); 21 | options.user_key_len = jkey_size; 22 | options.bloom_bits_per_key = jbloom_bits_per_key; 23 | options.hash_table_ratio = jhash_table_ratio; 24 | options.index_sparseness = jindex_sparseness; 25 | return reinterpret_cast(rocksdb::NewPlainTableFactory(options)); 26 | } 27 | -------------------------------------------------------------------------------- /deps/rocksdb-master/linters/__phutil_library_init__.php: -------------------------------------------------------------------------------- 1 | 2, 11 | 'class' => 12 | array( 13 | 'FacebookFbcodeLintEngine' => 'lint_engine/FacebookFbcodeLintEngine.php', 14 | 'FbcodeCppLinter' => 'cpp_linter/FbcodeCppLinter.php', 15 | 'PfffCppLinter' => 'cpp_linter/PfffCppLinter.php', 16 | 'ArcanistCpplintLinter' => 'cpp_linter/ArcanistCpplintLinter.php', 17 | ), 18 | 'function' => 19 | array( 20 | ), 21 | 'xmap' => 22 | array( 23 | 'FacebookFbcodeLintEngine' => 'ArcanistLintEngine', 24 | 'FbcodeCppLinter' => 'ArcanistLinter', 25 | 'PfffCppLinter' => 'ArcanistLinter', 26 | ), 27 | )); 28 | -------------------------------------------------------------------------------- /deps/rocksdb-master/linters/cpp_linter/PfffCppLinter.php: -------------------------------------------------------------------------------- 1 | &1", 33 | $program, $this->getEngine()->getFilePathOnDisk($p)); 34 | } 35 | foreach (Futures($futures)->limit(8) as $p => $f) { 36 | 37 | list($stdout, $stderr) = $f->resolvex(); 38 | $raw = json_decode($stdout, true); 39 | if (!is_array($raw)) { 40 | throw new Exception( 41 | "checkCpp returned invalid JSON!". 42 | "Stdout: {$stdout} Stderr: {$stderr}" 43 | ); 44 | } 45 | foreach($raw as $err) { 46 | $this->addLintMessage( 47 | ArcanistLintMessage::newFromDictionary( 48 | array( 49 | 'path' => $err['file'], 50 | 'line' => $err['line'], 51 | 'char' => 0, 52 | 'name' => $err['name'], 53 | 'description' => $err['info'], 54 | 'code' => $this->getLinterName(), 55 | 'severity' => ArcanistLintSeverity::SEVERITY_WARNING, 56 | ) 57 | ) 58 | ); 59 | } 60 | } 61 | } 62 | return; 63 | } 64 | 65 | public function lintPath($path) { 66 | return; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /deps/rocksdb-master/port/README: -------------------------------------------------------------------------------- 1 | This directory contains interfaces and implementations that isolate the 2 | rest of the package from platform details. 3 | 4 | Code in the rest of the package includes "port.h" from this directory. 5 | "port.h" in turn includes a platform specific "port_.h" file 6 | that provides the platform specific implementation. 7 | 8 | See port_posix.h for an example of what must be provided in a platform 9 | specific header file. 10 | 11 | -------------------------------------------------------------------------------- /deps/rocksdb-master/port/likely.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #ifndef PORT_LIKELY_H_ 11 | #define PORT_LIKELY_H_ 12 | 13 | #if defined(__GNUC__) && __GNUC__ >= 4 14 | #define LIKELY(x) (__builtin_expect((x), 1)) 15 | #define UNLIKELY(x) (__builtin_expect((x), 0)) 16 | #else 17 | #define LIKELY(x) (x) 18 | #define UNLIKELY(x) (x) 19 | #endif 20 | 21 | #endif // PORT_LIKELY_H_ 22 | -------------------------------------------------------------------------------- /deps/rocksdb-master/port/port.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #ifndef STORAGE_LEVELDB_PORT_PORT_H_ 11 | #define STORAGE_LEVELDB_PORT_PORT_H_ 12 | 13 | #include 14 | 15 | // Include the appropriate platform specific file below. If you are 16 | // porting to a new platform, see "port_example.h" for documentation 17 | // of what the new port_.h file must provide. 18 | #if defined(ROCKSDB_PLATFORM_POSIX) 19 | # include "port/port_posix.h" 20 | #endif 21 | 22 | #endif // STORAGE_LEVELDB_PORT_PORT_H_ 23 | -------------------------------------------------------------------------------- /deps/rocksdb-master/port/stack_trace.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #pragma once 7 | namespace rocksdb { 8 | namespace port { 9 | 10 | // Install a signal handler to print callstack on the following signals: 11 | // SIGILL SIGSEGV SIGBUS SIGABRT 12 | // Currently supports linux only. No-op otherwise. 13 | void InstallStackTraceHandler(); 14 | 15 | // Prints stack, skips skip_first_frames frames 16 | void PrintStack(int first_frames_to_skip = 0); 17 | 18 | } // namespace port 19 | } // namespace rocksdb 20 | -------------------------------------------------------------------------------- /deps/rocksdb-master/port/win/stdint.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | // MSVC didn't ship with this file until the 2010 version. 6 | 7 | #ifndef STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 8 | #define STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 9 | 10 | #if !defined(_MSC_VER) 11 | #error This file should only be included when compiling with MSVC. 12 | #endif 13 | 14 | // Define C99 equivalent types. 15 | typedef signed char int8_t; 16 | typedef signed short int16_t; 17 | typedef signed int int32_t; 18 | typedef signed long long int64_t; 19 | typedef unsigned char uint8_t; 20 | typedef unsigned short uint16_t; 21 | typedef unsigned int uint32_t; 22 | typedef unsigned long long uint64_t; 23 | 24 | #endif // STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 25 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/adaptive_table_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #pragma once 6 | 7 | #ifndef ROCKSDB_LITE 8 | 9 | #include "rocksdb/options.h" 10 | #include "rocksdb/table.h" 11 | 12 | namespace rocksdb { 13 | 14 | struct Options; 15 | struct EnvOptions; 16 | 17 | using std::unique_ptr; 18 | class Status; 19 | class RandomAccessFile; 20 | class WritableFile; 21 | class Table; 22 | class TableBuilder; 23 | 24 | class AdaptiveTableFactory : public TableFactory { 25 | public: 26 | ~AdaptiveTableFactory() {} 27 | 28 | explicit AdaptiveTableFactory( 29 | std::shared_ptr table_factory_to_write, 30 | std::shared_ptr block_based_table_factory, 31 | std::shared_ptr plain_table_factory); 32 | const char* Name() const override { return "AdaptiveTableFactory"; } 33 | Status NewTableReader(const Options& options, const EnvOptions& soptions, 34 | const InternalKeyComparator& internal_comparator, 35 | unique_ptr&& file, uint64_t file_size, 36 | unique_ptr* table) const override; 37 | TableBuilder* NewTableBuilder(const Options& options, 38 | const InternalKeyComparator& icomparator, 39 | WritableFile* file, 40 | CompressionType compression_type) const 41 | override; 42 | 43 | private: 44 | std::shared_ptr table_factory_to_write_; 45 | std::shared_ptr block_based_table_factory_; 46 | std::shared_ptr plain_table_factory_; 47 | }; 48 | 49 | } // namespace rocksdb 50 | #endif // ROCKSDB_LITE 51 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/block_based_table_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #pragma once 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include "rocksdb/flush_block_policy.h" 17 | #include "rocksdb/options.h" 18 | #include "rocksdb/table.h" 19 | 20 | namespace rocksdb { 21 | 22 | struct Options; 23 | struct EnvOptions; 24 | 25 | using std::unique_ptr; 26 | class BlockBasedTableBuilder; 27 | 28 | class BlockBasedTableFactory : public TableFactory { 29 | public: 30 | explicit BlockBasedTableFactory( 31 | const BlockBasedTableOptions& table_options = BlockBasedTableOptions()); 32 | 33 | ~BlockBasedTableFactory() {} 34 | 35 | const char* Name() const override { return "BlockBasedTable"; } 36 | 37 | Status NewTableReader(const Options& options, const EnvOptions& soptions, 38 | const InternalKeyComparator& internal_comparator, 39 | unique_ptr&& file, uint64_t file_size, 40 | unique_ptr* table_reader) const override; 41 | 42 | TableBuilder* NewTableBuilder( 43 | const Options& options, const InternalKeyComparator& internal_comparator, 44 | WritableFile* file, CompressionType compression_type) const override; 45 | 46 | private: 47 | BlockBasedTableOptions table_options_; 48 | }; 49 | 50 | extern const std::string kHashIndexPrefixesBlock; 51 | extern const std::string kHashIndexPrefixesMetadataBlock; 52 | 53 | } // namespace rocksdb 54 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/bloom_block.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #include "table/bloom_block.h" 7 | 8 | #include 9 | #include "rocksdb/slice.h" 10 | #include "util/dynamic_bloom.h" 11 | 12 | namespace rocksdb { 13 | 14 | void BloomBlockBuilder::AddKeysHashes(const std::vector keys_hashes) { 15 | for (auto hash : keys_hashes) { 16 | bloom_.AddHash(hash); 17 | } 18 | } 19 | 20 | Slice BloomBlockBuilder::Finish() { return bloom_.GetRawData(); } 21 | 22 | const std::string BloomBlockBuilder::kBloomBlock = "kBloomBlock"; 23 | } // namespace rocksdb 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/bloom_block.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include "util/dynamic_bloom.h" 10 | 11 | namespace rocksdb { 12 | class Logger; 13 | 14 | class BloomBlockBuilder { 15 | public: 16 | static const std::string kBloomBlock; 17 | 18 | explicit BloomBlockBuilder(uint32_t num_probes = 6) 19 | : bloom_(num_probes, nullptr) {} 20 | 21 | void SetTotalBits(Arena* arena, uint32_t total_bits, uint32_t locality, 22 | size_t huge_page_tlb_size, Logger* logger) { 23 | bloom_.SetTotalBits(arena, total_bits, locality, huge_page_tlb_size, 24 | logger); 25 | } 26 | 27 | uint32_t GetNumBlocks() const { return bloom_.GetNumBlocks(); } 28 | 29 | void AddKeysHashes(const std::vector keys_hashes); 30 | 31 | Slice Finish(); 32 | 33 | private: 34 | DynamicBloom bloom_; 35 | }; 36 | 37 | }; // namespace rocksdb 38 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/cuckoo_table_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | #ifndef ROCKSDB_LITE 8 | 9 | #include "util/murmurhash.h" 10 | 11 | namespace rocksdb { 12 | 13 | static const uint32_t kMaxNumHashTable = 64; 14 | 15 | uint64_t GetSliceMurmurHash(const Slice& s, uint32_t index, 16 | uint64_t max_num_buckets) { 17 | static constexpr uint32_t seeds[kMaxNumHashTable] = { 18 | 816922183, 506425713, 949485004, 22513986, 421427259, 500437285, 19 | 888981693, 847587269, 511007211, 722295391, 934013645, 566947683, 20 | 193618736, 428277388, 770956674, 819994962, 755946528, 40807421, 21 | 263144466, 241420041, 444294464, 731606396, 304158902, 563235655, 22 | 968740453, 336996831, 462831574, 407970157, 985877240, 637708754, 23 | 736932700, 205026023, 755371467, 729648411, 807744117, 46482135, 24 | 847092855, 620960699, 102476362, 314094354, 625838942, 550889395, 25 | 639071379, 834567510, 397667304, 151945969, 443634243, 196618243, 26 | 421986347, 407218337, 964502417, 327741231, 493359459, 452453139, 27 | 692216398, 108161624, 816246924, 234779764, 618949448, 496133787, 28 | 156374056, 316589799, 982915425, 553105889 }; 29 | return MurmurHash(s.data(), s.size(), seeds[index]) % max_num_buckets; 30 | } 31 | } // namespace rocksdb 32 | #endif // ROCKSDB_LITE 33 | -------------------------------------------------------------------------------- /deps/rocksdb-master/table/iter_heap.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | 7 | #pragma once 8 | #include 9 | 10 | #include "rocksdb/comparator.h" 11 | #include "table/iterator_wrapper.h" 12 | 13 | namespace rocksdb { 14 | 15 | // Return the max of two keys. 16 | class MaxIteratorComparator { 17 | public: 18 | MaxIteratorComparator(const Comparator* comparator) : 19 | comparator_(comparator) {} 20 | 21 | bool operator()(IteratorWrapper* a, IteratorWrapper* b) { 22 | return comparator_->Compare(a->key(), b->key()) <= 0; 23 | } 24 | private: 25 | const Comparator* comparator_; 26 | }; 27 | 28 | // Return the max of two keys. 29 | class MinIteratorComparator { 30 | public: 31 | // if maxHeap is set comparator returns the max value. 32 | // else returns the min Value. 33 | // Can use to create a minHeap or a maxHeap. 34 | MinIteratorComparator(const Comparator* comparator) : 35 | comparator_(comparator) {} 36 | 37 | bool operator()(IteratorWrapper* a, IteratorWrapper* b) { 38 | return comparator_->Compare(a->key(), b->key()) > 0; 39 | } 40 | private: 41 | const Comparator* comparator_; 42 | }; 43 | 44 | } // namespace rocksdb 45 | -------------------------------------------------------------------------------- /deps/rocksdb-master/third-party/rapidjson/filestream.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_FILESTREAM_H_ 2 | #define RAPIDJSON_FILESTREAM_H_ 3 | 4 | #include 5 | 6 | namespace rapidjson { 7 | 8 | //! Wrapper of C file stream for input or output. 9 | /*! 10 | This simple wrapper does not check the validity of the stream. 11 | \implements Stream 12 | */ 13 | class FileStream { 14 | public: 15 | typedef char Ch; //!< Character type. Only support char. 16 | 17 | FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); } 18 | char Peek() const { return current_; } 19 | char Take() { char c = current_; Read(); return c; } 20 | size_t Tell() const { return count_; } 21 | void Put(char c) { fputc(c, fp_); } 22 | 23 | // Not implemented 24 | char* PutBegin() { return 0; } 25 | size_t PutEnd(char*) { return 0; } 26 | 27 | private: 28 | void Read() { 29 | RAPIDJSON_ASSERT(fp_ != 0); 30 | int c = fgetc(fp_); 31 | if (c != EOF) { 32 | current_ = (char)c; 33 | count_++; 34 | } 35 | else 36 | current_ = '\0'; 37 | } 38 | 39 | FILE* fp_; 40 | char current_; 41 | size_t count_; 42 | }; 43 | 44 | } // namespace rapidjson 45 | 46 | #endif // RAPIDJSON_FILESTREAM_H_ 47 | -------------------------------------------------------------------------------- /deps/rocksdb-master/third-party/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 2 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Custom strlen() which works on different character types. 8 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 9 | \param s Null-terminated input string. 10 | \return Number of characters in the string. 11 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 12 | */ 13 | template 14 | inline SizeType StrLen(const Ch* s) { 15 | const Ch* p = s; 16 | while (*p != '\0') 17 | ++p; 18 | return SizeType(p - s); 19 | } 20 | 21 | } // namespace internal 22 | } // namespace rapidjson 23 | 24 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 25 | -------------------------------------------------------------------------------- /deps/rocksdb-master/third-party/rapidjson/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Milo Yip 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /deps/rocksdb-master/third-party/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 2 | #define RAPIDJSON_STRINGBUFFER_H_ 3 | 4 | #include "rapidjson.h" 5 | #include "internal/stack.h" 6 | 7 | namespace rapidjson { 8 | 9 | //! Represents an in-memory output stream. 10 | /*! 11 | \tparam Encoding Encoding of the stream. 12 | \tparam Allocator type for allocating memory buffer. 13 | \implements Stream 14 | */ 15 | template 16 | struct GenericStringBuffer { 17 | typedef typename Encoding::Ch Ch; 18 | 19 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 20 | 21 | void Put(Ch c) { *stack_.template Push() = c; } 22 | 23 | void Clear() { stack_.Clear(); } 24 | 25 | const char* GetString() const { 26 | // Push and pop a null terminator. This is safe. 27 | *stack_.template Push() = '\0'; 28 | stack_.template Pop(1); 29 | 30 | return stack_.template Bottom(); 31 | } 32 | 33 | size_t Size() const { return stack_.GetSize(); } 34 | 35 | static const size_t kDefaultCapacity = 256; 36 | mutable internal::Stack stack_; 37 | }; 38 | 39 | typedef GenericStringBuffer > StringBuffer; 40 | 41 | //! Implement specialized version of PutN() with memset() for better performance. 42 | template<> 43 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 44 | memset(stream.stack_.Push(n), c, n * sizeof(c)); 45 | } 46 | 47 | } // namespace rapidjson 48 | 49 | #endif // RAPIDJSON_STRINGBUFFER_H_ 50 | -------------------------------------------------------------------------------- /deps/rocksdb-master/tools/ldb.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | 7 | #include "rocksdb/ldb_tool.h" 8 | 9 | int main(int argc, char** argv) { 10 | rocksdb::LDBTool tool; 11 | tool.Run(argc, argv); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/benchharness_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | 7 | #include "util/benchharness.h" 8 | #include 9 | 10 | namespace rocksdb { 11 | 12 | BENCHMARK(insertFrontVector) { 13 | std::vector v; 14 | for (int i = 0; i < 100; i++) { 15 | v.insert(v.begin(), i); 16 | } 17 | } 18 | 19 | BENCHMARK_RELATIVE(insertBackVector) { 20 | std::vector v; 21 | for (size_t i = 0; i < 100; i++) { 22 | v.insert(v.end(), i); 23 | } 24 | } 25 | 26 | BENCHMARK_N(insertFrontVector_n, n) { 27 | std::vector v; 28 | for (size_t i = 0; i < n; i++) { 29 | v.insert(v.begin(), i); 30 | } 31 | } 32 | 33 | BENCHMARK_RELATIVE_N(insertBackVector_n, n) { 34 | std::vector v; 35 | for (size_t i = 0; i < n; i++) { 36 | v.insert(v.end(), i); 37 | } 38 | } 39 | 40 | BENCHMARK_N(insertFrontEnd_n, n) { 41 | std::vector v; 42 | for (size_t i = 0; i < n; i++) { 43 | v.insert(v.begin(), i); 44 | } 45 | for (size_t i = 0; i < n; i++) { 46 | v.insert(v.end(), i); 47 | } 48 | } 49 | 50 | BENCHMARK_RELATIVE_N(insertFrontEndSuspend_n, n) { 51 | std::vector v; 52 | for (size_t i = 0; i < n; i++) { 53 | v.insert(v.begin(), i); 54 | } 55 | BENCHMARK_SUSPEND { 56 | for (size_t i = 0; i < n; i++) { 57 | v.insert(v.end(), i); 58 | } 59 | } 60 | } 61 | 62 | } // namespace rocksdb 63 | 64 | int main(int argc, char** argv) { 65 | rocksdb::benchmark::RunBenchmarks(); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/build_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #pragma once 7 | #if !defined(IOS_CROSS_COMPILE) 8 | // if we compile with Xcode, we don't run build_detect_vesion, so we don't 9 | // generate these variables 10 | // these variables tell us about the git config and time 11 | extern const char* rocksdb_build_git_sha; 12 | 13 | // these variables tell us when the compilation occurred 14 | extern const char* rocksdb_build_compile_time; 15 | extern const char* rocksdb_build_compile_date; 16 | #endif 17 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/crc32c.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #pragma once 11 | #include 12 | #include 13 | 14 | namespace rocksdb { 15 | namespace crc32c { 16 | 17 | // Return the crc32c of concat(A, data[0,n-1]) where init_crc is the 18 | // crc32c of some string A. Extend() is often used to maintain the 19 | // crc32c of a stream of data. 20 | extern uint32_t Extend(uint32_t init_crc, const char* data, size_t n); 21 | 22 | // Return the crc32c of data[0,n-1] 23 | inline uint32_t Value(const char* data, size_t n) { 24 | return Extend(0, data, n); 25 | } 26 | 27 | static const uint32_t kMaskDelta = 0xa282ead8ul; 28 | 29 | // Return a masked representation of crc. 30 | // 31 | // Motivation: it is problematic to compute the CRC of a string that 32 | // contains embedded CRCs. Therefore we recommend that CRCs stored 33 | // somewhere (e.g., in files) should be masked before being stored. 34 | inline uint32_t Mask(uint32_t crc) { 35 | // Rotate right by 15 bits and add a constant. 36 | return ((crc >> 15) | (crc << 17)) + kMaskDelta; 37 | } 38 | 39 | // Return the crc whose masked representation is masked_crc. 40 | inline uint32_t Unmask(uint32_t masked_crc) { 41 | uint32_t rot = masked_crc - kMaskDelta; 42 | return ((rot >> 17) | (rot << 15)); 43 | } 44 | 45 | } // namespace crc32c 46 | } // namespace rocksdb 47 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/filelock_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #include "rocksdb/status.h" 7 | #include "rocksdb/env.h" 8 | 9 | #include 10 | #include "util/coding.h" 11 | #include "util/testharness.h" 12 | 13 | namespace rocksdb { 14 | 15 | class LockTest { 16 | public: 17 | static LockTest* current_; 18 | std::string file_; 19 | rocksdb::Env* env_; 20 | 21 | LockTest() : file_(test::TmpDir() + "/db_testlock_file"), 22 | env_(rocksdb::Env::Default()) { 23 | current_ = this; 24 | } 25 | 26 | ~LockTest() { 27 | } 28 | 29 | Status LockFile(FileLock** db_lock) { 30 | return env_->LockFile(file_, db_lock); 31 | } 32 | 33 | Status UnlockFile(FileLock* db_lock) { 34 | return env_->UnlockFile(db_lock); 35 | } 36 | }; 37 | LockTest* LockTest::current_; 38 | 39 | TEST(LockTest, LockBySameThread) { 40 | FileLock* lock1; 41 | FileLock* lock2; 42 | 43 | // acquire a lock on a file 44 | ASSERT_OK(LockFile(&lock1)); 45 | 46 | // re-acquire the lock on the same file. This should fail. 47 | ASSERT_TRUE(LockFile(&lock2).IsIOError()); 48 | 49 | // release the lock 50 | ASSERT_OK(UnlockFile(lock1)); 51 | 52 | } 53 | 54 | } // namespace rocksdb 55 | 56 | int main(int argc, char** argv) { 57 | return rocksdb::test::RunAllTests(); 58 | } 59 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/filter_policy.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2012 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #include "rocksdb/filter_policy.h" 11 | 12 | namespace rocksdb { 13 | 14 | FilterPolicy::~FilterPolicy() { } 15 | 16 | } // namespace rocksdb 17 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/hash.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #include 11 | #include "util/coding.h" 12 | #include "util/hash.h" 13 | 14 | namespace rocksdb { 15 | 16 | uint32_t Hash(const char* data, size_t n, uint32_t seed) { 17 | // Similar to murmur hash 18 | const uint32_t m = 0xc6a4a793; 19 | const uint32_t r = 24; 20 | const char* limit = data + n; 21 | uint32_t h = seed ^ (n * m); 22 | 23 | // Pick up four bytes at a time 24 | while (data + 4 <= limit) { 25 | uint32_t w = DecodeFixed32(data); 26 | data += 4; 27 | h += w; 28 | h *= m; 29 | h ^= (h >> 16); 30 | } 31 | 32 | // Pick up remaining bytes 33 | switch (limit - data) { 34 | case 3: 35 | h += data[2] << 16; 36 | // fall through 37 | case 2: 38 | h += data[1] << 8; 39 | // fall through 40 | case 1: 41 | h += data[0]; 42 | h *= m; 43 | h ^= (h >> r); 44 | break; 45 | } 46 | return h; 47 | } 48 | 49 | } // namespace rocksdb 50 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | // 10 | // Simple hash function used for internal data structures 11 | 12 | #pragma once 13 | #include 14 | #include 15 | 16 | namespace rocksdb { 17 | 18 | extern uint32_t Hash(const char* data, size_t n, uint32_t seed); 19 | 20 | inline uint32_t GetSliceHash(const Slice& s) { 21 | return Hash(s.data(), s.size(), 397); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/hash_cuckoo_rep.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 6 | // Use of this source code is governed by a BSD-style license that can be 7 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 8 | 9 | #ifndef ROCKSDB_LITE 10 | #pragma once 11 | #include "rocksdb/slice_transform.h" 12 | #include "rocksdb/memtablerep.h" 13 | 14 | namespace rocksdb { 15 | 16 | class HashCuckooRepFactory : public MemTableRepFactory { 17 | public: 18 | // maxinum number of hash functions used in the cuckoo hash. 19 | static const unsigned int kMaxHashCount = 10; 20 | 21 | explicit HashCuckooRepFactory(size_t write_buffer_size, 22 | size_t average_data_size, 23 | unsigned int hash_function_count) 24 | : write_buffer_size_(write_buffer_size), 25 | average_data_size_(average_data_size), 26 | hash_function_count_(hash_function_count) {} 27 | 28 | virtual ~HashCuckooRepFactory() {} 29 | 30 | virtual MemTableRep* CreateMemTableRep( 31 | const MemTableRep::KeyComparator& compare, Arena* arena, 32 | const SliceTransform* transform, Logger* logger) override; 33 | 34 | virtual const char* Name() const override { return "HashCuckooRepFactory"; } 35 | 36 | private: 37 | size_t write_buffer_size_; 38 | size_t average_data_size_; 39 | const unsigned int hash_function_count_; 40 | }; 41 | } // namespace rocksdb 42 | #endif // ROCKSDB_LITE 43 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/hash_linklist_rep.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 6 | // Use of this source code is governed by a BSD-style license that can be 7 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 8 | 9 | #ifndef ROCKSDB_LITE 10 | #pragma once 11 | #include "rocksdb/slice_transform.h" 12 | #include "rocksdb/memtablerep.h" 13 | 14 | namespace rocksdb { 15 | 16 | class HashLinkListRepFactory : public MemTableRepFactory { 17 | public: 18 | explicit HashLinkListRepFactory(size_t bucket_count, 19 | uint32_t threshold_use_skiplist, 20 | size_t huge_page_tlb_size, 21 | int bucket_entries_logging_threshold, 22 | bool if_log_bucket_dist_when_flash) 23 | : bucket_count_(bucket_count), 24 | threshold_use_skiplist_(threshold_use_skiplist), 25 | huge_page_tlb_size_(huge_page_tlb_size), 26 | bucket_entries_logging_threshold_(bucket_entries_logging_threshold), 27 | if_log_bucket_dist_when_flash_(if_log_bucket_dist_when_flash) {} 28 | 29 | virtual ~HashLinkListRepFactory() {} 30 | 31 | virtual MemTableRep* CreateMemTableRep( 32 | const MemTableRep::KeyComparator& compare, Arena* arena, 33 | const SliceTransform* transform, Logger* logger) override; 34 | 35 | virtual const char* Name() const override { 36 | return "HashLinkListRepFactory"; 37 | } 38 | 39 | private: 40 | const size_t bucket_count_; 41 | const uint32_t threshold_use_skiplist_; 42 | const size_t huge_page_tlb_size_; 43 | int bucket_entries_logging_threshold_; 44 | bool if_log_bucket_dist_when_flash_; 45 | }; 46 | 47 | } 48 | #endif // ROCKSDB_LITE 49 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/hash_skiplist_rep.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 6 | // Use of this source code is governed by a BSD-style license that can be 7 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 8 | 9 | #ifndef ROCKSDB_LITE 10 | #pragma once 11 | #include "rocksdb/slice_transform.h" 12 | #include "rocksdb/memtablerep.h" 13 | 14 | namespace rocksdb { 15 | 16 | class HashSkipListRepFactory : public MemTableRepFactory { 17 | public: 18 | explicit HashSkipListRepFactory( 19 | size_t bucket_count, 20 | int32_t skiplist_height, 21 | int32_t skiplist_branching_factor) 22 | : bucket_count_(bucket_count), 23 | skiplist_height_(skiplist_height), 24 | skiplist_branching_factor_(skiplist_branching_factor) { } 25 | 26 | virtual ~HashSkipListRepFactory() {} 27 | 28 | virtual MemTableRep* CreateMemTableRep( 29 | const MemTableRep::KeyComparator& compare, Arena* arena, 30 | const SliceTransform* transform, Logger* logger) override; 31 | 32 | virtual const char* Name() const override { 33 | return "HashSkipListRepFactory"; 34 | } 35 | 36 | private: 37 | const size_t bucket_count_; 38 | const int32_t skiplist_height_; 39 | const int32_t skiplist_branching_factor_; 40 | }; 41 | 42 | } 43 | #endif // ROCKSDB_LITE 44 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/histogram_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #include "util/histogram.h" 7 | 8 | #include "util/testharness.h" 9 | 10 | namespace rocksdb { 11 | 12 | class HistogramTest { }; 13 | 14 | TEST(HistogramTest, BasicOperation) { 15 | 16 | HistogramImpl histogram; 17 | for (uint64_t i = 1; i <= 100; i++) { 18 | histogram.Add(i); 19 | } 20 | 21 | { 22 | double median = histogram.Median(); 23 | // ASSERT_LE(median, 50); 24 | ASSERT_GT(median, 0); 25 | } 26 | 27 | { 28 | double percentile100 = histogram.Percentile(100.0); 29 | ASSERT_LE(percentile100, 100.0); 30 | ASSERT_GT(percentile100, 0.0); 31 | double percentile99 = histogram.Percentile(99.0); 32 | double percentile85 = histogram.Percentile(85.0); 33 | ASSERT_LE(percentile99, 99.0); 34 | ASSERT_TRUE(percentile99 >= percentile85); 35 | } 36 | 37 | ASSERT_EQ(histogram.Average(), 50.5); // avg is acurately caluclated. 38 | } 39 | 40 | TEST(HistogramTest, EmptyHistogram) { 41 | HistogramImpl histogram; 42 | ASSERT_EQ(histogram.Median(), 0.0); 43 | ASSERT_EQ(histogram.Percentile(85.0), 0.0); 44 | ASSERT_EQ(histogram.Average(), 0.0); 45 | } 46 | 47 | TEST(HistogramTest, ClearHistogram) { 48 | HistogramImpl histogram; 49 | for (uint64_t i = 1; i <= 100; i++) { 50 | histogram.Add(i); 51 | } 52 | histogram.Clear(); 53 | ASSERT_EQ(histogram.Median(), 0); 54 | ASSERT_EQ(histogram.Percentile(85.0), 0); 55 | ASSERT_EQ(histogram.Average(), 0); 56 | } 57 | 58 | } // namespace rocksdb 59 | 60 | int main(int argc, char** argv) { 61 | return rocksdb::test::RunAllTests(); 62 | } 63 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/iostats_context.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #include 7 | #include "rocksdb/env.h" 8 | #include "util/iostats_context_imp.h" 9 | 10 | namespace rocksdb { 11 | 12 | __thread IOStatsContext iostats_context; 13 | 14 | void IOStatsContext::Reset() { 15 | thread_pool_id = Env::Priority::TOTAL; 16 | bytes_read = 0; 17 | bytes_written = 0; 18 | } 19 | 20 | #define OUTPUT(counter) #counter << " = " << counter << ", " 21 | 22 | std::string IOStatsContext::ToString() const { 23 | std::ostringstream ss; 24 | ss << OUTPUT(thread_pool_id) 25 | << OUTPUT(bytes_read) 26 | << OUTPUT(bytes_written); 27 | return ss.str(); 28 | } 29 | 30 | } // namespace rocksdb 31 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/iostats_context_imp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #pragma once 7 | #include "rocksdb/iostats_context.h" 8 | 9 | // increment a specific counter by the specified value 10 | #define IOSTATS_ADD(metric, value) \ 11 | (iostats_context.metric += value) 12 | 13 | // Increase metric value only when it is positive 14 | #define IOSTATS_ADD_IF_POSITIVE(metric, value) \ 15 | if (value > 0) { IOSTATS_ADD(metric, value); } 16 | 17 | // reset a specific counter to zero 18 | #define IOSTATS_RESET(metric) \ 19 | (iostats_context.metric = 0) 20 | 21 | // reset all counters to zero 22 | #define IOSTATS_RESET_ALL() \ 23 | (iostats_context.Reset()) 24 | 25 | #define IOSTATS_SET_THREAD_POOL_ID(value) \ 26 | (iostats_context.thread_pool_id = value) 27 | 28 | #define IOSTATS_THREAD_POOL_ID() \ 29 | (iostats_context.thread_pool_id) 30 | 31 | #define IOSTATS(metric) \ 32 | (iostats_context.metric) 33 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/ldb_cmd_execute_result.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #pragma once 7 | 8 | namespace rocksdb { 9 | 10 | class LDBCommandExecuteResult { 11 | public: 12 | enum State { 13 | EXEC_NOT_STARTED = 0, EXEC_SUCCEED = 1, EXEC_FAILED = 2, 14 | }; 15 | 16 | LDBCommandExecuteResult() { 17 | state_ = EXEC_NOT_STARTED; 18 | message_ = ""; 19 | } 20 | 21 | LDBCommandExecuteResult(State state, std::string& msg) { 22 | state_ = state; 23 | message_ = msg; 24 | } 25 | 26 | std::string ToString() { 27 | std::string ret; 28 | switch (state_) { 29 | case EXEC_SUCCEED: 30 | break; 31 | case EXEC_FAILED: 32 | ret.append("Failed: "); 33 | break; 34 | case EXEC_NOT_STARTED: 35 | ret.append("Not started: "); 36 | } 37 | if (!message_.empty()) { 38 | ret.append(message_); 39 | } 40 | return ret; 41 | } 42 | 43 | void Reset() { 44 | state_ = EXEC_NOT_STARTED; 45 | message_ = ""; 46 | } 47 | 48 | bool IsSucceed() { 49 | return state_ == EXEC_SUCCEED; 50 | } 51 | 52 | bool IsNotStarted() { 53 | return state_ == EXEC_NOT_STARTED; 54 | } 55 | 56 | bool IsFailed() { 57 | return state_ == EXEC_FAILED; 58 | } 59 | 60 | static LDBCommandExecuteResult SUCCEED(std::string msg) { 61 | return LDBCommandExecuteResult(EXEC_SUCCEED, msg); 62 | } 63 | 64 | static LDBCommandExecuteResult FAILED(std::string msg) { 65 | return LDBCommandExecuteResult(EXEC_FAILED, msg); 66 | } 67 | 68 | private: 69 | State state_; 70 | std::string message_; 71 | 72 | bool operator==(const LDBCommandExecuteResult&); 73 | bool operator!=(const LDBCommandExecuteResult&); 74 | }; 75 | 76 | } 77 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/log_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #pragma once 7 | 8 | #include "rocksdb/env.h" 9 | #include "util/arena.h" 10 | #include "util/autovector.h" 11 | #include 12 | 13 | namespace rocksdb { 14 | 15 | class Logger; 16 | 17 | // A class to buffer info log entries and flush them in the end. 18 | class LogBuffer { 19 | public: 20 | // log_level: the log level for all the logs 21 | // info_log: logger to write the logs to 22 | LogBuffer(const InfoLogLevel log_level, Logger* info_log); 23 | 24 | // Add a log entry to the buffer. 25 | void AddLogToBuffer(const char* format, va_list ap); 26 | 27 | size_t IsEmpty() const { return logs_.empty(); } 28 | 29 | // Flush all buffered log to the info log. 30 | void FlushBufferToLog(); 31 | 32 | private: 33 | // One log entry with its timestamp 34 | struct BufferedLog { 35 | struct timeval now_tv; // Timestamp of the log 36 | char message[1]; // Beginning of log message 37 | }; 38 | 39 | const InfoLogLevel log_level_; 40 | Logger* info_log_; 41 | Arena arena_; 42 | autovector logs_; 43 | }; 44 | 45 | // Add log to the LogBuffer for a delayed info logging. It can be used when 46 | // we want to add some logs inside a mutex. 47 | extern void LogToBuffer(LogBuffer* log_buffer, const char* format, ...); 48 | 49 | } // namespace rocksdb 50 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | // 10 | // Must not be included from any .h files to avoid polluting the namespace 11 | // with macros. 12 | 13 | #pragma once 14 | #include 15 | #include 16 | #include 17 | #include "port/port.h" 18 | 19 | namespace rocksdb { 20 | 21 | class Slice; 22 | class WritableFile; 23 | 24 | // Append a human-readable size in bytes 25 | int AppendHumanBytes(uint64_t bytes, char* output, int len); 26 | 27 | // Append a human-readable printout of "num" to *str 28 | extern void AppendNumberTo(std::string* str, uint64_t num); 29 | 30 | // Append a human-readable printout of "value" to *str. 31 | // Escapes any non-printable characters found in "value". 32 | extern void AppendEscapedStringTo(std::string* str, const Slice& value); 33 | 34 | // Return a human-readable printout of "num" 35 | extern std::string NumberToString(uint64_t num); 36 | 37 | // Return a human-readable version of "value". 38 | // Escapes any non-printable characters found in "value". 39 | extern std::string EscapeString(const Slice& value); 40 | 41 | // Parse a human-readable number from "*in" into *value. On success, 42 | // advances "*in" past the consumed number and sets "*val" to the 43 | // numeric value. Otherwise, returns false and leaves *in in an 44 | // unspecified state. 45 | extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val); 46 | 47 | } // namespace rocksdb 48 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/murmurhash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | /* 7 | Murmurhash from http://sites.google.com/site/murmurhash/ 8 | 9 | All code is released to the public domain. For business purposes, Murmurhash is 10 | under the MIT license. 11 | */ 12 | #pragma once 13 | #include 14 | #include "rocksdb/slice.h" 15 | 16 | #if defined(__x86_64__) 17 | #define MURMUR_HASH MurmurHash64A 18 | uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed ); 19 | #define MurmurHash MurmurHash64A 20 | typedef uint64_t murmur_t; 21 | 22 | #elif defined(__i386__) 23 | #define MURMUR_HASH MurmurHash2 24 | unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed ); 25 | #define MurmurHash MurmurHash2 26 | typedef unsigned int murmur_t; 27 | 28 | #else 29 | #define MURMUR_HASH MurmurHashNeutral2 30 | unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed ); 31 | #define MurmurHash MurmurHashNeutral2 32 | typedef unsigned int murmur_t; 33 | #endif 34 | 35 | // Allow slice to be hashable by murmur hash. 36 | namespace rocksdb { 37 | struct murmur_hash { 38 | size_t operator()(const Slice& slice) const { 39 | return MurmurHash(slice.data(), slice.size(), 0); 40 | } 41 | }; 42 | } // rocksdb 43 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/signal_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #include "port/stack_trace.h" 7 | #include 8 | 9 | namespace { 10 | void f0() { 11 | char *p = nullptr; 12 | *p = 10; /* SIGSEGV here!! */ 13 | } 14 | 15 | void f1() { 16 | f0(); 17 | } 18 | 19 | void f2() { 20 | f1(); 21 | } 22 | 23 | void f3() { 24 | f2(); 25 | } 26 | } // namespace 27 | 28 | int main() { 29 | rocksdb::port::InstallStackTraceHandler(); 30 | 31 | f3(); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/stl_wrappers.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #pragma once 7 | 8 | #include "util/murmurhash.h" 9 | #include "util/coding.h" 10 | 11 | #include "rocksdb/memtablerep.h" 12 | #include "rocksdb/slice.h" 13 | 14 | namespace rocksdb { 15 | namespace stl_wrappers { 16 | class Base { 17 | protected: 18 | const MemTableRep::KeyComparator& compare_; 19 | explicit Base(const MemTableRep::KeyComparator& compare) 20 | : compare_(compare) { } 21 | }; 22 | 23 | struct Compare : private Base { 24 | explicit Compare(const MemTableRep::KeyComparator& compare) 25 | : Base(compare) { } 26 | inline bool operator()(const char* a, const char* b) const { 27 | return compare_(a, b) < 0; 28 | } 29 | }; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/string_util.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #include 7 | #include 8 | #include 9 | #include "util/string_util.h" 10 | 11 | namespace rocksdb { 12 | 13 | std::vector stringSplit(std::string arg, char delim) { 14 | std::vector splits; 15 | std::stringstream ss(arg); 16 | std::string item; 17 | while (std::getline(ss, item, delim)) { 18 | splits.push_back(item); 19 | } 20 | return splits; 21 | } 22 | 23 | } // namespace rocksdb 24 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/string_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #include 7 | #include 8 | #include 9 | 10 | #pragma once 11 | namespace rocksdb { 12 | 13 | extern std::vector stringSplit(std::string arg, char delim); 14 | 15 | } // namespace rocksdb 16 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/sync_point.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | 6 | #include "util/sync_point.h" 7 | 8 | #ifndef NDEBUG 9 | namespace rocksdb { 10 | 11 | SyncPoint* SyncPoint::GetInstance() { 12 | static SyncPoint sync_point; 13 | return &sync_point; 14 | } 15 | 16 | void SyncPoint::LoadDependency(const std::vector& dependencies) { 17 | successors_.clear(); 18 | predecessors_.clear(); 19 | cleared_points_.clear(); 20 | for (const auto& dependency : dependencies) { 21 | successors_[dependency.predecessor].push_back(dependency.successor); 22 | predecessors_[dependency.successor].push_back(dependency.predecessor); 23 | } 24 | } 25 | 26 | bool SyncPoint::PredecessorsAllCleared(const std::string& point) { 27 | for (const auto& pred : predecessors_[point]) { 28 | if (cleared_points_.count(pred) == 0) { 29 | return false; 30 | } 31 | } 32 | return true; 33 | } 34 | 35 | void SyncPoint::EnableProcessing() { 36 | std::unique_lock lock(mutex_); 37 | enabled_ = true; 38 | } 39 | 40 | void SyncPoint::DisableProcessing() { 41 | std::unique_lock lock(mutex_); 42 | enabled_ = false; 43 | } 44 | 45 | void SyncPoint::ClearTrace() { 46 | std::unique_lock lock(mutex_); 47 | cleared_points_.clear(); 48 | } 49 | 50 | void SyncPoint::Process(const std::string& point) { 51 | std::unique_lock lock(mutex_); 52 | 53 | if (!enabled_) return; 54 | 55 | while (!PredecessorsAllCleared(point)) { 56 | cv_.wait(lock); 57 | } 58 | 59 | cleared_points_.insert(point); 60 | cv_.notify_all(); 61 | } 62 | 63 | } // namespace rocksdb 64 | #endif // NDEBUG 65 | -------------------------------------------------------------------------------- /deps/rocksdb-master/util/testutil.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 | // Use of this source code is governed by a BSD-style license that can be 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 | 10 | #include "util/testutil.h" 11 | 12 | #include "util/random.h" 13 | 14 | namespace rocksdb { 15 | namespace test { 16 | 17 | Slice RandomString(Random* rnd, int len, std::string* dst) { 18 | dst->resize(len); 19 | for (int i = 0; i < len; i++) { 20 | (*dst)[i] = static_cast(' ' + rnd->Uniform(95)); // ' ' .. '~' 21 | } 22 | return Slice(*dst); 23 | } 24 | 25 | std::string RandomKey(Random* rnd, int len) { 26 | // Make sure to generate a wide variety of characters so we 27 | // test the boundary conditions for short-key optimizations. 28 | static const char kTestChars[] = { 29 | '\0', '\1', 'a', 'b', 'c', 'd', 'e', '\xfd', '\xfe', '\xff' 30 | }; 31 | std::string result; 32 | for (int i = 0; i < len; i++) { 33 | result += kTestChars[rnd->Uniform(sizeof(kTestChars))]; 34 | } 35 | return result; 36 | } 37 | 38 | 39 | extern Slice CompressibleString(Random* rnd, double compressed_fraction, 40 | int len, std::string* dst) { 41 | int raw = static_cast(len * compressed_fraction); 42 | if (raw < 1) raw = 1; 43 | std::string raw_data; 44 | RandomString(rnd, raw, &raw_data); 45 | 46 | // Duplicate the random data until we have filled "len" bytes 47 | dst->clear(); 48 | while (dst->size() < (unsigned int)len) { 49 | dst->append(raw_data); 50 | } 51 | dst->resize(len); 52 | return Slice(*dst); 53 | } 54 | 55 | } // namespace test 56 | } // namespace rocksdb 57 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/merge_operators.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Facebook, Inc. All rights reserved. 2 | // This source code is licensed under the BSD-style license found in the 3 | // LICENSE file in the root directory of this source tree. An additional grant 4 | // of patent rights can be found in the PATENTS file in the same directory. 5 | // 6 | #ifndef MERGE_OPERATORS_H 7 | #define MERGE_OPERATORS_H 8 | 9 | #include 10 | #include 11 | 12 | #include "rocksdb/merge_operator.h" 13 | 14 | namespace rocksdb { 15 | 16 | class MergeOperators { 17 | public: 18 | static std::shared_ptr CreatePutOperator(); 19 | static std::shared_ptr CreateUInt64AddOperator(); 20 | static std::shared_ptr CreateStringAppendOperator(); 21 | static std::shared_ptr CreateStringAppendTESTOperator(); 22 | 23 | // Will return a different merge operator depending on the string. 24 | // TODO: Hook the "name" up to the actual Name() of the MergeOperators? 25 | static std::shared_ptr CreateFromStringId( 26 | const std::string& name) { 27 | if (name == "put") { 28 | return CreatePutOperator(); 29 | } else if ( name == "uint64add") { 30 | return CreateUInt64AddOperator(); 31 | } else if (name == "stringappend") { 32 | return CreateStringAppendOperator(); 33 | } else if (name == "stringappendtest") { 34 | return CreateStringAppendTESTOperator(); 35 | } else { 36 | // Empty or unknown, just return nullptr 37 | return nullptr; 38 | } 39 | } 40 | 41 | }; 42 | 43 | } // namespace rocksdb 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/merge_operators/string_append/stringappend.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * A MergeOperator for rocksdb that implements string append. 3 | * @author Deon Nicholas (dnicholas@fb.com) 4 | * Copyright 2013 Facebook 5 | */ 6 | 7 | #include "stringappend.h" 8 | 9 | #include 10 | #include 11 | 12 | #include "rocksdb/slice.h" 13 | #include "rocksdb/merge_operator.h" 14 | #include "utilities/merge_operators.h" 15 | 16 | namespace rocksdb { 17 | 18 | // Constructor: also specify the delimiter character. 19 | StringAppendOperator::StringAppendOperator(char delim_char) 20 | : delim_(delim_char) { 21 | } 22 | 23 | // Implementation for the merge operation (concatenates two strings) 24 | bool StringAppendOperator::Merge(const Slice& key, 25 | const Slice* existing_value, 26 | const Slice& value, 27 | std::string* new_value, 28 | Logger* logger) const { 29 | 30 | // Clear the *new_value for writing. 31 | assert(new_value); 32 | new_value->clear(); 33 | 34 | if (!existing_value) { 35 | // No existing_value. Set *new_value = value 36 | new_value->assign(value.data(),value.size()); 37 | } else { 38 | // Generic append (existing_value != null). 39 | // Reserve *new_value to correct size, and apply concatenation. 40 | new_value->reserve(existing_value->size() + 1 + value.size()); 41 | new_value->assign(existing_value->data(),existing_value->size()); 42 | new_value->append(1,delim_); 43 | new_value->append(value.data(), value.size()); 44 | } 45 | 46 | return true; 47 | } 48 | 49 | const char* StringAppendOperator::Name() const { 50 | return "StringAppendOperator"; 51 | } 52 | 53 | std::shared_ptr MergeOperators::CreateStringAppendOperator() { 54 | return std::make_shared(','); 55 | } 56 | 57 | } // namespace rocksdb 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/merge_operators/string_append/stringappend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A MergeOperator for rocksdb that implements string append. 3 | * @author Deon Nicholas (dnicholas@fb.com) 4 | * Copyright 2013 Facebook 5 | */ 6 | 7 | #pragma once 8 | #include "rocksdb/merge_operator.h" 9 | #include "rocksdb/slice.h" 10 | 11 | namespace rocksdb { 12 | 13 | class StringAppendOperator : public AssociativeMergeOperator { 14 | public: 15 | StringAppendOperator(char delim_char); /// Constructor: specify delimiter 16 | 17 | virtual bool Merge(const Slice& key, 18 | const Slice* existing_value, 19 | const Slice& value, 20 | std::string* new_value, 21 | Logger* logger) const override; 22 | 23 | virtual const char* Name() const override; 24 | 25 | private: 26 | char delim_; // The delimiter is inserted between elements 27 | 28 | }; 29 | 30 | } // namespace rocksdb 31 | 32 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/merge_operators/string_append/stringappend2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A TEST MergeOperator for rocksdb that implements string append. 3 | * It is built using the MergeOperator interface rather than the simpler 4 | * AssociativeMergeOperator interface. This is useful for testing/benchmarking. 5 | * While the two operators are semantically the same, all production code 6 | * should use the StringAppendOperator defined in stringappend.{h,cc}. The 7 | * operator defined in the present file is primarily for testing. 8 | * 9 | * @author Deon Nicholas (dnicholas@fb.com) 10 | * Copyright 2013 Facebook 11 | */ 12 | 13 | #pragma once 14 | #include 15 | #include 16 | 17 | #include "rocksdb/merge_operator.h" 18 | #include "rocksdb/slice.h" 19 | 20 | namespace rocksdb { 21 | 22 | class StringAppendTESTOperator : public MergeOperator { 23 | public: 24 | // Constructor with delimiter 25 | explicit StringAppendTESTOperator(char delim_char); 26 | 27 | virtual bool FullMerge(const Slice& key, 28 | const Slice* existing_value, 29 | const std::deque& operand_sequence, 30 | std::string* new_value, 31 | Logger* logger) const override; 32 | 33 | virtual bool PartialMergeMulti(const Slice& key, 34 | const std::deque& operand_list, 35 | std::string* new_value, Logger* logger) const 36 | override; 37 | 38 | virtual const char* Name() const override; 39 | 40 | private: 41 | // A version of PartialMerge that actually performs "partial merging". 42 | // Use this to simulate the exact behaviour of the StringAppendOperator. 43 | bool _AssocPartialMergeMulti(const Slice& key, 44 | const std::deque& operand_list, 45 | std::string* new_value, Logger* logger) const; 46 | 47 | char delim_; // The delimiter is inserted between elements 48 | 49 | }; 50 | 51 | } // namespace rocksdb 52 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/merge_operators/uint64add.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rocksdb/env.h" 3 | #include "rocksdb/merge_operator.h" 4 | #include "rocksdb/slice.h" 5 | #include "util/coding.h" 6 | #include "utilities/merge_operators.h" 7 | 8 | using namespace rocksdb; 9 | 10 | namespace { // anonymous namespace 11 | 12 | // A 'model' merge operator with uint64 addition semantics 13 | // Implemented as an AssociativeMergeOperator for simplicity and example. 14 | class UInt64AddOperator : public AssociativeMergeOperator { 15 | public: 16 | virtual bool Merge(const Slice& key, 17 | const Slice* existing_value, 18 | const Slice& value, 19 | std::string* new_value, 20 | Logger* logger) const override { 21 | uint64_t orig_value = 0; 22 | if (existing_value){ 23 | orig_value = DecodeInteger(*existing_value, logger); 24 | } 25 | uint64_t operand = DecodeInteger(value, logger); 26 | 27 | assert(new_value); 28 | new_value->clear(); 29 | PutFixed64(new_value, orig_value + operand); 30 | 31 | return true; // Return true always since corruption will be treated as 0 32 | } 33 | 34 | virtual const char* Name() const override { 35 | return "UInt64AddOperator"; 36 | } 37 | 38 | private: 39 | // Takes the string and decodes it into a uint64_t 40 | // On error, prints a message and returns 0 41 | uint64_t DecodeInteger(const Slice& value, Logger* logger) const { 42 | uint64_t result = 0; 43 | 44 | if (value.size() == sizeof(uint64_t)) { 45 | result = DecodeFixed64(value.data()); 46 | } else if (logger != nullptr) { 47 | // If value is corrupted, treat it as 0 48 | Log(logger, "uint64 value corruption, size: %zu > %zu", 49 | value.size(), sizeof(uint64_t)); 50 | } 51 | 52 | return result; 53 | } 54 | 55 | }; 56 | 57 | } 58 | 59 | namespace rocksdb { 60 | 61 | std::shared_ptr MergeOperators::CreateUInt64AddOperator() { 62 | return std::make_shared(); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/redis/README: -------------------------------------------------------------------------------- 1 | This folder defines a REDIS-style interface for Rocksdb. 2 | Right now it is written as a simple tag-on in the rocksdb::RedisLists class. 3 | It implements Redis Lists, and supports only the "non-blocking operations". 4 | 5 | Internally, the set of lists are stored in a rocksdb database, mapping keys to 6 | values. Each "value" is the list itself, storing a sequence of "elements". 7 | Each element is stored as a 32-bit-integer, followed by a sequence of bytes. 8 | The 32-bit-integer represents the length of the element (that is, the number 9 | of bytes that follow). And then that many bytes follow. 10 | 11 | 12 | NOTE: This README file may be old. See the actual redis_lists.cc file for 13 | definitive details on the implementation. There should be a header at the top 14 | of that file, explaining a bit of the implementation details. 15 | -------------------------------------------------------------------------------- /deps/rocksdb-master/utilities/redis/redis_list_exception.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A simple structure for exceptions in RedisLists. 3 | * 4 | * @author Deon Nicholas (dnicholas@fb.com) 5 | * Copyright 2013 Facebook 6 | */ 7 | 8 | #ifndef ROCKSDB_LITE 9 | #pragma once 10 | #include 11 | 12 | namespace rocksdb { 13 | 14 | class RedisListException: public std::exception { 15 | public: 16 | const char* what() const throw() { 17 | return "Invalid operation or corrupt data in Redis List."; 18 | } 19 | }; 20 | 21 | } // namespace rocksdb 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/.gitignore: -------------------------------------------------------------------------------- 1 | *.lo 2 | *.libs 3 | *.deps 4 | *.la 5 | *.o 6 | Makefile 7 | config.h 8 | config.log 9 | config.status 10 | libtool 11 | snappy_unittest 12 | stamp-h1 13 | testdata 14 | 15 | 16 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2011, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | # Library. 4 | lib_LTLIBRARIES = libsnappy.la 5 | libsnappy_la_SOURCES = snappy.cc snappy-sinksource.cc snappy-stubs-internal.cc snappy-c.cc 6 | libsnappy_la_LDFLAGS = -version-info $(SNAPPY_LTVERSION) 7 | 8 | include_HEADERS = snappy.h snappy-sinksource.h snappy-stubs-public.h snappy-c.h 9 | noinst_HEADERS = snappy-internal.h snappy-stubs-internal.h snappy-test.h 10 | 11 | # Unit tests and benchmarks. 12 | snappy_unittest_CPPFLAGS = $(gflags_CFLAGS) $(GTEST_CPPFLAGS) 13 | snappy_unittest_SOURCES = snappy_unittest.cc snappy-test.cc 14 | snappy_unittest_LDFLAGS = $(GTEST_LDFLAGS) 15 | snappy_unittest_LDADD = libsnappy.la $(UNITTEST_LIBS) $(gflags_LIBS) $(GTEST_LIBS) 16 | TESTS = snappy_unittest 17 | noinst_PROGRAMS = $(TESTS) 18 | 19 | EXTRA_DIST = autogen.sh testdata/alice29.txt testdata/asyoulik.txt testdata/baddata1.snappy testdata/baddata2.snappy testdata/baddata3.snappy testdata/cp.html testdata/fields.c testdata/geo.protodata testdata/grammar.lsp testdata/house.jpg testdata/html testdata/html_x_4 testdata/kennedy.xls testdata/kppkn.gtb testdata/lcet10.txt testdata/mapreduce-osdi-1.pdf testdata/plrabn12.txt testdata/ptt5 testdata/sum testdata/urls.10K testdata/xargs.1 20 | dist_doc_DATA = ChangeLog COPYING INSTALL NEWS README format_description.txt framing_format.txt 21 | 22 | libtool: $(LIBTOOL_DEPS) 23 | $(SHELL) ./config.status --recheck 24 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -e 2 | rm -rf autom4te.cache 3 | aclocal -I m4 4 | autoheader 5 | libtoolize --copy 6 | automake --add-missing --copy 7 | autoconf 8 | -------------------------------------------------------------------------------- /deps/snappy-1.1.0/snappy-stubs-internal.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | #include "snappy-stubs-internal.h" 33 | 34 | namespace snappy { 35 | 36 | void Varint::Append32(string* s, uint32 value) { 37 | char buf[Varint::kMax32]; 38 | const char* p = Varint::Encode32(buf, value); 39 | s->append(buf, p - buf); 40 | } 41 | 42 | } // namespace snappy 43 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | include ../build_config.mk 2 | 3 | OBJS = ssdb.o t_kv.o t_hash.o t_zset.o t_queue.o link.o \ 4 | backend_dump.o backend_sync.o slave.o binlog.o serv.o \ 5 | iterator.o ttl.o 6 | UTIL_OBJS = util/log.o util/fde.o util/config.o util/bytes.o util/sorted_set.o 7 | EXES = ../ssdb-server 8 | 9 | 10 | all: ssdb.h ${OBJS} ssdb-server.o 11 | ${CXX} -o ../ssdb-server ssdb-server.o ${OBJS} ${UTIL_OBJS} ${CLIBS} 12 | 13 | ssdb-server.o: ssdb-server.cpp 14 | ${CXX} ${CFLAGS} -c ssdb-server.cpp 15 | 16 | objs: ssdb.h ${OBJS} 17 | 18 | ssdb.o: ssdb.h ssdb.cpp 19 | ${CXX} ${CFLAGS} -c ssdb.cpp 20 | 21 | iterator.o: ssdb.h iterator.h iterator.cpp 22 | ${CXX} ${CFLAGS} -c iterator.cpp 23 | 24 | t_kv.o: ssdb.h t_kv.h t_kv.cpp 25 | ${CXX} ${CFLAGS} -c t_kv.cpp 26 | 27 | t_hash.o: ssdb.h t_hash.h t_hash.cpp 28 | ${CXX} ${CFLAGS} -c t_hash.cpp 29 | 30 | t_zset.o: ssdb.h t_zset.h t_zset.cpp 31 | ${CXX} ${CFLAGS} -c t_zset.cpp 32 | 33 | t_queue.o: ssdb.h t_queue.h t_queue.cpp 34 | ${CXX} ${CFLAGS} -c t_queue.cpp 35 | 36 | link.o: ssdb.h link.h link.cpp link_redis.h link_redis.cpp 37 | ${CXX} ${CFLAGS} -c link.cpp 38 | 39 | binlog.o: ssdb.h binlog.h binlog.cpp 40 | ${CXX} ${CFLAGS} -c binlog.cpp 41 | 42 | slave.o: ssdb.h slave.h slave.cpp 43 | ${CXX} ${CFLAGS} -c slave.cpp 44 | 45 | serv.o: ssdb.h serv.h serv.cpp proc_kv.cpp proc_hash.cpp proc_zset.cpp proc_queue.cpp 46 | ${CXX} ${CFLAGS} -c serv.cpp 47 | 48 | backend_dump.o: ssdb.h backend_dump.h backend_dump.cpp 49 | ${CXX} ${CFLAGS} -c backend_dump.cpp 50 | 51 | backend_sync.o: ssdb.h backend_sync.h backend_sync.cpp 52 | ${CXX} ${CFLAGS} -c backend_sync.cpp 53 | 54 | ttl.o: ssdb.h ttl.h ttl.cpp 55 | ${CXX} ${CFLAGS} -c ttl.cpp 56 | 57 | clean: 58 | rm -f ${EXES} *.o *.exe 59 | 60 | -------------------------------------------------------------------------------- /src/backend_dump.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_BACKEND_DUMP_H_ 2 | #define SSDB_BACKEND_DUMP_H_ 3 | 4 | #include "include.h" 5 | #include "ssdb.h" 6 | #include "link.h" 7 | 8 | class BackendDump{ 9 | private: 10 | struct run_arg{ 11 | const Link *link; 12 | const BackendDump *backend; 13 | }; 14 | static void* _run_thread(void *arg); 15 | const SSDB *ssdb; 16 | public: 17 | BackendDump(const SSDB *ssdb); 18 | ~BackendDump(); 19 | void proc(const Link *link); 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/backend_sync.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_BACKEND_SYNC_H_ 2 | #define SSDB_BACKEND_SYNC_H_ 3 | 4 | #include "include.h" 5 | #include 6 | #include 7 | #include 8 | 9 | #include "ssdb.h" 10 | #include "link.h" 11 | #include "binlog.h" 12 | #include "util/thread.h" 13 | 14 | class BackendSync{ 15 | private: 16 | struct Client; 17 | private: 18 | std::vector clients; 19 | std::vector clients_tmp; 20 | 21 | struct run_arg{ 22 | const Link *link; 23 | const BackendSync *backend; 24 | }; 25 | volatile bool thread_quit; 26 | static void* _run_thread(void *arg); 27 | Mutex mutex; 28 | std::map workers; 29 | const SSDB *ssdb; 30 | public: 31 | BackendSync(const SSDB *ssdb); 32 | ~BackendSync(); 33 | void proc(const Link *link); 34 | }; 35 | 36 | struct BackendSync::Client{ 37 | static const int INIT = 0; 38 | static const int OUT_OF_SYNC = 1; 39 | static const int COPY = 2; 40 | static const int SYNC = 4; 41 | 42 | int status; 43 | Link *link; 44 | uint64_t last_seq; 45 | uint64_t last_noop_seq; 46 | std::string last_key; 47 | const BackendSync *backend; 48 | bool is_mirror; 49 | 50 | Iterator *iter; 51 | 52 | Client(const BackendSync *backend); 53 | ~Client(); 54 | void init(); 55 | void reset(); 56 | void noop(); 57 | int copy(); 58 | int sync(BinlogQueue *logs); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/iterator.cpp: -------------------------------------------------------------------------------- 1 | #include "iterator.h" 2 | 3 | Iterator::Iterator(leveldb::Iterator *it, 4 | const std::string &end, 5 | uint64_t limit, 6 | Direction direction) 7 | { 8 | this->it = it; 9 | this->end = end; 10 | this->limit = limit; 11 | this->is_first = true; 12 | this->direction = direction; 13 | } 14 | 15 | Iterator::~Iterator(){ 16 | delete it; 17 | } 18 | 19 | bool Iterator::skip(uint64_t offset){ 20 | while(offset-- > 0){ 21 | if(this->next() == false){ 22 | return false; 23 | } 24 | } 25 | return true; 26 | } 27 | 28 | bool Iterator::next(){ 29 | if(limit == 0){ 30 | return false; 31 | } 32 | if(is_first){ 33 | is_first = false; 34 | }else{ 35 | if(direction == FORWARD){ 36 | it->Next(); 37 | }else{ 38 | it->Prev(); 39 | } 40 | } 41 | 42 | if(!it->Valid()){ 43 | // make next() safe to be called after previous return false. 44 | limit = 0; 45 | return false; 46 | } 47 | if(direction == FORWARD){ 48 | if(!end.empty() && it->key() > end){ 49 | limit = 0; 50 | return false; 51 | } 52 | }else{ 53 | if(!end.empty() && it->key() < end){ 54 | limit = 0; 55 | return false; 56 | } 57 | } 58 | limit --; 59 | return true; 60 | } 61 | -------------------------------------------------------------------------------- /src/iterator.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_ITERATOR_H_ 2 | #define SSDB_ITERATOR_H_ 3 | 4 | #include 5 | #include 6 | #include "leveldb/iterator.h" 7 | #include "leveldb/slice.h" 8 | #include "util/bytes.h" 9 | 10 | class Iterator{ 11 | public: 12 | enum Direction{ 13 | FORWARD, BACKWARD 14 | }; 15 | private: 16 | leveldb::Iterator *it; 17 | std::string end; 18 | uint64_t limit; 19 | bool is_first; 20 | int direction; 21 | public: 22 | Iterator(leveldb::Iterator *it, 23 | const std::string &end, 24 | uint64_t limit, 25 | Direction direction=Iterator::FORWARD); 26 | ~Iterator(); 27 | bool skip(uint64_t offset); 28 | bool next(); 29 | 30 | Bytes key(){ 31 | return it->key(); 32 | } 33 | 34 | Bytes val(){ 35 | return it->value(); 36 | } 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/link_redis.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_REDIS_LINK_H_ 2 | #define SSDB_REDIS_LINK_H_ 3 | 4 | #include 5 | #include 6 | #include "util/bytes.h" 7 | 8 | struct RedisRequestDesc 9 | { 10 | int strategy; 11 | std::string redis_cmd; 12 | std::string ssdb_cmd; 13 | int reply_type; 14 | }; 15 | 16 | class RedisLink 17 | { 18 | private: 19 | std::string cmd; 20 | RedisRequestDesc *req_desc; 21 | 22 | std::vector recv_bytes; 23 | std::vector recv_string; 24 | int parse_req(Buffer *input); 25 | int convert_req(); 26 | 27 | public: 28 | RedisLink(){ 29 | req_desc = NULL; 30 | } 31 | 32 | const std::vector* recv_req(Buffer *input); 33 | int send_resp(Buffer *output, const std::vector &resp); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/slave.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_SLAVE_H_ 2 | #define SSDB_SLAVE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "ssdb.h" 9 | #include "link.h" 10 | 11 | class Slave{ 12 | private: 13 | uint64_t last_seq; 14 | std::string last_key; 15 | uint64_t copy_count; 16 | uint64_t sync_count; 17 | 18 | std::string id_; 19 | 20 | SSDB *ssdb; 21 | Link *link; 22 | leveldb::DB* meta_db; 23 | std::string master_ip; 24 | int master_port; 25 | bool is_mirror; 26 | char log_type; 27 | 28 | std::string status_key(); 29 | void load_status(); 30 | void save_status(); 31 | 32 | volatile bool thread_quit; 33 | pthread_t run_thread_tid; 34 | static void* _run_thread(void *arg); 35 | 36 | int proc(const std::vector &req); 37 | int proc_noop(const Binlog &log, const std::vector &req); 38 | int proc_copy(const Binlog &log, const std::vector &req); 39 | int proc_sync(const Binlog &log, const std::vector &req); 40 | 41 | unsigned int connect_retry; 42 | int connect(); 43 | bool connected(){ 44 | return link != NULL; 45 | } 46 | public: 47 | Slave(SSDB *ssdb, leveldb::DB* meta_db, const char *ip, int port, bool is_mirror=false); 48 | ~Slave(); 49 | void start(); 50 | void stop(); 51 | 52 | void set_id(const std::string &id); 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/t_kv.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_KV_H_ 2 | #define SSDB_KV_H_ 3 | 4 | #include "ssdb.h" 5 | 6 | static inline 7 | std::string encode_kv_key(const Bytes &key){ 8 | std::string buf; 9 | buf.append(1, DataType::KV); 10 | buf.append(key.data(), key.size()); 11 | return buf; 12 | } 13 | 14 | static inline 15 | int decode_kv_key(const Bytes &slice, std::string *key){ 16 | Decoder decoder(slice.data(), slice.size()); 17 | if(decoder.skip(1) == -1){ 18 | return -1; 19 | } 20 | if(decoder.read_data(key) == -1){ 21 | return -1; 22 | } 23 | return 0; 24 | } 25 | 26 | 27 | class KIterator{ 28 | private: 29 | Iterator *it; 30 | bool return_val_; 31 | public: 32 | std::string key; 33 | std::string val; 34 | // Bytes raw_key; 35 | // Bytes raw_val; 36 | 37 | KIterator(Iterator *it){ 38 | this->it = it; 39 | this->return_val_ = true; 40 | } 41 | 42 | ~KIterator(){ 43 | delete it; 44 | } 45 | 46 | void return_val(bool onoff){ 47 | this->return_val_ = onoff; 48 | } 49 | 50 | bool next(){ 51 | while(it->next()){ 52 | Bytes ks = it->key(); 53 | Bytes vs = it->val(); 54 | //dump(ks.data(), ks.size(), "z.next"); 55 | //dump(vs.data(), vs.size(), "z.next"); 56 | if(ks.data()[0] != DataType::KV){ 57 | return false; 58 | } 59 | if(decode_kv_key(ks, &this->key) == -1){ 60 | continue; 61 | } 62 | if(return_val_){ 63 | this->val.assign(vs.data(), vs.size()); 64 | } 65 | return true; 66 | } 67 | return false; 68 | } 69 | }; 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/t_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_QUEUE_H_ 2 | #define SSDB_QUEUE_H_ 3 | 4 | #include "ssdb.h" 5 | 6 | const uint64_t QFRONT_SEQ = 2; 7 | const uint64_t QBACK_SEQ = 3; 8 | const uint64_t QITEM_MIN_SEQ = 10000; 9 | const uint64_t QITEM_MAX_SEQ = 9223372036854775807ULL; 10 | const uint64_t QITEM_SEQ_INIT = QITEM_MAX_SEQ/2; 11 | 12 | inline static 13 | std::string encode_qsize_key(const Bytes &name){ 14 | std::string buf; 15 | buf.append(1, DataType::QSIZE); 16 | buf.append(name.data(), name.size()); 17 | return buf; 18 | } 19 | 20 | inline static 21 | int decode_qsize_key(const Bytes &slice, std::string *name){ 22 | Decoder decoder(slice.data(), slice.size()); 23 | if(decoder.skip(1) == -1){ 24 | return -1; 25 | } 26 | if(decoder.read_data(name) == -1){ 27 | return -1; 28 | } 29 | return 0; 30 | } 31 | 32 | inline static 33 | std::string encode_qitem_key(const Bytes &name, uint64_t seq){ 34 | std::string buf; 35 | buf.append(1, DataType::QUEUE); 36 | buf.append(1, (uint8_t)name.size()); 37 | buf.append(name.data(), name.size()); 38 | seq = big_endian(seq); 39 | buf.append((char *)&seq, sizeof(uint64_t)); 40 | return buf; 41 | } 42 | 43 | inline static 44 | int decode_qitem_key(const Bytes &slice, std::string *name, uint64_t *seq){ 45 | Decoder decoder(slice.data(), slice.size()); 46 | if(decoder.skip(1) == -1){ 47 | return -1; 48 | } 49 | if(decoder.read_8_data(name) == -1){ 50 | return -1; 51 | } 52 | if(decoder.read_uint64(seq) == -1){ 53 | return -1; 54 | } 55 | *seq = big_endian(*seq); 56 | return 0; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/ttl.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_TTL_H_ 2 | #define SSDB_TTL_H_ 3 | 4 | #include "include.h" 5 | #include "ssdb.h" 6 | #include "util/thread.h" 7 | #include "util/sorted_set.h" 8 | #include 9 | 10 | class ExpirationHandler 11 | { 12 | public: 13 | Mutex mutex; 14 | 15 | ExpirationHandler(SSDB *ssdb); 16 | ~ExpirationHandler(); 17 | int del_ttl(const Bytes &key); 18 | int set_ttl(const Bytes &key, int64_t ttl); 19 | // "In Redis 2.6 or older the command returns -1 if the key does not exist 20 | // or if the key exist but has no associated expire. Starting with Redis 2.8.." 21 | // I stick to Redis 2.6 22 | int64_t get_ttl(const Bytes &key); 23 | 24 | private: 25 | SSDB *ssdb; 26 | volatile bool thread_quit; 27 | std::string list_name; 28 | int64_t first_timeout; 29 | SortedSet fast_keys; 30 | 31 | void start(); 32 | void stop(); 33 | static void* thread_func(void *arg); 34 | void load_expiration_keys_from_db(int num); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/util/Makefile: -------------------------------------------------------------------------------- 1 | include ../../build_config.mk 2 | 3 | OBJS = log.o fde.o config.o bytes.o sorted_set.o 4 | EXES = 5 | 6 | all: ${OBJS} 7 | 8 | log.o: log.h log.cpp 9 | ${CXX} ${CFLAGS} -c log.cpp 10 | 11 | config.o: config.h config.cpp 12 | ${CXX} ${CFLAGS} -c config.cpp 13 | 14 | fde.o: fde.h fde.cpp fde_select.cpp fde_epoll.cpp 15 | ${CXX} ${CFLAGS} -c fde.cpp 16 | 17 | bytes.o: bytes.h bytes.cpp 18 | ${CXX} ${CFLAGS} -c bytes.cpp 19 | 20 | sorted_set.o: sorted_set.h sorted_set.cpp 21 | ${CXX} ${CFLAGS} -c sorted_set.cpp 22 | 23 | clean: 24 | rm -f ${EXES} ${OBJS} 25 | 26 | -------------------------------------------------------------------------------- /src/util/daemon.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_DAEMON_H 2 | #define UTIL_DAEMON_H 3 | 4 | #include "../include.h" 5 | 6 | int daemonize(const char *dir=NULL){ 7 | switch(fork()){ 8 | case -1: 9 | return -1; 10 | case 0: 11 | break; 12 | default: 13 | exit(0); 14 | } 15 | if(setsid() == -1){ 16 | exit(0); 17 | } 18 | if(dir != NULL){ 19 | if(chdir(dir) == -1){ 20 | exit(0); 21 | } 22 | } 23 | 24 | if(close(STDIN_FILENO) == -1){ 25 | exit(0); 26 | } 27 | if(close(STDOUT_FILENO) == -1){ 28 | exit(0); 29 | } 30 | if(close(STDERR_FILENO) == -1){ 31 | exit(0); 32 | } 33 | 34 | int fd = open("/dev/null", O_RDWR, 0); 35 | if(fd == -1){ 36 | exit(0); 37 | } 38 | if(dup2(fd, STDIN_FILENO) == -1){ 39 | exit(0); 40 | } 41 | if(dup2(fd, STDOUT_FILENO) == -1){ 42 | exit(0); 43 | } 44 | if(dup2(fd, STDERR_FILENO) == -1){ 45 | exit(0); 46 | } 47 | 48 | return 0; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/util/fde.cpp: -------------------------------------------------------------------------------- 1 | #include "fde.h" 2 | 3 | struct Fdevent* Fdevents::get_fde(int fd){ 4 | while((int)events.size() <= fd){ 5 | struct Fdevent *fde = new Fdevent(); 6 | fde->fd = events.size(); 7 | fde->s_flags = FDEVENT_NONE; 8 | fde->data.num = 0; 9 | fde->data.ptr = NULL; 10 | events.push_back(fde); 11 | } 12 | return events[fd]; 13 | } 14 | 15 | 16 | #ifdef HAVE_EPOLL 17 | #include "fde_epoll.cpp" 18 | #else 19 | #include "fde_select.cpp" 20 | #endif 21 | -------------------------------------------------------------------------------- /src/util/fde.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_FDE_H 2 | #define UTIL_FDE_H 3 | 4 | #include "../include.h" 5 | 6 | #ifdef __linux__ 7 | #define HAVE_EPOLL 1 8 | #endif 9 | 10 | #define FDEVENT_NONE (0) 11 | #define FDEVENT_IN (1<<0) 12 | #define FDEVENT_PRI (1<<1) 13 | #define FDEVENT_OUT (1<<2) 14 | #define FDEVENT_HUP (1<<3) 15 | #define FDEVENT_ERR (1<<4) 16 | 17 | struct Fdevent{ 18 | int fd; 19 | int s_flags; // subscribed events 20 | int events; // ready events 21 | struct{ 22 | int num; 23 | void *ptr; 24 | }data; 25 | }; 26 | 27 | #include 28 | #ifdef HAVE_EPOLL 29 | #include 30 | #else 31 | #include 32 | #endif 33 | 34 | 35 | class Fdevents{ 36 | public: 37 | typedef std::vector events_t; 38 | private: 39 | #ifdef HAVE_EPOLL 40 | static const int MAX_FDS = 8 * 1024; 41 | int ep_fd; 42 | struct epoll_event ep_events[MAX_FDS]; 43 | #else 44 | int maxfd; 45 | fd_set readset; 46 | fd_set writeset; 47 | #endif 48 | events_t events; 49 | events_t ready_events; 50 | 51 | struct Fdevent *get_fde(int fd); 52 | public: 53 | Fdevents(); 54 | ~Fdevents(); 55 | 56 | bool isset(int fd, int flag); 57 | int set(int fd, int flags, int data_num, void *data_ptr); 58 | int del(int fd); 59 | int clr(int fd, int flags); 60 | const events_t* wait(int timeout_ms=-1); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/util/file.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_FILE_H_ 2 | #define UTIL_FILE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static 9 | inline bool file_exists(const char *filename){ 10 | struct stat st; 11 | return stat(filename, &st) == 0; 12 | } 13 | 14 | static 15 | inline bool is_dir(const char *filename){ 16 | struct stat st; 17 | if(stat(filename, &st) == -1){ 18 | return false; 19 | } 20 | return (bool)S_ISDIR(st.st_mode); 21 | } 22 | 23 | static 24 | inline bool is_file(const char *filename){ 25 | struct stat st; 26 | if(stat(filename, &st) == -1){ 27 | return false; 28 | } 29 | return (bool)S_ISREG(st.st_mode); 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/util/sorted_set.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_SORTED_SET_H 2 | #define UTIL_SORTED_SET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SortedSet 10 | { 11 | public: 12 | bool empty() const{ 13 | return size() == 0; 14 | } 15 | int size() const; 16 | int add(const std::string &key, int64_t score); 17 | // 0: not found, 1: found and deleted 18 | int del(const std::string &key); 19 | // the first item is copied into key if SortedSet not empty 20 | int front(std::string *key, int64_t *score=NULL) const; 21 | int back(std::string *key, int64_t *score=NULL) const; 22 | int64_t max_score() const; 23 | int pop_front(); 24 | int pop_back(); 25 | 26 | /* 27 | class Iterator 28 | { 29 | public: 30 | bool next(); 31 | const std::string& key(); 32 | int64_t score(); 33 | }; 34 | 35 | Iterator begin(); 36 | */ 37 | 38 | private: 39 | struct Item 40 | { 41 | std::string key; 42 | int64_t score; 43 | 44 | bool operator<(const Item& b) const{ 45 | return this->score < b.score 46 | || (this->score == b.score && this->key < b.key); 47 | } 48 | }; 49 | 50 | std::map::iterator> existed; 51 | std::set sorted_set; 52 | }; 53 | 54 | 55 | /* 56 | TODO: HashedWheel 57 | Each item is linked in two list, one is slot list, the other 58 | one is total list. 59 | */ 60 | /* 61 | template 62 | class SortedList 63 | { 64 | public: 65 | void add(const T data, int64_t score); 66 | T front(); 67 | void pop_front(); 68 | 69 | class Item 70 | { 71 | public: 72 | int64_t score; 73 | Item *prev; 74 | Item *next; 75 | //Item *slot_prev; 76 | //Item *slot_next; 77 | T data; 78 | }; 79 | }; 80 | */ 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/util/test_sorted_set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "log.h" 6 | #include "sorted_set.h" 7 | 8 | int main(int argc, char **argv){ 9 | SortedSet zset; 10 | 11 | std::vector keys; 12 | for(int i='a'; i<='z'; i++){ 13 | char buf[10]; 14 | snprintf(buf, sizeof(buf), "%c", i); 15 | keys.push_back(buf); 16 | } 17 | 18 | log_debug(""); 19 | srand(time(NULL)); 20 | for(int i=0; i<1000 * 1000; i++){ 21 | std::string &key = keys[rand() % keys.size()]; 22 | zset.add(key, rand()%30 - 15); 23 | } 24 | log_debug(""); 25 | 26 | const std::string *key; 27 | int64_t score; 28 | int n = 0; 29 | while(zset.front(&key, &score)){ 30 | printf("%s : %4lld\n", key->c_str(), score); 31 | zset.pop_front(); 32 | n ++; 33 | } 34 | log_debug("%d", n); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDB_DEPS_H 2 | #ifndef SSDB_VERSION 3 | #define SSDB_VERSION "1.6.8.8" 4 | #endif 5 | #endif 6 | #include 7 | #include 8 | -------------------------------------------------------------------------------- /ssdb.conf: -------------------------------------------------------------------------------- 1 | # ssdb-server config 2 | # MUST indent by TAB! 3 | 4 | # relative to path of this file, directory must exists 5 | work_dir = ./var 6 | pidfile = ./var/ssdb.pid 7 | 8 | server: 9 | ip: 127.0.0.1 10 | port: 8888 11 | # bind to public ip 12 | #ip: 0.0.0.0 13 | # format: allow|deny: all|ip_prefix 14 | # multiple allows or denys is supported 15 | #deny: all 16 | #allow: 127.0.0.1 17 | #allow: 192.168 18 | 19 | replication: 20 | binlog: yes 21 | # Limit sync speed to *MB/s, -1: no limit 22 | sync_speed: -1 23 | slaveof: 24 | # to identify a master even if it moved(ip, port changed) 25 | # if set to empty or not defined, ip:port will be used. 26 | #id: svc_2 27 | # sync|mirror, default is sync 28 | #type: sync 29 | #ip: 127.0.0.1 30 | #port: 8889 31 | 32 | logger: 33 | level: debug 34 | output: log.txt 35 | rotate: 36 | size: 1000000000 37 | 38 | leveldb: 39 | # in MB 40 | cache_size: 500 41 | # in KB 42 | block_size: 32 43 | # in MB 44 | write_buffer_size: 64 45 | # in MB 46 | compaction_speed: 1000 47 | # yes|no 48 | compression: no 49 | 50 | 51 | -------------------------------------------------------------------------------- /ssdb_slave.conf: -------------------------------------------------------------------------------- 1 | # ssdb-server config 2 | 3 | # relative to path of this file, must exist 4 | work_dir = ./var_slave 5 | pidfile = ./var_slave/ssdb.pid 6 | 7 | server: 8 | ip: 127.0.0.1 9 | port: 8889 10 | 11 | replication: 12 | binlog: yes 13 | # Limit sync speed to *MB/s, -1: no limit 14 | sync_speed: -1 15 | slaveof: 16 | # to identify a master even if it moved(ip, port changed) 17 | # if set to empty or not defined, ip:port will be used. 18 | id: svc_1 19 | # sync|mirror, default is sync 20 | type: sync 21 | ip: 127.0.0.1 22 | port: 8888 23 | 24 | logger: 25 | level: debug 26 | output: log_slave.txt 27 | rotate: 28 | size: 1000000000 29 | 30 | leveldb: 31 | # in MB 32 | cache_size: 500 33 | # in KB 34 | block_size: 32 35 | # in MB 36 | write_buffer_size: 64 37 | # in MB 38 | compaction_speed: 200 39 | # yes|no 40 | compression: no 41 | 42 | 43 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | include ../build_config.mk 2 | 3 | OBJS += ../src/link.o ../src/util/fde.o ../src/util/log.o ../src/util/bytes.o 4 | CFLAGS += -I../src 5 | EXES = ssdb-bench ssdb-dump leveldb-import 6 | 7 | all: ssdb-bench.o ssdb-dump.o leveldb-import.o 8 | ${CXX} -o ssdb-bench ssdb-bench.o ${OBJS} ${UTIL_OBJS} ${CLIBS} 9 | ${CXX} -o ssdb-dump ssdb-dump.o ${OBJS} ${UTIL_OBJS} ${CLIBS} 10 | ${CXX} -o leveldb-import leveldb-import.o ${OBJS} ${UTIL_OBJS} ${CLIBS} 11 | 12 | ssdb-bench.o: ssdb-bench.cpp 13 | ${CXX} ${CFLAGS} -c ssdb-bench.cpp 14 | ssdb-dump.o: ssdb-dump.cpp 15 | ${CXX} ${CFLAGS} -c ssdb-dump.cpp 16 | leveldb-import.o: leveldb-import.cpp 17 | ${CXX} ${CFLAGS} -c leveldb-import.cpp 18 | 19 | clean: 20 | rm -f *.exe *.exe.stackdump *.o ${EXES} 21 | rm -rf _cpy_ 22 | 23 | -------------------------------------------------------------------------------- /tools/ssdb-cli: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DIR=`dirname $0` 3 | 4 | if [ -e $DIR/../deps/cpy/cpy ]; then 5 | CPY=$DIR/../deps/cpy/cpy 6 | else 7 | CPY=$DIR/deps/cpy/cpy 8 | fi 9 | 10 | $CPY $DIR/ssdb-cli.cpy $@ 11 | -------------------------------------------------------------------------------- /tools/ssdb-ins.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this script is used to start/stop one ssdb-server instance 3 | 4 | ssdb_root=/usr/local/ssdb 5 | config=$2 6 | 7 | usage(){ 8 | echo "Usage:" 9 | echo " $0 {start|stop|restart} config" 10 | } 11 | 12 | if [ -z "$config" ]; then 13 | echo "[error] no config file specified!" 14 | usage; 15 | exit; 16 | fi 17 | if [ ! -f "$config" ]; then 18 | echo "[error] bad config file: $config" 19 | exit; 20 | fi 21 | 22 | dir=`dirname $config` 23 | pidfile=$dir/`cat $config | sed -n 's/pidfile[[:blank:]]*=[[:blank:]]//p' | sed -n 's/^\.\///p'` 24 | 25 | start(){ 26 | ${ssdb_root}/ssdb-server -d ${config} 27 | if [ $? = "0" ]; then 28 | echo "ssdb started." 29 | else 30 | echo "" 31 | echo "[error] failed to start ssdb-server" 32 | fi 33 | } 34 | 35 | stop(){ 36 | if [ ! -f "$pidfile" ]; then 37 | return 38 | fi 39 | 40 | pid=`cat $pidfile` 41 | ps_pid=`ps aux | grep "$pid" | grep "$ssdb_root" | grep -v grep | awk '{print $2}'` 42 | 43 | if [ "$pid" = "$ps_pid" ]; then 44 | kill $pid 45 | fi 46 | 47 | for((i=0; i<10; i++)) do 48 | sleep 0.5 49 | if [ ! -f "$pidfile" ]; then 50 | break 51 | fi 52 | echo -n "." 53 | done 54 | 55 | if [ -f "$pidfile" ]; then 56 | echo "remove obsolete pidfile $pidfile" 57 | rm -f "$pidfile" 58 | fi 59 | echo "ssdb stopped." 60 | } 61 | 62 | 63 | case "$1" in 64 | 'start') 65 | stop 66 | start 67 | ;; 68 | 'stop') 69 | stop 70 | ;; 71 | 'restart') 72 | stop 73 | start 74 | ;; 75 | *) 76 | echo "Usage: $0 {start|stop|restart}" 77 | exit 1 78 | ;; 79 | esac 80 | -------------------------------------------------------------------------------- /tools/ssdb-repair.cpp: -------------------------------------------------------------------------------- 1 | #include "include.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "leveldb/db.h" 7 | #include "leveldb/env.h" 8 | #include "leveldb/options.h" 9 | #include "leveldb/slice.h" 10 | #include "leveldb/iterator.h" 11 | 12 | #include "link.h" 13 | #include "util/log.h" 14 | #include "util/file.h" 15 | #include "util/strings.h" 16 | 17 | void welcome(){ 18 | printf("ssdb-repair - SSDB repair tool\n"); 19 | printf("Copyright (c) 2013-2014 ssdb.io\n"); 20 | printf("\n"); 21 | } 22 | 23 | void usage(int argc, char **argv){ 24 | printf("Usage:\n"); 25 | printf(" %s leveldb_folder\n", argv[0]); 26 | printf("\n"); 27 | } 28 | 29 | int main(int argc, char **argv){ 30 | welcome(); 31 | 32 | set_log_level(Logger::LEVEL_MIN); 33 | 34 | if(argc <= 1){ 35 | usage(argc, argv); 36 | return 0; 37 | } 38 | std::string leveldb_folder(argv[1]); 39 | 40 | if(!file_exists(leveldb_folder.c_str())){ 41 | printf("leveldb_folder[%s] not exists!\n", leveldb_folder.c_str()); 42 | return 0; 43 | } 44 | 45 | leveldb::Status status; 46 | 47 | leveldb::Logger *logger; 48 | status = leveldb::Env::Default()->NewLogger("repair.log", &logger); 49 | if(!status.ok()){ 50 | printf("logger error!\n"); 51 | return 0; 52 | } 53 | printf("writing repair log into: repair.log\n"); 54 | 55 | leveldb::Options options; 56 | options.info_log = logger; 57 | status = leveldb::RepairDB(leveldb_folder.c_str(), options); 58 | if(!status.ok()){ 59 | printf("repair leveldb: %s error!\n", leveldb_folder.c_str()); 60 | return 0; 61 | } 62 | 63 | printf("leveldb repaired.\n"); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /tools/ssdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this script is used to start/stop ssdb-server instances on 3 | # system start/stop 4 | # put this script into /etc/init.d directory 5 | 6 | ssdb_root=/usr/local/ssdb 7 | # each config file for one instance 8 | # configs="/data/ssdb_data/test/ssdb.conf /data/ssdb_data/test2/ssdb.conf" 9 | configs="/data/ssdb_data/test/ssdb.conf" 10 | 11 | case "$1" in 12 | 'start') 13 | for conf in $configs; do 14 | $ssdb_root/ssdb-ins.sh start $conf 15 | done 16 | ;; 17 | 'stop') 18 | for conf in $configs; do 19 | $ssdb_root/ssdb-ins.sh stop $conf 20 | done 21 | ;; 22 | 'restart') 23 | for conf in $configs; do 24 | $ssdb_root/ssdb-ins.sh restart $conf 25 | done 26 | ;; 27 | *) 28 | echo "Usage: $0 {start|stop|restart}" 29 | exit 1 30 | ;; 31 | esac 32 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 1.6.8.8 2 | --------------------------------------------------------------------------------