forked from organicmaps/organicmaps
[search] Use protobuf in lite mode for production configuration.
This commit is contained in:
parent
9748df36ed
commit
db74ea08f6
10 changed files with 5257 additions and 14 deletions
|
@ -21,6 +21,22 @@ unix|win32-g++ {
|
|||
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused -Wno-extra
|
||||
}
|
||||
|
||||
CONFIG(production) {
|
||||
|
||||
SOURCES += \
|
||||
src/google/protobuf/stubs/common.cc \
|
||||
src/google/protobuf/stubs/once.cc \
|
||||
src/google/protobuf/extension_set.cc \
|
||||
src/google/protobuf/generated_message_util.cc \
|
||||
src/google/protobuf/message_lite.cc \
|
||||
src/google/protobuf/repeated_field.cc \
|
||||
src/google/protobuf/wire_format_lite.cc \
|
||||
src/google/protobuf/io/coded_stream.cc \
|
||||
src/google/protobuf/io/zero_copy_stream.cc \
|
||||
src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
|
||||
|
||||
} else {
|
||||
|
||||
SOURCES += \
|
||||
src/google/protobuf/descriptor.cc \
|
||||
src/google/protobuf/descriptor.pb.cc \
|
||||
|
@ -78,3 +94,5 @@ HEADERS += \
|
|||
src/google/protobuf/stubs/stl_util-inl.h \
|
||||
src/google/protobuf/stubs/strutil.h \
|
||||
src/google/protobuf/stubs/substitute.h \
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,10 @@ DEFINE_bool(version, false, "Display version");
|
|||
DEFINE_bool(generate_update, false,
|
||||
"If specified, update.maps file will be generated from cells in the data path");
|
||||
|
||||
#ifndef OMIM_PRODUCTION
|
||||
DEFINE_bool(generate_classif, false, "Generate classificator.");
|
||||
#endif
|
||||
|
||||
DEFINE_bool(preprocess_xml, false, "1st pass - create nodes/ways/relations data");
|
||||
DEFINE_bool(make_coasts, false, "create intermediate file with coasts data");
|
||||
DEFINE_bool(emit_coasts, false, "push coasts features from intermediate file to out files/countries");
|
||||
|
@ -93,6 +96,7 @@ int main(int argc, char ** argv)
|
|||
cout << "Built on: " << VERSION_DATE_STRING << endl;
|
||||
}
|
||||
|
||||
#ifndef OMIM_PRODUCTION
|
||||
// Make a classificator
|
||||
if (FLAGS_generate_classif)
|
||||
{
|
||||
|
@ -106,6 +110,7 @@ int main(int argc, char ** argv)
|
|||
ofstream s((path + DRAWING_RULES_BIN_FILE).c_str(), ios::out | ios::binary);
|
||||
rules.SaveToBinaryProto(buffer, s);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generating intermediate files
|
||||
if (FLAGS_preprocess_xml)
|
||||
|
|
|
@ -68,10 +68,12 @@ namespace classificator
|
|||
|
||||
#if defined(OMIM_PRODUCTION) || defined(USE_BINARY_STYLES)
|
||||
// Load from proto buffer binary file.
|
||||
ReaderStreamBuf buffer(p.GetReader(DRAWING_RULES_BIN_FILE));
|
||||
ModelReaderPtr reader(p.GetReader(DRAWING_RULES_BIN_FILE));
|
||||
|
||||
istream s(&buffer);
|
||||
rules.LoadFromBinaryProto(s);
|
||||
string buffer;
|
||||
reader.ReadAsString(buffer);
|
||||
|
||||
rules.LoadFromBinaryProto(buffer);
|
||||
#else
|
||||
// Load from proto buffer text file.
|
||||
string buffer;
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
#include "drawing_rules.hpp"
|
||||
#include "scales.hpp"
|
||||
#include "classificator.hpp"
|
||||
#include "drules_struct.pb.h"
|
||||
|
||||
#ifdef OMIM_PRODUCTION
|
||||
#include "drules_struct_lite.pb.h"
|
||||
#else
|
||||
#include "drules_struct.pb.h"
|
||||
#endif
|
||||
|
||||
#include "../std/bind.hpp"
|
||||
#include "../std/iterator_facade.hpp"
|
||||
|
@ -360,6 +365,7 @@ namespace
|
|||
};
|
||||
}
|
||||
|
||||
#ifndef OMIM_PRODUCTION
|
||||
void RulesHolder::LoadFromTextProto(string const & buffer)
|
||||
{
|
||||
Clean();
|
||||
|
@ -377,14 +383,15 @@ void RulesHolder::SaveToBinaryProto(string const & buffer, ostream & s)
|
|||
|
||||
CHECK ( cont.SerializeToOstream(&s), ("Error in proto saving!") );
|
||||
}
|
||||
#endif
|
||||
|
||||
void RulesHolder::LoadFromBinaryProto(istream & s)
|
||||
void RulesHolder::LoadFromBinaryProto(string const & s)
|
||||
{
|
||||
Clean();
|
||||
|
||||
DoSetIndex doSet(*this);
|
||||
|
||||
CHECK ( doSet.m_cont.ParseFromIstream(&s), ("Error in proto loading!") );
|
||||
CHECK ( doSet.m_cont.ParseFromString(s), ("Error in proto loading!") );
|
||||
|
||||
classif().GetMutableRoot()->ForEachObject(bind<void>(ref(doSet), _1));
|
||||
}
|
||||
|
|
|
@ -79,10 +79,12 @@ namespace drule
|
|||
|
||||
BaseRule const * Find(Key const & k) const;
|
||||
|
||||
#ifndef OMIM_PRODUCTION
|
||||
void LoadFromTextProto(string const & buffer);
|
||||
|
||||
static void SaveToBinaryProto(string const & buffer, ostream & s);
|
||||
void LoadFromBinaryProto(istream & s);
|
||||
#endif
|
||||
|
||||
void LoadFromBinaryProto(string const & s);
|
||||
|
||||
template <class ToDo> void ForEachRule(ToDo toDo)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// option optimize_for = LITE_RUNTIME;
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
message DashDotProto
|
||||
{
|
||||
|
|
2966
indexer/drules_struct_lite.pb.cc
Normal file
2966
indexer/drules_struct_lite.pb.cc
Normal file
File diff suppressed because it is too large
Load diff
2233
indexer/drules_struct_lite.pb.h
Normal file
2233
indexer/drules_struct_lite.pb.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -40,8 +40,7 @@ SOURCES += \
|
|||
index.cpp \
|
||||
categories_holder.cpp \
|
||||
search_string_utils.cpp \
|
||||
drules_struct.pb.cc \
|
||||
string_file.cpp
|
||||
string_file.cpp \
|
||||
|
||||
HEADERS += \
|
||||
feature.hpp \
|
||||
|
@ -87,8 +86,14 @@ HEADERS += \
|
|||
mwm_set.hpp \
|
||||
categories_holder.hpp \
|
||||
drules_struct.pb.h \
|
||||
string_file.hpp
|
||||
string_file.hpp \
|
||||
|
||||
OTHER_FILES += drules_struct.proto
|
||||
|
||||
|
||||
CONFIG(production) {
|
||||
SOURCES += drules_struct_lite.pb.cc
|
||||
HEADERS += drules_struct_lite.pb.h
|
||||
} else {
|
||||
SOURCES += drules_struct.pb.cc
|
||||
HEADERS += drules_struct.pb.h
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include "proto_to_yg_styles.hpp"
|
||||
|
||||
#include "../indexer/drules_struct.pb.h"
|
||||
#ifdef OMIM_PRODUCTION
|
||||
#include "../indexer/drules_struct_lite.pb.h"
|
||||
#else
|
||||
#include "../indexer/drules_struct.pb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "../std/algorithm.hpp"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue