public ELFSection(MappedByteBuffer fmap) { sh_name = fmap.getInt(); sh_type = fmap.getInt(); sh_flags = fmap.getInt(); sh_addr = fmap.getInt(); sh_offset = fmap.getInt(); sh_size = fmap.getInt(); sh_link = fmap.getInt(); sh_info = fmap.getInt(); sh_addralign = fmap.getInt(); sh_entsize = fmap.getInt(); }
public int getInt(long index) { return buf.getInt((int) index); }
int getInt(long index) { return dumpBuffer.getInt((int) index); }
@Override public int readInt(int offset) { assert buffer != null; return buffer.getInt((int) (start + offset)); }
@Override public int readInt() { assert buffer != null; int i = buffer.getInt((int) position); position += 4; return i; }
static long memoryMapped() { long start = System.currentTimeMillis(); long sum = 0; for (int i = 0; i < readIndices.length; i++) { sum += mmappedByteBuffer.getInt(readIndices[i] * 4); } long end = System.currentTimeMillis(); System.out.println("memory mapped time:" + (end - start)); return sum; }
@NoWarning("RCN,NP") public int foo() throws IOException { try (FileChannel c = open()) { final MappedByteBuffer mb = c.map(MapMode.READ_ONLY, 0L, c.size()); return mb.getInt(); } }
@Override public DmaIdList build(String filename) { try { File file = new File(filename); if (!file.exists()) { //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); //noinspection ResultOfMethodCallIgnored file.createNewFile(); try (RandomAccessFile raf = new RandomAccessFile(new File(filename), "rw")) { raf.setLength(DmaIdList.META_DATA_SIZE + defaultCapacity * DmaIdList.SIZE_OF_DATA); } } try (RandomAccessFile raf = new RandomAccessFile(new File(filename), "rw")) { FileChannel channel = raf.getChannel(); MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, raf.length()); int numRecords = buffer.getInt(); int capacity = (int) (raf.length() - DmaIdList.META_DATA_SIZE) / DmaIdList.SIZE_OF_DATA; buffer.position(DmaIdList.META_DATA_SIZE + numRecords * DmaIdList.SIZE_OF_DATA); return new DmaIdList(filename, buffer, numRecords, capacity); } } catch (IOException e) { throw new RuntimeException(e); } } }
int getInt(long index) { return dumpBuffer[getBufferIndex(index)].getInt(getBufferOffset(index)); }
public int getInt(long index) { return dumpBuffer[getBufferIndex(index)].getInt(getBufferOffset(index)); }
private void checkStartIndex() { this.header.position(IDENTIFIER.length + 2 + 1); int start = this.header.getInt(); if (start == IDENTIFIER.length + 2 + 1 + 8) { // ignore } else if (start == 0) { this.header.position(IDENTIFIER.length + 2 + 1); this.header.putInt(IDENTIFIER.length + 2 + 1 + 8); } else { throw new IllegalStateException(); } }
private int checkEndIndex() { this.header.position(IDENTIFIER.length + 2 + 1 + 4); int end = this.header.getInt(); if (end == 0) { this.header.position(IDENTIFIER.length + 2 + 1 + 4); this.header.putInt(IDENTIFIER.length + 2 + 1 + 8); return IDENTIFIER.length + 2 + 1 + 8; } else if (end < CONSTANTS_START_INDEX) { throw new IllegalStateException(); } else { return end; } }
if (directoryMap.getInt(currentOffset) != kCDESignature) { Log.w(LOG_TAG, "Missed a central dir sig (at " + currentOffset + ")"); ze.mWhenModified = directoryMap.getInt(currentOffset + kCDEModWhen) & 0xffffffffL; ze.mCRC32 = directoryMap.getLong(currentOffset + kCDECRC) & 0xffffffffL; ze.mCompressedLength = directoryMap.getLong(currentOffset ze.mUncompressedLength = directoryMap.getLong(currentOffset + kCDEUncompLen) & 0xffffffffL; ze.mLocalHdrOffset = directoryMap.getInt(currentOffset + kCDELocalOffset) & 0xffffffffL;
if (directoryMap.getInt(currentOffset) != kCDESignature) { Log.w(LOG_TAG, "Missed a central dir sig (at " + currentOffset + ")"); ze.mWhenModified = directoryMap.getInt(currentOffset + kCDEModWhen) & 0xffffffffL; ze.mCRC32 = directoryMap.getLong(currentOffset + kCDECRC) & 0xffffffffL; ze.mCompressedLength = directoryMap.getLong(currentOffset ze.mUncompressedLength = directoryMap.getLong(currentOffset + kCDEUncompLen) & 0xffffffffL; ze.mLocalHdrOffset = directoryMap.getInt(currentOffset + kCDELocalOffset) & 0xffffffffL;
int slotValue = this.mappedByteBuffer.getInt(absSlotPos); + nextIndexToRead * indexSize; int keyHashRead = this.mappedByteBuffer.getInt(absIndexPos); long phyOffsetRead = this.mappedByteBuffer.getLong(absIndexPos + 4); long timeDiff = (long) this.mappedByteBuffer.getInt(absIndexPos + 4 + 8); int prevIndexRead = this.mappedByteBuffer.getInt(absIndexPos + 4 + 8 + 4);
public ELFHeader(MappedByteBuffer fmap) throws IllegalArgumentException { if (fmap.get(ELFIdentification.EI_MAG0.value()) != 0x7f || fmap.get(ELFIdentification.EI_MAG1.value()) != 'E' || fmap.get(ELFIdentification.EI_MAG2.value()) != 'L' || fmap.get(ELFIdentification.EI_MAG3.value()) != 'F') { throw new IllegalArgumentException("Not an ELF file"); } ei_class = EI_Class.valueOf(fmap.get(ELFIdentification.EI_CLASS.value())); ei_data = EI_Data.valueOf(fmap.get(ELFIdentification.EI_DATA.value())); ei_version = fmap.get(ELFIdentification.EI_VERSION.value()); if (ei_data == EI_Data.ELFDATA2LSB) { fmap.order(ByteOrder.LITTLE_ENDIAN); } else { fmap.order(ByteOrder.BIG_ENDIAN); } fmap.position(ELFIdentification.EI_NIDENT.value()); e_type = E_Type.valueOf(fmap.getShort()); e_machine = E_Machine.valueOf(fmap.getShort()); e_version = E_Version.valueOf(fmap.getInt()); e_entry = fmap.getInt(); e_phoff = fmap.getInt(); e_shoff = fmap.getInt(); e_flags = fmap.getInt(); e_ehsize = fmap.getShort(); e_phentsize = fmap.getShort(); e_phnum = fmap.getShort(); e_shentsize = fmap.getShort(); e_shnum = fmap.getShort(); e_shstrndx = fmap.getShort(); }
int slotValue = this.mappedByteBuffer.getInt(absSlotPos); if (slotValue <= invalidIndex || slotValue > this.indexHeader.getIndexCount()) { slotValue = invalidIndex;
private void pageIn() throws IndexOutOfBoundsException { if (!pagedIn) { // Map the memory region MappedByteBuffer buffer = spillFile.getPage(pageIndex); int numElements = buffer.getInt(); for (int i = 0; i < numElements; i++) { int kvSize = buffer.getInt(); byte[] data = new byte[kvSize]; buffer.get(data, 0, kvSize); try { pageMap.put(SpillManager.getKey(data), data); totalResultSize += (data.length + Bytes.SIZEOF_INT); } catch (IOException ioe) { // Error during key access on spilled resource // TODO rework error handling throw new RuntimeException(ioe); } } pagedIn = true; dirtyPage = false; } }
private void pageIn() throws IndexOutOfBoundsException { if (!pagedIn) { // Map the memory region MappedByteBuffer buffer = spillFile.getPage(pageIndex); int numElements = buffer.getInt(); for (int i = 0; i < numElements; i++) { int kvSize = buffer.getInt(); byte[] data = new byte[kvSize]; buffer.get(data, 0, kvSize); try { pageMap.put(SpillManager.getKey(data), data); totalResultSize += (data.length + Bytes.SIZEOF_INT); } catch (IOException ioe) { // Error during key access on spilled resource // TODO rework error handling throw new RuntimeException(ioe); } } pagedIn = true; dirtyPage = false; } }
@Override protected Tuple readFromBuffer(MappedByteBuffer buffer) { int length = buffer.getInt(); if (length < 0) return null; byte[] b = new byte[length]; buffer.get(b); Result result = ResultUtil.toResult(new ImmutableBytesWritable(b)); return new ResultTuple(result); }