Skip to content

Commit

Permalink
PARQUET-2005: Upgrade thrift to 0.14.1 (apache#884)
Browse files Browse the repository at this point in the history
* PARQUET-2005: Upgrade thrift to 0.14.1

* PARQUET-2005: Update thrift version in CI scripts and README

* Update README.md

Co-authored-by: Fokko Driesprong <[email protected]>

Co-authored-by: Fokko Driesprong <[email protected]>
  • Loading branch information
gszadovszky and Fokko authored Apr 8, 2021
1 parent 8624081 commit d23a9a7
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 23 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ Parquet-MR uses Maven to build and depends on the thrift compiler (protoc is now
To build and install the thrift compiler, run:

```
wget -nv http://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz
tar xzf thrift-0.13.0.tar.gz
cd thrift-0.13.0
wget -nv http://archive.apache.org/dist/thrift/0.14.1/thrift-0.14.1.tar.gz
tar xzf thrift-0.14.1.tar.gz
cd thrift-0.14.1
chmod +x ./configure
./configure --disable-libs
sudo make install
```

If you're on OSX and use homebrew, you can instead install Thrift 0.13.0 with `brew` and ensure that it comes first in your `PATH`.
If you're on OSX and use homebrew, you can instead install Thrift 0.14.1 with `brew` and ensure that it comes first in your `PATH`.

```
brew install thrift@0.13
export PATH="/usr/local/opt/thrift@0.13.0/bin:$PATH"
brew install thrift
export PATH="/usr/local/opt/thrift@0.14.1/bin:$PATH"
```

### Build Parquet with Maven
Expand Down
2 changes: 1 addition & 1 deletion dev/ci-before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# This script gets invoked by the CI system in a "before install" step
################################################################################

export THRIFT_VERSION=0.13.0
export THRIFT_VERSION=0.14.1

set -e
date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class CliUtils {
* @throws IOException if any Thrift error occurs during the serialization
*/
public static String toJson(TBase<?, ?> tbase) throws IOException {
TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
try {
TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
return serializer.toString(tbase);
} catch (TException e) {
// Wrapping the exception the not to expose the shaded Thrift class TException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,9 @@ public String toString() {
return delegate.toString();
}

@Override
public int getMinSerializedSize(byte type) throws TException {
return delegate.getMinSerializedSize(type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TMemoryBuffer;
import org.apache.thrift.transport.TTransportException;
import org.apache.parquet.format.event.Consumers.Consumer;
import org.apache.parquet.format.event.Consumers.DelegatingFieldConsumer;
import org.apache.parquet.format.event.EventBasedThriftReader;
Expand Down Expand Up @@ -336,11 +337,11 @@ public void consume(RowGroup rowGroup) {
}
}

private static TProtocol protocol(OutputStream to) {
private static TProtocol protocol(OutputStream to) throws TTransportException {
return protocol(new TIOStreamTransport(to));
}

private static TProtocol protocol(InputStream from) {
private static TProtocol protocol(InputStream from) throws TTransportException {
return protocol(new TIOStreamTransport(from));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.parquet.hadoop.BadConfigurationException;
Expand Down Expand Up @@ -156,7 +157,7 @@ public WriteContext init(Configuration configuration) {
}
}

private TProtocol protocol(BytesWritable record) {
private TProtocol protocol(BytesWritable record) throws TTransportException {
TProtocol protocol = protocolFactory.getProtocol(new TIOStreamTransport(new ByteArrayInputStream(record.getBytes())));

/* Reduce the chance of OOM when data is corrupted. When readBinary is called on TBinaryProtocol, it reads the length of the binary first,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ public String readString() throws TException {
public ByteBuffer readBinary() throws TException {
return null;
}

@Override
public int getMinSerializedSize(byte type) throws TException {
return 0;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,9 @@ public ByteBuffer readBinary() throws TException {
throw exception();
}

@Override
public int getMinSerializedSize(byte type) throws TException {
throw exception();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TField;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransportException;
import org.junit.Test;
import org.apache.parquet.thrift.test.Phone;
import org.apache.parquet.thrift.test.StructWithExtraField;
Expand Down Expand Up @@ -358,11 +359,11 @@ public void handleFieldIgnored(TField field) {
assertEquals(1, countingHandler.fieldIgnoredCount);
}

private TCompactProtocol protocol(OutputStream to) {
private TCompactProtocol protocol(OutputStream to) throws TTransportException {
return new TCompactProtocol(new TIOStreamTransport(to));
}

private TCompactProtocol protocol(InputStream from) {
private TCompactProtocol protocol(InputStream from) throws TTransportException {
return new TCompactProtocol(new TIOStreamTransport(from));
}

Expand Down
13 changes: 3 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<parquet.format.version>2.8.0</parquet.format.version>
<previous.version>1.12.0</previous.version>
<thrift.executable>thrift</thrift.executable>
<format.thrift.executable>thrift</format.thrift.executable>
<format.thrift.executable>${thrift.executable}</format.thrift.executable>
<scala.version>2.12.8</scala.version>
<!-- scala.binary.version is used for projects that fetch dependencies that are in scala -->
<scala.binary.version>2.12</scala.binary.version>
Expand All @@ -94,8 +94,8 @@
<pig.version>0.16.0</pig.version>
<pig.classifier>h2</pig.classifier>
<thrift-maven-plugin.version>0.10.0</thrift-maven-plugin.version>
<thrift.version>0.13.0</thrift.version>
<format.thrift.version>0.13.0</format.thrift.version>
<thrift.version>0.14.1</thrift.version>
<format.thrift.version>${thrift.version}</format.thrift.version>
<fastutil.version>8.4.2</fastutil.version>
<semver.api.version>0.9.33</semver.api.version>
<slf4j.version>1.7.22</slf4j.version>
Expand Down Expand Up @@ -586,13 +586,6 @@
</build>
</profile>

<profile>
<id>thrift9</id>
<properties>
<thrift.version>0.9.0</thrift.version>
</properties>
</profile>

<!-- Profile for CI tests to have less output -->
<profile>
<id>ci-test</id>
Expand Down

0 comments on commit d23a9a7

Please sign in to comment.