-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a MergeOperator for Cassandra Row Value #2289
Conversation
@scv119 updated the pull request - view changes |
@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment too much on the C++ implementation itself because my C++ knowledge is not adequate. However, the Java and C++ JNI code looks fine to me. Nice job :-)
Just a few small comments mostly around cosmetics and whether you meant to implement the deprecated methods of rocksdb::MergeOperator
rather than the newer ones?
@@ -0,0 +1,291 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the standard RocksDB copyright header?
} | ||
|
||
std::size_t Column::Size() const { | ||
return ColumnBase::Size() + 12 + value_size_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 12
? Is this a magic number? Would it make sense to define it as a static constant with a meaningful name?
ttl_(ttl) {} | ||
|
||
std::size_t ExpiringColumn::Size() const { | ||
return Column::Size() + 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as previously. Why 4
? Could this be a const of sizeof(type)?
} | ||
|
||
std::size_t Tombstone::Size() const { | ||
return ColumnBase::Size() + 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 - const/sizeof?
columns_(std::move(columns)), last_modified_time_(last_modified_time) {} | ||
|
||
std::size_t RowValue::Size() const { | ||
std::size_t size = 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12
- const/sizeof?
@@ -0,0 +1,188 @@ | |||
/** | |||
* @author Chen Shen (chenshen@fb.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the standard RocksDB copyright header?
@@ -0,0 +1,63 @@ | |||
/** | |||
* Helper functions to create test row/column and verify their correctness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the standard RocksDB copyright header?
@@ -0,0 +1,41 @@ | |||
/** | |||
* Helper functions to create test row/column and verify their correctness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the standard RocksDB copyright header?
|
||
template<> | ||
inline void Serialize<int32_t>(int32_t t, std::string* dest) { | ||
for (int i = 0; i < 4; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this class there are many constant numbers used, such as 4
, 8
, 3
and 7
. Could I guess that might be better as sizeof(int32_t)
, sizeof(int64_t)
, sizeof(int32_t) - 1
etc
std::size_t RowValue::Size() const { | ||
std::size_t size = 12; | ||
for (const auto& column : columns_) { | ||
size += column -> Size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be column->Size()
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
thank you @adamretter I'll address the comments :) |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Restarted a few travis tests which failed, to verify all the tests are passing before accepting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few nits. lgtm to go once these are fixed.
I'll run the make unity_test
on my side to verify if there are any issues with filename collisions.
#include <memory> | ||
#include "rocksdb/merge_operator.h" | ||
#include "rocksdb/slice.h" | ||
#include "util/testharness.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if testharness is really needed in this file?
#include <memory> | ||
#include <assert.h> | ||
|
||
#include "format.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should be utilities/merge_operators/cassandra/format.h following the convention in other files.
|
||
#include <memory> | ||
#include "format.h" | ||
#include "test_utils.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use Lets use "utilties/merge_operators/cassandra/" prefix
#include "rocksdb/db.h" | ||
#include "rocksdb/merge_operator.h" | ||
#include "rocksdb/utilities/db_ttl.h" | ||
#include "test_utils.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use "utilties/merge_operators/cassandra/" prefix here too.
#include <cstring> | ||
#include <memory> | ||
#include "format.h" | ||
#include "serialize.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use "utilties/merge_operators/cassandra/" prefix here too.
// of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
#pragma once | ||
#include "rocksdb/merge_operator.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if file name collisions (merge_operator.h, format.h) will lead to unity_test failure?! Checking on my side by running make unity_test
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked unity_test, and it looks good on scv119:merge-ops
branch.
// Copyright (c) 2017-present, 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the couple of lines that were added in #2226, for GPLv2, for all the new files.
Made sure that all travis tests are passing. RateLimiterTest.Rate test on OSX is failing due to unrelated reasons. Fixing that in #2451 . |
std::vector<std::unique_ptr<ColumnBase>> columns_; | ||
int64_t last_modified_time_; | ||
|
||
FRIEND_TEST(RowValueMergeTest, Merge); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sagar0 FRIEND_TEST macro is from testharness header.
@scv119 updated the pull request - view changes - changes since last import |
@scv119 updated the pull request - view changes - changes since last import |
@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Thanks for making the changes. Accepted, and Landing this now. |
👍 thank you for the review! |
Summary: This PR implements the MergeOperator for Cassandra Row Values. Closes #2289 Differential Revision: D5055464 Pulled By: scv119 fbshipit-source-id: 45f276ef8cbc4704279202f6a20c64889bc1adef
This PR implements the MergeOperator for Cassandra Row Values.