fix lint and clang-format

This commit is contained in:
Yurui Zhou committed 2019-06-06 15:12:01 +08:00
1 parent 44505df5db
commit dd981af5fb
2 files changed
+50 -49

No files matched your search

+43 -42
View File
@@ -19,62 +19,63 @@
#define JNI_ID_TO_MODULE_MAP_H
#include <memory>
#include <unordered_map>
#include <utility>
namespace arrow {
template <typename HOLDER>
class concurrentMap {
public:
concurrentMap() : module_id_(kInitModuleId) {}
public:
concurrentMap() : module_id_(kInitModuleId) {}
jlong Insert(HOLDER holder) {
mtx_.lock();
jlong result = module_id_++;
map_.insert(std::pair<jlong, HOLDER>(result, holder));
mtx_.unlock();
return result;
jlong Insert(HOLDER holder) {
mtx_.lock();
jlong result = module_id_++;
map_.insert(std::pair<jlong, HOLDER>(result, holder));
mtx_.unlock();
return result;
}
void Erase(jlong module_id) {
mtx_.lock();
map_.erase(module_id);
mtx_.unlock();
}
HOLDER Lookup(jlong module_id) {
HOLDER result = nullptr;
try {
result = map_.at(module_id);
} catch (const std::out_of_range& e) {
}
void Erase(jlong module_id) {
mtx_.lock();
map_.erase(module_id);
mtx_.unlock();
if (result != nullptr) {
return result;
}
HOLDER Lookup(jlong module_id) {
HOLDER result = nullptr;
try {
result = map_.at(module_id);
} catch (const std::out_of_range &e) {
}
if (result != nullptr) {
return result;
}
mtx_.lock();
try {
result = map_.at(module_id);
} catch (const std::out_of_range &e) {
}
mtx_.unlock();
return result;
mtx_.lock();
try {
result = map_.at(module_id);
} catch (const std::out_of_range& e) {
}
mtx_.unlock();
return result;
}
void Clear() {
mtx_.lock();
map_.clear();
mtx_.unlock();
}
void Clear() {
mtx_.lock();
map_.clear();
mtx_.unlock();
}
private:
static const int kInitModuleId = 4;
private:
static const int kInitModuleId = 4;
long module_id_;
std::mutex mtx_;
// map from module ids returned to Java and module pointers
std::unordered_map<jlong, HOLDER> map_;
int64_t module_id_;
std::mutex mtx_;
// map from module ids returned to Java and module pointers
std::unordered_map<jlong, HOLDER> map_;
};
} // namespace gandiva
} // namespace arrow
#endif // JNI_ID_TO_MODULE_MAP_H
+7 -7
View File
@@ -22,14 +22,14 @@
#include <arrow/ipc/api.h>
#include <arrow/util/logging.h>
#include <cassert>
#include <string>
#include <iostream>
#include <string>
#include "org_apache_arrow_adapter_orc_OrcMemoryJniWrapper.h"
#include "org_apache_arrow_adapter_orc_OrcReaderJniWrapper.h"
#include "org_apache_arrow_adapter_orc_OrcStripeReaderJniWrapper.h"
#include "concurrent_map.h"
#include "./concurrent_map.h"
using ORCFileReader = arrow::adapters::orc::ORCFileReader;
using RecordBatchReader = arrow::RecordBatchReader;
@@ -89,9 +89,10 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
record_batch_class =
CreateGlobalClassReference(env, "Lorg/apache/arrow/adapter/orc/OrcRecordBatch;");
record_batch_constructor = GetMethodID(env, record_batch_class, "<init>",
"(I[Lorg/apache/arrow/adapter/orc/OrcFieldNode;"
"[Lorg/apache/arrow/adapter/orc/OrcMemoryJniWrapper;)V");
record_batch_constructor =
GetMethodID(env, record_batch_class, "<init>",
"(I[Lorg/apache/arrow/adapter/orc/OrcFieldNode;"
"[Lorg/apache/arrow/adapter/orc/OrcMemoryJniWrapper;)V");
env->ExceptionDescribe();
@@ -157,8 +158,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_arrow_adapter_orc_OrcReaderJniWrapper_op
env->ThrowNew(io_exception_class, std::string("Failed open file" + path).c_str());
}
return orc_reader_holder_.Insert(
std::shared_ptr<ORCFileReader>(reader.release()));
return orc_reader_holder_.Insert(std::shared_ptr<ORCFileReader>(reader.release()));
}
return static_cast<jlong>(ret.code()) * -1;