RocksDB CLI Tools provides different administration & data access commands. In this post we are going to download & build the rocksdb source to perform those operation in windows terminal.
Content
- Install Pre-requisites
- Download Source
- Build Source
- Run Commands
Install Pre-requisites
- Microsoft Visual Studio 2019 with “Desktop development with C++”
Open “Visual Studio Installer”
From More Option Choose Modify
Choose Desktop Development with C++
C++ CMake Tools for Windows is an Installation Part
Download Source
URL: https://github.com/facebook/rocksdb
Download ZIP or git clone
Build Source
In Windows Terminal change directory to cMake
cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
Configuring Directory: rocksdb-master
cmake -Hd:/Work/S3i/RocksDB/RocksDbTools/rocksdb-master -Bd:/Work/S3i/RocksDB/RocksDbTools/rocksdb-master/build -G "Visual Studio 16 2019"
CLI Tools
- Ldb Tool
- SST dump tool
Build Ldb
cmake --build d:/Work/S3i/RocksDB/RocksDbTools/rocksdb-master/build --config Debug --target ldb
Build SST dump
cmake --build d:/Work/S3i/RocksDB/RocksDbTools/rocksdb-master/build --config Debug --target sst_dump
After successfully build, in “build\tools\Debug” Folder
Run Commands : LDB Tool
Open windows terminal from “build\tools\Debug” or run command in visual code terminal
In terminal run command, get help Instructions
ldb --help
Ldb: Data Access Commands
- Put
- BatchPut
- Get
- Scan
- Delete
- DeleteRange
Ldb: Put
ldb --db=C:\Database\rocksdb --create_if_missing --bloom_bits=14 --fix_prefix_len=14 --compression_max_dict_bytes=16384 --block_size=1048576 --auto_compaction=true --write_buffer_size=4194304 --file_size=2097152 put firstname Shashangka
Output: Ok
Ldb: Get
ldb --db=C:\Database\rocksdb get firstname
Output: Shashangka
Ldb: BatchPut
ldb --db=C:\Database\rocksdb batchput key1 value1 key2 value2 key3 Value3 key4 Value4 key5 Value5
Output: Ok
Ldb: Get
ldb --db=C:\Database\rocksdb get key1
Output: value1
Ldb: Scan
ldb --db=C:\Database\rocksdb scan
Output:
firstname : Shashangka
key1 : value1
key2 : value2
key3 : Value3
key4 : Value4
key5 : Value5
Ldb: Delete
ldb --db=C:\Database\rocksdb delete firstname
Output: Failed: NotFound:
Ldb: DeleteRange
ldb --db=C:\Database\rocksdb deleterange key2 key4
Output: Ok
Ldb: Admin Commands
- Create Column Family
- List Column Family
- Drop Column Family
Ldb: Create Column Family
ldb create_column_family --db=C:\Database\rocksdb Customer
Output: Ok
Ldb: List Column Family
Output: {default, Customer}
Ldb: Drop Column Family
ldb drop_column_family --db=C:\Database\rocksdb Customer
Output: {default}
Hope this will help to build and use ldb command line tool.