class MapQuery<K, V, R> extends HashQuery<K>
        implements MapEntry<K, V>, ExternalMapQueryContext<K, V, R>,
        ExternalSetQueryContext<K, R>, QueryContextInterface<K, V, R>, MapAndSetContext<K, V, R> {

    @StageRef
    public AcquireHandle<K, V> acquireHandle;
    @StageRef
    public DefaultReturnValue<V> defaultReturnValue;
    @StageRef
    public UsingReturnValue<V> usingReturnValue;
    @StageRef
    public MapAbsent<K, V> absent;
    @StageRef
    VanillaChronicleMapHolder<K, V, R> mh;
    final DataAccess<V> innerInputValueDataAccess = mh.m().valueDataAccess.copy();
    @StageRef
    MapEntryStages<K, V> e;
    @StageRef
    SearchAllocatedChunks allocatedChunks;
    @StageRef
    KeySearch<K> ks;
    @StageRef
    InputKeyBytesData<K> inputKeyBytesData;
    @Stage("InputValueDataAccess")
    private boolean inputValueDataAccessInitialized = false;

    void initInputValueDataAccess() {
        inputValueDataAccessInitialized = true;
    }

    void closeInputValueDataAccess() {
        innerInputValueDataAccess.uninit();
        inputValueDataAccessInitialized = false;
    }

    @Override
    public DataAccess<V> inputValueDataAccess() {
        initInputValueDataAccess();
        return innerInputValueDataAccess;
    }

    @Override
    public MapQuery<K, V, R> entry() {
        checkOnEachPublicOperation.checkOnEachPublicOperation();
        return entryPresent() ? this : null;
    }

    @Nullable
    @Override
    public Absent<K, V> absentEntry() {
        checkOnEachPublicOperation.checkOnEachPublicOperation();
        return entryPresent() ? null : absent;
    }

    protected void putPrefix() {
        checkOnEachPublicOperation.checkOnEachPublicOperation();
        if (!s.innerUpdateLock.isHeldByCurrentThread())
            s.innerUpdateLock.lock();
        if (s.nestedContextsLockedOnSameSegment &&
                s.rootContextLockedOnThisSegment.latestSameThreadSegmentModCount() !=
                        s.contextModCount) {
            if (hlp.hashLookupPosInit() && ks.searchStateAbsent())
                hlp.closeHashLookupPos();
        }
    }

    @Override
    public void doReplaceValue(Data<V> newValue) {<FILL_FUNCTION_BODY>}

    @NotNull
    @Override
    public MapQuery<K, V, R> context() {
        checkOnEachPublicOperation.checkOnEachPublicOperation();
        return this;
    }

    @Override
    public Data<K> getInputKeyBytesAsData(BytesStore bytesStore, long offset, long size) {
        inputKeyBytesData.initInputKeyBytesStore(bytesStore, offset, size);
        return inputKeyBytesData;
    }
}

        putPrefix();
        if (entryPresent()) {
            e.innerDefaultReplaceValue(newValue);
            s.incrementModCount();
            ks.setSearchState(PRESENT);
            initPresenceOfEntry(EntryPresence.PRESENT);
        } else {
            throw new IllegalStateException(mh.h().toIdentityString() +
                    ": Entry is absent in the map when doReplaceValue() is called");
        }
    
<methods>public non-sealed void <init>() ,public void doRemove() ,public void dropSearchIfNestedContextsAndPresentHashLookupSlotCheckFailed() ,public boolean entryPresent() ,public void initPresenceOfEntry(net.openhft.chronicle.hash.impl.stage.query.HashQuery.EntryPresence) ,public DataAccess<K> inputKeyDataAccess() ,public Data<K> queriedKey() <variables>public net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation checkOnEachPublicOperation,public HashEntryStages<K> entry,private net.openhft.chronicle.hash.impl.stage.query.HashQuery.EntryPresence entryPresence,public net.openhft.chronicle.hash.impl.stage.entry.HashLookupSearch hashLookupSearch,public VanillaChronicleHashHolder<K> hh,public net.openhft.chronicle.hash.impl.stage.entry.HashLookupPos hlp,final DataAccess<K> innerInputKeyDataAccess,private boolean inputKeyDataAccessInitialized,public KeySearch<K> ks,public net.openhft.chronicle.hash.impl.stage.entry.SegmentStages s