use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.
the class BookKeeperDataStorageManager method readIndexStatusFromFile.
public IndexStatus readIndexStatusFromFile(byte[] fileContent, String checkpointsFile) throws DataStorageManagerException {
try {
if (fileContent == null) {
throw new DataStorageManagerException("Missing znode for " + checkpointsFile + " IndexStatusFile");
}
XXHash64Utils.verifyBlockWithFooter(fileContent, 0, fileContent.length);
try (InputStream input = new SimpleByteArrayInputStream(fileContent);
ExtendedDataInputStream dataIn = new ExtendedDataInputStream(input)) {
// version
long version = dataIn.readVLong();
// flags for future implementations
long flags = dataIn.readVLong();
if (version != 1 || flags != 0) {
throw new DataStorageManagerException("corrupted index status file " + checkpointsFile);
}
return IndexStatus.deserialize(dataIn);
}
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.
the class BookKeeperDataStorageManager method readLogSequenceNumberFromTablesMetadataFile.
private static LogSequenceNumber readLogSequenceNumberFromTablesMetadataFile(String tableSpace, byte[] data, String znode) throws DataStorageManagerException {
try (InputStream input = new ByteArrayInputStream(data);
ExtendedDataInputStream din = new ExtendedDataInputStream(input)) {
// version
long version = din.readVLong();
// flags for future implementations
long flags = din.readVLong();
if (version != 1 || flags != 0) {
throw new DataStorageManagerException("corrupted table list znode" + znode);
}
String readname = din.readUTF();
if (!readname.equals(tableSpace)) {
throw new DataStorageManagerException("znode " + znode + " is not for spablespace " + tableSpace);
}
long ledgerId = din.readZLong();
long offset = din.readZLong();
return new LogSequenceNumber(ledgerId, offset);
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.
the class BookKeeperDataStorageManager method readLogSequenceNumberFromCheckpointInfoFile.
private static LogSequenceNumber readLogSequenceNumberFromCheckpointInfoFile(String tableSpace, byte[] data, String checkPointFile) throws DataStorageManagerException, IOException {
try (InputStream input = new ByteArrayInputStream(data);
ExtendedDataInputStream din = new ExtendedDataInputStream(input)) {
// version
long version = din.readVLong();
// flags for future implementations
long flags = din.readVLong();
if (version != 1 || flags != 0) {
throw new IOException("corrupted checkpoint file");
}
String readname = din.readUTF();
if (!readname.equals(tableSpace)) {
throw new DataStorageManagerException("zonde " + checkPointFile + " is not for spablespace " + tableSpace + " but for " + readname);
}
long ledgerId = din.readZLong();
long offset = din.readZLong();
return new LogSequenceNumber(ledgerId, offset);
}
}
Aggregations