MCPcopy Create free account
hub / github.com/ByConity/ByConity / MongoDBDictionarySource

Method MongoDBDictionarySource

src/Dictionaries/MongoDBDictionarySource.cpp:69–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69MongoDBDictionarySource::MongoDBDictionarySource(
70 const DictionaryStructure & dict_struct_,
71 const std::string & uri_,
72 const std::string & host_,
73 UInt16 port_,
74 const std::string & user_,
75 const std::string & password_,
76 const std::string & method_,
77 const std::string & db_,
78 const std::string & collection_,
79 const Block & sample_block_)
80 : dict_struct{dict_struct_}
81 , uri{uri_}
82 , host{host_}
83 , port{port_}
84 , user{user_}
85 , password{password_}
86 , method{method_}
87 , db{db_}
88 , collection{collection_}
89 , sample_block{sample_block_}
90 , connection{std::make_shared<Poco::MongoDB::Connection>()}
91{
92 if (!uri.empty())
93 {
94 Poco::URI poco_uri(uri);
95
96 // Parse database from URI. This is required for correctness -- the
97 // cursor is created using database name and colleciton name, so we have
98 // to specify them properly.
99 db = poco_uri.getPath();
100 // getPath() may return a leading slash, remove it.
101 if (!db.empty() && db[0] == '/')
102 {
103 db.erase(0, 1);
104 }
105
106 // Parse some other parts from URI, for logging and display purposes.
107 host = poco_uri.getHost();
108 port = poco_uri.getPort();
109 user = poco_uri.getUserInfo();
110 if (size_t separator = user.find(':'); separator != std::string::npos)
111 {
112 user.resize(separator);
113 }
114
115 // Connect with URI.
116 Poco::MongoDB::Connection::SocketFactory socket_factory;
117 connection->connect(uri, socket_factory);
118 }
119 else
120 {
121 // Connect with host/port/user/etc.
122 connection->connect(host, port);
123 if (!user.empty())
124 {
125#if POCO_VERSION >= 0x01070800
126 Poco::MongoDB::Database poco_db(db);

Callers

nothing calls this directly

Calls 11

authenticateFunction · 0.85
getUserInfoMethod · 0.80
ExceptionClass · 0.50
emptyMethod · 0.45
getPathMethod · 0.45
eraseMethod · 0.45
getPortMethod · 0.45
findMethod · 0.45
resizeMethod · 0.45
connectMethod · 0.45
authenticateMethod · 0.45

Tested by

no test coverage detected