[generator] Refactoring: some code was put to features_processing_helpers.hpp; renamed method

This commit is contained in:
Maksim Andrianov 2019-08-08 13:36:39 +03:00 committed by LaGrunge
parent 62a5a2c496
commit ee880637d3
12 changed files with 39 additions and 28 deletions

View file

@ -0,0 +1,28 @@
#pragma once
#include "generator/feature_builder.hpp"
#include "base/thread_safe_queue.hpp"
#include <cstddef>
#include <utility>
#include <string>
#include <vector>
namespace generator
{
size_t static const kAffilationsBufferSize = 512;
struct ProcessedData
{
explicit ProcessedData(feature::FeatureBuilder::Buffer && buffer,
std::vector<std::string> && affiliations)
: m_buffer(std::move(buffer)), m_affiliations(std::move(affiliations)) {}
feature::FeatureBuilder::Buffer m_buffer;
std::vector<std::string> m_affiliations;
};
using FeatureProcessorChank = base::threads::DataWrapper<std::vector<ProcessedData>>;
using FeatureProcessorQueue = base::threads::ThreadSafeQueue<FeatureProcessorChank>;
} // namespace generator

View file

@ -36,7 +36,7 @@ public:
m_features.emplace(fb.GetMostGenericOsmId(), fb);
}
void Flush() override {}
void Finish() override {}
void Merge(FeatureProcessorInterface const &) override
{

View file

@ -35,7 +35,7 @@ void ProcessorCoastline::Process(feature::FeatureBuilder & feature)
m_affilationsLayer->AddBufferToQueueIfFull(m_queue);
}
void ProcessorCoastline::Flush()
void ProcessorCoastline::Finish()
{
m_affilationsLayer->AddBufferToQueue(m_queue);
}

View file

@ -18,7 +18,7 @@ public:
std::shared_ptr<FeatureProcessorInterface> Clone() const override;
void Process(feature::FeatureBuilder & feature) override;
void Flush() override;
void Finish() override;
void Merge(FeatureProcessorInterface const & other) override;
void MergeInto(ProcessorCoastline & other) const override;

View file

@ -37,7 +37,7 @@ void ProcessorCountry::Process(feature::FeatureBuilder & feature)
m_affilationsLayer->AddBufferToQueueIfFull(m_queue);
}
void ProcessorCountry::Flush()
void ProcessorCountry::Finish()
{
m_affilationsLayer->AddBufferToQueue(m_queue);
}

View file

@ -27,7 +27,7 @@ public:
std::shared_ptr<FeatureProcessorInterface> Clone() const override;
void Process(feature::FeatureBuilder & feature) override;
void Flush() override;
void Finish() override;
void Merge(FeatureProcessorInterface const & other) override;
void MergeInto(ProcessorCountry & other) const override;

View file

@ -29,7 +29,7 @@ public:
// This method is used by OsmTranslator to pass |fb| to Processor for further processing.
virtual void Process(feature::FeatureBuilder & fb) = 0;
virtual void Flush() = 0;
virtual void Finish() = 0;
virtual void Merge(FeatureProcessorInterface const &) = 0;
@ -42,21 +42,4 @@ public:
private:
void FailIfMethodUnsupported() const { CHECK(false, ("This method is unsupported.")); }
};
size_t static const kAffilationsBufferSize = 128;
struct ProcessedData
{
explicit ProcessedData(feature::FeatureBuilder::Buffer && buffer, std::vector<std::string> && affiliations)
: m_buffer(std::move(buffer)), m_affiliations(std::move(affiliations))
{
}
feature::FeatureBuilder::Buffer m_buffer;
std::vector<std::string> m_affiliations;
};
using FeatureProcessorChank = base::threads::DataWrapper<std::vector<ProcessedData>>;
using FeatureProcessorQueue = base::threads::ThreadSafeQueue<FeatureProcessorChank>;
} // namespace generator

View file

@ -19,7 +19,7 @@ public:
}
void Process(feature::FeatureBuilder &) override {}
void Flush() override {}
void Finish() override {}
void Merge(FeatureProcessorInterface const &) override {}
void MergeInto(ProcessorNoop &) const override {}

View file

@ -29,7 +29,7 @@ void ProcessorSimple::Process(feature::FeatureBuilder & fb)
m_affilationsLayer->AddBufferToQueueIfFull(m_queue);
}
void ProcessorSimple::Flush()
void ProcessorSimple::Finish()
{
m_affilationsLayer->AddBufferToQueue(m_queue);
}

View file

@ -21,7 +21,7 @@ public:
std::shared_ptr<FeatureProcessorInterface> Clone() const override;
void Process(feature::FeatureBuilder & fb) override;
void Flush() override;
void Finish() override;
void Merge(FeatureProcessorInterface const & other) override;
void MergeInto(ProcessorSimple & other) const override;

View file

@ -32,7 +32,7 @@ void ProcessorWorld::Process(feature::FeatureBuilder & feature)
m_affilationsLayer->AddBufferToQueueIfFull(m_queue);
}
void ProcessorWorld::Flush()
void ProcessorWorld::Finish()
{
m_affilationsLayer->AddBufferToQueue(m_queue);
}

View file

@ -26,7 +26,7 @@ public:
std::shared_ptr<FeatureProcessorInterface> Clone() const override;
void Process(feature::FeatureBuilder & feature) override;
void Flush() override;
void Finish() override;
void Merge(FeatureProcessorInterface const & other) override;
void MergeInto(ProcessorWorld & other) const override;