Skip to content

Commit

Permalink
fix percentage in log output for ID query
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbr committed Sep 26, 2024
1 parent 50baa21 commit 1debf64
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/qlever-petrimaps/GeomCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void GeomCache::parse(const char *c, size_t size) {
_curRow++;
if (_curRow % 1000000 == 0) {
LOG(INFO) << "[GEOMCACHE] "
<< "@ row " << _curRow << " (" << std::fixed
<< "@ " << _curRow << " (" << std::fixed
<< std::setprecision(2) << getLoadStatusPercent()
<< "%, " << _pointsFSize << " points, " << _linesFSize
<< " (open) polygons (with " << _linePointsFSize
Expand Down Expand Up @@ -386,17 +386,19 @@ void GeomCache::parseIds(const char *c, size_t size) {
_curByte = (_curByte + 1) % 8;

if (_curByte == 0) {
if (_curIdRow % 1000000 == 0) {
_curRow++;

if (_curRow % 1000000 == 0) {
LOG(INFO) << "[GEOMCACHE] "
<< "@ row " << _curIdRow << " (" << std::fixed
<< std::setprecision(2) << getLoadStatusPercent() << "%, "
<< _pointsFSize << " points, " << _linesFSize
<< " (open) polygons)";
<< "@ " << _curRow << " (" << std::fixed
<< std::setprecision(2) << getLoadStatusPercent()
<< "%, " << _pointsFSize << " points, " << _linesFSize
<< " (open) polygons (with " << _linePointsFSize
<< " points), " << _geometryDuplicates
<< " duplicates)";
}

_curIdRow++;

if (_curRow < _qidToId.size() && _qidToId[_curRow].qid == 0) {
if (_curIdRow < _qidToId.size() && _qidToId[_curIdRow].qid == 0) {
// if we have two consecutive and equivalent QLever ids, the geometry
// was returned multiple times in the fill query. This can happen if the
// same WKT string is used in multiple distinct objects, but then stored
Expand All @@ -407,30 +409,30 @@ void GeomCache::parseIds(const char *c, size_t size) {
LOG(DEBUG) << "Found duplicate internal qlever ID " << _curId.val
<< " for row " << _curRow
<< ", ignoring this geometry duplicate!";
_qidToId[_curRow].qid = -1;
_qidToId[_curIdRow].qid = -1;
_geometryDuplicates++;
} else {
_qidToId[_curRow].qid = _curId.val;
_qidToId[_curIdRow].qid = _curId.val;
}
_lastQid = _curId.val;
if (_curId.val > _maxQid) _maxQid = _curId.val;
} else {
LOG(WARN) << "The results for the binary IDs are out of sync.";
LOG(WARN) << "_curRow: " << _curRow
<< " _qleverIdInt.size: " << _qidToId.size()
<< " cur val: " << _qidToId[_curRow].qid;
<< " cur val: " << _qidToId[_curIdRow].qid;
}

// if a qlever entity contained multiple geometries (MULTILINESTRING,
// MULTIPOLYGON, MULTIPOINT), they appear consecutively in
// _qidToId; continuation geometries are marked by a
// preliminary qlever ID of 1, while the first geometry always has a
// preliminary id of 0
while (_curRow < _qidToId.size() - 1 && _qidToId[_curRow + 1].qid == 1) {
_qidToId[++_curRow].qid = _curId.val;
while (_curIdRow < _qidToId.size() - 1 && _qidToId[_curIdRow + 1].qid == 1) {
_qidToId[++_curIdRow].qid = _curId.val;
}

_curRow++;
_curIdRow++;
}
}
}
Expand Down Expand Up @@ -647,6 +649,8 @@ void GeomCache::request() {
lastNum = _curRow - offset;
}

LOG(INFO) << "Received " << _curRow << " rows";

if (_curRow != _totalSize) {
LOG(WARN) << "Last received row was " << _curRow << ", but expected "
<< _totalSize << " rows (determined via count query)";
Expand Down Expand Up @@ -705,18 +709,18 @@ void GeomCache::requestIds() {
size_t lastNum = -1;

while (lastNum != 0) {
size_t offset = _curIdRow;
size_t offset = _curRow;
requestIdPart(offset);
lastNum = _curIdRow - offset;
lastNum = _curRow - offset;
}

if (_curIdRow != _totalSize) {
LOG(WARN) << "Last received row was " << _curIdRow << ", but expected "
if (_curRow != _totalSize) {
LOG(WARN) << "Last received row was " << _curRow << ", but expected "
<< _totalSize << " rows (determined via count query)";
LOG(WARN) << "Last answer from QLever began with " << _raw;
}

LOG(INFO) << "[GEOMCACHE] Received " << _curIdRow << " rows";
LOG(INFO) << "[GEOMCACHE] Received " << _curRow << " rows";
LOG(INFO) << "[GEOMCACHE] Max QLever id was " << _maxQid;
LOG(INFO) << "[GEOMCACHE] Done";

Expand All @@ -732,7 +736,7 @@ void GeomCache::requestIdPart(size_t offset) {
char errbuf[CURL_ERROR_SIZE];

if (_curl) {
auto qUrl = queryUrl(getQuery(_backendUrl), offset, 100000000);
auto qUrl = queryUrl(getQuery(_backendUrl), offset, 1000000);
curl_easy_setopt(_curl, CURLOPT_URL, qUrl.c_str());
curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, GeomCache::writeCbIds);
curl_easy_setopt(_curl, CURLOPT_WRITEDATA, this);
Expand Down

0 comments on commit 1debf64

Please sign in to comment.