From d5fc35021aa747278c5f070731d9224fcebd67b8 Mon Sep 17 00:00:00 2001 From: Sudeep Sunthankar Date: Tue, 28 Jun 2016 19:25:16 +1000 Subject: [PATCH] Added CELL_TYPE enum instead of using PB header. --- hbase-native-client/core/cell.cc | 27 +++++++++++ hbase-native-client/core/cell.h | 48 ++++++++++++++++++++ hbase-native-client/core/cell_impl.cc | 85 +++++++++++++++++++++++++++++++++++ hbase-native-client/core/cell_impl.h | 51 +++++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 hbase-native-client/core/cell.cc create mode 100644 hbase-native-client/core/cell.h create mode 100644 hbase-native-client/core/cell_impl.cc create mode 100644 hbase-native-client/core/cell_impl.h diff --git a/hbase-native-client/core/cell.cc b/hbase-native-client/core/cell.cc new file mode 100644 index 0000000..2efad55 --- /dev/null +++ b/hbase-native-client/core/cell.cc @@ -0,0 +1,27 @@ +/* + * 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 "cell.h" + +namespace hbase { + +Cell::~Cell() { +} + +} /* namespace hbase */ diff --git a/hbase-native-client/core/cell.h b/hbase-native-client/core/cell.h new file mode 100644 index 0000000..9f6d425 --- /dev/null +++ b/hbase-native-client/core/cell.h @@ -0,0 +1,48 @@ +/* + * 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 + +namespace hbase { + +enum CELL_TYPE { + MINIMUM = 0, + PUT = 4, + DELETE = 8, + DELETEFAMILYVERSION = 10, + DELETE_COLUMN = 12, + DELETE_FAMILY = 14, + MAXIMUM = 255 +}; + +class Cell { + public: + virtual ~Cell(); + virtual const std::string &Row() const = 0; + virtual const std::string &Family() const = 0; + virtual const std::string &Qualifier() const = 0; + virtual unsigned long Timestamp() const = 0; + virtual const std::string &Value() const = 0; + virtual CELL_TYPE Type() const = 0; + virtual long SequenceId() const = 0; +}; + +} /* namespace hbase */ diff --git a/hbase-native-client/core/cell_impl.cc b/hbase-native-client/core/cell_impl.cc new file mode 100644 index 0000000..0bbd89e --- /dev/null +++ b/hbase-native-client/core/cell_impl.cc @@ -0,0 +1,85 @@ +/* + * 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 "cell_impl.h" +#include + +namespace hbase { + +CellImpl::CellImpl(const std::string &row, const std::string &family, + const std::string &qualifier, const long ×tamp, + const std::string &value, const hbase::CELL_TYPE &cell_type) + : row_(row), + family_(family), + qualifier_(qualifier), + timestamp_(timestamp), + cell_type_(cell_type), + value_(value), + sequence_id_(0) { + + if (0 == row.size()) + throw std::runtime_error("Row size should be greater than 0"); + + if (0 == family.size()) + throw std::runtime_error("Column family should be greater than 0"); + + if (0 >= timestamp) + throw std::runtime_error("Timestamp should be greater than 0"); +} + +CellImpl::~CellImpl() { + +} + +const std::string &CellImpl::Row() const { + + return row_; +} + +const std::string &CellImpl::Family() const { + + return family_; +} + +const std::string &CellImpl::Qualifier() const { + + return qualifier_; +} + +unsigned long CellImpl::Timestamp() const { + + return timestamp_; +} + +const std::string &CellImpl::Value() const { + + return value_; +} + +hbase::CELL_TYPE CellImpl::Type() const { + + return cell_type_; +} + +long CellImpl::SequenceId() const { + + return sequence_id_; +} + +} /* namespace hbase */ diff --git a/hbase-native-client/core/cell_impl.h b/hbase-native-client/core/cell_impl.h new file mode 100644 index 0000000..6a2ea9e --- /dev/null +++ b/hbase-native-client/core/cell_impl.h @@ -0,0 +1,51 @@ +/* + * 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 "cell.h" + +namespace hbase { + +class CellImpl : public Cell { + public: + CellImpl(const std::string &row, const std::string &family, + const std::string &qualifier, const long ×tamp, + const std::string &value, const hbase::CELL_TYPE &cell_type); + virtual ~CellImpl(); + + const std::string &Row() const; + const std::string &Family() const; + const std::string &Qualifier() const; + unsigned long Timestamp() const; + const std::string &Value() const; + hbase::CELL_TYPE Type() const; + long SequenceId() const; + + private: + std::string row_; + std::string family_; + std::string qualifier_; + unsigned long timestamp_; + hbase::CELL_TYPE cell_type_; + std::string value_; + long sequence_id_; +}; + +} /* namespace hbase */ -- 1.8.3.1