long next = Entry.nextAddress(entryAddr, mem); long newBinAddr = binAddress(hash, newTblAddr, newCap);
long next = Entry.nextAddress(entryAddr, mem); long newBinAddr = binAddress(hash, newTblAddr, newCap);
/** * @param initCap Initial capacity. * @param size Size. */ private void init(long initCap, int size) { long c = initCap / size; if (c < MIN_SIZE) c = MIN_SIZE; if (c * size < initCap) ++c; int cap = 1; while (cap < c) cap <<= 1; for (int i = 0; i < size; i++) { try { segs[i] = new Segment(i, cap); } catch (GridOffHeapOutOfMemoryException e) { destruct(); throw e; } } }
/** {@inheritDoc} */ @Override public boolean contains(int hash, byte[] keyBytes) { return segmentFor(hash).contains(hash, keyBytes); }
/** {@inheritDoc} */ @Override public void insert(int hash, byte[] keyBytes, byte[] valBytes) { segmentFor(hash).insert(hash, keyBytes, valBytes); }
/** {@inheritDoc} */ @Override public byte[] get(int hash, byte[] keyBytes) { return segmentFor(hash).get(hash, keyBytes); }
/** * Acquires write lock and returns bin address for given hash code. * * @param hash Hash code. * @return Locked bin address. */ @SuppressWarnings("LockAcquiredButNotSafelyReleased") private long writeLock(int hash) { lock.writeLock().lock(); // Get bin address inside the lock. return binAddress(hash); }
private void advance() throws IgniteCheckedException { curIt = null; while (idx < segs.length) { curIt = segs[idx++].iterator(c); if (curIt.hasNext()) return; else curIt.close(); } curIt = null; }
/** * @param hash Hash. * @param tblPtr Table pointer. * @param cap Capacity. * @return Bin address. */ long binAddress(int hash, long tblPtr, long cap) { return tblPtr + binIndex(hash, cap) * 8; }
/** {@inheritDoc} */ @Override public void enableEviction(int hash, byte[] keyBytes) { assert lru != null; segmentFor(hash).enableEviction(hash, keyBytes); }
/** * @param hash Hash. * @return Memory address for the bin. */ long binAddress(int hash) { return binAddress(hash, tblAddr, cap); }
/** {@inheritDoc} */ @Override public long size() { long size = 0; for (int i = 0; i < segs.length; i++) size += segs[i].count(); return size; }
/** * Acquires read lock abd returns bin address for given hash code. * * @param hash Hash code. * @return Locked bin address. */ @SuppressWarnings("LockAcquiredButNotSafelyReleased") private long readLock(int hash) { lock.readLock().lock(); // Get bin address inside the lock. return binAddress(hash); }
/** {@inheritDoc} */ @Override public void destruct() { for (Segment seg : segs) { if (seg != null) seg.destruct(); } if (lru != null && lruRelease) lru.destruct(); }
private void advance() throws IgniteCheckedException { curIt = null; while (idx < segs.length) { curIt = segs[idx++].iterator(); if (curIt.hasNext()) return; else curIt.close(); } curIt = null; }
/** * @param initCap Initial capacity. * @param size Size. */ private void init(long initCap, int size) { long c = initCap / size; if (c < MIN_SIZE) c = MIN_SIZE; if (c * size < initCap) ++c; int cap = 1; while (cap < c) cap <<= 1; for (int i = 0; i < size; i++) { try { segs[i] = new Segment(i, cap); } catch (GridOffHeapOutOfMemoryException e) { destruct(); throw e; } } }
/** {@inheritDoc} */ @Override public boolean contains(int hash, byte[] keyBytes) { return segmentFor(hash).contains(hash, keyBytes); }
/** {@inheritDoc} */ @Override public void insert(int hash, byte[] keyBytes, byte[] valBytes) { segmentFor(hash).insert(hash, keyBytes, valBytes); }
private void advance() throws IgniteCheckedException { curIt = null; while (idx < segs.length) { curIt = segs[idx++].iterator(); if (curIt.hasNext()) return; else curIt.close(); } curIt = null; }
/** {@inheritDoc} */ @Override public byte[] get(int hash, byte[] keyBytes) { return segmentFor(hash).get(hash, keyBytes); }