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

Method getFdCacheRecord

core/src/main/java/io/questdb/std/FdCache.java:283–306  ·  view source on GitHub ↗
(LPSZ lpsz)

Source from the content-addressed store, hash-verified

281 }
282
283 @Nullable
284 private FdCacheRecord getFdCacheRecord(LPSZ lpsz) {
285 int keyIndex = openFdMapByPath.keyIndex(lpsz);
286 final FdCacheRecord holder;
287 if (keyIndex > -1) {
288 int osFd = Files.openRO(lpsz.ptr());
289 if (osFd < 0) {
290 // Failed to open
291 holder = null;
292 } else {
293 OPEN_OS_FILE_COUNT.incrementAndGet();
294 Utf8String path = Utf8String.newInstance(lpsz);
295 holder = createFdCacheRecord(path, mmapKeyGenerator.getAndIncrement());
296 holder.osFd = osFd;
297 // Reuse the same Utf8String for the map key so putAt picks the
298 // Utf8String overload and skips its own newInstance() copy.
299 openFdMapByPath.putAt(keyIndex, path, holder);
300 }
301 } else {
302 holder = openFdMapByPath.valueAtQuick(keyIndex);
303 fdReuseCount++;
304 }
305 return holder;
306 }
307
308 private int nextIndex() {
309 int raw = fdCounter.getAndIncrement();

Callers 1

openROCachedMethod · 0.95

Calls 8

openROMethod · 0.95
newInstanceMethod · 0.95
createFdCacheRecordMethod · 0.95
ptrMethod · 0.65
incrementAndGetMethod · 0.65
keyIndexMethod · 0.45
putAtMethod · 0.45
valueAtQuickMethod · 0.45

Tested by

no test coverage detected