Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generator:locidx-building] Speedup: skip middle points #65

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions generator/locality_sorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ bool ParseNodes(string nodesFile, set<uint64_t> & nodeIds)

using NeedSerialize = function<bool(FeatureBuilder & fb1)>;
bool GenerateLocalityDataImpl(FeaturesCollector & collector,
CalculateMidPoints::MinDrawableScalePolicy const & minDrawableScalePolicy,
NeedSerialize const & needSerialize,
string const & featuresFile)
{
Expand All @@ -203,24 +202,10 @@ bool GenerateLocalityDataImpl(FeaturesCollector & collector,
{
LOG(LINFO, ("Processing", featuresFile));

CalculateMidPoints midPoints{minDrawableScalePolicy};
ForEachFromDatRawFormat(featuresFile, midPoints);

// Sort features by their middle point.
midPoints.Sort();

FileReader reader(featuresFile);
for (auto const & point : midPoints.GetVector())
{
ReaderSource<FileReader> src(reader);
src.Skip(point.second);

FeatureBuilder f;
ReadFromSourceRawFormat(src, f);
// Emit object.
if (needSerialize(f))
collector.Collect(f);
}
ForEachFromDatRawFormat(featuresFile, [&](FeatureBuilder & fb, uint64_t /* currPos */) {
if (needSerialize(fb))
collector.Collect(fb);
});

collector.Finish();
}
Expand All @@ -247,7 +232,6 @@ bool GenerateGeoObjectsData(string const & toDataFile, string const & featuresFi
static_cast<uint32_t>(base::SecondsSinceEpoch()));
return GenerateLocalityDataImpl(
localityCollector,
static_cast<int (*)(TypesHolder const & types, m2::RectD limitRect)>(GetMinDrawableScale),
needSerialize, featuresFile);
}

Expand Down Expand Up @@ -302,15 +286,13 @@ bool GenerateRegionsData(std::string const & toDataFile, string const & features
LocalityCollector regionsCollector(toDataFile, header,
static_cast<uint32_t>(base::SecondsSinceEpoch()));
auto const needSerialize = [](FeatureBuilder const & fb) { return fb.IsArea(); };
return GenerateLocalityDataImpl(regionsCollector, GetMinDrawableScaleGeometryOnly,
needSerialize, featuresFile);
return GenerateLocalityDataImpl(regionsCollector, needSerialize, featuresFile);
}

bool GenerateBorders(std::string const & toDataFile, string const & featuresFile)
{
BordersCollector bordersCollector(toDataFile);
auto const needSerialize = [](FeatureBuilder const & fb) { return fb.IsArea(); };
return GenerateLocalityDataImpl(bordersCollector, GetMinDrawableScaleGeometryOnly,
needSerialize, featuresFile);
return GenerateLocalityDataImpl(bordersCollector, needSerialize, featuresFile);
}
} // namespace feature
13 changes: 0 additions & 13 deletions indexer/feature_visibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,6 @@ int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect)
return -1;
}

int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRect)
{
int const upBound = scales::GetUpperStyleScale();

for (int level = 0; level <= upBound; ++level)
{
if (IsDrawableForIndexGeometryOnly(types, limitRect, level))
return level;
}

return -1;
}

int GetMinDrawableScaleClassifOnly(TypesHolder const & types)
{
int const upBound = scales::GetUpperStyleScale();
Expand Down
1 change: 0 additions & 1 deletion indexer/feature_visibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace feature

int GetMinDrawableScale(FeatureType & ft);
int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect);
int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRect);
int GetMinDrawableScaleClassifOnly(TypesHolder const & types);

/// @return [-1, -1] if range is not drawable
Expand Down