You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by en...@apache.org on 2017/09/15 21:20:37 UTC
[20/25] hbase git commit: HBASE-18725 [C++] Install header files as
well as library
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/filter.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/filter.h b/hbase-native-client/core/filter.h
deleted file mode 100644
index 1e870f9..0000000
--- a/hbase-native-client/core/filter.h
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#pragma once
-
-#include <memory>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "if/Comparator.pb.h"
-#include "if/Filter.pb.h"
-#include "if/HBase.pb.h"
-
-namespace hbase {
-
-/**
- * In C++ Client, Filter is a thin wrapper for calling filters defined as a Java class. The actual
- * filtering logic is not implemented here, but this class provides a mechanism to call
- * pre-existing Filter classes (like KeyOnlyFilter, SingleColumnValueFilter, etc) with your Get or
- * Scan RPCs. This class can also be used to call custom Filters defined as a Java class, or
- * pre-existing Filters not defined below. Some of the interfaces depends on protobuf classes
- * defined in HBase.proto, Filter.proto and Comparator.proto.
- *
- * Consult the Java class docs for learning about the various filters and how they work (and filter
- * arguments).
- *
- * Pre-existing Filters can be used like this:
- *
- * Get get(row);
- * get.SetFilter(FilterFactory::ColumnPrefixFilter("foo_"));
- *
- * Custom filters can be invoked like this:
- * Get get(row);
- * std::string filter_java_class_name = "foo.bar.baz";
- * auto filter_data = std::make_unique<pb::MyFilter>();
- * filter_data->set_foo(foo);
- * get.SetFilter(std::make_unique<Filter>(filter_java_class_name, filter_data));
- *
- */
-class Filter {
- public:
- Filter(std::string java_class_name, std::unique_ptr<google::protobuf::Message> data)
- : java_class_name_(java_class_name), data_(std::move(data)) {}
- virtual ~Filter() {}
-
- const std::string java_class_name() const { return java_class_name_; }
-
- const google::protobuf::Message& data() const { return *data_; }
- /**
- * Serialize the filter data to the given buffer. Does protobuf encoding by default.
- * Can be overriden if Filter does not use protobuf.
- */
- virtual void Serialize(std::string* buf) const {
- if (data_ != nullptr) {
- data_->SerializeToString(buf);
- }
- }
-
- /** Internal method */
- static std::unique_ptr<pb::Filter> ToProto(const Filter& filter) {
- auto pb_filter = std::make_unique<pb::Filter>();
- pb_filter->set_name(filter.java_class_name());
- filter.Serialize(pb_filter->mutable_serialized_filter());
- return std::move(pb_filter);
- }
-
- private:
- std::unique_ptr<google::protobuf::Message> data_;
- std::string java_class_name_;
-};
-
-/**
- * Comparator for filters. See ByteArrayComparable documentation in Java.
- */
-class Comparator {
- public:
- Comparator(std::string java_class_name, std::unique_ptr<google::protobuf::Message> data)
- : java_class_name_(java_class_name), data_(std::move(data)) {}
- virtual ~Comparator() {}
-
- const std::string java_class_name() const { return java_class_name_; }
-
- /**
- * Serialize the Comparator data to the given buffer. Does protobuf encoding by default.
- * Can be overriden if Comparator does not use protobuf.
- */
- virtual void Serialize(std::string* buf) const {
- if (data_ != nullptr) {
- data_->SerializeToString(buf);
- }
- }
-
- /** Internal method */
- static std::unique_ptr<pb::Comparator> ToProto(const Comparator& comparator) {
- auto pb_comparator = std::make_unique<pb::Comparator>();
- pb_comparator->set_name(comparator.java_class_name());
- comparator.Serialize(pb_comparator->mutable_serialized_comparator());
- return std::move(pb_comparator);
- }
-
- private:
- std::unique_ptr<google::protobuf::Message> data_;
- std::string java_class_name_;
-};
-
-/**
- * Used in row range filters
- */
-struct RowRange {
- std::string start_row;
- bool start_row_inclusive;
- std::string stop_row;
- bool stop_row_inclusive;
-};
-
-/**
- * Factory for creating pre-defined filters.
- */
-class FilterFactory {
- public:
- static std::unique_ptr<Filter> ColumnCountGetFilter(uint32_t limit) noexcept {
- auto data = std::make_unique<pb::ColumnCountGetFilter>();
- data->set_limit(limit);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ColumnCountGetFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> ColumnPaginationFilter(uint32_t limit, uint32_t offset) noexcept {
- auto data = std::make_unique<pb::ColumnPaginationFilter>();
- data->set_limit(limit);
- data->set_offset(offset);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ColumnPaginationFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> ColumnPaginationFilter(uint32_t limit,
- const std::string& column_offset) noexcept {
- auto data = std::make_unique<pb::ColumnPaginationFilter>();
- data->set_limit(limit);
- data->set_column_offset(column_offset);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ColumnPaginationFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> ColumnPrefixFilter(const std::string& prefix) noexcept {
- auto data = std::make_unique<pb::ColumnPrefixFilter>();
- data->set_prefix(prefix);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ColumnPrefixFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> ColumnRangeFilter(const std::string& min_column,
- bool min_column_inclusive,
- const std::string& max_column,
- bool max_column_inclusive) noexcept {
- auto data = std::make_unique<pb::ColumnRangeFilter>();
- data->set_min_column(min_column);
- data->set_min_column_inclusive(min_column_inclusive);
- data->set_max_column(max_column);
- data->set_max_column_inclusive(max_column_inclusive);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ColumnRangeFilter",
- std::move(data));
- }
-
- static std::unique_ptr<pb::CompareFilter> CompareFilter(pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::CompareFilter>();
- data->set_compare_op(compare_op);
- data->set_allocated_comparator(Comparator::ToProto(comparator).release());
- return std::move(data);
- }
-
- /**
- * Build a dependent column filter with value checking
- * dependent column varies will be compared using the supplied
- * compareOp and comparator, for usage of which
- * refer to {@link CompareFilter}
- *
- * @param family dependent column family
- * @param qualifier dependent column qualifier
- * @param drop_dependent_column whether the column should be discarded after
- * @param compare_op comparison op
- * @param comparator comparator
- */
- static std::unique_ptr<Filter> DependentColumnFilter(const std::string& family,
- const std::string& qualifier,
- bool drop_dependent_column,
- pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::DependentColumnFilter>();
- data->set_column_family(family);
- data->set_column_qualifier(qualifier);
- data->set_drop_dependent_column(drop_dependent_column);
- data->set_allocated_compare_filter(CompareFilter(compare_op, comparator).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.DependentColumnFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> FamilyFilter(pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::FamilyFilter>();
- data->set_allocated_compare_filter(CompareFilter(compare_op, comparator).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.FamilyFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> FilterAllFilter() noexcept {
- auto data = std::make_unique<pb::FilterAllFilter>();
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.FilterAllFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> FilterList(
- pb::FilterList_Operator op, const std::vector<std::unique_ptr<Filter>>& filters) noexcept {
- auto data = std::make_unique<pb::FilterList>();
- data->set_operator_(op);
- for (auto const& f : filters) {
- data->mutable_filters()->AddAllocated(Filter::ToProto(*f).release());
- }
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.FilterList", std::move(data));
- }
-
- static std::unique_ptr<Filter> FirstKeyOnlyFilter() noexcept {
- auto data = std::make_unique<pb::FirstKeyOnlyFilter>();
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> FirstKeyValueMatchingQualifiersFilter(
- const std::set<std::string>& qualifiers) noexcept {
- auto data = std::make_unique<pb::FirstKeyValueMatchingQualifiersFilter>();
- for (auto q : qualifiers) {
- data->add_qualifiers(q);
- }
- return std::make_unique<Filter>(
- "org.apache.hadoop.hbase.filter.FirstKeyValueMatchingQualifiersFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> FuzzyRowFilter(
- const std::vector<std::pair<std::string, std::string>>& fuzzy_keys_data) noexcept {
- auto data = std::make_unique<pb::FuzzyRowFilter>();
- for (auto q : fuzzy_keys_data) {
- auto p = data->add_fuzzy_keys_data();
- p->set_first(q.first);
- p->set_second(q.second);
- }
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.FuzzyRowFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> InclusiveStopFilter(const std::string& stop_row_key) noexcept {
- auto data = std::make_unique<pb::InclusiveStopFilter>();
- data->set_stop_row_key(stop_row_key);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.InclusiveStopFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> KeyOnlyFilter(bool len_as_val) noexcept {
- auto data = std::make_unique<pb::KeyOnlyFilter>();
- data->set_len_as_val(len_as_val);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.KeyOnlyFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> MultipleColumnPrefixFilter(
- const std::vector<std::string>& sorted_prefixes) noexcept {
- auto data = std::make_unique<pb::MultipleColumnPrefixFilter>();
- for (auto p : sorted_prefixes) {
- data->add_sorted_prefixes(p);
- }
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.MultipleColumnPrefixFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> MultiRowRangeFilter(
- const std::vector<RowRange>& row_ranges) noexcept {
- auto data = std::make_unique<pb::MultiRowRangeFilter>();
- for (auto r : row_ranges) {
- auto range = data->add_row_range_list();
- range->set_start_row(r.start_row);
- range->set_start_row_inclusive(r.start_row_inclusive);
- range->set_stop_row(r.stop_row);
- range->set_stop_row_inclusive(r.stop_row_inclusive);
- }
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.MultiRowRangeFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> PageFilter(uint64_t page_size) noexcept {
- auto data = std::make_unique<pb::PageFilter>();
- data->set_page_size(page_size);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.PageFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> PrefixFilter(const std::string& prefix) noexcept {
- auto data = std::make_unique<pb::PrefixFilter>();
- data->set_prefix(prefix);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.PrefixFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> QualifierFilter(pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::QualifierFilter>();
- data->set_allocated_compare_filter(CompareFilter(compare_op, comparator).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.QualifierFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> RandomRowFilter(float chance) noexcept {
- auto data = std::make_unique<pb::RandomRowFilter>();
- data->set_chance(chance);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.RandomRowFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> RowFilter(pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::RowFilter>();
- data->set_allocated_compare_filter(CompareFilter(compare_op, comparator).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.RowFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> SingleColumnValueExcludeFilter(
- const std::string& family, const std::string& qualifier, bool filter_if_missing,
- bool latest_version_only, pb::CompareType compare_op, const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::SingleColumnValueExcludeFilter>();
- auto f = SingleColumnValueFilterProto(family, qualifier, filter_if_missing, latest_version_only,
- compare_op, comparator);
- data->set_allocated_single_column_value_filter(f.release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter",
- std::move(data));
- }
-
- static std::unique_ptr<pb::SingleColumnValueFilter> SingleColumnValueFilterProto(
- const std::string& family, const std::string& qualifier, bool filter_if_missing,
- bool latest_version_only, pb::CompareType compare_op, const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::SingleColumnValueFilter>();
- data->set_column_family(family);
- data->set_column_qualifier(qualifier);
- data->set_compare_op(compare_op);
- data->set_filter_if_missing(filter_if_missing);
- data->set_latest_version_only(latest_version_only);
- data->set_allocated_comparator(Comparator::ToProto(comparator).release());
- return data;
- }
-
- static std::unique_ptr<Filter> SingleColumnValueFilter(
- const std::string& family, const std::string& qualifier, bool filter_if_missing,
- bool latest_version_only, pb::CompareType compare_op, const Comparator& comparator) noexcept {
- auto data = SingleColumnValueFilterProto(family, qualifier, filter_if_missing,
- latest_version_only, compare_op, comparator);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.SingleColumnValueFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> SkipFilter(const Filter& filter) noexcept {
- auto data = std::make_unique<pb::SkipFilter>();
- data->set_allocated_filter(Filter::ToProto(filter).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.SkipFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> TimestampsFilter(std::vector<uint64_t> timestamps,
- bool can_hint) noexcept {
- auto data = std::make_unique<pb::TimestampsFilter>();
- for (auto t : timestamps) {
- data->add_timestamps(t);
- }
- data->set_can_hint(can_hint);
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.TimestampsFilter",
- std::move(data));
- }
-
- static std::unique_ptr<Filter> ValueFilter(pb::CompareType compare_op,
- const Comparator& comparator) noexcept {
- auto data = std::make_unique<pb::ValueFilter>();
- data->set_allocated_compare_filter(CompareFilter(compare_op, comparator).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.ValueFilter", std::move(data));
- }
-
- static std::unique_ptr<Filter> WhileMatchFilter(const Filter& filter) noexcept {
- auto data = std::make_unique<pb::WhileMatchFilter>();
- data->set_allocated_filter(Filter::ToProto(filter).release());
- return std::make_unique<Filter>("org.apache.hadoop.hbase.filter.WhileMatchFilter",
- std::move(data));
- }
-};
-
-/**
- * Factory for creating pre-defined Comparators.
- */
-class ComparatorFactory {
- public:
- static std::unique_ptr<pb::ByteArrayComparable> ByteArrayComparable(
- const std::string& value) noexcept {
- auto data = std::make_unique<pb::ByteArrayComparable>();
- data->set_value(value);
- return std::move(data);
- }
-
- static std::unique_ptr<Comparator> BinaryComparator(const std::string& value) noexcept {
- auto data = std::make_unique<pb::BinaryComparator>();
- data->set_allocated_comparable(ByteArrayComparable(value).release());
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.BinaryComparator",
- std::move(data));
- }
-
- static std::unique_ptr<Comparator> LongComparator(const std::string& value) noexcept {
- // TODO: this should take a uint64_t argument, not a byte array.
- auto data = std::make_unique<pb::LongComparator>();
- data->set_allocated_comparable(ByteArrayComparable(value).release());
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.LongComparator",
- std::move(data));
- }
-
- static std::unique_ptr<Comparator> BinaryPrefixComparator(const std::string& value) noexcept {
- auto data = std::make_unique<pb::BinaryPrefixComparator>();
- data->set_allocated_comparable(ByteArrayComparable(value).release());
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.BinaryPrefixComparator",
- std::move(data));
- }
-
- static std::unique_ptr<Comparator> BitComparator(const std::string& value,
- pb::BitComparator_BitwiseOp bit_op) noexcept {
- auto data = std::make_unique<pb::BitComparator>();
- data->set_allocated_comparable(ByteArrayComparable(value).release());
- data->set_bitwise_op(bit_op);
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.BitComparator",
- std::move(data));
- }
-
- static std::unique_ptr<Comparator> NullComparator() noexcept {
- auto data = std::make_unique<pb::NullComparator>();
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.NullComparator",
- std::move(data));
- }
-
- /**
- * @param pattern a valid regular expression
- * @param pattern_flags java.util.regex.Pattern flags
- * @param charset the charset name
- * @param engine engine implementation type, either JAVA or JONI
- */
- static std::unique_ptr<Comparator> RegexStringComparator(
- const std::string& pattern, int32_t pattern_flags, const std::string& charset = "UTF-8",
- const std::string& engine = "JAVA") noexcept {
- auto data = std::make_unique<pb::RegexStringComparator>();
- data->set_pattern(pattern);
- data->set_pattern_flags(pattern_flags);
- data->set_charset(charset);
- data->set_engine(engine);
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.RegexStringComparator",
- std::move(data));
- }
-
- static std::unique_ptr<Comparator> SubstringComparator(const std::string& substr) noexcept {
- auto data = std::make_unique<pb::SubstringComparator>();
- data->set_substr(substr);
- return std::make_unique<Comparator>("org.apache.hadoop.hbase.filter.SubstringComparator",
- std::move(data));
- }
-};
-} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/get-test.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/get-test.cc b/hbase-native-client/core/get-test.cc
deleted file mode 100644
index 4a44a26..0000000
--- a/hbase-native-client/core/get-test.cc
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/get.h"
-#include "core/cell.h"
-
-#include <glog/logging.h>
-#include <gtest/gtest.h>
-
-using hbase::Cell;
-using hbase::Get;
-
-const int NUMBER_OF_GETS = 5;
-
-void CheckFamilies(Get &get) {
- EXPECT_EQ(false, get.HasFamilies());
- get.AddFamily("family-1");
- EXPECT_EQ(true, get.HasFamilies());
- EXPECT_EQ(1, get.FamilyMap().size());
- for (const auto &family : get.FamilyMap()) {
- EXPECT_STREQ("family-1", family.first.c_str());
- EXPECT_EQ(0, family.second.size());
- }
- // Not allowed to add the same CF.
- get.AddFamily("family-1");
- EXPECT_EQ(1, get.FamilyMap().size());
- get.AddFamily("family-2");
- EXPECT_EQ(2, get.FamilyMap().size());
- get.AddFamily("family-3");
- EXPECT_EQ(3, get.FamilyMap().size());
- int i = 1;
- for (const auto &family : get.FamilyMap()) {
- std::string family_name = "family-" + std::to_string(i);
- EXPECT_STREQ(family_name.c_str(), family.first.c_str());
- EXPECT_EQ(0, family.second.size());
- i += 1;
- }
-
- get.AddColumn("family-1", "column-1");
- get.AddColumn("family-1", "column-2");
- get.AddColumn("family-1", "");
- get.AddColumn("family-1", "column-3");
- get.AddColumn("family-2", "column-X");
-
- EXPECT_EQ(3, get.FamilyMap().size());
- auto it = get.FamilyMap().begin();
- EXPECT_STREQ("family-1", it->first.c_str());
- EXPECT_EQ(4, it->second.size());
- EXPECT_STREQ("column-1", it->second[0].c_str());
- EXPECT_STREQ("column-2", it->second[1].c_str());
- EXPECT_STREQ("", it->second[2].c_str());
- EXPECT_STREQ("column-3", it->second[3].c_str());
- ++it;
- EXPECT_STREQ("family-2", it->first.c_str());
- EXPECT_EQ(1, it->second.size());
- EXPECT_STREQ("column-X", it->second[0].c_str());
- ++it;
- EXPECT_STREQ("family-3", it->first.c_str());
- EXPECT_EQ(0, it->second.size());
- ++it;
- EXPECT_EQ(it, get.FamilyMap().end());
-}
-
-void CheckFamiliesAfterCopy(Get &get) {
- EXPECT_EQ(true, get.HasFamilies());
- EXPECT_EQ(3, get.FamilyMap().size());
- int i = 1;
- for (const auto &family : get.FamilyMap()) {
- std::string family_name = "family-" + std::to_string(i);
- EXPECT_STREQ(family_name.c_str(), family.first.c_str());
- i += 1;
- }
- // Check if the alreaday added CF's and CQ's are as expected
- auto it = get.FamilyMap().begin();
- EXPECT_STREQ("family-1", it->first.c_str());
- EXPECT_EQ(4, it->second.size());
- EXPECT_STREQ("column-1", it->second[0].c_str());
- EXPECT_STREQ("column-2", it->second[1].c_str());
- EXPECT_STREQ("", it->second[2].c_str());
- EXPECT_STREQ("column-3", it->second[3].c_str());
- ++it;
- EXPECT_STREQ("family-2", it->first.c_str());
- EXPECT_EQ(1, it->second.size());
- EXPECT_STREQ("column-X", it->second[0].c_str());
- ++it;
- EXPECT_STREQ("family-3", it->first.c_str());
- EXPECT_EQ(0, it->second.size());
- ++it;
- EXPECT_EQ(it, get.FamilyMap().end());
-}
-
-void GetMethods(Get &get, const std::string &row) {
- EXPECT_EQ(row, get.row());
-
- CheckFamilies(get);
- EXPECT_EQ(true, get.CacheBlocks());
- get.SetCacheBlocks(false);
- EXPECT_EQ(false, get.CacheBlocks());
-
- EXPECT_EQ(hbase::pb::Consistency::STRONG, get.Consistency());
- get.SetConsistency(hbase::pb::Consistency::TIMELINE);
- EXPECT_EQ(hbase::pb::Consistency::TIMELINE, get.Consistency());
-
- EXPECT_EQ(1, get.MaxVersions());
- get.SetMaxVersions(2);
- EXPECT_EQ(2, get.MaxVersions());
- get.SetMaxVersions();
- EXPECT_EQ(1, get.MaxVersions());
-
- // Test initial values
- EXPECT_EQ(0, get.Timerange().MinTimeStamp());
- EXPECT_EQ(std::numeric_limits<int64_t>::max(), get.Timerange().MaxTimeStamp());
-
- // Set & Test new values using TimeRange and TimeStamp
- get.SetTimeRange(1000, 2000);
- EXPECT_EQ(1000, get.Timerange().MinTimeStamp());
- EXPECT_EQ(2000, get.Timerange().MaxTimeStamp());
- get.SetTimeStamp(0);
- EXPECT_EQ(0, get.Timerange().MinTimeStamp());
- EXPECT_EQ(1, get.Timerange().MaxTimeStamp());
-
- // Test some exceptions
- ASSERT_THROW(get.SetTimeRange(-1000, 2000), std::runtime_error);
- ASSERT_THROW(get.SetTimeRange(1000, -2000), std::runtime_error);
- ASSERT_THROW(get.SetTimeRange(1000, 200), std::runtime_error);
- ASSERT_THROW(get.SetTimeStamp(std::numeric_limits<int64_t>::max()), std::runtime_error);
-
- // Test some exceptions
- ASSERT_THROW(get.SetMaxVersions(0), std::runtime_error);
- ASSERT_THROW(get.SetMaxVersions(std::numeric_limits<uint32_t>::max() + 1), std::runtime_error);
-}
-
-TEST(Get, SingleGet) {
- std::string row_str = "row-test";
- Get get(row_str);
- GetMethods(get, row_str);
-
- Get get_tmp(row_str);
- Get getcp(get_tmp);
- GetMethods(getcp, row_str);
-
- Get geteq("test");
- geteq = get_tmp;
- GetMethods(geteq, row_str);
-
- // Adding the below tests as there were some concerns raised that the same
- // vector of qualifiers in FamilyMap is being shared between copied objects
- // Verify the source object's family map size before using it to copy.
- EXPECT_EQ(3, get.FamilyMap().size());
-
- Get getcp_fam(get);
- // address of family maps should be different.
- EXPECT_NE(&(get.FamilyMap()), &(getcp_fam.FamilyMap()));
-
- // Add family to the source object
- get.AddColumn("family-4", "column-A");
- get.AddColumn("family-4", "column-B");
- // Verify the source object's family map size
- EXPECT_EQ(4, get.FamilyMap().size());
- // Verify the source object's family elements
- auto it = get.FamilyMap().begin();
- EXPECT_STREQ("family-1", it->first.c_str());
- EXPECT_EQ(4, it->second.size());
- EXPECT_STREQ("column-1", it->second[0].c_str());
- EXPECT_STREQ("column-2", it->second[1].c_str());
- EXPECT_STREQ("", it->second[2].c_str());
- EXPECT_STREQ("column-3", it->second[3].c_str());
- ++it;
- EXPECT_STREQ("family-2", it->first.c_str());
- EXPECT_EQ(1, it->second.size());
- EXPECT_STREQ("column-X", it->second[0].c_str());
- ++it;
- EXPECT_STREQ("family-3", it->first.c_str());
- EXPECT_EQ(0, it->second.size());
- ++it;
- EXPECT_STREQ("family-4", it->first.c_str());
- EXPECT_EQ(2, it->second.size());
- EXPECT_STREQ("column-A", it->second[0].c_str());
- EXPECT_STREQ("column-B", it->second[1].c_str());
- ++it;
- EXPECT_EQ(it, get.FamilyMap().end());
-
- // Verifying the copied object's families. It will remain unchanged and below
- // tests should pass
- CheckFamiliesAfterCopy(getcp_fam);
-}
-
-TEST(Get, MultiGet) {
- std::vector<std::unique_ptr<Get>> gets;
- for (int i = 0; i < NUMBER_OF_GETS; i++) {
- std::string row_str = "row-test";
- row_str += std::to_string(i);
- auto get = std::make_unique<Get>(row_str);
-
- GetMethods(*get, row_str);
- gets.push_back(std::move(get));
- }
- EXPECT_EQ(NUMBER_OF_GETS, gets.size());
-}
-
-TEST(Get, Exception) {
- std::string row(std::numeric_limits<int16_t>::max() + 1, 'X');
- ASSERT_THROW(Get tmp = Get(row), std::runtime_error);
- ASSERT_THROW(Get tmp = Get(""), std::runtime_error);
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/get.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/get.cc b/hbase-native-client/core/get.cc
deleted file mode 100644
index bc0d446..0000000
--- a/hbase-native-client/core/get.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/get.h"
-#include <algorithm>
-#include <limits>
-#include <stdexcept>
-
-namespace hbase {
-
-Get::~Get() {}
-
-Get::Get(const std::string &row) : Row(row) {}
-
-Get::Get(const Get &get) : Query(get) {
- row_ = get.row_;
- max_versions_ = get.max_versions_;
- cache_blocks_ = get.cache_blocks_;
- check_existence_only_ = get.check_existence_only_;
- consistency_ = get.consistency_;
- tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(), get.Timerange().MaxTimeStamp()));
- family_map_.insert(get.family_map_.begin(), get.family_map_.end());
-}
-
-Get &Get::operator=(const Get &get) {
- Query::operator=(get);
- row_ = get.row_;
- max_versions_ = get.max_versions_;
- cache_blocks_ = get.cache_blocks_;
- check_existence_only_ = get.check_existence_only_;
- consistency_ = get.consistency_;
- tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(), get.Timerange().MaxTimeStamp()));
- family_map_.insert(get.family_map_.begin(), get.family_map_.end());
- return *this;
-}
-
-Get &Get::AddFamily(const std::string &family) {
- const auto &it = family_map_.find(family);
-
- /**
- * Check if any qualifiers are already present or not.
- * Remove all existing qualifiers if the given family is already present in
- * the map
- */
- if (family_map_.end() != it) {
- it->second.clear();
- } else {
- family_map_[family];
- }
- return *this;
-}
-
-Get &Get::AddColumn(const std::string &family, const std::string &qualifier) {
- const auto &it = std::find(family_map_[family].begin(), family_map_[family].end(), qualifier);
-
- /**
- * Check if any qualifiers are already present or not.
- * Add only if qualifiers for a given family are not present
- */
- if (it == family_map_[family].end()) {
- family_map_[family].push_back(qualifier);
- }
- return *this;
-}
-
-hbase::pb::Consistency Get::Consistency() const { return consistency_; }
-
-Get &Get::SetConsistency(hbase::pb::Consistency consistency) {
- consistency_ = consistency;
- return *this;
-}
-
-bool Get::HasFamilies() const { return !family_map_.empty(); }
-
-const std::map<std::string, std::vector<std::string>> &Get::FamilyMap() const {
- return family_map_;
-}
-
-int Get::MaxVersions() const { return max_versions_; }
-
-Get &Get::SetMaxVersions(int32_t max_versions) {
- if (0 == max_versions) throw std::runtime_error("max_versions must be positive");
-
- max_versions_ = max_versions;
- return *this;
-}
-
-bool Get::CacheBlocks() const { return cache_blocks_; }
-
-Get &Get::SetCacheBlocks(bool cache_blocks) {
- cache_blocks_ = cache_blocks;
- return *this;
-}
-
-Get &Get::SetTimeRange(int64_t min_timestamp, int64_t max_timestamp) {
- tr_.reset(new TimeRange(min_timestamp, max_timestamp));
- return *this;
-}
-
-Get &Get::SetTimeStamp(int64_t timestamp) {
- tr_.reset(new TimeRange(timestamp, timestamp + 1));
- return *this;
-}
-
-const TimeRange &Get::Timerange() const { return *tr_; }
-
-} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/get.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/get.h b/hbase-native-client/core/get.h
deleted file mode 100644
index c4cddfb..0000000
--- a/hbase-native-client/core/get.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#pragma once
-
-#include <cstdint>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-#include "core/query.h"
-#include "core/row.h"
-#include "core/time-range.h"
-#include "if/Client.pb.h"
-
-namespace hbase {
-
-class Get : public Row, public Query {
- public:
- /**
- * Constructors
- */
- explicit Get(const std::string& row);
- Get(const Get& cget);
- Get& operator=(const Get& cget);
-
- ~Get();
-
- /**
- * @brief Returns the maximum number of values to fetch per CF
- */
- int MaxVersions() const;
-
- /**
- * @brief Get up to the specified number of versions of each column. default
- * is 1.
- * @param max_versions max_versons to set
- */
- Get& SetMaxVersions(int32_t max_versions = 1);
-
- /**
- * @brief Returns whether blocks should be cached for this Get operation.
- */
- bool CacheBlocks() const;
-
- /**
- * @brief Set whether blocks should be cached for this Get operation.
- * @param cache_blocks to set
- */
- Get& SetCacheBlocks(bool cache_blocks);
-
- /**
- * @brief Returns the Get family map for this Get operation. Used
- * for constructing Scan object with an already constructed Get
- */
- const std::map<std::string, std::vector<std::string>>& FamilyMap() const;
-
- /**
- * @brief Returns the timerange for this Get
- */
- const TimeRange& Timerange() const;
-
- /**
- * @brief Get versions of columns only within the specified timestamp range,
- * [minStamp, maxStamp).
- * @param minStamp the minimum timestamp, inclusive
- * @param maxStamp the maximum timestamp, exclusive
- */
- Get& SetTimeRange(int64_t min_timestamp, int64_t max_timestamp);
-
- /**
- * @brief Get versions of columns with the specified timestamp.
- * @param The timestamp to be set
- */
- Get& SetTimeStamp(int64_t timestamp);
-
- /**
- * @brief Get all columns from the specified family.
- * @param family to be retrieved
- */
- Get& AddFamily(const std::string& family);
-
- /**
- * @brief Get the column from the specific family with the specified
- * qualifier.
- * @param family to be retrieved
- * @param qualifier to be retrieved
- */
- Get& AddColumn(const std::string& family, const std::string& qualifier);
-
- /**
- * @brief Returns true if family map is non empty false otherwise
- */
- bool HasFamilies() const;
-
- /**
- * @brief Returns the consistency level for this Get operation
- */
- hbase::pb::Consistency Consistency() const;
-
- /**
- * @brief Sets the consistency level for this Get operation
- * @param Consistency to be set
- */
- Get& SetConsistency(hbase::pb::Consistency consistency);
-
- private:
- int32_t max_versions_ = 1;
- bool cache_blocks_ = true;
- bool check_existence_only_ = false;
- std::map<std::string, std::vector<std::string>> family_map_;
- hbase::pb::Consistency consistency_ = hbase::pb::Consistency::STRONG;
- std::unique_ptr<TimeRange> tr_ = std::make_unique<TimeRange>();
-};
-
-} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/hbase-configuration-loader.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/hbase-configuration-loader.cc b/hbase-native-client/core/hbase-configuration-loader.cc
deleted file mode 100644
index 4d6a3e9..0000000
--- a/hbase-native-client/core/hbase-configuration-loader.cc
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/hbase-configuration-loader.h"
-
-#include <glog/logging.h>
-#include <boost/foreach.hpp>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-
-namespace hbase {
-
-bool is_valid_bool(const std::string &raw) {
- if (raw.empty()) {
- return false;
- }
-
- if (!strcasecmp(raw.c_str(), "true")) {
- return true;
- }
- if (!strcasecmp(raw.c_str(), "false")) {
- return true;
- }
- return false;
-}
-
-bool str_to_bool(const std::string &raw) {
- if (!strcasecmp(raw.c_str(), "true")) {
- return true;
- }
- return false;
-}
-
-HBaseConfigurationLoader::HBaseConfigurationLoader() {}
-
-HBaseConfigurationLoader::~HBaseConfigurationLoader() {}
-
-void HBaseConfigurationLoader::SetDefaultSearchPath() {
- /*
- * Try (in order, taking the first valid one):
- * $HBASE_CONF_DIR
- * /etc/hbase/conf
- *
- */
- const char *hadoop_conf_dir_env = getenv("HBASE_CONF");
- if (hadoop_conf_dir_env) {
- AddToSearchPath(hadoop_conf_dir_env);
- } else {
- AddToSearchPath(kHBaseDefauktConfPath);
- }
-}
-
-void HBaseConfigurationLoader::ClearSearchPath() { search_paths_.clear(); }
-
-void HBaseConfigurationLoader::SetSearchPath(const std::string &search_path) {
- search_paths_.clear();
-
- std::vector<std::string> paths;
- std::string::size_type start = 0;
- std::string::size_type end = search_path.find(kSearchPathSeparator);
-
- while (end != std::string::npos) {
- paths.push_back(search_path.substr(start, end - start));
- start = ++end;
- end = search_path.find(kSearchPathSeparator, start);
- }
- paths.push_back(search_path.substr(start, search_path.length()));
-
- for (auto path : paths) {
- AddToSearchPath(path);
- }
-}
-
-void HBaseConfigurationLoader::AddToSearchPath(const std::string &search_path) {
- if (search_path.empty()) return;
-
- std::string path_to_add(search_path);
- if (search_path.back() != kFileSeparator) {
- path_to_add += kFileSeparator;
- }
- if (std::find(search_paths_.begin(), search_paths_.end(), path_to_add) == search_paths_.end())
- search_paths_.push_back(path_to_add);
-}
-
-void HBaseConfigurationLoader::AddDefaultResources() {
- resources_.push_back(kHBaseDefaultXml);
- resources_.push_back(kHBaseSiteXml);
-}
-
-void HBaseConfigurationLoader::AddResources(const std::string &filename) {
- if (std::find(resources_.begin(), resources_.end(), filename) == resources_.end())
- resources_.push_back(filename);
-}
-
-optional<Configuration> HBaseConfigurationLoader::LoadDefaultResources() {
- SetDefaultSearchPath();
- AddDefaultResources();
- ConfigMap conf_property;
- bool success = false;
- for (auto dir : search_paths_) {
- for (auto file : resources_) {
- std::string config_file = dir + file;
- std::ifstream stream(config_file);
- if (stream.is_open()) {
- success |= LoadProperties(config_file, conf_property);
- } else {
- DLOG(WARNING) << "Unable to open file[" << config_file << "]";
- }
- }
- }
- if (success) {
- return std::experimental::make_optional<Configuration>(Configuration(conf_property));
- } else {
- return optional<Configuration>();
- }
-}
-
-optional<Configuration> HBaseConfigurationLoader::LoadResources(
- const std::string &search_path, const std::vector<std::string> &resources) {
- SetSearchPath(search_path);
- for (const auto &resource : resources) AddResources(resource);
- ConfigMap conf_property;
- bool success = false;
- for (auto dir : search_paths_) {
- for (auto file : resources_) {
- std::string config_file = dir + file;
- std::ifstream stream(config_file);
- if (stream.is_open()) {
- success |= LoadProperties(config_file, conf_property);
- } else {
- DLOG(WARNING) << "Unable to open file[" << config_file << "]";
- }
- }
- }
- if (success) {
- return std::experimental::make_optional<Configuration>(Configuration(conf_property));
- } else {
- return optional<Configuration>();
- }
-}
-
-bool HBaseConfigurationLoader::LoadProperties(const std::string &file, ConfigMap &property_map) {
- // Create empty property tree object
- using boost::property_tree::ptree;
- ptree pt;
- try {
- // Load XML file and put contents in a property tree.
- // If read fails, throw exception.
- read_xml(file, pt);
-
- // If configuration key is not found exception is thrown
- std::string configuration = pt.get<std::string>("configuration");
-
- // Iterate over configuration section.
- // Store all found properties in ConfigMap
- BOOST_FOREACH (ptree::value_type &v, pt.get_child("configuration")) {
- if ("property" == v.first) {
- std::string name_node = v.second.get<std::string>("name");
- std::string value_node = v.second.get<std::string>("value");
- if ((name_node.size() > 0) && (value_node.size() > 0)) {
- boost::optional<std::string> final_node = v.second.get_optional<std::string>("final");
- UpdateMapWithValue(property_map, name_node, value_node, final_node);
- }
- }
- }
- } catch (std::exception &ex) {
- DLOG(WARNING) << "Exception in parsing file [" << file << "]:[" << ex.what() << "]";
- return false;
- }
- return true;
-}
-
-bool HBaseConfigurationLoader::UpdateMapWithValue(ConfigMap &map, const std::string &key,
- const std::string &value,
- boost::optional<std::string> final_text) {
- auto map_value = map.find(key);
- if (map_value != map.end() && map_value->second.final) {
- return false;
- }
-
- bool final_value = false;
- if (nullptr != final_text.get_ptr()) {
- if (is_valid_bool(final_text.get())) {
- final_value = str_to_bool(final_text.get());
- }
- }
-
- map[key].value = value;
- map[key].final = final_value;
- return true;
-}
-} /* namespace hbase */
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/hbase-configuration-loader.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/hbase-configuration-loader.h b/hbase-native-client/core/hbase-configuration-loader.h
deleted file mode 100644
index 95b2541..0000000
--- a/hbase-native-client/core/hbase-configuration-loader.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#pragma once
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include <boost/optional.hpp>
-
-#include "core/configuration.h"
-#include "utils/optional.h"
-
-namespace hbase {
-
-class HBaseConfigurationLoader {
- public:
- HBaseConfigurationLoader();
- ~HBaseConfigurationLoader();
-
- /**
- * @brief Creates a Configuration object based on default resources loaded
- * from default search paths. Default search path will be either $HBASE_CONF
- * is set or /etc/hbase/conf. Default resources are hbase-default.xml and
- * hbase-site.xml.SetDefaultSearchPath() and AddDefaultResources() are used
- * for the same.
- * Values are loaded in from hbase-default.xml first and then from
- * hbase-site.xml.
- * Properties in hbase-site.xml will override the ones in hbase-default.xml
- * unless marked as final
- */
- optional<Configuration> LoadDefaultResources();
-
- /*
- * @brief Creates a Configuration object based on resources loaded from search
- * paths. Search paths are defined in search_path. Values are loaded from
- * resources and will be overridden unless marked as final
- * @param search_path - ':' search paths to load resources.
- * @param resources - list of resources used to load configuration properties.
- */
- optional<Configuration> LoadResources(const std::string &search_path,
- const std::vector<std::string> &resources);
-
- private:
- using ConfigMap = Configuration::ConfigMap;
- const std::string kHBaseDefaultXml = "hbase-default.xml";
- const std::string kHBaseSiteXml = "hbase-site.xml";
- const std::string kHBaseDefauktConfPath = "/etc/hbase/conf";
-
- // Adds FILE_SEPARATOR to the search path
- const char kFileSeparator = '/';
-
- // Separator using which multiple search paths can be defined.
- const char kSearchPathSeparator = ':';
-
- /**
- * List of paths which will be looked up for loading properties.
- */
- std::vector<std::string> search_paths_;
-
- /**
- * List of files which will be looked up in search_paths_ to load properties.
- */
- std::vector<std::string> resources_;
-
- /**
- * @brief This method sets the search path to the default search path (i.e.
- * "$HBASE_CONF" or "/etc/hbase/conf" if HBASE_CONF is absent)
- */
- void SetDefaultSearchPath();
-
- /**
- * @brief Clears out the set search path(s)
- */
- void ClearSearchPath();
-
- /**
- * @brief Sets the search path to ":"-delimited paths, clearing already
- * defined values
- * @param search_path Single path or ":"-delimited separated paths
- */
- void SetSearchPath(const std::string &search_path);
-
- /**
- * @brief Adds an element to the search path if not already present.
- * @param search_path Path that will be added to load config values
- */
- void AddToSearchPath(const std::string &search_path);
-
- /**
- * @brief This method will add default resources i.e. hbase-default.xml and
- * hbase-site.xml to the default search path.
- */
- void AddDefaultResources();
-
- /**
- * @brief Adds resources to list for loading config values.
- * @param filename to be added to resources.
- */
- void AddResources(const std::string &filename);
-
- /**
- * @brief Loads properties in file identified by file in a map identified by
- * property_map
- * @param file XML file which defines HBase configuration properties.
- * @param property_map Property map representing HBase configuration as key
- * value pairs.
- * @throws Boost ptree exception if some parsing issue occurs.
- */
- bool LoadProperties(const std::string &file, ConfigMap &property_map);
-
- /**
- * @brief This method will create a map of the name and properties.
- * @param map Property map to hold configuration properties.
- * @param key value of name node.
- * @param value value of value node.
- * @param final_text value of final node true or false if present
- */
- bool UpdateMapWithValue(ConfigMap &map, const std::string &key, const std::string &value,
- boost::optional<std::string> final_text);
-};
-
-} /* namespace hbase */
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/hbase-configuration-test.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/hbase-configuration-test.cc b/hbase-native-client/core/hbase-configuration-test.cc
deleted file mode 100644
index 56b4463..0000000
--- a/hbase-native-client/core/hbase-configuration-test.cc
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <fstream>
-#include <iostream>
-
-#include <glog/logging.h>
-#include <gtest/gtest.h>
-#include <boost/filesystem.hpp>
-#include "core/configuration.h"
-#include "core/hbase-configuration-loader.h"
-
-using namespace hbase;
-using std::experimental::nullopt;
-
-const std::string kDefHBaseConfPath("./build/test-data/hbase-configuration-test/conf/");
-const std::string kHBaseConfPath("./build/test-data/hbase-configuration-test/custom-conf/");
-
-const std::string kHBaseDefaultXml("hbase-default.xml");
-const std::string kHBaseSiteXml("hbase-site.xml");
-
-const std::string kHBaseDefaultXmlData(
- "<?xml version=\"1.0\"?>\n<?xml-stylesheet type=\"text/xsl\" "
- "href=\"configuration.xsl\"?>\n<!--\n/**\n *\n * Licensed to the Apache "
- "Software Foundation (ASF) under one\n * or more contributor license "
- "agreements. See the NOTICE file\n * distributed with this work for "
- "additional information\n * regarding copyright ownership. The ASF "
- "licenses this file\n * to you under the Apache License, Version 2.0 "
- "(the\n * \"License\"); you may not use this file except in compliance\n * "
- "with the License. You may obtain a copy of the License at\n *\n * "
- "http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by "
- "applicable law or agreed to in writing, software\n * distributed under "
- "the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES "
- "OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License "
- "for the specific language governing permissions and\n * limitations under "
- "the License.\n "
- "*/\n-->\n<configuration>\n\n<property>\n<name>hbase.rootdir</"
- "name>\n<value>/root/hbase-docker/apps/hbase/data</value>\n<final>true</"
- "final>\n</"
- "property>\n\n<property>\n<name>hbase.zookeeper.property.datadir</"
- "name>\n<value>This value will be "
- "overwritten</value>\n<final>false</final>\n</"
- "property>\n\n<property>\n<name>default-prop</name>\n<value>default-value</"
- "value>\n</property>\n\n</configuration>");
-const std::string kHBaseSiteXmlData(
- "<?xml version=\"1.0\"?>\n<?xml-stylesheet type=\"text/xsl\" "
- "href=\"configuration.xsl\"?>\n<!--\n/**\n *\n * Licensed to the Apache "
- "Software Foundation (ASF) under one\n * or more contributor license "
- "agreements. See the NOTICE file\n * distributed with this work for "
- "additional information\n * regarding copyright ownership. The ASF "
- "licenses this file\n * to you under the Apache License, Version 2.0 "
- "(the\n * \"License\"); you may not use this file except in compliance\n * "
- "with the License. You may obtain a copy of the License at\n *\n * "
- "http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by "
- "applicable law or agreed to in writing, software\n * distributed under "
- "the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES "
- "OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License "
- "for the specific language governing permissions and\n * limitations under "
- "the License.\n "
- "*/\n-->\n<configuration>\n\n<property>\n<name>hbase.rootdir</"
- "name>\n<value>This value will not be be "
- "overwritten</value>\n</"
- "property>\n\n<property>\n<name>hbase.zookeeper.property.datadir</"
- "name>\n<value>/root/hbase-docker/zookeeper</value>\n</"
- "property>\n\n<property>\n<name>hbase-client.user.name</"
- "name>\n<value>${user.name}</value>\n</"
- "property>\n\n<property>\n<name>hbase-client.user.dir</"
- "name>\n<value>${user.dir}</value>\n</"
- "property>\n\n<property>\n<name>hbase-client.user.home</"
- "name>\n<value>${user.home}</value>\n</"
- "property>\n\n<property>\n<name>selfRef</name>\n<value>${selfRef}</"
- "value>\n</property>\n\n<property>\n<name>foo.substs</"
- "name>\n<value>${bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar},${"
- "bar},${bar},</value>\n</"
- "property>\n\n<property>\n<name>foo.substs.exception</"
- "name>\n<value>${bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar},${"
- "bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar},${bar}"
- ",${bar},${bar}</value>\n</property>\n\n<property>\n<name>bar</"
- "name>\n<value>bar-value</value>\n</"
- "property>\n\n<property>\n<name>custom-prop</name>\n<value>custom-value</"
- "value>\n</property>\n\n<property>\n<name>int</name>\n<value>16000</"
- "value>\n</property>\n\n<property>\n<name>int.largevalue</"
- "name>\n<value>2147483646</value>\n</"
- "property>\n\n<property>\n<name>int.exception</name>\n<value>2147483648</"
- "value>\n</property>\n\n<property>\n<name>long</name>\n<value>2147483850</"
- "value>\n</property>\n\n<property>\n<name>long.largevalue</"
- "name>\n<value>9223372036854775807</value>\n</"
- "property>\n\n<property>\n<name>long.exception</"
- "name>\n<value>9223372036854775810</value>\n</"
- "property>\n\n<property>\n<name>double</name>\n<value>17.9769e+100</"
- "value>\n</property>\n\n<property>\n<name>double.largevalue</"
- "name>\n<value>170.769e+200</value>\n</"
- "property>\n\n<property>\n<name>double.exception</"
- "name>\n<value>1.79769e+310</value>\n</"
- "property>\n\n<property>\n<name>bool.true</name>\n<value>true</value>\n</"
- "property>\n\n<property>\n<name>bool.false</name>\n<value>false</value>\n</"
- "property>\n\n<property>\n<name>bool.exception</name>\n<value>unknown "
- "bool</value>\n</property>\n\n</configuration>");
-
-void WriteDataToFile(const std::string &file, const std::string &xml_data) {
- std::ofstream hbase_conf;
- hbase_conf.open(file.c_str());
- hbase_conf << xml_data;
- hbase_conf.close();
-}
-
-void CreateHBaseConf(const std::string &dir, const std::string &file, const std::string xml_data) {
- // Directory will be created if not present
- if (!boost::filesystem::exists(dir)) {
- boost::filesystem::create_directories(dir);
- }
- // Remove temp file always
- boost::filesystem::remove((dir + file).c_str());
- WriteDataToFile((dir + file), xml_data);
-}
-
-void CreateHBaseConfWithEnv() {
- CreateHBaseConf(kDefHBaseConfPath, kHBaseDefaultXml, kHBaseDefaultXmlData);
- CreateHBaseConf(kDefHBaseConfPath, kHBaseSiteXml, kHBaseSiteXmlData);
- setenv("HBASE_CONF", kDefHBaseConfPath.c_str(), 1);
-}
-
-/*
- * Config will be loaded from $HBASE_CONF. We set it @ kDefHBaseConfPath
- * Config values will be loaded from hbase-default.xml and hbase-site.xml
- * present in the above path.
- */
-TEST(Configuration, LoadConfFromDefaultLocation) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConf(kDefHBaseConfPath, kHBaseDefaultXml, kHBaseDefaultXmlData);
- CreateHBaseConf(kDefHBaseConfPath, kHBaseSiteXml, kHBaseSiteXmlData);
- setenv("HBASE_CONF", kDefHBaseConfPath.c_str(), 0);
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("custom-prop", "Set this value").c_str(), "custom-value");
- EXPECT_STREQ((*conf).Get("default-prop", "Set this value").c_str(), "default-value");
-}
-
-/*
- * Config will be loaded from hbase-site.xml defined at
- * kHBaseConfPath
- */
-TEST(Configuration, LoadConfFromCustomLocation) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConf(kHBaseConfPath, kHBaseSiteXml, kHBaseSiteXmlData);
-
- HBaseConfigurationLoader loader;
- std::vector<std::string> resources{kHBaseSiteXml};
- hbase::optional<Configuration> conf = loader.LoadResources(kHBaseConfPath, resources);
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value");
- EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value");
-}
-
-/*
- * Config will be loaded from hbase-defualt.xml and hbase-site.xml @
- * kDefHBaseConfPath and kHBaseConfPath respectively.
- */
-TEST(Configuration, LoadConfFromMultipleLocatons) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConf(kDefHBaseConfPath, kHBaseDefaultXml, kHBaseDefaultXmlData);
- CreateHBaseConf(kDefHBaseConfPath, kHBaseSiteXml, kHBaseSiteXmlData);
- CreateHBaseConf(kHBaseConfPath, kHBaseDefaultXml, kHBaseDefaultXmlData);
- CreateHBaseConf(kHBaseConfPath, kHBaseSiteXml, kHBaseSiteXmlData);
-
- HBaseConfigurationLoader loader;
- std::string conf_paths = kDefHBaseConfPath + ":" + kHBaseConfPath;
- std::vector<std::string> resources{kHBaseDefaultXml, kHBaseSiteXml};
- hbase::optional<Configuration> conf = loader.LoadResources(conf_paths, resources);
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("default-prop", "From hbase-default.xml").c_str(), "default-value");
- EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value");
- EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value");
-}
-
-/*
- * Config will be loaded from hbase-defualt.xml and hbase-site.xml @
- * $HBASE_CONF.
- * We set HBASE_CONF to kDefHBaseConfPath
- * Below tests load the conf files in the same way unless specified.
- */
-TEST(Configuration, DefaultValues) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("default-prop", "Set this value.").c_str(), "default-value");
- EXPECT_STREQ((*conf).Get("custom-prop", "Set this value.").c_str(), "custom-value");
-}
-
-TEST(Configuration, FinalValues) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("hbase.rootdir", "").c_str(), "/root/hbase-docker/apps/hbase/data");
- EXPECT_STREQ((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(),
- "/root/hbase-docker/zookeeper");
- EXPECT_STRNE((*conf).Get("hbase.rootdir", "").c_str(), "This value will not be be overwritten");
- EXPECT_STRNE((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(),
- "This value will be overwritten");
-}
-
-/*
- * Config will be loaded from HBASE_CONF which we set in
- * CreateHBaseConfWithEnv().
- * Config values will be loaded from hbase-default.xml and hbase-site.xml in the
- * above path.
- */
-TEST(Configuration, EnvVars) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("hbase-client.user.name", "").c_str(), "${user.name}");
- EXPECT_STRNE((*conf).Get("hbase-client.user.name", "root").c_str(), "test-user");
-}
-
-TEST(Configuration, SelfRef) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("selfRef", "${selfRef}").c_str(), "${selfRef}");
-}
-
-TEST(Configuration, VarExpansion) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("foo.substs", "foo-value").c_str(),
- "bar-value,bar-value,bar-value,bar-value,bar-value,bar-value,"
- "bar-value,bar-value,bar-value,bar-value,");
- EXPECT_STRNE((*conf).Get("foo.substs", "foo-value").c_str(), "bar-value");
-}
-
-TEST(Configuration, VarExpansionException) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- ASSERT_THROW((*conf).Get("foo.substs.exception", "foo-value").c_str(), std::runtime_error);
-}
-
-TEST(Configuration, GetInt) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_EQ(16000, (*conf).GetInt("int", 0));
- EXPECT_EQ(2147483646, (*conf).GetInt("int.largevalue", 0));
-}
-
-TEST(Configuration, GetLong) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_EQ(2147483850, (*conf).GetLong("long", 0));
- EXPECT_EQ(9223372036854775807, (*conf).GetLong("long.largevalue", 0));
-}
-
-TEST(Configuration, GetDouble) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_DOUBLE_EQ(17.9769e+100, (*conf).GetDouble("double", 0.0));
- EXPECT_DOUBLE_EQ(170.769e+200, (*conf).GetDouble("double.largevalue", 0.0));
-}
-
-TEST(Configuration, GetBool) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- EXPECT_EQ(true, (*conf).GetBool("bool.true", true));
- EXPECT_EQ(false, (*conf).GetBool("bool.false", false));
-}
-
-TEST(Configuration, GetIntException) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- ASSERT_THROW((*conf).GetInt("int.exception", 0), std::runtime_error);
-}
-
-TEST(Configuration, GetLongException) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- ASSERT_THROW((*conf).GetLong("long.exception", 0), std::runtime_error);
-}
-
-TEST(Configuration, GetDoubleException) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- ASSERT_THROW((*conf).GetDouble("double.exception", 0), std::runtime_error);
-}
-
-TEST(Configuration, GetBoolException) {
- // Remove already configured env if present.
- unsetenv("HBASE_CONF");
- CreateHBaseConfWithEnv();
-
- HBaseConfigurationLoader loader;
- hbase::optional<Configuration> conf = loader.LoadDefaultResources();
- ASSERT_TRUE(conf != nullopt) << "No configuration object present.";
- ASSERT_THROW((*conf).GetBool("bool.exception", false), std::runtime_error);
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/hbase-rpc-controller.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/hbase-rpc-controller.cc b/hbase-native-client/core/hbase-rpc-controller.cc
deleted file mode 100644
index bc53781..0000000
--- a/hbase-native-client/core/hbase-rpc-controller.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/hbase-rpc-controller.h"
-
-namespace hbase {} /* namespace hbase */
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/hbase-rpc-controller.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/hbase-rpc-controller.h b/hbase-native-client/core/hbase-rpc-controller.h
deleted file mode 100644
index 33f552b..0000000
--- a/hbase-native-client/core/hbase-rpc-controller.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#pragma once
-
-#include <folly/ExceptionWrapper.h>
-#include <google/protobuf/service.h>
-#include <chrono>
-#include <string>
-
-namespace hbase {
-
-class HBaseRpcController : public google::protobuf::RpcController {
- public:
- HBaseRpcController() {}
- virtual ~HBaseRpcController() = default;
-
- void set_call_timeout(const std::chrono::milliseconds& call_timeout) {
- // TODO:
- }
-
- void Reset() override {}
-
- bool Failed() const override { return false; }
-
- folly::exception_wrapper exception() { return exception_; }
-
- void set_exception(const folly::exception_wrapper& exception) { exception_ = exception; }
-
- std::string ErrorText() const override { return ""; }
-
- void StartCancel() override {}
-
- void SetFailed(const std::string& reason) override {}
-
- bool IsCanceled() const override { return false; }
-
- void NotifyOnCancel(google::protobuf::Closure* callback) override {}
-
- private:
- folly::exception_wrapper exception_;
-};
-
-} /* namespace hbase */
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/increment-test.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/increment-test.cc b/hbase-native-client/core/increment-test.cc
deleted file mode 100644
index aa9b864..0000000
--- a/hbase-native-client/core/increment-test.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <glog/logging.h>
-#include <gtest/gtest.h>
-
-#include "core/increment.h"
-#include "core/mutation.h"
-#include "core/put.h"
-#include "utils/time-util.h"
-
-using hbase::Increment;
-using hbase::Increment;
-using hbase::Cell;
-using hbase::CellType;
-using hbase::Mutation;
-using hbase::TimeUtil;
-
-const constexpr int64_t Mutation::kLatestTimestamp;
-
-TEST(Increment, Row) {
- Increment incr{"foo"};
- EXPECT_EQ("foo", incr.row());
-}
-
-TEST(Increment, Durability) {
- Increment incr{"row"};
- EXPECT_EQ(hbase::pb::MutationProto_Durability_USE_DEFAULT, incr.Durability());
-
- auto skipWal = hbase::pb::MutationProto_Durability_SKIP_WAL;
- incr.SetDurability(skipWal);
- EXPECT_EQ(skipWal, incr.Durability());
-}
-
-TEST(Increment, Timestamp) {
- Increment incr{"row"};
-
- // test default timestamp
- EXPECT_EQ(Mutation::kLatestTimestamp, incr.TimeStamp());
-
- // set custom timestamp
- auto ts = TimeUtil::ToMillis(TimeUtil::GetNowNanos());
- incr.SetTimeStamp(ts);
- EXPECT_EQ(ts, incr.TimeStamp());
-
- // Add a column with custom timestamp
- incr.AddColumn("f", "q", 5l);
- auto &cell = incr.FamilyMap().at("f")[0];
- EXPECT_EQ(ts, cell->Timestamp());
-}
-
-TEST(Increment, HasFamilies) {
- Increment incr{"row"};
-
- EXPECT_EQ(false, incr.HasFamilies());
-
- incr.AddColumn("f", "q", 5l);
- EXPECT_EQ(true, incr.HasFamilies());
-}
-
-TEST(Increment, Add) {
- CellType cell_type = CellType::PUT;
- std::string row = "row";
- std::string family = "family";
- std::string column = "column";
- std::string value = "value";
- int64_t timestamp = std::numeric_limits<int64_t>::max();
- auto cell = std::make_unique<Cell>(row, family, column, timestamp, value, cell_type);
-
- // add first cell
- Increment incr{"row"};
- incr.Add(std::move(cell));
- EXPECT_EQ(1, incr.FamilyMap().size());
- EXPECT_EQ(1, incr.FamilyMap().at(family).size());
-
- // add a non-matching row
- auto cell2 = std::make_unique<Cell>(row, family, column, timestamp, value, cell_type);
- Increment incr2{"foo"};
- ASSERT_THROW(incr2.Add(std::move(cell2)), std::runtime_error); // rows don't match
-
- // add a second cell with same family
- auto cell3 = std::make_unique<Cell>(row, family, "column-2", timestamp, value, cell_type);
- incr.Add(std::move(cell3));
- EXPECT_EQ(1, incr.FamilyMap().size());
- EXPECT_EQ(2, incr.FamilyMap().at(family).size());
-
- // add a cell to a different family
- auto cell4 = std::make_unique<Cell>(row, "family-2", "column-2", timestamp, value, cell_type);
- incr.Add(std::move(cell4));
- EXPECT_EQ(2, incr.FamilyMap().size());
- EXPECT_EQ(1, incr.FamilyMap().at("family-2").size());
-}
-
-TEST(Increment, AddColumn) {
- std::string row = "row";
- std::string family = "family";
- std::string column = "column";
- std::string value = "value";
-
- Increment incr{"row"};
- incr.AddColumn(family, column, 5l);
- EXPECT_EQ(1, incr.FamilyMap().size());
- EXPECT_EQ(1, incr.FamilyMap().at(family).size());
-
- // add a second cell with same family
- incr.AddColumn(family, "column-2", 6l);
- EXPECT_EQ(1, incr.FamilyMap().size());
- EXPECT_EQ(2, incr.FamilyMap().at(family).size());
-
- // add a cell to a different family
- incr.AddColumn("family-2", column, 7l);
- EXPECT_EQ(2, incr.FamilyMap().size());
- EXPECT_EQ(1, incr.FamilyMap().at("family-2").size());
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/increment.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/increment.cc b/hbase-native-client/core/increment.cc
deleted file mode 100644
index a21a764..0000000
--- a/hbase-native-client/core/increment.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/increment.h"
-#include <folly/Conv.h>
-#include <algorithm>
-#include <limits>
-#include <stdexcept>
-#include <utility>
-
-#include "utils/bytes-util.h"
-
-namespace hbase {
-
-/**
- * @brief Increment the column from the specific family with the specified qualifier
- * by the specified amount.
- * @param family family name
- * @param qualifier column qualifier
- * @param amount amount to increment by
- */
-Increment& Increment::AddColumn(const std::string& family, const std::string& qualifier,
- int64_t amount) {
- family_map_[family].push_back(std::move(std::make_unique<Cell>(
- row_, family, qualifier, timestamp_, BytesUtil::ToString(amount), hbase::CellType::PUT)));
- return *this;
-}
-Increment& Increment::Add(std::unique_ptr<Cell> cell) {
- if (cell->Row() != row_) {
- throw std::runtime_error("The row in " + cell->DebugString() +
- " doesn't match the original one " + row_);
- }
-
- family_map_[cell->Family()].push_back(std::move(cell));
- return *this;
-}
-
-} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/increment.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/increment.h b/hbase-native-client/core/increment.h
deleted file mode 100644
index 330f44a..0000000
--- a/hbase-native-client/core/increment.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#pragma once
-
-#include <cstdint>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-#include "core/cell.h"
-#include "core/mutation.h"
-
-namespace hbase {
-
-class Increment : public Mutation {
- public:
- /**
- * Constructors
- */
- explicit Increment(const std::string& row) : Mutation(row) {}
- Increment(const Increment& cincrement) : Mutation(cincrement) {}
- Increment& operator=(const Increment& cincrement) {
- Mutation::operator=(cincrement);
- return *this;
- }
-
- ~Increment() = default;
-
- /**
- * @brief Increment the column from the specific family with the specified qualifier
- * by the specified amount.
- * @param family family name
- * @param qualifier column qualifier
- * @param amount amount to increment by
- */
- Increment& AddColumn(const std::string& family, const std::string& qualifier, int64_t amount);
- Increment& Add(std::unique_ptr<Cell> cell);
-};
-
-} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/keyvalue-codec.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/keyvalue-codec.cc b/hbase-native-client/core/keyvalue-codec.cc
deleted file mode 100644
index 1b526b9..0000000
--- a/hbase-native-client/core/keyvalue-codec.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "core/keyvalue-codec.h"
-
-#include <string>
-
-namespace hbase {
-
-KeyValueCodec::KVDecoder::KVDecoder(std::unique_ptr<folly::IOBuf> cell_block, uint32_t offset,
- uint32_t length)
- : cell_block_(std::move(cell_block)), offset_(offset), length_(length) {}
-
-KeyValueCodec::KVDecoder::~KVDecoder() {}
-
-std::shared_ptr<Cell> KeyValueCodec::KVDecoder::Decode(folly::io::Cursor &cursor) {
- uint32_t key_length = cursor.readBE<uint32_t>();
- uint32_t value_length = cursor.readBE<uint32_t>();
- uint16_t row_length = cursor.readBE<uint16_t>();
- std::string row = cursor.readFixedString(row_length);
- uint8_t column_family_length = cursor.readBE<uint8_t>();
- std::string column_family = cursor.readFixedString(column_family_length);
- int qualifier_length =
- key_length - (row_length + column_family_length + kHBaseSizeOfKeyInfrastructure_);
- std::string column_qualifier = cursor.readFixedString(qualifier_length);
- uint64_t timestamp = cursor.readBE<uint64_t>();
- uint8_t key_type = cursor.readBE<uint8_t>();
- std::string value = cursor.readFixedString(value_length);
-
- return std::make_shared<Cell>(row, column_family, column_qualifier, timestamp, value,
- static_cast<hbase::CellType>(key_type));
-}
-
-bool KeyValueCodec::KVDecoder::Advance() {
- if (end_of_cell_block_) {
- return false;
- }
-
- if (cur_pos_ == length_) {
- end_of_cell_block_ = true;
- return false;
- }
-
- folly::io::Cursor cursor(cell_block_.get());
- cursor.skip(offset_ + cur_pos_);
- uint32_t current_cell_size = cursor.readBE<uint32_t>();
- current_cell_ = Decode(cursor);
- cur_pos_ += kHBaseSizeOfInt_ + current_cell_size;
- return true;
-}
-
-uint32_t KeyValueCodec::KVDecoder::CellBlockLength() const { return length_; }
-} /* namespace hbase */
http://git-wip-us.apache.org/repos/asf/hbase/blob/128fc306/hbase-native-client/core/keyvalue-codec.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/core/keyvalue-codec.h b/hbase-native-client/core/keyvalue-codec.h
deleted file mode 100644
index fd58346..0000000
--- a/hbase-native-client/core/keyvalue-codec.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#pragma once
-
-#include <folly/io/Cursor.h>
-#include <folly/io/IOBuf.h>
-#include <memory>
-
-#include "core/cell.h"
-#include "serde/codec.h"
-
-namespace hbase {
-
-/**
- * @brief Class for parsing sequence of Cells based on org.apache.hadoop.hbase.KeyValueCodec.java
- *
- * KeyValueCodec implements CellScanner interface. Sequence of cells are obtained from cell_block.
- * We have CreateEncoder and CreateDecoder public methods which will return Encoder/Decoder
- * instances which will be used to obtain individual cells in cell_block.
- * Usage:-
- * 1) Cell Decoding:-
- * unique_ptr<CellScanner> cell_scanner = KeyValueCodec::CreateDecoder(cell_block, cb_start_offset,
- * cb_length);
- * while (cell_scanner->Advance()) {
- * auto current_cell = cell_scanner->Current
- * }
- */
-class KeyValueCodec : public Codec {
- public:
- /**
- * Constructor
- */
- KeyValueCodec() {}
-
- std::unique_ptr<Codec::Encoder> CreateEncoder() override { return std::make_unique<KVEncoder>(); }
- std::unique_ptr<Codec::Decoder> CreateDecoder(std::unique_ptr<folly::IOBuf> cell_block,
- uint32_t offset, uint32_t length) override {
- return std::make_unique<KVDecoder>(std::move(cell_block), offset, length);
- }
-
- /** @brief returns the java class name corresponding to this Codec implementation */
- virtual const char* java_class_name() const override { return kJavaClassName; }
-
- static constexpr const char* kJavaClassName = "org.apache.hadoop.hbase.codec.KeyValueCodec";
-
- private:
- class KVEncoder : public Codec::Encoder {
- public:
- KVEncoder() {}
-
- void Write(const Cell& cell) {
- // TODO: Encode Cells using KeyValueCodec wire format
- }
-
- void Flush() {}
- };
-
- class KVDecoder : public Codec::Decoder {
- public:
- KVDecoder(std::unique_ptr<folly::IOBuf> cell_block, uint32_t cell_block_start_offset,
- uint32_t cell_block_length);
- ~KVDecoder();
-
- /**
- * @brief Overridden from CellScanner. This method parses cell_block and stores the current in
- * current_cell_. Current cell can be obtained using cell_scanner.Current();
- */
- bool Advance();
-
- /**
- * @brief returns the current cell
- */
- const std::shared_ptr<Cell> Current() const { return current_cell_; }
-
- /**
- * @brief returns the total length of cell_meta_block
- */
- uint32_t CellBlockLength() const;
-
- private:
- std::shared_ptr<Cell> Decode(folly::io::Cursor& cursor);
-
- /**
- * Size of boolean in bytes
- */
- const int kHBaseSizeOfBoolean_ = sizeof(uint8_t) / sizeof(uint8_t);
-
- /**
- * Size of byte in bytes
- */
- const uint8_t kHBaseSizeOfByte_ = kHBaseSizeOfBoolean_;
-
- /**
- * Size of int in bytes
- */
- const uint32_t kHBaseSizeOfInt_ = sizeof(uint32_t) / kHBaseSizeOfByte_;
-
- /**
- * Size of long in bytes
- */
- const uint64_t kHBaseSizeOfLong_ = sizeof(uint64_t) / kHBaseSizeOfByte_;
-
- /**
- * Size of Short in bytes
- */
- const uint16_t kHBaseSizeOfShort_ = sizeof(uint16_t) / kHBaseSizeOfByte_;
-
- const uint32_t kHBaseSizeOfKeyLength_ = kHBaseSizeOfInt_;
- const uint32_t kHBaseSizeOfValueLength_ = kHBaseSizeOfInt_;
- const uint16_t kHBaseSizeOfRowLength_ = kHBaseSizeOfShort_;
- const uint8_t kHBaseSizeOfFamilyLength_ = kHBaseSizeOfByte_;
- const uint64_t kHBaseSizeOfTimestamp_ = kHBaseSizeOfLong_;
- const uint8_t kHBaseSizeOfKeyType_ = kHBaseSizeOfByte_;
- const uint32_t kHBaseSizeOfTimestampAndKey_ = kHBaseSizeOfTimestamp_ + kHBaseSizeOfKeyType_;
- const uint32_t kHBaseSizeOfKeyInfrastructure_ =
- kHBaseSizeOfRowLength_ + kHBaseSizeOfFamilyLength_ + kHBaseSizeOfTimestampAndKey_;
- const uint32_t kHBaseSizeOfKeyValueInfrastructure_ =
- kHBaseSizeOfKeyLength_ + kHBaseSizeOfValueLength_;
-
- std::unique_ptr<folly::IOBuf> cell_block_ = nullptr;
- uint32_t offset_ = 0;
- uint32_t length_ = 0;
- uint32_t cur_pos_ = 0;
- bool end_of_cell_block_ = false;
-
- std::shared_ptr<Cell> current_cell_ = nullptr;
- };
-};
-
-} /* namespace hbase */