resolve comments

This commit is contained in:
Yurui Zhou committed 2019-06-06 15:12:01 +08:00
1 parent 9b04b762d6
commit fc801756d2
6 files changed
+24 -33

No files matched your search

+10 -14
View File
@@ -33,9 +33,9 @@ namespace jni {
* @tparam Holder class of the object to hold.
*/
template <typename Holder>
class concurrentMap {
class ConcurrentMap {
public:
concurrentMap() : module_id_(kInitModuleId) {}
ConcurrentMap() : module_id_(init_module_id_) {}
jlong Insert(Holder holder) {
std::lock_guard<std::mutex> lock(mtx_);
@@ -50,20 +50,16 @@ class concurrentMap {
}
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;
auto it = map_.find(module_id);
if (it != map_.end()) {
return it->second;
}
std::lock_guard<std::mutex> lock(mtx_);
try {
result = map_.at(module_id);
} catch (const std::out_of_range& e) {
it = map_.find(module_id);
if (it != map_.end()) {
return it->second;
}
return result;
return NULLPTR;
}
void Clear() {
@@ -73,7 +69,7 @@ class concurrentMap {
private:
// starting value of the module_id.
static constexpr int kInitModuleId = 4;
static constexpr int init_module_id_ = 4;
int64_t module_id_;
std::mutex mtx_;
+4 -4
View File
@@ -48,11 +48,11 @@ static jmethodID record_batch_constructor;
static jint JNI_VERSION = JNI_VERSION_1_6;
using arrow::jni::concurrentMap;
using arrow::jni::ConcurrentMap;
static concurrentMap<std::shared_ptr<arrow::Buffer>> buffer_holder_;
static concurrentMap<std::shared_ptr<RecordBatchReader>> orc_stripe_reader_holder_;
static concurrentMap<std::shared_ptr<ORCFileReader>> orc_reader_holder_;
static ConcurrentMap<std::shared_ptr<arrow::Buffer>> buffer_holder_;
static ConcurrentMap<std::shared_ptr<RecordBatchReader>> orc_stripe_reader_holder_;
static ConcurrentMap<std::shared_ptr<ORCFileReader>> orc_reader_holder_;
jclass CreateGlobalClassReference(JNIEnv* env, const char* class_name) {
jclass local_class = env->FindClass(class_name);
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.UUID;
/**
* Helper class for JNI related operations.
@@ -34,10 +33,6 @@ class OrcJniUtils {
private OrcJniUtils() {}
/**
* Load arrow orc jni library from jar.
* @throws IOException throws IOException in case target library can not be found.
*/
static void loadOrcAdapterLibraryFromJar()
throws IOException {
synchronized (OrcJniUtils.class) {
@@ -53,7 +48,7 @@ class OrcJniUtils {
private static File moveFileFromJarToTemp(final String tmpDir, String libraryToLoad)
throws IOException {
final File temp = setupFile(tmpDir, libraryToLoad);
final File temp = File.createTempFile(tmpDir, libraryToLoad);
try (final InputStream is = OrcReaderJniWrapper.class.getClassLoader()
.getResourceAsStream(libraryToLoad)) {
if (is == null) {
@@ -64,10 +59,4 @@ class OrcJniUtils {
}
return temp;
}
private static File setupFile(String tmpDir, String libraryToLoad)
throws IOException {
final String randomizeFileName = libraryToLoad + UUID.randomUUID();
return File.createTempFile(tmpDir, randomizeFileName);
}
}
@@ -46,7 +46,7 @@ class OrcMemoryJniWrapper implements AutoCloseable {
/**
* Return the size of underlying chunk of memory that has valid data.
* @return
* @return valid data size
*/
long getSize() {
return size;
@@ -54,7 +54,7 @@ class OrcMemoryJniWrapper implements AutoCloseable {
/**
* Return the size of underlying chunk of memory managed by this OrcMemoryJniWrapper.
* @return
* @return underlying memory size
*/
long getCapacity() {
return capacity;
@@ -62,7 +62,7 @@ class OrcMemoryJniWrapper implements AutoCloseable {
/**
* Return the memory address of underlying chunk of memory.
* @return
* @return memory address
*/
long getMemoryAddress() {
return memoryAddress;
@@ -32,6 +32,9 @@ public class OrcReader implements AutoCloseable {
private final OrcReaderJniWrapper jniWrapper;
private BufferAllocator allocator;
/**
* reference to native reader instance.
*/
private final long id;
/**
@@ -40,6 +40,9 @@ import io.netty.buffer.ArrowBuf;
* Orc stripe that load data into ArrowRecordBatch.
*/
public class OrcStripeReader extends ArrowReader {
/**
* reference to native stripe reader instance.
*/
private final long id;
private MessageChannelReader schemaReader;