Skip to content

Commit

Permalink
[CARBONDATA-4349] Upgrade thrift version (#4355)
Browse files Browse the repository at this point in the history
* upgrade thrift version

* change to use 0.20.0

---------

Co-authored-by: jacky <[email protected]>
  • Loading branch information
jackylk and jacky authored Jun 30, 2024
1 parent 5ff36b6 commit f370d20
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransportException;

/**
* A simple class for reading Thrift objects (of a single type) from a fileName.
Expand Down Expand Up @@ -89,7 +90,11 @@ public ThriftReader(String fileName, Configuration configuration) {
*/
public ThriftReader(byte[] fileData) {
dataInputStream = new DataInputStream(new ByteArrayInputStream(fileData));
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
try {
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
} catch (TTransportException e) {
throw new RuntimeException(e);
}
}

/**
Expand All @@ -98,7 +103,11 @@ public ThriftReader(byte[] fileData) {
public void open() throws IOException {
Configuration conf = configuration != null ? configuration : FileFactory.getConfiguration();
dataInputStream = FileFactory.getDataInputStream(fileName, conf);
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
try {
binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
} catch (TTransportException e) {
throw new IOException(e);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1413,8 +1413,8 @@ public static String convertToString(List<Segment> values) {
public static byte[] getByteArray(TBase t) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
byte[] thriftByteArray = null;
TProtocol binaryOut = new TCompactProtocol(new TIOStreamTransport(stream));
try {
TProtocol binaryOut = new TCompactProtocol(new TIOStreamTransport(stream));
t.write(binaryOut);
stream.flush();
thriftByteArray = stream.toByteArray();
Expand All @@ -1439,9 +1439,9 @@ public static DataChunk3 readDataChunk3(ByteBuffer dataChunkBuffer, int offset,

public static DataChunk3 readDataChunk3(InputStream stream) throws IOException {
TBaseCreator creator = DataChunk3::new;
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
TBase t = creator.create();
try {
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
t.read(binaryIn);
} catch (TException e) {
throw new IOException(e);
Expand All @@ -1461,9 +1461,9 @@ public static DataChunk3 readDataChunk3(InputStream stream) throws IOException {
private static TBase read(byte[] data, TBaseCreator creator, int offset, int length)
throws IOException {
ByteArrayInputStream stream = new ByteArrayInputStream(data, offset, length);
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
TBase t = creator.create();
try {
TProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(stream));
t.read(binaryIn);
} catch (TException e) {
throw new IOException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransportException;

/**
* Simple class that makes it easy to write Thrift objects to disk.
Expand Down Expand Up @@ -80,7 +81,11 @@ public ThriftWriter(String fileName, boolean append) {
*/
public void open() throws IOException {
dataOutputStream = FileFactory.getDataOutputStream(fileName, bufferSize, append);
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
try {
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
} catch (TTransportException e) {
throw new IOException(e);
}
}

/**
Expand All @@ -92,7 +97,11 @@ public void open() throws IOException {
public void open(FileWriteOperation fileWriteOperation) throws IOException {
atomicFileOperationsWriter = AtomicFileOperationFactory.getAtomicFileOperations(fileName);
dataOutputStream = atomicFileOperationsWriter.openForWrite(fileWriteOperation);
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
try {
binaryOut = new TCompactProtocol(new TIOStreamTransport(dataOutputStream));
} catch (TTransportException e) {
throw new IOException(e);
}
}

/**
Expand Down
9 changes: 7 additions & 2 deletions format/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.9.3</version>
<version>0.20.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -77,4 +82,4 @@
</profile>
</profiles>

</project>
</project>
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
<properties>
<!-- default properties-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<snappy.version>1.1.2.6</snappy.version>
<hadoop.version>2.7.2</hadoop.version>
<httpclient.version>4.3.4</httpclient.version>
Expand Down

0 comments on commit f370d20

Please sign in to comment.