// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include namespace search::common { struct ICompactableLidSpace; } namespace proton { /** * Implements a flush target that shrinks lid space in target. */ class ShrinkLidSpaceFlushTarget : public searchcorespi::LeafFlushTarget { /** * Task representing that shrinking has been performed. **/ class Flusher; using ICompactableLidSpace = search::common::ICompactableLidSpace; using FlushStats = searchcorespi::FlushStats; std::shared_ptr _target; SerialNum _flushedSerialNum; Time _lastFlushTime; FlushStats _lastStats; public: /** * Constructs a new instance of this class. * * @param name The handler-wide unique name of this target. * @param type The flush type of this target. * @param component The component type of this target. * @param flushedSerialNum When target shrank lid space last time * @param target The target supporting lid space compaction */ ShrinkLidSpaceFlushTarget(const vespalib::string &name, Type type, Component component, SerialNum flushedSerialNum, Time lastFlushTime, std::shared_ptr target); // Implements IFlushTarget. MemoryGain getApproxMemoryGain() const override; DiskGain getApproxDiskGain() const override; SerialNum getFlushedSerialNum() const override; Time getLastFlushTime() const override; Task::UP initFlush(SerialNum currentSerial, std::shared_ptr flush_token) override; searchcorespi::FlushStats getLastFlushStats() const override; uint64_t getApproxBytesToWriteToDisk() const override; }; } // namespace proton