parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject [parquet-mr] branch master updated: PARQUET-1444: Prefer ArrayList over LinkedList (#583)
Date Wed, 23 Oct 2019 13:24:41 GMT
This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-mr.git


The following commit(s) were added to refs/heads/master by this push:
     new 10b926f  PARQUET-1444: Prefer ArrayList over LinkedList (#583)
10b926f is described below

commit 10b926f021a6a441685c01d3dfe32c7ef07b1900
Author: belugabehr <12578579+belugabehr@users.noreply.github.com>
AuthorDate: Wed Oct 23 09:24:00 2019 -0400

    PARQUET-1444: Prefer ArrayList over LinkedList (#583)
---
 .../org/apache/parquet/hadoop/ColumnChunkPageReadStore.java  | 12 +++++++-----
 .../apache/parquet/thrift/BufferedProtocolReadToWrite.java   |  4 ++--
 .../java/org/apache/parquet/thrift/ParquetReadProtocol.java  |  4 ++--
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
index 2e646e7..3067e2b 100644
--- a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
+++ b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
@@ -19,12 +19,14 @@
 package org.apache.parquet.hadoop;
 
 import java.io.IOException;
+import java.util.ArrayDeque;
 import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.PrimitiveIterator;
+import java.util.Queue;
+
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.ColumnDescriptor;
 import org.apache.parquet.column.page.DataPage;
@@ -61,7 +63,7 @@ class ColumnChunkPageReadStore implements PageReadStore, DictionaryPageReadStore
 
     private final BytesInputDecompressor decompressor;
     private final long valueCount;
-    private final List<DataPage> compressedPages;
+    private final Queue<DataPage> compressedPages;
     private final DictionaryPage compressedDictionaryPage;
     // null means no page synchronization is required; firstRowIndex will not be returned
by the pages
     private final OffsetIndex offsetIndex;
@@ -71,7 +73,7 @@ class ColumnChunkPageReadStore implements PageReadStore, DictionaryPageReadStore
     ColumnChunkPageReader(BytesInputDecompressor decompressor, List<DataPage> compressedPages,
         DictionaryPage compressedDictionaryPage, OffsetIndex offsetIndex, long rowCount)
{
       this.decompressor = decompressor;
-      this.compressedPages = new LinkedList<DataPage>(compressedPages);
+      this.compressedPages = new ArrayDeque<DataPage>(compressedPages);
       this.compressedDictionaryPage = compressedDictionaryPage;
       long count = 0;
       for (DataPage p : compressedPages) {
@@ -89,10 +91,10 @@ class ColumnChunkPageReadStore implements PageReadStore, DictionaryPageReadStore
 
     @Override
     public DataPage readPage() {
-      if (compressedPages.isEmpty()) {
+      final DataPage compressedPage = compressedPages.poll();
+      if (compressedPage == null) {
         return null;
       }
-      DataPage compressedPage = compressedPages.remove(0);
       final int currentPageIndex = pageIndex++;
       return compressedPage.accept(new DataPage.Visitor<DataPage>() {
         @Override
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java
b/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java
index 54aac6d..2e76642 100644
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java
+++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java
@@ -19,7 +19,7 @@
 package org.apache.parquet.thrift;
 
 import java.nio.ByteBuffer;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.thrift.TException;
@@ -140,7 +140,7 @@ public class BufferedProtocolReadToWrite implements ProtocolPipe {
    */
   @Override
   public void readOne(TProtocol in, TProtocol out) throws TException {
-    List<Action> buffer = new LinkedList<Action>();
+    List<Action> buffer = new ArrayList<Action>(1);
     try{
         boolean hasFieldsIgnored = readOneStruct(in, buffer, thriftType);
         if (hasFieldsIgnored) {
diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetReadProtocol.java
b/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetReadProtocol.java
index b72c85c..c85b13b 100644
--- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetReadProtocol.java
+++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetReadProtocol.java
@@ -20,9 +20,9 @@ package org.apache.parquet.thrift;
 
 
 import java.nio.ByteBuffer;
+import java.util.ArrayDeque;
 import java.util.Collection;
 import java.util.Deque;
-import java.util.LinkedList;
 
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TField;
@@ -43,7 +43,7 @@ class ParquetReadProtocol extends ParquetProtocol {
     super("read");
   }
 
-  private Deque<TProtocol> events = new  LinkedList<TProtocol>();
+  private Deque<TProtocol> events = new ArrayDeque<TProtocol>();
 
   public void add(TProtocol p) {
     events.addLast(p);


Mime
View raw message