use of org.apache.geode.cache.query.internal.index.IndexManager in project geode by apache.
the class EntryEventImpl method setNewValueInRegion.
@Retained(ENTRY_EVENT_NEW_VALUE)
private void setNewValueInRegion(final LocalRegion owner, final RegionEntry reentry, Object oldValueForDelta) throws RegionClearedException {
boolean wasTombstone = reentry.isTombstone();
// not be applied. This is possible if the event originated locally.
if (this.deltaBytes != null && this.newValue == null) {
processDeltaBytes(oldValueForDelta);
}
if (owner != null) {
owner.generateAndSetVersionTag(this, reentry);
} else {
this.region.generateAndSetVersionTag(this, reentry);
}
Object v = this.newValue;
if (v == null) {
v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID;
} else {
this.region.regionInvalid = false;
}
reentry.setValueResultOfSearch(this.op.isNetSearch());
// in the primary.
if (v instanceof org.apache.geode.Delta && region.isUsedForPartitionedRegionBucket()) {
int vSize;
Object ov = basicGetOldValue();
if (ov instanceof CachedDeserializable && !GemFireCacheImpl.DELTAS_RECALCULATE_SIZE) {
vSize = ((CachedDeserializable) ov).getValueSizeInBytes();
} else {
vSize = CachedDeserializableFactory.calcMemSize(v, region.getObjectSizer(), false);
}
v = CachedDeserializableFactory.create(v, vSize);
basicSetNewValue(v);
}
Object preparedV = reentry.prepareValueForCache(this.region, v, this, false);
if (preparedV != v) {
v = preparedV;
if (v instanceof StoredObject) {
if (!((StoredObject) v).isCompressed()) {
// fix bug 52109
// If we put it off heap and it is not compressed then remember that value.
// Otherwise we want to remember the decompressed value in the event.
basicSetNewValue(v);
}
}
}
boolean isTombstone = (v == Token.TOMBSTONE);
boolean success = false;
boolean calledSetValue = false;
try {
setNewValueBucketSize(owner, v);
if ((this.op.isUpdate() && !reentry.isInvalid()) || this.op.isInvalidate()) {
IndexManager idxManager = IndexUtils.getIndexManager(this.region, false);
if (idxManager != null) {
try {
idxManager.updateIndexes(reentry, IndexManager.REMOVE_ENTRY, this.op.isUpdate() ? IndexProtocol.BEFORE_UPDATE_OP : IndexProtocol.OTHER_OP);
} catch (QueryException e) {
throw new IndexMaintenanceException(e);
}
}
}
calledSetValue = true;
// already called prepareValueForCache
reentry.setValueWithTombstoneCheck(v, this);
success = true;
} finally {
if (!success && reentry instanceof OffHeapRegionEntry && v instanceof StoredObject) {
OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry) reentry, (StoredObject) v);
}
}
if (logger.isTraceEnabled()) {
if (v instanceof CachedDeserializable) {
logger.trace("EntryEventImpl.setNewValueInRegion: put CachedDeserializable({},{})", this.getKey(), ((CachedDeserializable) v).getStringForm());
} else {
logger.trace("EntryEventImpl.setNewValueInRegion: put({},{})", this.getKey(), StringUtils.forceToString(v));
}
}
if (!isTombstone && wasTombstone) {
owner.unscheduleTombstone(reentry);
}
}
Aggregations