private VersionValue getUnderLock(final BytesRef uid, Maps currentMaps) { assert assertKeyedLockHeldByCurrentThread(uid); // First try to get the "live" value: VersionValue value = currentMaps.current.get(uid); if (value != null) { return value; } value = currentMaps.old.get(uid); if (value != null) { return value; } return tombstones.get(uid); }
/** * Adds this uid/version to the pending adds map iff the map needs safe access. */ void maybePutIndexUnderLock(BytesRef uid, IndexVersionValue version) { assert assertKeyedLockHeldByCurrentThread(uid); Maps maps = this.maps; if (maps.isSafeAccessMode()) { putIndexUnderLock(uid, version); } else { // Even though we don't store a record of the indexing operation (and mark as unsafe), // we should still remove any previous delete for this uuid (avoid accidental accesses). // Not this should not hurt performance because the tombstone is small (or empty) when unsafe is relevant. removeTombstoneUnderLock(uid); maps.current.markAsUnsafe(); assert putAssertionMap(uid, version); } }
Maps() { this(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency()), VersionLookup.EMPTY, false); }
/** * Adds this uid/version to the pending adds map iff the map needs safe access. */ void maybePutIndexUnderLock(BytesRef uid, IndexVersionValue version) { assert assertKeyedLockHeldByCurrentThread(uid); Maps maps = this.maps; if (maps.isSafeAccessMode()) { putIndexUnderLock(uid, version); } else { // Even though we don't store a record of the indexing operation (and mark as unsafe), // we should still remove any previous delete for this uuid (avoid accidental accesses). // Not this should not hurt performance because the tombstone is small (or empty) when unsafe is relevant. removeTombstoneUnderLock(uid); maps.current.markAsUnsafe(); assert putAssertionMap(uid, version); } }
private VersionValue getUnderLock(final BytesRef uid, Maps currentMaps) { assert assertKeyedLockHeldByCurrentThread(uid); // First try to get the "live" value: VersionValue value = currentMaps.current.get(uid); if (value != null) { return value; } value = currentMaps.old.get(uid); if (value != null) { return value; } return tombstones.get(uid); }
void put(BytesRef uid, VersionValue version) { long uidRAMBytesUsed = BASE_BYTES_PER_BYTESREF + uid.bytes.length; long ramAccounting = BASE_BYTES_PER_CHM_ENTRY + version.ramBytesUsed() + uidRAMBytesUsed; VersionValue previousValue = current.put(uid, version); ramAccounting += previousValue == null ? 0 : -(BASE_BYTES_PER_CHM_ENTRY + previousValue.ramBytesUsed() + uidRAMBytesUsed); adjustRam(ramAccounting); }
void put(BytesRef uid, VersionValue version) { long uidRAMBytesUsed = BASE_BYTES_PER_BYTESREF + uid.bytes.length; long ramAccounting = BASE_BYTES_PER_CHM_ENTRY + version.ramBytesUsed() + uidRAMBytesUsed; VersionValue previousValue = current.put(uid, version); ramAccounting += previousValue == null ? 0 : -(BASE_BYTES_PER_CHM_ENTRY + previousValue.ramBytesUsed() + uidRAMBytesUsed); adjustRam(ramAccounting); }
Maps() { this(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency()), VersionLookup.EMPTY, false); }
void remove(BytesRef uid, DeleteVersionValue deleted) { VersionValue previousValue = current.remove(uid); current.updateMinDeletedTimestamp(deleted); if (previousValue != null) { long uidRAMBytesUsed = BASE_BYTES_PER_BYTESREF + uid.bytes.length; adjustRam(-(BASE_BYTES_PER_CHM_ENTRY + previousValue.ramBytesUsed() + uidRAMBytesUsed)); } if (old != VersionLookup.EMPTY) { // we also need to remove it from the old map here to make sure we don't read this stale value while // we are in the middle of a refresh. Most of the time the old map is an empty map so we can skip it there. old.remove(uid); } }
void remove(BytesRef uid, DeleteVersionValue deleted) { VersionValue previousValue = current.remove(uid); current.updateMinDeletedTimestamp(deleted); if (previousValue != null) { long uidRAMBytesUsed = BASE_BYTES_PER_BYTESREF + uid.bytes.length; adjustRam(-(BASE_BYTES_PER_CHM_ENTRY + previousValue.ramBytesUsed() + uidRAMBytesUsed)); } if (old != VersionLookup.EMPTY) { // we also need to remove it from the old map here to make sure we don't read this stale value while // we are in the middle of a refresh. Most of the time the old map is an empty map so we can skip it there. old.remove(uid); } }
/** * Builds a new map for the refresh transition this should be called in beforeRefresh() */ Maps buildTransitionMap() { return new Maps(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(current.size())), current, shouldInheritSafeAccess()); }
/** * Builds a new map for the refresh transition this should be called in beforeRefresh() */ Maps buildTransitionMap() { return new Maps(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(current.size())), current, shouldInheritSafeAccess()); }
/** * Adds this uid/version to the pending adds map iff the map needs safe access. */ void maybePutIndexUnderLock(BytesRef uid, IndexVersionValue version) { assert assertKeyedLockHeldByCurrentThread(uid); Maps maps = this.maps; if (maps.isSafeAccessMode()) { putIndexUnderLock(uid, version); } else { // Even though we don't store a record of the indexing operation (and mark as unsafe), // we should still remove any previous delete for this uuid (avoid accidental accesses). // Not this should not hurt performance because the tombstone is small (or empty) when unsafe is relevant. removeTombstoneUnderLock(uid); maps.current.markAsUnsafe(); assert putAssertionMap(uid, version); } }
private VersionValue getUnderLock(final BytesRef uid, Maps currentMaps) { assert assertKeyedLockHeldByCurrentThread(uid); // First try to get the "live" value: VersionValue value = currentMaps.current.get(uid); if (value != null) { return value; } value = currentMaps.old.get(uid); if (value != null) { return value; } return tombstones.get(uid); }
void remove(BytesRef uid, DeleteVersionValue deleted) { VersionValue previousValue = current.remove(uid); current.updateMinDeletedTimestamp(deleted); if (previousValue != null) { long uidRAMBytesUsed = BASE_BYTES_PER_BYTESREF + uid.bytes.length; adjustRam(-(BASE_BYTES_PER_CHM_ENTRY + previousValue.ramBytesUsed() + uidRAMBytesUsed)); } if (old != VersionLookup.EMPTY) { // we also need to remove it from the old map here to make sure we don't read this stale value while // we are in the middle of a refresh. Most of the time the old map is an empty map so we can skip it there. old.remove(uid); } }