/** * gets the refCount a given index, or returns 0, if the there is no mapping for this index * * @param index * @return the mapping at this {@code index} * @throws IndexOutOfBoundsException if the index is out of range */ public int getRefCount(long index) { try { for (MappedMemory m : maps) { if (m.index() == index) return m.refCount(); } } catch (Exception e) { return 0; } return 0; }
/** * gets the refCount a given index, or returns 0, if the there is no mapping for this index * * @param index * @return the mapping at this {@code index} * @throws IndexOutOfBoundsException if the index is out of range */ public int getRefCount(long index) { try { for (MappedMemory m : maps) { if (m.index() == index) return m.refCount(); } } catch (Exception e) { return 0; } return 0; }
public long toAddress0(long address) { int index = (int) ((address / chunkSize)); long remainder = address - (((long) index) * chunkSize); // index == 0 is the header, so we wont reference count the header if (mappedMemory != null && mappedMemory.index() != 0) mappedFile.release(mappedMemory); try { this.mappedMemory = mappedFile.acquire(index); } catch (IOException e) { throw new RuntimeException(e); } long result = mappedMemory.bytes().address() + remainder; this.offset = result - address; this.last = mask & address; return result; }
public long toAddress0(long address) { int index = (int) ((address / chunkSize)); long remainder = address - (((long) index) * chunkSize); // index == 0 is the header, so we wont reference count the header if (mappedMemory != null && mappedMemory.index() != 0) mappedFile.release(mappedMemory); try { this.mappedMemory = mappedFile.acquire(index); } catch (IOException e) { throw new RuntimeException(e); } long result = mappedMemory.bytes().address() + remainder; this.offset = result - address; this.last = mask & address; return result; }