Skip to content

Instantly share code, notes, and snippets.

@RebieKong
Created May 8, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RebieKong/6a3d2346900807a75fedcfde02b954b6 to your computer and use it in GitHub Desktop.
Save RebieKong/6a3d2346900807a75fedcfde02b954b6 to your computer and use it in GitHub Desktop.
import org.apache.carbondata.format.BlockIndex;
import org.apache.carbondata.format.FileFooter3;
import org.apache.carbondata.format.IndexHeader;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.transport.TIOStreamTransport;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class U {
public static void main(String... args) throws IOException {
FileInputStream fs = new FileInputStream("F:\\system.warehouse\\Desktop\\0_batchno0-0-1525773174010.carbonindex");
FileInputStream fs2 = new FileInputStream("F:\\system.warehouse\\Desktop\\part-0-0_batchno0-0-1525773174010.carbondata");
byte[] buffer = new byte[4096];
int q = fs.read(buffer);
DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(buffer));
TCompactProtocol binaryIn = new TCompactProtocol(new TIOStreamTransport(dataInputStream));
IndexHeader b = new IndexHeader();
BlockIndex cc = new BlockIndex();
FileFooter3 nn = new FileFooter3();
try {
b.read(binaryIn);
System.out.println("反序列化后的对象:" + b.toString());
cc.read(binaryIn);
System.out.println("反序列化后的对象:" +cc.toString());
fs2.skip(cc.offset);
byte[] buffer2 = new byte[8192];
int ttt = fs2.read(buffer2);
DataInputStream dataInputStream2 = new DataInputStream(new ByteArrayInputStream(buffer2));
TCompactProtocol binaryIn2 = new TCompactProtocol(new TIOStreamTransport(dataInputStream2));
nn.read(binaryIn2);
System.out.println("反序列化后的对象:" +nn.toString());
} catch (TException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment