Skip to content

Commit

Permalink
Leverage //go:build over +build (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Aug 27, 2022
1 parent 0254e5d commit 2e0c626
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 93 deletions.
19 changes: 9 additions & 10 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ import (
//
// For example:
//
// it := db.NewIterator(readOpts)
// defer it.Close()
// it := db.NewIterator(readOpts)
// defer it.Close()
//
// it.Seek([]byte("foo"))
// for ; it.Valid(); it.Next() {
// fmt.Printf("Key: %v Value: %v\n", it.Key().Data(), it.Value().Data())
// }
//
// if err := it.Err(); err != nil {
// return err
// }
// it.Seek([]byte("foo"))
// for ; it.Valid(); it.Next() {
// fmt.Printf("Key: %v Value: %v\n", it.Key().Data(), it.Value().Data())
// }
//
// if err := it.Err(); err != nil {
// return err
// }
type Iterator struct {
c *C.rocksdb_iterator_t
}
Expand Down
2 changes: 1 addition & 1 deletion jemalloc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !testing,jemalloc
//go:build !testing && jemalloc

package grocksdb

Expand Down
2 changes: 1 addition & 1 deletion jemalloc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !testing,jemalloc
//go:build !testing && jemalloc

package grocksdb

Expand Down
2 changes: 1 addition & 1 deletion non_builtin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !testing
//go:build !testing

package grocksdb

Expand Down
14 changes: 10 additions & 4 deletions options_compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,15 @@ func (opts *UniversalCompactionOptions) GetMaxSizeAmplificationPercent() int {
// When we are compacting to a new file, here is the criteria whether
// it needs to be compressed: assuming here are the list of files sorted
// by generation time:
// A1...An B1...Bm C1...Ct
//
// A1...An B1...Bm C1...Ct
//
// where A1 is the newest and Ct is the oldest, and we are going to compact
// B1...Bm, we calculate the total size of all the files as total_size, as
// well as the total size of C1...Ct as total_C, the compaction output file
// will be compressed iff
// total_C / total_size < this percentage
//
// total_C / total_size < this percentage
//
// Default: -1
func (opts *UniversalCompactionOptions) SetCompressionSizePercent(value int) {
Expand All @@ -268,12 +271,15 @@ func (opts *UniversalCompactionOptions) SetCompressionSizePercent(value int) {
// When we are compacting to a new file, here is the criteria whether
// it needs to be compressed: assuming here are the list of files sorted
// by generation time:
// A1...An B1...Bm C1...Ct
//
// A1...An B1...Bm C1...Ct
//
// where A1 is the newest and Ct is the oldest, and we are going to compact
// B1...Bm, we calculate the total size of all the files as total_size, as
// well as the total size of C1...Ct as total_C, the compaction output file
// will be compressed iff
// total_C / total_size < this percentage
//
// total_C / total_size < this percentage
func (opts *UniversalCompactionOptions) GetCompressionSizePercent() int {
return int(C.rocksdb_universal_compaction_options_get_compression_size_percent(opts.c))
}
Expand Down
149 changes: 78 additions & 71 deletions perf_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,77 +43,84 @@ func (ctx *PerfContext) Report(excludeZeroCounters bool) (value string) {
//
// Id is one of:
//
// enum {
// rocksdb_user_key_comparison_count = 0,
// rocksdb_block_cache_hit_count,
// rocksdb_block_read_count,
// rocksdb_block_read_byte,
// rocksdb_block_read_time,
// rocksdb_block_checksum_time,
// rocksdb_block_decompress_time,
// rocksdb_get_read_bytes,
// rocksdb_multiget_read_bytes,
// rocksdb_iter_read_bytes,
// rocksdb_internal_key_skipped_count,
// rocksdb_internal_delete_skipped_count,
// rocksdb_internal_recent_skipped_count,
// rocksdb_internal_merge_count,
// rocksdb_get_snapshot_time,
// rocksdb_get_from_memtable_time,
// rocksdb_get_from_memtable_count,
// rocksdb_get_post_process_time,
// rocksdb_get_from_output_files_time,
// rocksdb_seek_on_memtable_time,
// rocksdb_seek_on_memtable_count,
// rocksdb_next_on_memtable_count,
// rocksdb_prev_on_memtable_count,
// rocksdb_seek_child_seek_time,
// rocksdb_seek_child_seek_count,
// rocksdb_seek_min_heap_time,
// rocksdb_seek_max_heap_time,
// rocksdb_seek_internal_seek_time,
// rocksdb_find_next_user_entry_time,
// rocksdb_write_wal_time,
// rocksdb_write_memtable_time,
// rocksdb_write_delay_time,
// rocksdb_write_pre_and_post_process_time,
// rocksdb_db_mutex_lock_nanos,
// rocksdb_db_condition_wait_nanos,
// rocksdb_merge_operator_time_nanos,
// rocksdb_read_index_block_nanos,
// rocksdb_read_filter_block_nanos,
// rocksdb_new_table_block_iter_nanos,
// rocksdb_new_table_iterator_nanos,
// rocksdb_block_seek_nanos,
// rocksdb_find_table_nanos,
// rocksdb_bloom_memtable_hit_count,
// rocksdb_bloom_memtable_miss_count,
// rocksdb_bloom_sst_hit_count,
// rocksdb_bloom_sst_miss_count,
// rocksdb_key_lock_wait_time,
// rocksdb_key_lock_wait_count,
// rocksdb_env_new_sequential_file_nanos,
// rocksdb_env_new_random_access_file_nanos,
// rocksdb_env_new_writable_file_nanos,
// rocksdb_env_reuse_writable_file_nanos,
// rocksdb_env_new_random_rw_file_nanos,
// rocksdb_env_new_directory_nanos,
// rocksdb_env_file_exists_nanos,
// rocksdb_env_get_children_nanos,
// rocksdb_env_get_children_file_attributes_nanos,
// rocksdb_env_delete_file_nanos,
// rocksdb_env_create_dir_nanos,
// rocksdb_env_create_dir_if_missing_nanos,
// rocksdb_env_delete_dir_nanos,
// rocksdb_env_get_file_size_nanos,
// rocksdb_env_get_file_modification_time_nanos,
// rocksdb_env_rename_file_nanos,
// rocksdb_env_link_file_nanos,
// rocksdb_env_lock_file_nanos,
// rocksdb_env_unlock_file_nanos,
// rocksdb_env_new_logger_nanos,
// rocksdb_total_metric_count = 68
// };
// enum {
// rocksdb_user_key_comparison_count = 0,
// rocksdb_block_cache_hit_count,
// rocksdb_block_read_count,
// rocksdb_block_read_byte,
// rocksdb_block_read_time,
// rocksdb_block_checksum_time,
// rocksdb_block_decompress_time,
// rocksdb_get_read_bytes,
// rocksdb_multiget_read_bytes,
// rocksdb_iter_read_bytes,
// rocksdb_internal_key_skipped_count,
// rocksdb_internal_delete_skipped_count,
// rocksdb_internal_recent_skipped_count,
// rocksdb_internal_merge_count,
// rocksdb_get_snapshot_time,
// rocksdb_get_from_memtable_time,
// rocksdb_get_from_memtable_count,
// rocksdb_get_post_process_time,
// rocksdb_get_from_output_files_time,
// rocksdb_seek_on_memtable_time,
// rocksdb_seek_on_memtable_count,
// rocksdb_next_on_memtable_count,
// rocksdb_prev_on_memtable_count,
// rocksdb_seek_child_seek_time,
// rocksdb_seek_child_seek_count,
// rocksdb_seek_min_heap_time,
// rocksdb_seek_max_heap_time,
// rocksdb_seek_internal_seek_time,
// rocksdb_find_next_user_entry_time,
// rocksdb_write_wal_time,
// rocksdb_write_memtable_time,
// rocksdb_write_delay_time,
// rocksdb_write_pre_and_post_process_time,
// rocksdb_db_mutex_lock_nanos,
// rocksdb_db_condition_wait_nanos,
// rocksdb_merge_operator_time_nanos,
// rocksdb_read_index_block_nanos,
// rocksdb_read_filter_block_nanos,
// rocksdb_new_table_block_iter_nanos,
// rocksdb_new_table_iterator_nanos,
// rocksdb_block_seek_nanos,
// rocksdb_find_table_nanos,
// rocksdb_bloom_memtable_hit_count,
// rocksdb_bloom_memtable_miss_count,
// rocksdb_bloom_sst_hit_count,
// rocksdb_bloom_sst_miss_count,
// rocksdb_key_lock_wait_time,
// rocksdb_key_lock_wait_count,
// rocksdb_env_new_sequential_file_nanos,
// rocksdb_env_new_random_access_file_nanos,
// rocksdb_env_new_writable_file_nanos,
// rocksdb_env_reuse_writable_file_nanos,
// rocksdb_env_new_random_rw_file_nanos,
// rocksdb_env_new_directory_nanos,
// rocksdb_env_file_exists_nanos,
// rocksdb_env_get_children_nanos,
// rocksdb_env_get_children_file_attributes_nanos,
// rocksdb_env_delete_file_nanos,
// rocksdb_env_create_dir_nanos,
// rocksdb_env_create_dir_if_missing_nanos,
// rocksdb_env_delete_dir_nanos,
// rocksdb_env_get_file_size_nanos,
// rocksdb_env_get_file_modification_time_nanos,
// rocksdb_env_rename_file_nanos,
// rocksdb_env_link_file_nanos,
// rocksdb_env_lock_file_nanos,
// rocksdb_env_unlock_file_nanos,
// rocksdb_env_new_logger_nanos,
// rocksdb_number_async_seek,
// rocksdb_blob_cache_hit_count,
// rocksdb_blob_read_count,
// rocksdb_blob_read_byte,
// rocksdb_blob_read_time,
// rocksdb_blob_checksum_time,
// rocksdb_blob_decompress_time,
// rocksdb_total_metric_count = 77
// };
func (ctx *PerfContext) Metric(id int) uint64 {
value := C.rocksdb_perfcontext_metric(ctx.c, C.int(id))
return uint64(value)
Expand Down
2 changes: 1 addition & 1 deletion testing_linux_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build testing
//go:build testing

package grocksdb

Expand Down
8 changes: 4 additions & 4 deletions write_batch_wi.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type WriteBatchWI struct {
}

// NewWriteBatchWI create a WriteBatchWI object.
// - reserved_bytes: reserved bytes in underlying WriteBatch
// - overwrite_key: if true, overwrite the key in the index when inserting
// the same key as previously, so iterator will never
// show two entries with the same key.
// - reserved_bytes: reserved bytes in underlying WriteBatch
// - overwrite_key: if true, overwrite the key in the index when inserting
// the same key as previously, so iterator will never
// show two entries with the same key.
func NewWriteBatchWI(reservedBytes uint, overwriteKeys bool) *WriteBatchWI {
return NewNativeWriteBatchWI(C.rocksdb_writebatch_wi_create(C.size_t(reservedBytes), boolToChar(overwriteKeys)))
}
Expand Down

0 comments on commit 2e0c626

Please sign in to comment.