You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2021/05/20 14:20:13 UTC

[impala] 03/03: IMPALA-10701: Switch to use TByteBuffer from thrift

This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 71ccad2f415aa2e3f1cac35514c2d6b9c6db3ebc
Author: stiga-huang <hu...@gmail.com>
AuthorDate: Wed May 12 09:55:34 2021 +0800

    IMPALA-10701: Switch to use TByteBuffer from thrift
    
    We have a copy of the TByteBuffer when we are using thrift versions
    prior to 0.10. After IMPALA-7825 bumps the thrift version to 0.11.0, we
    can use it directly.
    
    Tests
     - Run CORE tests
    
    Change-Id: Ia0c7834253a16e440204264b0462a1590dea2463
    Reviewed-on: http://gerrit.cloudera.org:8080/17428
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 .../org/apache/impala/catalog/ImpaladCatalog.java  |  4 +-
 .../impala/catalog/local/CatalogdMetaProvider.java |  2 +-
 .../java/org/apache/impala/util/TByteBuffer.java   | 60 ----------------------
 3 files changed, 2 insertions(+), 64 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/catalog/ImpaladCatalog.java b/fe/src/main/java/org/apache/impala/catalog/ImpaladCatalog.java
index edbfee2..a033934 100644
--- a/fe/src/main/java/org/apache/impala/catalog/ImpaladCatalog.java
+++ b/fe/src/main/java/org/apache/impala/catalog/ImpaladCatalog.java
@@ -27,9 +27,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.impala.analysis.TableName;
 import org.apache.impala.authorization.AuthorizationChecker;
 import org.apache.impala.authorization.AuthorizationPolicy;
@@ -50,10 +48,10 @@ import org.apache.impala.thrift.TUniqueId;
 import org.apache.impala.thrift.TUpdateCatalogCacheRequest;
 import org.apache.impala.thrift.TUpdateCatalogCacheResponse;
 import org.apache.impala.util.PatternMatcher;
-import org.apache.impala.util.TByteBuffer;
 import org.apache.impala.util.TUniqueIdUtil;
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TByteBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
diff --git a/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java b/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
index 46db9c3..1ee1041 100644
--- a/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
+++ b/fe/src/main/java/org/apache/impala/catalog/local/CatalogdMetaProvider.java
@@ -89,11 +89,11 @@ import org.apache.impala.thrift.TUpdateCatalogCacheRequest;
 import org.apache.impala.thrift.TUpdateCatalogCacheResponse;
 import org.apache.impala.thrift.TValidWriteIdList;
 import org.apache.impala.util.ListMap;
-import org.apache.impala.util.TByteBuffer;
 import org.apache.thrift.TDeserializer;
 import org.apache.thrift.TException;
 import org.apache.thrift.TSerializer;
 import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TByteBuffer;
 import org.ehcache.sizeof.SizeOf;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/fe/src/main/java/org/apache/impala/util/TByteBuffer.java b/fe/src/main/java/org/apache/impala/util/TByteBuffer.java
deleted file mode 100644
index 28d05aa..0000000
--- a/fe/src/main/java/org/apache/impala/util/TByteBuffer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.impala.util;
-
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-
-/**
- * ByteBuffer-backed implementation of TTransport. This is copied from thrift 0.10.0.
- * TODO: Upgrade thrift to 0.10.0 or higher and remove this file.
- */
-public final class TByteBuffer extends TTransport {
-  private final ByteBuffer byteBuffer;
-
-  public TByteBuffer(ByteBuffer byteBuffer) { this.byteBuffer = byteBuffer; }
-
-  @Override
-  public boolean isOpen() { return true; }
-
-  @Override
-  public void open() {}
-
-  @Override
-  public void close() {}
-
-  @Override
-  public int read(byte[] buf, int off, int len) throws TTransportException {
-    final int n = Math.min(byteBuffer.remaining(), len);
-    if (n > 0) {
-      try {
-        byteBuffer.get(buf, off, n);
-      } catch (BufferUnderflowException e) {
-        throw new TTransportException("Unexpected end of input buffer", e);
-      }
-    }
-    return n;
-  }
-
-  @Override
-  public void write(byte[] buf, int off, int len) throws TTransportException {
-    throw new TTransportException("Write is not supported by TByteBuffer");
-  }
-}