Skip to content

Commit f370d20

Browse files
Jacky Lijackylk
Jacky Li
andauthored
[CARBONDATA-4349] Upgrade thrift version (#4355)
* upgrade thrift version * change to use 0.20.0 --------- Co-authored-by: jacky <[email protected]>
1 parent 5ff36b6 commit f370d20

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

core/src/main/java/org/apache/carbondata/core/reader/ThriftReader.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.thrift.protocol.TCompactProtocol;
3232
import org.apache.thrift.protocol.TProtocol;
3333
import org.apache.thrift.transport.TIOStreamTransport;
34+
import org.apache.thrift.transport.TTransportException;
3435

3536
/**
3637
* A simple class for reading Thrift objects (of a single type) from a fileName.
@@ -89,7 +90,11 @@ public ThriftReader(String fileName, Configuration configuration) {
8990
*/
9091
public ThriftReader(byte[] fileData) {
9192
dataInputStream = new DataInputStream(new ByteArrayInputStream(fileData));
92-
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
93+
try {
94+
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
95+
} catch (TTransportException e) {
96+
throw new RuntimeException(e);
97+
}
9398
}
9499

95100
/**
@@ -98,7 +103,11 @@ public ThriftReader(byte[] fileData) {
98103
public void open() throws IOException {
99104
Configuration conf = configuration != null ? configuration : FileFactory.getConfiguration();
100105
dataInputStream = FileFactory.getDataInputStream(fileName, conf);
101-
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
106+
try {
107+
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
108+
} catch (TTransportException e) {
109+
throw new IOException(e);
110+
}
102111
}
103112

104113
/**

core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1413,8 +1413,8 @@ public static String convertToString(List<Segment> values) {
14131413
public static byte[] getByteArray(TBase t) {
14141414
ByteArrayOutputStream stream = new ByteArrayOutputStream();
14151415
byte[] thriftByteArray = null;
1416-
TProtocol binaryOut = new TCompactProtocol(new TIOStreamTransport(stream));
14171416
try {
1417+
TProtocol binaryOut = new TCompactProtocol(new TIOStreamTransport(stream));
14181418
t.write(binaryOut);
14191419
stream.flush();
14201420
thriftByteArray = stream.toByteArray();
@@ -1439,9 +1439,9 @@ public static DataChunk3 readDataChunk3(ByteBuffer dataChunkBuffer, int offset,
14391439

14401440
public static DataChunk3 readDataChunk3(InputStream stream) throws IOException {
14411441
TBaseCreator creator = DataChunk3::new;
1442-
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
14431442
TBase t = creator.create();
14441443
try {
1444+
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
14451445
t.read(binaryIn);
14461446
} catch (TException e) {
14471447
throw new IOException(e);
@@ -1461,9 +1461,9 @@ public static DataChunk3 readDataChunk3(InputStream stream) throws IOException {
14611461
private static TBase read(byte[] data, TBaseCreator creator, int offset, int length)
14621462
throws IOException {
14631463
ByteArrayInputStream stream = new ByteArrayInputStream(data, offset, length);
1464-
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
14651464
TBase t = creator.create();
14661465
try {
1466+
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
14671467
t.read(binaryIn);
14681468
} catch (TException e) {
14691469
throw new IOException(e);

core/src/main/java/org/apache/carbondata/core/writer/ThriftWriter.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.thrift.protocol.TCompactProtocol;
3232
import org.apache.thrift.protocol.TProtocol;
3333
import org.apache.thrift.transport.TIOStreamTransport;
34+
import org.apache.thrift.transport.TTransportException;
3435

3536
/**
3637
* Simple class that makes it easy to write Thrift objects to disk.
@@ -80,7 +81,11 @@ public ThriftWriter(String fileName, boolean append) {
8081
*/
8182
public void open() throws IOException {
8283
dataOutputStream = FileFactory.getDataOutputStream(fileName, bufferSize, append);
83-
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
84+
try {
85+
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
86+
} catch (TTransportException e) {
87+
throw new IOException(e);
88+
}
8489
}
8590

8691
/**
@@ -92,7 +97,11 @@ public void open() throws IOException {
9297
public void open(FileWriteOperation fileWriteOperation) throws IOException {
9398
atomicFileOperationsWriter = AtomicFileOperationFactory.getAtomicFileOperations(fileName);
9499
dataOutputStream = atomicFileOperationsWriter.openForWrite(fileWriteOperation);
95-
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
100+
try {
101+
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
102+
} catch (TTransportException e) {
103+
throw new IOException(e);
104+
}
96105
}
97106

98107
/**

format/pom.xml

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
<dependency>
3838
<groupId>org.apache.thrift</groupId>
3939
<artifactId>libthrift</artifactId>
40-
<version>0.9.3</version>
40+
<version>0.20.0</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>javax.annotation</groupId>
44+
<artifactId>javax.annotation-api</artifactId>
45+
<version>1.3.2</version>
4146
</dependency>
4247
</dependencies>
4348

@@ -77,4 +82,4 @@
7782
</profile>
7883
</profiles>
7984

80-
</project>
85+
</project>

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
<properties>
123123
<!-- default properties-->
124124
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
125+
<maven.compiler.source>8</maven.compiler.source>
126+
<maven.compiler.target>8</maven.compiler.target>
125127
<snappy.version>1.1.2.6</snappy.version>
126128
<hadoop.version>2.7.2</hadoop.version>
127129
<httpclient.version>4.3.4</httpclient.version>

0 commit comments

Comments
 (0)