You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2019/04/22 18:31:35 UTC
[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5187 Avoid using
FileInputStream and FileOutputStream
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
new 892fd34 PHOENIX-5187 Avoid using FileInputStream and FileOutputStream
892fd34 is described below
commit 892fd34ce34aff6da7a5348e25e7312b5ea132c7
Author: Aman Poonia <am...@gmail.com>
AuthorDate: Mon Mar 11 23:14:23 2019 +0530
PHOENIX-5187 Avoid using FileInputStream and FileOutputStream
---
.../main/java/org/apache/phoenix/cache/ServerCacheClient.java | 9 +++++----
.../src/main/java/org/apache/phoenix/iterate/BufferedQueue.java | 7 +++----
.../java/org/apache/phoenix/iterate/SpoolingResultIterator.java | 4 ++--
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 93d16f5..b6b53df 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -22,9 +22,10 @@ import static org.apache.phoenix.util.LogUtil.addCustomAnnotations;
import java.io.Closeable;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
@@ -148,7 +149,7 @@ public class ServerCacheClient {
} catch (InsufficientMemoryException e) {
this.outputFile = File.createTempFile("HashJoinCacheSpooler", ".bin", new File(services.getProps()
.get(QueryServices.SPOOL_DIRECTORY, QueryServicesOptions.DEFAULT_SPOOL_DIRECTORY)));
- try (FileOutputStream fio = new FileOutputStream(outputFile)) {
+ try (OutputStream fio = Files.newOutputStream(outputFile.toPath())) {
fio.write(cachePtr.get(), cachePtr.getOffset(), cachePtr.getLength());
}
}
@@ -158,7 +159,7 @@ public class ServerCacheClient {
public ImmutableBytesWritable getCachePtr() throws IOException {
if(this.outputFile!=null){
- try (FileInputStream fio = new FileInputStream(outputFile)) {
+ try (InputStream fio = Files.newInputStream(outputFile.toPath())) {
byte[] b = new byte[this.size];
fio.read(b);
cachePtr = new ImmutableBytesWritable(b);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
index 1a646e6..3352641 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BufferedQueue.java
@@ -23,9 +23,8 @@ import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.AbstractQueue;
import java.util.Comparator;
import java.util.Iterator;
@@ -304,7 +303,7 @@ public abstract class BufferedQueue<T> extends AbstractQueue<T> implements SizeA
if (totalResultSize >= thresholdBytes) {
this.file = File.createTempFile(UUID.randomUUID().toString(), null);
try (DataOutputStream out = new DataOutputStream(
- new BufferedOutputStream(new FileOutputStream(file)))) {
+ new BufferedOutputStream(Files.newOutputStream(file.toPath())))) {
int resSize = inMemQueue.size();
for (int i = 0; i < resSize; i++) {
T e = inMemQueue.poll();
@@ -342,7 +341,7 @@ public abstract class BufferedQueue<T> extends AbstractQueue<T> implements SizeA
this.next = null;
try {
this.in = new DataInputStream(
- new BufferedInputStream(new FileInputStream(file)));
+ new BufferedInputStream(Files.newInputStream(file.toPath())));
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
index fa90b1a..0823026 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/SpoolingResultIterator.java
@@ -27,8 +27,8 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.nio.file.Files;
import java.sql.SQLException;
import java.util.List;
@@ -273,7 +273,7 @@ public class SpoolingResultIterator implements PeekingResultIterator {
private synchronized void init() throws IOException {
if (spoolFrom == null) {
- spoolFrom = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+ spoolFrom = new DataInputStream(new BufferedInputStream(Files.newInputStream(file.toPath())));
advance();
}
}