@Test void testLocalHeap() { LocalHeap heap = new LocalHeap(hdfFc, 680); assertThat(heap.getVersion(), is(equalTo((short) 0))); assertThat(heap.getDataSegmentSize(), is(equalTo(88L))); assertThat(heap.getOffsetToHeadOfFreeList(), is(equalTo(56L))); assertThat(heap.getAddressOfDataSegment(), is(equalTo(712L))); assertThat(heap.toString(), is(equalTo( "LocalHeap [address=0x2a8, version=0, dataSegmentSize=88, offsetToHeadOfFreeList=56, addressOfDataSegment=0x2c8]"))); }
public LocalHeap(HdfFileChannel hdfFc, long address) { this.address = address; try { int headerSize = 8 + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfOffsets(); ByteBuffer header = hdfFc.readBufferFromAddress(address, headerSize); byte[] formatSignatureBytes = new byte[4]; header.get(formatSignatureBytes, 0, formatSignatureBytes.length); if (!Arrays.equals(HEAP_SIGNATURE, formatSignatureBytes)) { throw new HdfException("Heap signature not matched"); } version = header.get(); header.position(8); dataSegmentSize = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("dataSegmentSize = {}", dataSegmentSize); offsetToHeadOfFreeList = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("offsetToHeadOfFreeList = {}", offsetToHeadOfFreeList); addressOfDataSegment = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfOffsets()); logger.trace("addressOfDataSegment = {}", addressOfDataSegment); dataBuffer = hdfFc.map(addressOfDataSegment, dataSegmentSize); } catch (Exception e) { throw new HdfException("Error reading local heap", e); } }
LocalHeap { public LocalHeap(HdfFileChannel hdfFc, long address) { this.address = address; try { int headerSize = 8 + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfOffsets(); ByteBuffer header = hdfFc.readBufferFromAddress(address, headerSize); byte[] formatSignatureBytes = new byte[4]; header.get(formatSignatureBytes, 0, formatSignatureBytes.length); if (!Arrays.equals(HEAP_SIGNATURE, formatSignatureBytes)) { throw new HdfException("Heap signature not matched"); } version = header.get(); header.position(8); dataSegmentSize = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("dataSegmentSize = {}", dataSegmentSize); offsetToHeadOfFreeList = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("offsetToHeadOfFreeList = {}", offsetToHeadOfFreeList); addressOfDataSegment = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfOffsets()); logger.trace("addressOfDataSegment = {}", addressOfDataSegment); dataBuffer = hdfFc.map(addressOfDataSegment, dataSegmentSize); } catch (Exception e) { throw new HdfException("Error reading local heap", e); } } }
LocalHeap { public LocalHeap(HdfFileChannel hdfFc, long address) { this.address = address; try { int headerSize = 8 + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfOffsets(); ByteBuffer header = hdfFc.readBufferFromAddress(address, headerSize); byte[] formatSignatureBytes = new byte[4]; header.get(formatSignatureBytes, 0, formatSignatureBytes.length); if (!Arrays.equals(HEAP_SIGNATURE, formatSignatureBytes)) { throw new HdfException("Heap signature not matched"); } version = header.get(); header.position(8); dataSegmentSize = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("dataSegmentSize = {}", dataSegmentSize); offsetToHeadOfFreeList = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("offsetToHeadOfFreeList = {}", offsetToHeadOfFreeList); addressOfDataSegment = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfOffsets()); logger.trace("addressOfDataSegment = {}", addressOfDataSegment); dataBuffer = hdfFc.map(addressOfDataSegment, dataSegmentSize); } catch (Exception e) { throw new HdfException("Error reading local heap", e); } } LocalHeap(HdfFileChannel hdfFc, long address); }
LocalHeap { public LocalHeap(HdfFileChannel hdfFc, long address) { this.address = address; try { int headerSize = 8 + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfOffsets(); ByteBuffer header = hdfFc.readBufferFromAddress(address, headerSize); byte[] formatSignatureBytes = new byte[4]; header.get(formatSignatureBytes, 0, formatSignatureBytes.length); if (!Arrays.equals(HEAP_SIGNATURE, formatSignatureBytes)) { throw new HdfException("Heap signature not matched"); } version = header.get(); header.position(8); dataSegmentSize = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("dataSegmentSize = {}", dataSegmentSize); offsetToHeadOfFreeList = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("offsetToHeadOfFreeList = {}", offsetToHeadOfFreeList); addressOfDataSegment = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfOffsets()); logger.trace("addressOfDataSegment = {}", addressOfDataSegment); dataBuffer = hdfFc.map(addressOfDataSegment, dataSegmentSize); } catch (Exception e) { throw new HdfException("Error reading local heap", e); } } LocalHeap(HdfFileChannel hdfFc, long address); short getVersion(); long getDataSegmentSize(); long getOffsetToHeadOfFreeList(); long getAddressOfDataSegment(); @Override String toString(); ByteBuffer getDataBuffer(); }
LocalHeap { public LocalHeap(HdfFileChannel hdfFc, long address) { this.address = address; try { int headerSize = 8 + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfLengths() + hdfFc.getSizeOfOffsets(); ByteBuffer header = hdfFc.readBufferFromAddress(address, headerSize); byte[] formatSignatureBytes = new byte[4]; header.get(formatSignatureBytes, 0, formatSignatureBytes.length); if (!Arrays.equals(HEAP_SIGNATURE, formatSignatureBytes)) { throw new HdfException("Heap signature not matched"); } version = header.get(); header.position(8); dataSegmentSize = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("dataSegmentSize = {}", dataSegmentSize); offsetToHeadOfFreeList = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfLengths()); logger.trace("offsetToHeadOfFreeList = {}", offsetToHeadOfFreeList); addressOfDataSegment = Utils.readBytesAsUnsignedLong(header, hdfFc.getSizeOfOffsets()); logger.trace("addressOfDataSegment = {}", addressOfDataSegment); dataBuffer = hdfFc.map(addressOfDataSegment, dataSegmentSize); } catch (Exception e) { throw new HdfException("Error reading local heap", e); } } LocalHeap(HdfFileChannel hdfFc, long address); short getVersion(); long getDataSegmentSize(); long getOffsetToHeadOfFreeList(); long getAddressOfDataSegment(); @Override String toString(); ByteBuffer getDataBuffer();  }