ClickHouse/src/Disks/ObjectStorages/ObjectStorageIterator.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.6 KiB
C++
Raw Normal View History

2023-06-04 14:03:44 +00:00
#pragma once
#include <Disks/ObjectStorages/IObjectStorage.h>
#include <memory>
namespace DB
{
class IObjectStorageIterator
{
public:
virtual void next() = 0;
virtual void nextBatch() = 0;
2023-06-06 12:55:17 +00:00
virtual bool isValid() = 0;
virtual RelativePathWithMetadata current() = 0;
virtual RelativePathsWithMetadata currentBatch() = 0;
virtual std::optional<RelativePathsWithMetadata> getCurrrentBatchAndScheduleNext() = 0;
2023-06-04 14:03:44 +00:00
virtual size_t getAccumulatedSize() const = 0;
virtual ~IObjectStorageIterator() = default;
};
using ObjectStorageIteratorPtr = std::shared_ptr<IObjectStorageIterator>;
class ObjectStorageIteratorFromList : public IObjectStorageIterator
{
public:
explicit ObjectStorageIteratorFromList(RelativePathsWithMetadata && batch_)
: batch(std::move(batch_))
, batch_iterator(batch.begin())
{
}
void next() override
{
if (isValid())
++batch_iterator;
}
void nextBatch() override
{
batch_iterator = batch.end();
}
2023-06-06 12:55:17 +00:00
bool isValid() override
2023-06-04 14:03:44 +00:00
{
return batch_iterator != batch.end();
}
2023-06-06 12:55:17 +00:00
RelativePathWithMetadata current() override;
2023-06-04 14:03:44 +00:00
2023-06-06 12:55:17 +00:00
RelativePathsWithMetadata currentBatch() override
{
return batch;
}
virtual std::optional<RelativePathsWithMetadata> getCurrrentBatchAndScheduleNext() override
{
return std::nullopt;
}
2023-06-04 14:03:44 +00:00
size_t getAccumulatedSize() const override
{
return batch.size();
}
private:
RelativePathsWithMetadata batch;
RelativePathsWithMetadata::iterator batch_iterator;
};
}