Skip to content

Commit

Permalink
Merge branch 'master' into rocksdb8
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Mar 24, 2023
2 parents 1219854 + cd2d186 commit cc7617a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
21 changes: 11 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@ DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

INSTALL_PREFIX=$1

export CFLAGS='-fPIC -O3 -pipe'
export CXXFLAGS='-fPIC -O3 -pipe -Wno-maybe-uninitialized'

BUILD_PATH=/tmp/build
mkdir -p $BUILD_PATH

CMAKE_REQUIRED_PARAMS="-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}"

snappy_version="1.1.10"
cd $BUILD_PATH && wget https://github.com/google/snappy/archive/${snappy_version}.tar.gz && tar xzf ${snappy_version}.tar.gz && cd snappy-${snappy_version} && \
mkdir -p build_place && cd build_place && \
CXXFLAGS='-fPIC -O3 -pipe -Wno-uninitialized -Werror,-Wno-sign-compare' cmake $CMAKE_REQUIRED_PARAMS -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF .. && make install/strip -j16 && \
cd $BUILD_PATH && rm -rf *

export CFLAGS='-fPIC -O3 -pipe'
export CXXFLAGS='-fPIC -O3 -pipe -Wno-uninitialized'

zlib_version="1.2.11"
cd $BUILD_PATH && wget https://github.com/madler/zlib/archive/v${zlib_version}.tar.gz && tar xzf v${zlib_version}.tar.gz && cd zlib-${zlib_version} && \
./configure --prefix=$INSTALL_PREFIX --static && make -j16 install && \
cd $BUILD_PATH && rm -rf *

snappy_version="1.1.8"
cd $BUILD_PATH && wget https://github.com/google/snappy/archive/${snappy_version}.tar.gz && tar xzf ${snappy_version}.tar.gz && cd snappy-${snappy_version} && \
mkdir -p build_place && cd build_place && cmake $CMAKE_REQUIRED_PARAMS -DSNAPPY_BUILD_TESTS=OFF .. && make install/strip -j16 && \
cd $BUILD_PATH && rm -rf *

lz4_version="1.9.3"
lz4_version="1.9.4"
cd $BUILD_PATH && wget https://github.com/lz4/lz4/archive/v${lz4_version}.tar.gz && tar xzf v${lz4_version}.tar.gz && cd lz4-${lz4_version}/build/cmake && \
cmake $CMAKE_REQUIRED_PARAMS -DLZ4_BUILD_LEGACY_LZ4C=OFF -DBUILD_SHARED_LIBS=OFF -DLZ4_POSITION_INDEPENDENT_LIB=ON && make -j16 install && \
cd $BUILD_PATH && rm -rf *

zstd_version="1.5.0"
zstd_version="1.5.4"
cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}.tar.gz && tar xzf v${zstd_version}.tar.gz && \
cd zstd-${zstd_version}/build/cmake && mkdir -p build_place && cd build_place && \
cmake $CMAKE_REQUIRED_PARAMS -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_CONTRIB=OFF -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_TESTS=OFF \
Expand Down
13 changes: 13 additions & 0 deletions options_block_based_table_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package grocksdb

import (
"testing"
)

func TestBBT(t *testing.T) {
b := NewDefaultBlockBasedTableOptions()
defer b.Destroy()

b.SetBlockSize(123)
b.SetOptimizeFiltersForMemory(true)
}
18 changes: 18 additions & 0 deletions options_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,24 @@ func (opts *ReadOptions) SetIOTimeout(microseconds uint64) {
C.rocksdb_readoptions_set_io_timeout(opts.c, C.uint64_t(microseconds))
}

// SetAsyncIO toggles async_io flag.
//
// If async_io is enabled, RocksDB will prefetch some of data asynchronously.
// RocksDB apply it if reads are sequential and its internal automatic
// prefetching.
//
// Default: false
//
// Note: Experimental
func (opts *ReadOptions) SetAsyncIO(value bool) {
C.rocksdb_readoptions_set_async_io(opts.c, boolToChar(value))
}

// IsAsyncIO checks if async_io flag is on.
func (opts *ReadOptions) IsAsyncIO() bool {
return charToBool(C.rocksdb_readoptions_get_async_io(opts.c))
}

// GetIOTimeout gets timeout in microseconds to be passed to the underlying FileSystem for
// reads. As opposed to deadline, this determines the timeout for each
// individual file read request. If a MultiGet/Get/Seek/Next etc call
Expand Down
4 changes: 4 additions & 0 deletions options_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ func TestReadOptions(t *testing.T) {
require.EqualValues(t, 0, ro.GetIOTimeout())
ro.SetIOTimeout(1212)
require.EqualValues(t, 1212, ro.GetIOTimeout())

require.False(t, ro.IsAsyncIO())
ro.SetAsyncIO(true)
require.True(t, ro.IsAsyncIO())
}
8 changes: 8 additions & 0 deletions testing_darwin_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build testing

package grocksdb

// #cgo CFLAGS: -I${SRCDIR}/dist/darwin_arm64/include
// #cgo CXXFLAGS: -I${SRCDIR}/dist/darwin_arm64/include
// #cgo LDFLAGS: -L${SRCDIR}/dist/darwin_arm64/lib -lrocksdb -pthread -lstdc++ -ldl -lm -lzstd -llz4 -lz -lsnappy
import "C"

0 comments on commit cc7617a

Please sign in to comment.