Skip to content

Commit

Permalink
Merge remote-tracking branch 'mergetrees/merge-myrocks' into 10.2-mar…
Browse files Browse the repository at this point in the history
…iarocks
  • Loading branch information
spetrunia committed Jan 1, 2017
2 parents ae0a490 + cfb59f3 commit d8288b3
Show file tree
Hide file tree
Showing 137 changed files with 6,106 additions and 3,222 deletions.
2 changes: 2 additions & 0 deletions mysql-test/include/have_rocksdb.opt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
--loose-enable-rocksdb_index_file_map
--loose-enable-rocksdb_dbstats
--loose-enable-rocksdb_cfstats
--loose-enable-rocksdb_lock_info
--loose-enable-rocksdb_trx
1 change: 0 additions & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8734,7 +8734,6 @@ double Field_enum::val_real(void)

longlong Field_enum::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
return read_lowendian(ptr, packlength);
}

Expand Down
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5403,7 +5403,7 @@ int handler::compare_key(key_range *range)
This is used by index condition pushdown implementation.
*/

int handler::compare_key2(key_range *range)
int handler::compare_key2(key_range *range) const
{
int cmp;
if (!range)
Expand Down
2 changes: 1 addition & 1 deletion sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ class handler :public Sql_alloc
virtual int read_range_next();
void set_end_range(const key_range *end_key);
int compare_key(key_range *range);
int compare_key2(key_range *range);
int compare_key2(key_range *range) const;
virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
void ft_end() { ft_handler=NULL; }
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
Expand Down
19 changes: 9 additions & 10 deletions storage/rocksdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ ENDIF()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(HAVE_SCHED_GETCPU)
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1)
ENDIF()

# get a list of rocksdb library source files
# run with env -i to avoid passing variables
EXECUTE_PROCESS(
Expand Down Expand Up @@ -78,32 +83,26 @@ ENDIF()
SET(rocksdb_static_libs )
IF (NOT "$ENV{WITH_SNAPPY}" STREQUAL "")
SET(rocksdb_static_libs ${rocksdb_static_libs}
$ENV{WITH_SNAPPY}/lib/libsnappy${PIC_EXT}.a)
$ENV{WITH_SNAPPY}/libsnappy${PIC_EXT}.a)
ADD_DEFINITIONS(-DSNAPPY)
ELSE()
SET(rocksdb_static_libs ${rocksdb_static_libs} snappy)
ENDIF()

IF (NOT "$ENV{WITH_LZ4}" STREQUAL "")
SET(rocksdb_static_libs ${rocksdb_static_libs}
$ENV{WITH_LZ4}/lib/liblz4${PIC_EXT}.a)
$ENV{WITH_LZ4}/liblz4${PIC_EXT}.a)
ADD_DEFINITIONS(-DLZ4)
ELSE()
SET(rocksdb_static_libs ${rocksdb_static_libs} lz4)
ENDIF()

IF (NOT "$ENV{WITH_BZ2}" STREQUAL "")
SET(rocksdb_static_libs ${rocksdb_static_libs}
$ENV{WITH_BZ2}/lib/libbz2${PIC_EXT}.a)
$ENV{WITH_BZ2}/libbz2${PIC_EXT}.a)
ADD_DEFINITIONS(-DBZIP2)
ELSE()
SET(rocksdb_static_libs ${rocksdb_static_libs} bz2)
ENDIF()

# link ZSTD only if instructed
IF (NOT "$ENV{WITH_ZSTD}" STREQUAL "")
SET(rocksdb_static_libs ${rocksdb_static_libs}
$ENV{WITH_ZSTD}/lib/libzstd${PIC_EXT}.a)
$ENV{WITH_ZSTD}/libzstd${PIC_EXT}.a)
ADD_DEFINITIONS(-DZSTD)
ENDIF()

Expand Down
31 changes: 22 additions & 9 deletions storage/rocksdb/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extract_index_stats(
) {
std::vector<Rdb_index_stats> ret;
for (auto fn : files) {
auto it = props.find(fn);
const auto it = props.find(fn);
DBUG_ASSERT(it != props.end());
std::vector<Rdb_index_stats> stats;
Rdb_tbl_prop_coll::read_stats_from_tbl_props(it->second, &stats);
Expand All @@ -50,6 +50,19 @@ extract_index_stats(
return ret;
}

void Rdb_event_listener::update_index_stats(
const rocksdb::TableProperties& props
) {
DBUG_ASSERT(m_ddl_manager != nullptr);
const auto tbl_props =
std::make_shared<const rocksdb::TableProperties>(props);

std::vector<Rdb_index_stats> stats;
Rdb_tbl_prop_coll::read_stats_from_tbl_props(tbl_props, &stats);

m_ddl_manager->adjust_stats(stats);
}

void Rdb_event_listener::OnCompactionCompleted(
rocksdb::DB *db,
const rocksdb::CompactionJobInfo& ci
Expand All @@ -69,14 +82,14 @@ void Rdb_event_listener::OnFlushCompleted(
const rocksdb::FlushJobInfo& flush_job_info
) {
DBUG_ASSERT(db != nullptr);
DBUG_ASSERT(m_ddl_manager != nullptr);

auto tbl_props = std::make_shared<const rocksdb::TableProperties>(
flush_job_info.table_properties);

std::vector<Rdb_index_stats> stats;
Rdb_tbl_prop_coll::read_stats_from_tbl_props(tbl_props, &stats);
m_ddl_manager->adjust_stats(stats);
update_index_stats(flush_job_info.table_properties);
}

void Rdb_event_listener::OnExternalFileIngested(
rocksdb::DB* db,
const rocksdb::ExternalFileIngestionInfo& info
) {
DBUG_ASSERT(db != nullptr);
update_index_stats(info.table_properties);
}
} // namespace myrocks
13 changes: 11 additions & 2 deletions storage/rocksdb/event_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,26 @@ class Rdb_ddl_manager;
class Rdb_event_listener : public rocksdb::EventListener
{
public:
explicit Rdb_event_listener(Rdb_ddl_manager* ddl_manager) :
Rdb_event_listener(const Rdb_event_listener&) = delete;
Rdb_event_listener& operator=(const Rdb_event_listener&) = delete;

explicit Rdb_event_listener(Rdb_ddl_manager* const ddl_manager) :
m_ddl_manager(ddl_manager) {
}

void OnCompactionCompleted(
rocksdb::DB *db, const rocksdb::CompactionJobInfo& ci) override;
rocksdb::DB* db, const rocksdb::CompactionJobInfo& ci) override;
void OnFlushCompleted(
rocksdb::DB* db, const rocksdb::FlushJobInfo& flush_job_info) override;
void OnExternalFileIngested(
rocksdb::DB* db, const rocksdb::ExternalFileIngestionInfo& ingestion_info)
override;

private:
Rdb_ddl_manager* m_ddl_manager;

void update_index_stats(
const rocksdb::TableProperties& props);
};

} // namespace myrocks
Loading

0 comments on commit d8288b3

Please sign in to comment.