Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

scv119
Copy link
Contributor

@scv119 scv119 commented May 12, 2017

This PR implements the MergeOperator for Cassandra Row Values.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@sagar0 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

Copy link
Collaborator

@adamretter adamretter left a 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 @@
/**
Copy link
Collaborator

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_;
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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)
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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++) {
Copy link
Collaborator

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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be column->Size()

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@scv119
Copy link
Contributor Author

scv119 commented May 19, 2017

thank you @adamretter I'll address the comments :)

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@sagar0
Copy link
Contributor

sagar0 commented Jun 14, 2017

Restarted a few travis tests which failed, to verify all the tests are passing before accepting.

Copy link
Contributor

@sagar0 sagar0 left a 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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

@sagar0 sagar0 Jun 14, 2017

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"
Copy link
Contributor

@sagar0 sagar0 Jun 14, 2017

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"
Copy link
Contributor

@sagar0 sagar0 Jun 14, 2017

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"
Copy link
Contributor

@sagar0 sagar0 Jun 14, 2017

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 ...

Copy link
Contributor

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.
Copy link
Contributor

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.

@sagar0
Copy link
Contributor

sagar0 commented Jun 14, 2017

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);
Copy link
Contributor Author

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.

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@scv119 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@sagar0
Copy link
Contributor

sagar0 commented Jun 16, 2017

Thanks for making the changes. Accepted, and Landing this now.

@scv119
Copy link
Contributor Author

scv119 commented Jun 16, 2017

👍 thank you for the review!

sagar0 pushed a commit that referenced this pull request Jun 27, 2017
Summary:
This PR implements the MergeOperator for Cassandra Row Values.
Closes #2289

Differential Revision: D5055464

Pulled By: scv119

fbshipit-source-id: 45f276ef8cbc4704279202f6a20c64889bc1adef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants