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

Method getString

src/Functions/IP2GeoUDF.cpp:290–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290String IP2GeoManager::IPIPLocator::getString(String ip, int location_type, ipdb_reader * reader)
291{
292 char body[512];
293 if (reader == nullptr)
294 throw Exception("IPDB file is not open or memory has been freed ", ErrorCodes::FILE_NOT_FOUND);
295 int err = ipdb_reader_find(reader, ip.c_str(), "CN", body);
296 if (!err)
297 {
298 char tmp[64];
299 int f = 0, p1 = 0, p2 = -1;
300 do
301 {
302 if (*(body + p1) == '\t' || !*(body + p1))
303 {
304 if (f == location_type)
305 {
306 strncpy(tmp, body + p2 + 1, static_cast<size_t>(p1 - p2));
307 tmp[p1 - p2] = 0;
308 return tmp;
309 }
310 else
311 {
312 p2 = p1;
313 ++f;
314 }
315 }
316 } while (*(body + p1++));
317 }
318 return "NULL";
319}
320
321void IP2GeoManager::IPIPLocator::freeIpipReader()
322{

Callers 12

PartMergerImplMethod · 0.45
initBridgeMethod · 0.45
FunctionDisplayNameMethod · 0.45
createMethod · 0.45
jsonElementEqualMethod · 0.45
internalExecuteImplMethod · 0.45
traverseFunction · 0.45
insertResultToColumnMethod · 0.45
insertResultToColumnMethod · 0.45
insertResultToColumnMethod · 0.45
insertResultToColumnMethod · 0.45
insertResultToColumnMethod · 0.45

Calls 1

ExceptionClass · 0.50

Tested by

no test coverage detected