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;
|
2023-06-05 22:40:05 +00:00
|
|
|
virtual void nextBatch() = 0;
|
2023-06-06 12:55:17 +00:00
|
|
|
virtual bool isValid() = 0;
|
|
|
|
virtual RelativePathWithMetadata current() = 0;
|
|
|
|
virtual RelativePathsWithMetadata currentBatch() = 0;
|
2023-06-21 20:17:39 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-06-05 22:40:05 +00:00
|
|
|
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
|
2023-06-05 22:40:05 +00:00
|
|
|
{
|
|
|
|
return batch;
|
|
|
|
}
|
|
|
|
|
2023-06-21 20:17:39 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|