Summary: This diff adds three sets of APIs to RocksDB. = GetColumnFamilyMetaData = * This APIs allow users to obtain the current state of a RocksDB instance on one column family. * See GetColumnFamilyMetaData in include/rocksdb/db.h = EventListener = * A virtual class that allows users to implement a set of call-back functions which will be called when specific events of a RocksDB instance happens. * To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners = CompactFiles = * CompactFiles API inputs a set of file numbers and an output level, and RocksDB will try to compact those files into the specified level. = Example = * Example code can be found in example/compact_files_example.cc, which implements a simple external compactor using EventListener, GetColumnFamilyMetaData, and CompactFiles API. Test Plan: listener_test compactor_test example/compact_files_example export ROCKSDB_TESTS=CompactFiles db_test export ROCKSDB_TESTS=MetaData db_test Reviewers: ljin, igor, rven, sdong Reviewed By: sdong Subscribers: MarkCallaghan, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D24705
72 lines
2.7 KiB
C++
72 lines
2.7 KiB
C++
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under the BSD-style license found in the
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#ifndef STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_
|
|
#define STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_
|
|
|
|
#include <string>
|
|
|
|
namespace rocksdb {
|
|
|
|
class Slice;
|
|
|
|
// A Comparator object provides a total order across slices that are
|
|
// used as keys in an sstable or a database. A Comparator implementation
|
|
// must be thread-safe since rocksdb may invoke its methods concurrently
|
|
// from multiple threads.
|
|
class Comparator {
|
|
public:
|
|
virtual ~Comparator();
|
|
|
|
// Three-way comparison. Returns value:
|
|
// < 0 iff "a" < "b",
|
|
// == 0 iff "a" == "b",
|
|
// > 0 iff "a" > "b"
|
|
virtual int Compare(const Slice& a, const Slice& b) const = 0;
|
|
|
|
// The name of the comparator. Used to check for comparator
|
|
// mismatches (i.e., a DB created with one comparator is
|
|
// accessed using a different comparator.
|
|
//
|
|
// The client of this package should switch to a new name whenever
|
|
// the comparator implementation changes in a way that will cause
|
|
// the relative ordering of any two keys to change.
|
|
//
|
|
// Names starting with "rocksdb." are reserved and should not be used
|
|
// by any clients of this package.
|
|
virtual const char* Name() const = 0;
|
|
|
|
// Advanced functions: these are used to reduce the space requirements
|
|
// for internal data structures like index blocks.
|
|
|
|
// If *start < limit, changes *start to a short string in [start,limit).
|
|
// Simple comparator implementations may return with *start unchanged,
|
|
// i.e., an implementation of this method that does nothing is correct.
|
|
virtual void FindShortestSeparator(
|
|
std::string* start,
|
|
const Slice& limit) const = 0;
|
|
|
|
// Changes *key to a short string >= *key.
|
|
// Simple comparator implementations may return with *key unchanged,
|
|
// i.e., an implementation of this method that does nothing is correct.
|
|
virtual void FindShortSuccessor(std::string* key) const = 0;
|
|
};
|
|
|
|
// Return a builtin comparator that uses lexicographic byte-wise
|
|
// ordering. The result remains the property of this module and
|
|
// must not be deleted.
|
|
extern const Comparator* BytewiseComparator();
|
|
|
|
// Return a builtin comparator that uses reverse lexicographic byte-wise
|
|
// ordering.
|
|
extern const Comparator* ReverseBytewiseComparator();
|
|
|
|
} // namespace rocksdb
|
|
|
|
#endif // STORAGE_ROCKSDB_INCLUDE_COMPARATOR_H_
|