ClickHouse/src/Disks/ObjectStorages/ObjectStorageIterator.h

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

66 lines
1.4 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-04 14:03:44 +00:00
virtual bool isValid() const = 0;
virtual RelativePathWithMetadata current() const = 0;
virtual RelativePathsWithMetadata currentBatch() const = 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-04 14:03:44 +00:00
bool isValid() const override
{
return batch_iterator != batch.end();
}
RelativePathWithMetadata current() const override;
RelativePathsWithMetadata currentBatch() const override
{
return batch;
}
2023-06-04 14:03:44 +00:00
size_t getAccumulatedSize() const override
{
return batch.size();
}
private:
RelativePathsWithMetadata batch;
RelativePathsWithMetadata::iterator batch_iterator;
};
}