You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2018/11/15 23:44:37 UTC
[accumulo] branch 1.9 updated: Format C++ code (manually)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch 1.9
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/1.9 by this push:
new ba572b4 Format C++ code (manually)
ba572b4 is described below
commit ba572b4f8cc58237ac41e87c82801ed43afdcfa0
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Nov 15 18:41:43 2018 -0500
Format C++ code (manually)
* Replace tabs with 2-space indents
* Remove trailing whitespace
* Remove a few excessive blank lines
* Apply indentation uniformly with vim '='
---
.../native/src/main/c++/nativeMap/BlockAllocator.h | 402 ++++++++++-----------
server/native/src/main/c++/nativeMap/Field.h | 215 ++++++-----
server/native/src/main/c++/nativeMap/Key.h | 208 +++++------
server/native/src/main/c++/nativeMap/NativeMap.h | 331 +++++++++--------
server/native/src/main/c++/nativeMap/SubKey.h | 229 ++++++------
.../org_apache_accumulo_tserver_NativeMap.cc | 102 +++---
6 files changed, 741 insertions(+), 746 deletions(-)
diff --git a/server/native/src/main/c++/nativeMap/BlockAllocator.h b/server/native/src/main/c++/nativeMap/BlockAllocator.h
index 81c14d8..b7eb60e 100644
--- a/server/native/src/main/c++/nativeMap/BlockAllocator.h
+++ b/server/native/src/main/c++/nativeMap/BlockAllocator.h
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
#ifndef _BLOCK_ALLOCATOR_H_
#define _BLOCK_ALLOCATOR_H_ 1
@@ -27,241 +25,241 @@
#include <stddef.h>
struct Block {
- unsigned char *data;
- unsigned char *currentPos;
- unsigned char *end;
- unsigned char *prevPos;
-
- Block(uint32_t size){
- data = new unsigned char[size];
- end = data + size;
- currentPos = data;
- prevPos = NULL;
- }
-
- ~Block(){
- }
-
- void *allocate(size_t amount){
- unsigned char *nextPos = currentPos + amount;
-
- if(nextPos > end){
- return NULL;
- }
-
- prevPos = currentPos;
- currentPos = nextPos;
- return prevPos;
- }
-
- size_t rollback(void *p){
- if(p == prevPos){
- size_t diff = currentPos - prevPos;
- currentPos = prevPos;
- return diff;
- }else{
- std::cerr << "Tried to delete something that was not previous allocation " << p << " " << prevPos << std::endl;
- exit(-1);
- }
-
- return 0;
- }
-
- size_t getMemoryFree() {
- return end - currentPos;
- }
+ unsigned char *data;
+ unsigned char *currentPos;
+ unsigned char *end;
+ unsigned char *prevPos;
+
+ Block(uint32_t size){
+ data = new unsigned char[size];
+ end = data + size;
+ currentPos = data;
+ prevPos = NULL;
+ }
+
+ ~Block(){
+ }
+
+ void *allocate(size_t amount){
+ unsigned char *nextPos = currentPos + amount;
+
+ if(nextPos > end){
+ return NULL;
+ }
+
+ prevPos = currentPos;
+ currentPos = nextPos;
+ return prevPos;
+ }
+
+ size_t rollback(void *p){
+ if(p == prevPos){
+ size_t diff = currentPos - prevPos;
+ currentPos = prevPos;
+ return diff;
+ }else{
+ std::cerr << "Tried to delete something that was not previous allocation " << p << " " << prevPos << std::endl;
+ exit(-1);
+ }
+
+ return 0;
+ }
+
+ size_t getMemoryFree() {
+ return end - currentPos;
+ }
};
struct BigBlock {
- unsigned char *ptr;
- size_t length;
+ unsigned char *ptr;
+ size_t length;
- BigBlock(unsigned char *p, size_t len):ptr(p),length(len){}
+ BigBlock(unsigned char *p, size_t len):ptr(p),length(len){}
};
struct LinkedBlockAllocator {
- std::vector<Block> blocks;
- std::vector<BigBlock> bigBlocks;
- int blockSize;
- int bigBlockSize;
- int64_t memused;
- void *lastAlloc;
-
- LinkedBlockAllocator(int blockSize, int bigBlockSize){
- this->blockSize = blockSize;
- this->bigBlockSize = bigBlockSize;
- lastAlloc = NULL;
- memused = 0;
- }
-
- void *allocate(size_t amount){
-
- if(amount > (size_t)bigBlockSize){
- unsigned char *p = new unsigned char[amount];
- bigBlocks.push_back(BigBlock(p, amount));
- memused += sizeof(BigBlock) + amount;
- return p;
- }else{
- if(blocks.size() == 0){
- //do lazy allocation of memory, do not allocate a block until it is used
- blocks.push_back(Block(blockSize));
- memused += sizeof(Block) + blockSize;
- }
-
- lastAlloc = blocks.back().allocate(amount);
- if(lastAlloc == NULL){
- blocks.push_back(Block(blockSize));
- lastAlloc = blocks.back().allocate(amount);
- memused += sizeof(Block) + blockSize;
- }
-
- return lastAlloc;
- }
- }
-
- void deleteLast(void *p){
- if(p != NULL){
- if(p == lastAlloc){
- blocks.back().rollback(p);
- lastAlloc = NULL;
- return;
- }else if(bigBlocks.back().ptr == p){
- memused -= (sizeof(BigBlock) + bigBlocks.back().length);
- bigBlocks.pop_back();
- delete((unsigned char *)p);
- return;
- }
- }
-
- std::cerr << "Tried to delete something that was not last allocation " << p << " " << lastAlloc << std::endl;
- exit(-1);
- }
-
- size_t getMemoryUsed(){
- if(blocks.size() == 0)
- return memused;
- else
- return memused - blocks.back().getMemoryFree();
- }
-
- ~LinkedBlockAllocator(){
- //std::cout << "Deleting " << blocks.size() << " blocks, memused : " << memused << std::endl;
- std::vector<Block>::iterator iter = blocks.begin();
- while(iter != blocks.end()){
- delete [] (iter->data);
- iter++;
- }
-
- std::vector<BigBlock>::iterator iter2 = bigBlocks.begin();
- while(iter2 != bigBlocks.end()){
- delete [] (iter2->ptr);
- iter2++;
- }
- }
-
-};
-
+ std::vector<Block> blocks;
+ std::vector<BigBlock> bigBlocks;
+ int blockSize;
+ int bigBlockSize;
+ int64_t memused;
+ void *lastAlloc;
+
+ LinkedBlockAllocator(int blockSize, int bigBlockSize){
+ this->blockSize = blockSize;
+ this->bigBlockSize = bigBlockSize;
+ lastAlloc = NULL;
+ memused = 0;
+ }
+
+ void *allocate(size_t amount){
+
+ if(amount > (size_t)bigBlockSize){
+ unsigned char *p = new unsigned char[amount];
+ bigBlocks.push_back(BigBlock(p, amount));
+ memused += sizeof(BigBlock) + amount;
+ return p;
+ }else{
+ if(blocks.size() == 0){
+ //do lazy allocation of memory, do not allocate a block until it is used
+ blocks.push_back(Block(blockSize));
+ memused += sizeof(Block) + blockSize;
+ }
- /**
- * @brief An allocator that uses global new, as per [20.4].
- *
- * This is precisely the allocator defined in the C++ Standard.
- * - all allocation calls operator new
- * - all deallocation calls operator delete
- */
- template<typename _Tp>
- class BlockAllocator
- {
- public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp* pointer;
- typedef const _Tp* const_pointer;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
- typedef _Tp value_type;
-
- LinkedBlockAllocator *lba;
-
- template<typename _Tp1>
- struct rebind
- { typedef BlockAllocator<_Tp1> other; };
-
- BlockAllocator() throw() {
- lba = NULL;
+ lastAlloc = blocks.back().allocate(amount);
+ if(lastAlloc == NULL){
+ blocks.push_back(Block(blockSize));
+ lastAlloc = blocks.back().allocate(amount);
+ memused += sizeof(Block) + blockSize;
}
- BlockAllocator(LinkedBlockAllocator *lba) throw() {
- this->lba = lba;
+ return lastAlloc;
+ }
+ }
+
+ void deleteLast(void *p){
+ if(p != NULL){
+ if(p == lastAlloc){
+ blocks.back().rollback(p);
+ lastAlloc = NULL;
+ return;
+ }else if(bigBlocks.back().ptr == p){
+ memused -= (sizeof(BigBlock) + bigBlocks.back().length);
+ bigBlocks.pop_back();
+ delete((unsigned char *)p);
+ return;
}
+ }
+
+ std::cerr << "Tried to delete something that was not last allocation " << p << " " << lastAlloc << std::endl;
+ exit(-1);
+ }
+
+ size_t getMemoryUsed(){
+ if(blocks.size() == 0)
+ return memused;
+ else
+ return memused - blocks.back().getMemoryFree();
+ }
+
+ ~LinkedBlockAllocator(){
+ //std::cout << "Deleting " << blocks.size() << " blocks, memused : " << memused << std::endl;
+ std::vector<Block>::iterator iter = blocks.begin();
+ while(iter != blocks.end()){
+ delete [] (iter->data);
+ iter++;
+ }
+
+ std::vector<BigBlock>::iterator iter2 = bigBlocks.begin();
+ while(iter2 != bigBlocks.end()){
+ delete [] (iter2->ptr);
+ iter2++;
+ }
+ }
+
+};
+
- BlockAllocator(const BlockAllocator& ba) throw() {
+/**
+ * @brief An allocator that uses global new, as per [20.4].
+ *
+ * This is precisely the allocator defined in the C++ Standard.
+ * - all allocation calls operator new
+ * - all deallocation calls operator delete
+ */
+template<typename _Tp>
+class BlockAllocator
+{
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp* pointer;
+ typedef const _Tp* const_pointer;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+ typedef _Tp value_type;
+
+ LinkedBlockAllocator *lba;
+
+ template<typename _Tp1>
+ struct rebind
+ { typedef BlockAllocator<_Tp1> other; };
+
+ BlockAllocator() throw() {
+ lba = NULL;
+ }
+
+ BlockAllocator(LinkedBlockAllocator *lba) throw() {
+ this->lba = lba;
+ }
+
+ BlockAllocator(const BlockAllocator& ba) throw() {
+ lba = ba.lba;
+ }
+
+ template<typename _Tp1>
+ BlockAllocator(const BlockAllocator<_Tp1>& ba) throw() {
lba = ba.lba;
}
- template<typename _Tp1>
- BlockAllocator(const BlockAllocator<_Tp1>& ba) throw() {
- lba = ba.lba;
- }
+ ~BlockAllocator() throw() { }
- ~BlockAllocator() throw() { }
-
- pointer
+ pointer
address(reference __x) const { return &__x; }
- const_pointer
+ const_pointer
address(const_reference __x) const { return &__x; }
- // NB: __n is permitted to be 0. The C++ standard says nothing
- // about what the return value is when __n == 0.
- pointer
+ // NB: __n is permitted to be 0. The C++ standard says nothing
+ // about what the return value is when __n == 0.
+ pointer
allocate(size_type __n, const void* = 0)
- {
- if (__builtin_expect(__n > this->max_size(), false))
- std::__throw_bad_alloc();
+ {
+ if (__builtin_expect(__n > this->max_size(), false))
+ std::__throw_bad_alloc();
- //void *p = ::operator new(__n * sizeof(_Tp));
- void *p = lba->allocate(__n * sizeof(_Tp));
+ //void *p = ::operator new(__n * sizeof(_Tp));
+ void *p = lba->allocate(__n * sizeof(_Tp));
- //std::cout << "Allocating "<< name <<" " << __n * sizeof(_Tp) << " " << ((unsigned long long)p) % 4 << " " << ((unsigned long long)p) % 8 << std::endl;
+ //std::cout << "Allocating "<< name <<" " << __n * sizeof(_Tp) << " " << ((unsigned long long)p) % 4 << " " << ((unsigned long long)p) % 8 << std::endl;
- return static_cast<_Tp*>(p);
+ return static_cast<_Tp*>(p);
}
- // __p is not permitted to be a null pointer.
- void
+ // __p is not permitted to be a null pointer.
+ void
deallocate(pointer __p, size_type)
- {
+ {
//::operator delete(__p);
- }
+ }
- size_type
- max_size() const throw()
+ size_type
+ max_size() const throw()
{ return size_t(-1) / sizeof(_Tp); }
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 402. wrong new expression in [some_] allocator::construct
- void
- construct(pointer __p, const _Tp& __val)
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 402. wrong new expression in [some_] allocator::construct
+ void
+ construct(pointer __p, const _Tp& __val)
{ ::new(__p) _Tp(__val); }
- void
+ void
destroy(pointer __p) { __p->~_Tp(); }
-
-
- };
-
-
- template<typename _Tp>
- inline bool
- operator==(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
- { return true; }
-
- template<typename _Tp>
- inline bool
- operator!=(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
- { return false; }
+
+
+};
+
+
+template<typename _Tp>
+ inline bool
+operator==(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
+{ return true; }
+
+template<typename _Tp>
+ inline bool
+operator!=(const BlockAllocator<_Tp>& ba1, const BlockAllocator<_Tp>& ba2)
+{ return false; }
#endif
diff --git a/server/native/src/main/c++/nativeMap/Field.h b/server/native/src/main/c++/nativeMap/Field.h
index 7c3884e..0dc6208 100644
--- a/server/native/src/main/c++/nativeMap/Field.h
+++ b/server/native/src/main/c++/nativeMap/Field.h
@@ -29,115 +29,114 @@ using namespace std;
#define __FIELD__
struct Field {
- uint8_t *field;
- int32_t len;
-
- int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
- int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
-
- if(result != 0)
- return result;
- if(len1 == len2)
- return 0;
- if(len1 < len2)
- return -1;
-
- return 1;
- }
-
- Field(){}
-
- Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f, int l){
- len = l;
- field=(uint8_t *)lba->allocate(len);
- env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
- }
-
- Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f){
- len = env->GetArrayLength(f);
- field=(uint8_t *)lba->allocate(len);
- env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
- }
-
- Field(uint8_t *f, int32_t l):field(f),len(l){
- }
-
- Field(const char *cstr){
- //constructor for testing C++
- len = strlen(cstr);
- field=new uint8_t[len];
- memcpy(field, cstr, len);
- }
-
- Field(LinkedBlockAllocator *lba, const char *cstr){
- //constructor for testing C++
- len = strlen(cstr);
- field=(uint8_t *)lba->allocate(len);
- memcpy(field, cstr, len);
- }
-
- void set(const char *d, int l){
- if(l < 0 || l > len){
- cerr << "Tried to set field with value that is too long " << l << " " << len << endl;
- }
- memcpy(field, d, l);
- len = l;
- }
-
- void set(JNIEnv *env, jbyteArray f, int l){
- if(l < 0 || l > len){
- cerr << "Tried to set field with value that is too long " << l << " " << len << endl;
- }
- len = l;
- env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
- }
-
- int compare(const Field &of) const{
- return compare(field, len, of.field, of.len);
- }
-
- bool operator<(const Field &of) const{
- return compare(of) < 0;
- }
-
- int32_t length() const {
- return len;
- }
-
- void fillIn(JNIEnv *env, jbyteArray d) const {
- //TODO ensure lengths match up
- env->SetByteArrayRegion(d, 0, len, (jbyte *)field);
- }
-
- jbyteArray createJByteArray(JNIEnv *env) const{
- jbyteArray valData = env->NewByteArray(len);
- env->SetByteArrayRegion(valData, 0, len, (jbyte *)field);
- return valData;
- }
-
- string toString() const{
- return string((char *)field, len);
- }
-
- void clear(){
- //delete(field);
- }
-
- void clear(LinkedBlockAllocator *lba){
- lba->deleteLast(field);
- }
-};
+ uint8_t *field;
+ int32_t len;
+
+ int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+ int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
+
+ if(result != 0)
+ return result;
+ if(len1 == len2)
+ return 0;
+ if(len1 < len2)
+ return -1;
+
+ return 1;
+ }
+
+ Field(){}
+
+ Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f, int l){
+ len = l;
+ field=(uint8_t *)lba->allocate(len);
+ env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+ }
+
+ Field(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray f){
+ len = env->GetArrayLength(f);
+ field=(uint8_t *)lba->allocate(len);
+ env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+ }
+
+ Field(uint8_t *f, int32_t l):field(f),len(l){
+ }
+
+ Field(const char *cstr){
+ //constructor for testing C++
+ len = strlen(cstr);
+ field=new uint8_t[len];
+ memcpy(field, cstr, len);
+ }
+
+ Field(LinkedBlockAllocator *lba, const char *cstr){
+ //constructor for testing C++
+ len = strlen(cstr);
+ field=(uint8_t *)lba->allocate(len);
+ memcpy(field, cstr, len);
+ }
+
+ void set(const char *d, int l){
+ if(l < 0 || l > len){
+ cerr << "Tried to set field with value that is too long " << l << " " << len << endl;
+ }
+ memcpy(field, d, l);
+ len = l;
+ }
+
+ void set(JNIEnv *env, jbyteArray f, int l){
+ if(l < 0 || l > len){
+ cerr << "Tried to set field with value that is too long " << l << " " << len << endl;
+ }
+ len = l;
+ env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+ }
+
+ int compare(const Field &of) const{
+ return compare(field, len, of.field, of.len);
+ }
+
+ bool operator<(const Field &of) const{
+ return compare(of) < 0;
+ }
+
+ int32_t length() const {
+ return len;
+ }
+
+ void fillIn(JNIEnv *env, jbyteArray d) const {
+ //TODO ensure lengths match up
+ env->SetByteArrayRegion(d, 0, len, (jbyte *)field);
+ }
+
+ jbyteArray createJByteArray(JNIEnv *env) const{
+ jbyteArray valData = env->NewByteArray(len);
+ env->SetByteArrayRegion(valData, 0, len, (jbyte *)field);
+ return valData;
+ }
+
+ string toString() const{
+ return string((char *)field, len);
+ }
+
+ void clear(){
+ //delete(field);
+ }
+
+ void clear(LinkedBlockAllocator *lba){
+ lba->deleteLast(field);
+ }
+};
struct LocalField : public Field {
- LocalField(JNIEnv *env, jbyteArray f){
- len = env->GetArrayLength(f);
- field= new uint8_t[len];
- env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
- }
-
- ~LocalField(){
- delete(field);
- }
+ LocalField(JNIEnv *env, jbyteArray f){
+ len = env->GetArrayLength(f);
+ field= new uint8_t[len];
+ env->GetByteArrayRegion(f, 0, len, (jbyte *)field);
+ }
+
+ ~LocalField(){
+ delete(field);
+ }
};
#endif
-
diff --git a/server/native/src/main/c++/nativeMap/Key.h b/server/native/src/main/c++/nativeMap/Key.h
index f902426..9d74ca6 100644
--- a/server/native/src/main/c++/nativeMap/Key.h
+++ b/server/native/src/main/c++/nativeMap/Key.h
@@ -24,120 +24,120 @@ using namespace std;
class Key {
-public:
- int32_t colFamilyOffset;
- int32_t colQualifierOffset;
- int32_t colVisibilityOffset;
- int32_t totalLen;
-
- uint8_t *keyData;
-
- int64_t timestamp;
- bool deleted;
-
- int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
- int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
-
- if(result != 0)
- return result;
- if(len1 == len2)
- return 0;
- if(len1 < len2)
- return -1;
-
- return 1;
- }
-
- /**
- * Constructor for testing purposes
- */
-
- Key(){}
-
- Key(const string &r, const string &cf, const string &cq, const string &cv, long ts, bool del){
-
- colFamilyOffset = r.length();
- colQualifierOffset = colFamilyOffset + cf.length();
- colVisibilityOffset = colQualifierOffset + cq.length();
- totalLen = colVisibilityOffset + cv.length();
-
- keyData = new uint8_t[totalLen];
-
- copy(r.begin(), r.end(), keyData);
- copy(cf.begin(), cf.end(), keyData+colFamilyOffset);
- copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
- copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
-
- timestamp = ts;
- deleted = del;
- }
-
- /**
- * Constructor used for taking data from Java Key
- */
-
- Key(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
-
- colFamilyOffset = cfo;
- colQualifierOffset = cqo;
- colVisibilityOffset = cvo;
- totalLen = tl;
- timestamp = ts;
- deleted = del == JNI_TRUE ? true : false;
-
- keyData = new uint8_t[totalLen];
- env->GetByteArrayRegion(kd, 0, totalLen, (jbyte *)keyData);
- }
-
- bool operator<(const Key &key) const{
- int result = compare(keyData, colFamilyOffset, key.keyData, key.colFamilyOffset);
- if(result != 0) return result < 0;
-
- result = compare(keyData + colFamilyOffset, colQualifierOffset - colFamilyOffset, key.keyData + key.colFamilyOffset, key.colQualifierOffset - key.colFamilyOffset);
- if(result != 0) return result < 0;
-
- result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
- if(result != 0) return result < 0;
-
- result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
- if(result != 0) return result < 0;
-
- if(timestamp < key.timestamp){
- return false;
- }else if(timestamp > key.timestamp){
- return true;
- }
-
- return deleted && !key.deleted;
- }
+ public:
+ int32_t colFamilyOffset;
+ int32_t colQualifierOffset;
+ int32_t colVisibilityOffset;
+ int32_t totalLen;
+
+ uint8_t *keyData;
+
+ int64_t timestamp;
+ bool deleted;
+
+ int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+ int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
+
+ if(result != 0)
+ return result;
+ if(len1 == len2)
+ return 0;
+ if(len1 < len2)
+ return -1;
+
+ return 1;
+ }
+
+ /**
+ * Constructor for testing purposes
+ */
+
+ Key(){}
+
+ Key(const string &r, const string &cf, const string &cq, const string &cv, long ts, bool del){
+
+ colFamilyOffset = r.length();
+ colQualifierOffset = colFamilyOffset + cf.length();
+ colVisibilityOffset = colQualifierOffset + cq.length();
+ totalLen = colVisibilityOffset + cv.length();
+
+ keyData = new uint8_t[totalLen];
+
+ copy(r.begin(), r.end(), keyData);
+ copy(cf.begin(), cf.end(), keyData+colFamilyOffset);
+ copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
+ copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
+
+ timestamp = ts;
+ deleted = del;
+ }
+
+ /**
+ * Constructor used for taking data from Java Key
+ */
+
+ Key(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
+
+ colFamilyOffset = cfo;
+ colQualifierOffset = cqo;
+ colVisibilityOffset = cvo;
+ totalLen = tl;
+ timestamp = ts;
+ deleted = del == JNI_TRUE ? true : false;
+
+ keyData = new uint8_t[totalLen];
+ env->GetByteArrayRegion(kd, 0, totalLen, (jbyte *)keyData);
+ }
+
+ bool operator<(const Key &key) const{
+ int result = compare(keyData, colFamilyOffset, key.keyData, key.colFamilyOffset);
+ if(result != 0) return result < 0;
+
+ result = compare(keyData + colFamilyOffset, colQualifierOffset - colFamilyOffset, key.keyData + key.colFamilyOffset, key.colQualifierOffset - key.colFamilyOffset);
+ if(result != 0) return result < 0;
+
+ result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
+ if(result != 0) return result < 0;
+
+ result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
+ if(result != 0) return result < 0;
+
+ if(timestamp < key.timestamp){
+ return false;
+ }else if(timestamp > key.timestamp){
+ return true;
+ }
+
+ return deleted && !key.deleted;
+ }
};
class LocalKey : public Key {
-public:
+ public:
+
+ JNIEnv *envPtr;
+ jbyteArray kd;
- JNIEnv *envPtr;
- jbyteArray kd;
-
- LocalKey(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
- envPtr = env;
+ LocalKey(JNIEnv *env, jbyteArray kd, jint cfo, jint cqo, jint cvo, jint tl, jlong ts, jboolean del){
+ envPtr = env;
- colFamilyOffset = cfo;
- colQualifierOffset = cqo;
- colVisibilityOffset = cvo;
- totalLen = tl;
- timestamp = ts;
- deleted = del == JNI_TRUE ? true : false;
+ colFamilyOffset = cfo;
+ colQualifierOffset = cqo;
+ colVisibilityOffset = cvo;
+ totalLen = tl;
+ timestamp = ts;
+ deleted = del == JNI_TRUE ? true : false;
- this->kd = kd;
- keyData = (uint8_t *)env->GetByteArrayElements((jbyteArray)kd, NULL);
- }
+ this->kd = kd;
+ keyData = (uint8_t *)env->GetByteArrayElements((jbyteArray)kd, NULL);
+ }
- ~LocalKey(){
- envPtr->ReleaseByteArrayElements(kd, (jbyte *)keyData, JNI_ABORT);
- }
+ ~LocalKey(){
+ envPtr->ReleaseByteArrayElements(kd, (jbyte *)keyData, JNI_ABORT);
+ }
};
diff --git a/server/native/src/main/c++/nativeMap/NativeMap.h b/server/native/src/main/c++/nativeMap/NativeMap.h
index 5934e2e..10133db 100644
--- a/server/native/src/main/c++/nativeMap/NativeMap.h
+++ b/server/native/src/main/c++/nativeMap/NativeMap.h
@@ -31,180 +31,179 @@ typedef map<Field, ColumnMap, std::less<Field>, BlockAllocator<std::pair<const
struct NativeMapData {
- LinkedBlockAllocator *lba;
- RowMap rowmap;
- int count;
-
- NativeMapData(int blockSize, int bigBlockSize):lba(new LinkedBlockAllocator(blockSize, bigBlockSize)),
- rowmap(RowMap(std::less<Field>(), BlockAllocator<std::pair<Field, ColumnMap> >(lba))){
- }
-
- ~NativeMapData(){
- rowmap.clear(); //if row map is not cleared here, it will be deconstructed after lba is deleted
- delete(lba);
- }
+ LinkedBlockAllocator *lba;
+ RowMap rowmap;
+ int count;
+
+ NativeMapData(int blockSize, int bigBlockSize):lba(new LinkedBlockAllocator(blockSize, bigBlockSize)),
+ rowmap(RowMap(std::less<Field>(), BlockAllocator<std::pair<Field, ColumnMap> >(lba))){
+ }
+
+ ~NativeMapData(){
+ rowmap.clear(); //if row map is not cleared here, it will be deconstructed after lba is deleted
+ delete(lba);
+ }
};
struct Iterator {
- NativeMapData &nativeMap;
- RowMap::iterator rowIter;
- ColumnMap::iterator colIter;
-
- Iterator(NativeMapData &nm, int32_t *ia):nativeMap(nm){
- rowIter = nativeMap.rowmap.begin();
- if(rowIter == nativeMap.rowmap.end()){
- return;
- }
-
- colIter = rowIter->second.begin();
-
- skipAndFillIn(ia, true);
- }
-
-
- Iterator(NativeMapData &nm, Field &row, SubKey &sk, int32_t *ia):nativeMap(nm){
- rowIter = nativeMap.rowmap.lower_bound(row);
- if(rowIter == nativeMap.rowmap.end()){
- return;
- }
-
- //TODO use equals instead of compare
- if(rowIter->first.compare(row) == 0){
- colIter = rowIter->second.lower_bound(sk);
- }else{
- colIter = rowIter->second.begin();
- }
-
- skipAndFillIn(ia, true);
- }
-
- bool skipAndFillIn(int32_t *ia, bool firstCall)
- {
- bool rowChanged = false;
-
- while(colIter == rowIter->second.end()){
- rowIter++;
- rowChanged = true;
- if(rowIter == nativeMap.rowmap.end()){
- return false;
- }
- colIter = rowIter->second.begin();
- }
-
- ia[0] = (firstCall || rowChanged) ? rowIter->first.length() : -1;
- ia[1] = colIter->first.getCFLen();
- ia[2] = colIter->first.getCQLen();
- ia[3] = colIter->first.getCVLen();
- ia[4] = colIter->first.isDeleted() ? 1 : 0;
- ia[5] = colIter->second.length();
- ia[6] = colIter->first.getMC();
-
- return true;
- }
-
- bool atEnd(){
- return rowIter == nativeMap.rowmap.end();
- }
-
- void advance(int32_t *ia){
- colIter++;
- skipAndFillIn(ia, false);
- }
+ NativeMapData &nativeMap;
+ RowMap::iterator rowIter;
+ ColumnMap::iterator colIter;
+
+ Iterator(NativeMapData &nm, int32_t *ia):nativeMap(nm){
+ rowIter = nativeMap.rowmap.begin();
+ if(rowIter == nativeMap.rowmap.end()){
+ return;
+ }
+
+ colIter = rowIter->second.begin();
+
+ skipAndFillIn(ia, true);
+ }
+
+
+ Iterator(NativeMapData &nm, Field &row, SubKey &sk, int32_t *ia):nativeMap(nm){
+ rowIter = nativeMap.rowmap.lower_bound(row);
+ if(rowIter == nativeMap.rowmap.end()){
+ return;
+ }
+
+ //TODO use equals instead of compare
+ if(rowIter->first.compare(row) == 0){
+ colIter = rowIter->second.lower_bound(sk);
+ }else{
+ colIter = rowIter->second.begin();
+ }
+
+ skipAndFillIn(ia, true);
+ }
+
+ bool skipAndFillIn(int32_t *ia, bool firstCall)
+ {
+ bool rowChanged = false;
+
+ while(colIter == rowIter->second.end()){
+ rowIter++;
+ rowChanged = true;
+ if(rowIter == nativeMap.rowmap.end()){
+ return false;
+ }
+ colIter = rowIter->second.begin();
+ }
+
+ ia[0] = (firstCall || rowChanged) ? rowIter->first.length() : -1;
+ ia[1] = colIter->first.getCFLen();
+ ia[2] = colIter->first.getCQLen();
+ ia[3] = colIter->first.getCVLen();
+ ia[4] = colIter->first.isDeleted() ? 1 : 0;
+ ia[5] = colIter->second.length();
+ ia[6] = colIter->first.getMC();
+
+ return true;
+ }
+
+ bool atEnd(){
+ return rowIter == nativeMap.rowmap.end();
+ }
+
+ void advance(int32_t *ia){
+ colIter++;
+ skipAndFillIn(ia, false);
+ }
};
struct NativeMap : public NativeMapData {
- NativeMap(int blockSize, int bigBlockSize):NativeMapData(blockSize, bigBlockSize){
- count = 0;
- }
-
- ~NativeMap(){
-
- }
-
-
- ColumnMap *startUpdate(JNIEnv * env, jbyteArray r){
- Field row(lba, env, r);
- return startUpdate(row);
- }
-
- ColumnMap *startUpdate(const char *r){
- Field row(lba, r);
- return startUpdate(row);
- }
-
- ColumnMap *startUpdate(Field &row){
- // This method is structured to avoid allocating the column map in the case
- // where it already exists in the map. This is done so the row key memory can
- // be easily deallocated.
- RowMap::iterator lbi = rowmap.lower_bound(row);
- if(lbi == rowmap.end() || row < lbi->first) {
- RowMap::iterator iter = rowmap.insert(lbi, pair<Field, ColumnMap>(row, ColumnMap(std::less<SubKey>(), BlockAllocator<std::pair<SubKey, Field> >(lba))));
- return &(iter->second);
- } else {
- // Return row memory because an insert was not done.
- row.clear(lba);
- return &(lbi->second);
- }
- }
-
- void update(ColumnMap *cm, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount){
-
- SubKey sk(lba, env, cf, cq, cv, ts, del, mutationCount);
- //cout << "Updating " << sk.toString() << " " << sk.getTimestamp() << " " << sk.isDeleted() << endl;
- //do not bother allocating value if not needed
- Field value(NULL, 0);
-
- pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
- if(insertResult.second){
- insertResult.first->second = Field(lba, env, val);
- count++;
- }else{
- sk.clear(lba);
- int valLen = env->GetArrayLength(val);
- if(valLen <= insertResult.first->second.length()){
- insertResult.first->second.set(env, val, valLen);
- }else{
- insertResult.first->second.clear();
- insertResult.first->second = Field(lba, env, val, valLen);
- }
- }
- }
-
- void update(ColumnMap *cm, const char *cf, const char *cq, const char *cv, long ts, bool del, const char *val, int valLen, int mutationCount){
-
- SubKey sk(lba, cf, cq, cv, ts, del, mutationCount);
- //do not bother allocating value if not needed
- Field value(NULL, 0);
-
- pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
- if(insertResult.second){
- insertResult.first->second = Field(lba, val);
- count++;
- }else{
- sk.clear(lba);
- if(insertResult.first->second.length() <= valLen){
- insertResult.first->second.set(val, valLen);
- }else{
- insertResult.first->second.clear();
- insertResult.first->second = Field(lba, val);
- }
- }
- }
-
- Iterator *iterator(int32_t *ia){
- return new Iterator(*this, ia);
- }
-
- Iterator *iterator(Field &row, SubKey &sk, int32_t *ia){
- return new Iterator(*this, row, sk, ia);
- }
-
- int64_t getMemoryUsed(){
- return lba->getMemoryUsed();
- }
+ NativeMap(int blockSize, int bigBlockSize):NativeMapData(blockSize, bigBlockSize){
+ count = 0;
+ }
+
+ ~NativeMap(){
+
+ }
+
+
+ ColumnMap *startUpdate(JNIEnv * env, jbyteArray r){
+ Field row(lba, env, r);
+ return startUpdate(row);
+ }
+
+ ColumnMap *startUpdate(const char *r){
+ Field row(lba, r);
+ return startUpdate(row);
+ }
+
+ ColumnMap *startUpdate(Field &row){
+ // This method is structured to avoid allocating the column map in the case
+ // where it already exists in the map. This is done so the row key memory can
+ // be easily deallocated.
+ RowMap::iterator lbi = rowmap.lower_bound(row);
+ if(lbi == rowmap.end() || row < lbi->first) {
+ RowMap::iterator iter = rowmap.insert(lbi, pair<Field, ColumnMap>(row, ColumnMap(std::less<SubKey>(), BlockAllocator<std::pair<SubKey, Field> >(lba))));
+ return &(iter->second);
+ } else {
+ // Return row memory because an insert was not done.
+ row.clear(lba);
+ return &(lbi->second);
+ }
+ }
+
+ void update(ColumnMap *cm, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount){
+
+ SubKey sk(lba, env, cf, cq, cv, ts, del, mutationCount);
+ //cout << "Updating " << sk.toString() << " " << sk.getTimestamp() << " " << sk.isDeleted() << endl;
+ //do not bother allocating value if not needed
+ Field value(NULL, 0);
+
+ pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
+ if(insertResult.second){
+ insertResult.first->second = Field(lba, env, val);
+ count++;
+ }else{
+ sk.clear(lba);
+ int valLen = env->GetArrayLength(val);
+ if(valLen <= insertResult.first->second.length()){
+ insertResult.first->second.set(env, val, valLen);
+ }else{
+ insertResult.first->second.clear();
+ insertResult.first->second = Field(lba, env, val, valLen);
+ }
+ }
+ }
+
+ void update(ColumnMap *cm, const char *cf, const char *cq, const char *cv, long ts, bool del, const char *val, int valLen, int mutationCount){
+
+ SubKey sk(lba, cf, cq, cv, ts, del, mutationCount);
+ //do not bother allocating value if not needed
+ Field value(NULL, 0);
+
+ pair<ColumnMap::iterator, bool> insertResult = cm->insert(pair<SubKey, Field>(sk, value));
+ if(insertResult.second){
+ insertResult.first->second = Field(lba, val);
+ count++;
+ }else{
+ sk.clear(lba);
+ if(insertResult.first->second.length() <= valLen){
+ insertResult.first->second.set(val, valLen);
+ }else{
+ insertResult.first->second.clear();
+ insertResult.first->second = Field(lba, val);
+ }
+ }
+ }
+
+ Iterator *iterator(int32_t *ia){
+ return new Iterator(*this, ia);
+ }
+
+ Iterator *iterator(Field &row, SubKey &sk, int32_t *ia){
+ return new Iterator(*this, row, sk, ia);
+ }
+
+ int64_t getMemoryUsed(){
+ return lba->getMemoryUsed();
+ }
};
#endif
-
diff --git a/server/native/src/main/c++/nativeMap/SubKey.h b/server/native/src/main/c++/nativeMap/SubKey.h
index 0522308..d74853f 100644
--- a/server/native/src/main/c++/nativeMap/SubKey.h
+++ b/server/native/src/main/c++/nativeMap/SubKey.h
@@ -26,162 +26,161 @@ using namespace std;
class SubKey {
-public:
+ public:
- int32_t colQualifierOffset;
- int32_t colVisibilityOffset;
- int32_t totalLen;
- uint8_t *keyData;
- int64_t timestamp;
- int32_t mutationCount;
- bool deleted;
+ int32_t colQualifierOffset;
+ int32_t colVisibilityOffset;
+ int32_t totalLen;
+ uint8_t *keyData;
+ int64_t timestamp;
+ int32_t mutationCount;
+ bool deleted;
- int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
- int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
-
- if(result != 0)
- return result;
- if(len1 == len2)
- return 0;
- if(len1 < len2)
- return -1;
+ int compare(const uint8_t *d1, int len1, const uint8_t *d2, int len2) const{
+ int result = memcmp(d1, d2, len1 < len2 ? len1 : len2);
- return 1;
- }
+ if(result != 0)
+ return result;
+ if(len1 == len2)
+ return 0;
+ if(len1 < len2)
+ return -1;
- /**
- * Constructor for testing purposes
- */
- SubKey(LinkedBlockAllocator *lba, const string &cf, const string &cq, const string &cv, int64_t ts, bool del, int32_t mc){
+ return 1;
+ }
- colQualifierOffset = cf.length();
- colVisibilityOffset = colQualifierOffset + cq.length();
- totalLen = colVisibilityOffset + cv.length();
+ /**
+ * Constructor for testing purposes
+ */
+ SubKey(LinkedBlockAllocator *lba, const string &cf, const string &cq, const string &cv, int64_t ts, bool del, int32_t mc){
- keyData = (uint8_t *)lba->allocate(totalLen);
+ colQualifierOffset = cf.length();
+ colVisibilityOffset = colQualifierOffset + cq.length();
+ totalLen = colVisibilityOffset + cv.length();
- copy(cf.begin(), cf.end(), keyData);
- copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
- copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
+ keyData = (uint8_t *)lba->allocate(totalLen);
- timestamp = ts;
- deleted = del;
+ copy(cf.begin(), cf.end(), keyData);
+ copy(cq.begin(), cq.end(), keyData+colQualifierOffset);
+ copy(cv.begin(), cv.end(), keyData+colVisibilityOffset);
- mutationCount = mc;
- }
+ timestamp = ts;
+ deleted = del;
- SubKey(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, int32_t mc){
+ mutationCount = mc;
+ }
- int cfLen = env->GetArrayLength(cf);
- int cqLen = env->GetArrayLength(cq);
- int cvLen = env->GetArrayLength(cv);
+ SubKey(LinkedBlockAllocator *lba, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, int32_t mc){
- colQualifierOffset = cfLen;
- colVisibilityOffset = colQualifierOffset + cqLen;
- totalLen = colVisibilityOffset + cvLen;
+ int cfLen = env->GetArrayLength(cf);
+ int cqLen = env->GetArrayLength(cq);
+ int cvLen = env->GetArrayLength(cv);
- if(lba == NULL)
- keyData = new uint8_t[totalLen];
- else
- keyData = (uint8_t *)lba->allocate(totalLen);
+ colQualifierOffset = cfLen;
+ colVisibilityOffset = colQualifierOffset + cqLen;
+ totalLen = colVisibilityOffset + cvLen;
+ if(lba == NULL)
+ keyData = new uint8_t[totalLen];
+ else
+ keyData = (uint8_t *)lba->allocate(totalLen);
- env->GetByteArrayRegion(cf, 0, cfLen, (jbyte *)keyData);
- env->GetByteArrayRegion(cq, 0, cqLen, (jbyte *)(keyData+colQualifierOffset));
- env->GetByteArrayRegion(cv, 0, cvLen, (jbyte *)(keyData+colVisibilityOffset));
- timestamp = ts;
- deleted = del;
+ env->GetByteArrayRegion(cf, 0, cfLen, (jbyte *)keyData);
+ env->GetByteArrayRegion(cq, 0, cqLen, (jbyte *)(keyData+colQualifierOffset));
+ env->GetByteArrayRegion(cv, 0, cvLen, (jbyte *)(keyData+colVisibilityOffset));
- mutationCount = mc;
- }
+ timestamp = ts;
+ deleted = del;
+ mutationCount = mc;
+ }
- bool operator<(const SubKey &key) const{
- int result = compare(keyData, colQualifierOffset, key.keyData, key.colQualifierOffset);
- if(result != 0) return result < 0;
+ bool operator<(const SubKey &key) const{
- result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
- if(result != 0) return result < 0;
+ int result = compare(keyData, colQualifierOffset, key.keyData, key.colQualifierOffset);
+ if(result != 0) return result < 0;
- result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
- if(result != 0) return result < 0;
+ result = compare(keyData + colQualifierOffset, colVisibilityOffset - colQualifierOffset, key.keyData + key.colQualifierOffset, key.colVisibilityOffset - key.colQualifierOffset);
+ if(result != 0) return result < 0;
- if(timestamp < key.timestamp){
- return false;
- }else if(timestamp > key.timestamp){
- return true;
- }
+ result = compare(keyData + colVisibilityOffset, totalLen - colVisibilityOffset, key.keyData + key.colVisibilityOffset, key.totalLen - key.colVisibilityOffset);
+ if(result != 0) return result < 0;
- if(deleted != key.deleted)
- return deleted && !key.deleted;
-
- return mutationCount > key.mutationCount;
- }
+ if(timestamp < key.timestamp){
+ return false;
+ }else if(timestamp > key.timestamp){
+ return true;
+ }
- void clear(){
- //delete(keyData);
- }
+ if(deleted != key.deleted)
+ return deleted && !key.deleted;
- void clear(LinkedBlockAllocator *lba){
- lba->deleteLast(keyData);
- }
+ return mutationCount > key.mutationCount;
+ }
- int64_t bytesUsed() const{
- return totalLen + 9;
- }
+ void clear(){
+ //delete(keyData);
+ }
- bool isDeleted() const{
- return deleted;
- }
+ void clear(LinkedBlockAllocator *lba){
+ lba->deleteLast(keyData);
+ }
- int32_t getCFLen() const{
- return colQualifierOffset;
- }
-
- int32_t getCQLen() const {
- return colVisibilityOffset - colQualifierOffset;
- }
+ int64_t bytesUsed() const{
+ return totalLen + 9;
+ }
- int32_t getCVLen() const {
- return totalLen - colVisibilityOffset;
- }
+ bool isDeleted() const{
+ return deleted;
+ }
- const Field getCF() const{
- return Field(keyData, getCFLen());
- }
+ int32_t getCFLen() const{
+ return colQualifierOffset;
+ }
- const Field getCQ() const{
- return Field(keyData + colQualifierOffset, getCQLen());
- }
+ int32_t getCQLen() const {
+ return colVisibilityOffset - colQualifierOffset;
+ }
- const Field getCV() const{
- return Field(keyData + colVisibilityOffset, getCVLen());
- }
+ int32_t getCVLen() const {
+ return totalLen - colVisibilityOffset;
+ }
- string toString() const{
- return getCF().toString()+":"+getCQ().toString()+":"+getCV().toString();
- }
+ const Field getCF() const{
+ return Field(keyData, getCFLen());
+ }
- int64_t getTimestamp() const{
- return timestamp;
- }
+ const Field getCQ() const{
+ return Field(keyData + colQualifierOffset, getCQLen());
+ }
- int32_t getMC() const{
- return mutationCount;
- }
+ const Field getCV() const{
+ return Field(keyData + colVisibilityOffset, getCVLen());
+ }
+
+ string toString() const{
+ return getCF().toString()+":"+getCQ().toString()+":"+getCV().toString();
+ }
+
+ int64_t getTimestamp() const{
+ return timestamp;
+ }
+
+ int32_t getMC() const{
+ return mutationCount;
+ }
};
struct LocalSubKey : public SubKey {
-
- LocalSubKey(JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del):SubKey(NULL, env, cf, cq, cv, ts, del, INT_MAX){}
- ~LocalSubKey(){
- delete(keyData);
- }
+ LocalSubKey(JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del):SubKey(NULL, env, cf, cq, cv, ts, del, INT_MAX){}
+
+ ~LocalSubKey(){
+ delete(keyData);
+ }
};
#endif
-
diff --git a/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc b/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
index 4c17fb3..fd6c4e5 100644
--- a/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
+++ b/server/native/src/main/c++/nativeMap/org_apache_accumulo_tserver_NativeMap.cc
@@ -30,101 +30,101 @@
using namespace std;
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNM(JNIEnv *env, jclass cls) {
- return (jlong)(new NativeMap(1<<17, 1<<11));
+ return (jlong)(new NativeMap(1<<17, 1<<11));
}
JNIEXPORT jint JNICALL Java_org_apache_accumulo_tserver_NativeMap_sizeNM(JNIEnv *env, jclass cls, jlong nm) {
- return ((NativeMap *)nm)->count;
+ return ((NativeMap *)nm)->count;
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_memoryUsedNM(JNIEnv *env, jclass cls, jlong nm) {
- return ((NativeMap *)nm)->getMemoryUsed();
+ return ((NativeMap *)nm)->getMemoryUsed();
}
JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_singleUpdate(JNIEnv *env, jclass cls, jlong nm, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount) {
- jlong uid = Java_org_apache_accumulo_tserver_NativeMap_startUpdate(env, cls, nm, r);
- Java_org_apache_accumulo_tserver_NativeMap_update(env, cls, nm, uid, cf, cq, cv, ts, del, val, mutationCount);
+ jlong uid = Java_org_apache_accumulo_tserver_NativeMap_startUpdate(env, cls, nm, r);
+ Java_org_apache_accumulo_tserver_NativeMap_update(env, cls, nm, uid, cf, cq, cv, ts, del, val, mutationCount);
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_startUpdate(JNIEnv *env, jclass cls, jlong nm, jbyteArray r) {
- NativeMap *nativeMap = (NativeMap *)nm;
- ColumnMap *cm = nativeMap->startUpdate(env, r);
- return (jlong)cm;
+ NativeMap *nativeMap = (NativeMap *)nm;
+ ColumnMap *cm = nativeMap->startUpdate(env, r);
+ return (jlong)cm;
}
JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_update(JNIEnv *env, jclass cls, jlong nm, jlong uid, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount) {
- NativeMap *nativeMap = (NativeMap *)nm;
- nativeMap->update((ColumnMap *)uid, env, cf, cq, cv, ts, del, val, mutationCount);
+ NativeMap *nativeMap = (NativeMap *)nm;
+ nativeMap->update((ColumnMap *)uid, env, cf, cq, cv, ts, del, val, mutationCount);
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_deleteNM(JNIEnv *env, jclass cls, jlong nm) {
- NativeMap *nativeMap = (NativeMap *)nm;
- delete(nativeMap);
+ NativeMap *nativeMap = (NativeMap *)nm;
+ delete(nativeMap);
return 0;
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNMI__J_3I(JNIEnv *env, jclass cls, jlong nm, jintArray lens) {
- NativeMap *nativeMap = (NativeMap *)nm;
- int32_t ia[7];
- Iterator *iter = nativeMap->iterator(ia);
- if (iter->atEnd()) {
- delete(iter);
- return 0;
- }
- env->SetIntArrayRegion(lens, 0, 7, ia);
- return (jlong)iter;
+ NativeMap *nativeMap = (NativeMap *)nm;
+ int32_t ia[7];
+ Iterator *iter = nativeMap->iterator(ia);
+ if (iter->atEnd()) {
+ delete(iter);
+ return 0;
+ }
+ env->SetIntArrayRegion(lens, 0, 7, ia);
+ return (jlong)iter;
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_createNMI__J_3B_3B_3B_3BJZ_3I(JNIEnv *env, jclass cls, jlong nm, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jintArray lens) {
NativeMap *nativeMap = (NativeMap *)nm;
- LocalField row(env, r);
- LocalSubKey sk(env, cf, cq, cv, ts, del);
+ LocalField row(env, r);
+ LocalSubKey sk(env, cf, cq, cv, ts, del);
- int32_t ia[7];
- Iterator *iter = nativeMap->iterator(row, sk, ia);
+ int32_t ia[7];
+ Iterator *iter = nativeMap->iterator(row, sk, ia);
- if(iter->atEnd()) {
- delete(iter);
- return 0;
- }
+ if(iter->atEnd()) {
+ delete(iter);
+ return 0;
+ }
- env->SetIntArrayRegion(lens, 0, 7, ia);
- return (jlong)iter;
+ env->SetIntArrayRegion(lens, 0, 7, ia);
+ return (jlong)iter;
}
JNIEXPORT jboolean JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiNext(JNIEnv *env, jclass cls, jlong ip, jintArray lens) {
- Iterator &iter = *((Iterator *)ip);
+ Iterator &iter = *((Iterator *)ip);
- int32_t ia[7];
- iter.advance(ia);
- if(iter.atEnd()) {
- return false;
- }
+ int32_t ia[7];
+ iter.advance(ia);
+ if(iter.atEnd()) {
+ return false;
+ }
- env->SetIntArrayRegion(lens, 0, 7, ia);
- return true;
+ env->SetIntArrayRegion(lens, 0, 7, ia);
+ return true;
}
JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiGetData(JNIEnv *env, jclass cls, jlong ip, jbyteArray r, jbyteArray cf, jbyteArray cq, jbyteArray cv, jbyteArray val) {
- Iterator &iter = *((Iterator *)ip);
- if(r != NULL) {
- iter.rowIter->first.fillIn(env, r);
- }
-
- iter.colIter->first.getCF().fillIn(env, cf);
- iter.colIter->first.getCQ().fillIn(env, cq);
- iter.colIter->first.getCV().fillIn(env, cv);
- iter.colIter->second.fillIn(env, val);
+ Iterator &iter = *((Iterator *)ip);
+ if(r != NULL) {
+ iter.rowIter->first.fillIn(env, r);
+ }
+
+ iter.colIter->first.getCF().fillIn(env, cf);
+ iter.colIter->first.getCQ().fillIn(env, cq);
+ iter.colIter->first.getCV().fillIn(env, cv);
+ iter.colIter->second.fillIn(env, val);
}
JNIEXPORT jlong JNICALL Java_org_apache_accumulo_tserver_NativeMap_nmiGetTS(JNIEnv *env, jclass cls, jlong ip) {
- Iterator &iter = *((Iterator *)ip);
- return iter.colIter->first.getTimestamp();
+ Iterator &iter = *((Iterator *)ip);
+ return iter.colIter->first.getTimestamp();
}
JNIEXPORT void JNICALL Java_org_apache_accumulo_tserver_NativeMap_deleteNMI(JNIEnv *env, jclass cls, jlong ip) {
- delete((Iterator *)ip);
+ delete((Iterator *)ip);
}