MCPcopy Create free account
hub / github.com/questdb/questdb / getDirSize

Method getDirSize

core/src/main/java/io/questdb/Telemetry.java:334–373  ·  view source on GitHub ↗
(FilesFacade ff, Path path, boolean topLevel, StringSink sink)

Source from the content-addressed store, hash-verified

332 }
333
334 private long getDirSize(FilesFacade ff, Path path, boolean topLevel, StringSink sink) {
335 long totalSize = 0L;
336
337 final long pFind = ff.findFirst(path.$());
338 if (pFind > 0L) {
339 final int len = path.size();
340 try {
341 do {
342 if (hasTimedOut()) {
343 return 0L;
344 }
345
346 final long nameUtf8Ptr = ff.findName(pFind);
347 path.trimTo(len).concat(nameUtf8Ptr).$();
348 if (ff.findType(pFind) == DT_FILE) {
349 totalSize += ff.length(path.$());
350 } else if (notDots(nameUtf8Ptr)) {
351 if (topLevel) {
352 sink.clear();
353 Utf8s.utf8ToUtf16(path, len + 1, path.size(), sink);
354 final int tableNameLen = Chars.indexOf(sink, SYSTEM_TABLE_NAME_SUFFIX);
355 if (tableNameLen > -1) {
356 sink.trimTo(tableNameLen);
357 }
358 if (!TableUtils.isValidTableName(sink, maxFileNameLen)) {
359 // This is not a table, skip
360 continue;
361 }
362 }
363 totalSize += getDirSize(ff, path, false, sink);
364 }
365 }
366 while (ff.findNext(pFind) > 0);
367 } finally {
368 ff.findClose(pFind);
369 path.trimTo(len);
370 }
371 }
372 return totalSize;
373 }
374
375 protected boolean hasTimedOut() {
376 return clock.getTicks() - dbSizeEstimateStartTimestamp > dbSizeEstimateTimeout;

Callers 1

getDBSizeClassMethod · 0.95

Calls 15

hasTimedOutMethod · 0.95
utf8ToUtf16Method · 0.95
indexOfMethod · 0.95
isValidTableNameMethod · 0.95
concatMethod · 0.80
notDotsMethod · 0.80
findFirstMethod · 0.65
$Method · 0.65
sizeMethod · 0.65
findNameMethod · 0.65
trimToMethod · 0.65
findTypeMethod · 0.65

Tested by

no test coverage detected