this.in = new DataInputStream(in);
// Check magic number
byte[] magicNumber = IOUtil.readBytes(in, MAGIC_NUMBER.length);
if (!Arrays.equals(magicNumber, MAGIC_NUMBER)) {
throw new QueryResultParseException("File does not contain a binary RDF table result");
}
// Check format version (parser is backward-compatible with version 1, 2
// and 3)
formatVersion = this.in.readInt();
if (formatVersion > FORMAT_VERSION || formatVersion < 1) {
throw new QueryResultParseException("Incompatible format version: " + formatVersion);
}
if (formatVersion == 2) {
// read FLAG byte (ordered and distinct flags) and ignore it
this.in.readByte();
}
// Read column headers
int columnCount = this.in.readInt();
if (columnCount < 0) {
throw new QueryResultParseException("Illegal column count specified: " + columnCount);
}
List<String> columnHeaders = new ArrayList<String>(columnCount);
for (int i = 0; i < columnCount; i++) {
columnHeaders.add(readString());