|
@@ -210,7 +210,7 @@ hdf5.Variable = class {
|
|
|
switch (this._dataLayout.layoutClass) {
|
|
switch (this._dataLayout.layoutClass) {
|
|
|
case 1: // Contiguous
|
|
case 1: // Contiguous
|
|
|
if (this._dataLayout.address) {
|
|
if (this._dataLayout.address) {
|
|
|
- return this._reader.at(this._dataLayout.address).read(this._dataLayout.size);
|
|
|
|
|
|
|
+ return this._reader.at(this._dataLayout.address).stream(this._dataLayout.size);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 2: { // Chunked
|
|
case 2: { // Chunked
|
|
@@ -481,11 +481,26 @@ hdf5.BinaryReader = class extends hdf5.Reader {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ peek(length) {
|
|
|
|
|
+ const position = this._offset + this._position;
|
|
|
|
|
+ length = length !== undefined ? length : this._buffer.length - position;
|
|
|
|
|
+ this.take(length);
|
|
|
|
|
+ const buffer = this._buffer.subarray(position, position + length);
|
|
|
|
|
+ this._position = position - this._offset;
|
|
|
|
|
+ return buffer;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
read(length) {
|
|
read(length) {
|
|
|
const position = this.take(length);
|
|
const position = this.take(length);
|
|
|
return this._buffer.subarray(position, position + length);
|
|
return this._buffer.subarray(position, position + length);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ stream(length) {
|
|
|
|
|
+ const position = this.take(length);
|
|
|
|
|
+ const buffer = this._buffer.subarray(position, position + length);
|
|
|
|
|
+ return new hdf5.BinaryReader(buffer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
size(terminator) {
|
|
size(terminator) {
|
|
|
let position = this._offset + this._position;
|
|
let position = this._offset + this._position;
|
|
|
while (this._buffer[position] !== terminator) {
|
|
while (this._buffer[position] !== terminator) {
|
|
@@ -540,6 +555,12 @@ hdf5.StreamReader = class extends hdf5.Reader {
|
|
|
return this._stream.read(length);
|
|
return this._stream.read(length);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ stream(length) {
|
|
|
|
|
+ this._stream.seek(this._offset + this._position);
|
|
|
|
|
+ this.skip(length);
|
|
|
|
|
+ return this._stream.stream(length);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
byte() {
|
|
byte() {
|
|
|
const position = this.take(1);
|
|
const position = this.take(1);
|
|
|
return this._view.getUint8(position);
|
|
return this._view.getUint8(position);
|