use of herddb.utils.SimpleByteArrayInputStream in project herddb by diennea.
the class Index method deserialize.
@SuppressFBWarnings("OS_OPEN_STREAM")
public static Index deserialize(byte[] data) {
try {
SimpleByteArrayInputStream ii = new SimpleByteArrayInputStream(data);
ExtendedDataInputStream dii = new ExtendedDataInputStream(ii);
// version
long iversion = dii.readVLong();
// flags for future implementations
long iflags = dii.readVLong();
if (iversion != 1 || iflags != 0) {
throw new IOException("corrupted index file");
}
String tablespace = dii.readUTF();
String name = dii.readUTF();
String uuid = dii.readUTF();
String table = dii.readUTF();
// extensible for future implementations
int properties = dii.readVInt();
boolean unique = false;
if ((properties & PROPERTY_UNIQUE) == PROPERTY_UNIQUE) {
unique = true;
}
String type = dii.readUTF();
int ncols = dii.readVInt();
Column[] columns = new Column[ncols];
for (int i = 0; i < ncols; i++) {
// version
long cversion = dii.readVLong();
// flags for future implementations
long cflags = dii.readVLong();
if (cversion != 1 || cflags != 0) {
throw new IOException("corrupted index file");
}
String cname = dii.readUTF();
int ctype = dii.readVInt();
int serialPosition = dii.readVInt();
// for future implementations
dii.readVInt();
columns[i] = Column.column(cname, ctype, serialPosition);
}
return new Index(uuid, name, table, tablespace, type, columns, unique);
} catch (IOException err) {
throw new IllegalArgumentException(err);
}
}
use of herddb.utils.SimpleByteArrayInputStream in project herddb by diennea.
the class LedgersInfo method deserialize.
public static LedgersInfo deserialize(byte[] data, int zkVersion) {
if (data == null || data.length == 0) {
LedgersInfo info = new LedgersInfo();
info.setZkVersion(zkVersion);
return info;
}
try {
LedgersInfo info = MAPPER.readValue(new SimpleByteArrayInputStream(data), LedgersInfo.class);
info.setZkVersion(zkVersion);
return info;
} catch (IOException impossible) {
throw new RuntimeException(impossible);
}
}
use of herddb.utils.SimpleByteArrayInputStream 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);
}
}
Aggregations