Skip to content

Commit e449f8c

Browse files
Added getDirentCacheMaxSize, getDirentCacheCurrentSize, and setDirentCacheMaxSize methods in archive.
1 parent fc22d0f commit e449f8c

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

lib/src/main/cpp/libzim/archive.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ GETTER(jstring, getChecksum)
341341
GETTER(jboolean, check)
342342
GETTER(jboolean, isMultiPart)
343343
GETTER(jboolean, hasNewNamespaceScheme)
344+
GETTER(jlong, getDirentCacheMaxSize)
345+
GETTER(jlong, getDirentCacheCurrentSize)
346+
347+
METHOD(void, setDirentCacheMaxSize, jlong nbDirents) {
348+
THIS->setDirentCacheMaxSize(static_cast<size_t>(nbDirents));
349+
} CATCH_EXCEPTION()
344350

345351
#define ITER_BY_PATH 0
346352
#define ITER_BY_TITLE 1

lib/src/main/java/org/kiwix/libzim/Archive.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public Archive(FdInput[] fds, OpenConfig openConfig)
132132
public native EntryIterator iterEfficient();
133133
public native EntryIterator findByPath(String path);
134134
public native EntryIterator findByTitle(String path);
135+
public native long getDirentCacheMaxSize();
136+
public native long getDirentCacheCurrentSize();
137+
public native void setDirentCacheMaxSize(long nbDirents);
135138

136139

137140
private native void setNativeArchive(String filename);

lib/src/test/org/kiwix/test/libzim/TestArchive.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,9 @@ public TestArchive(FdInput[] fds, OpenConfig openConfig)
136136
public TestEntryIterator findByPath(String path) { return new TestEntryIterator(inner.findByPath(path)); }
137137
public TestEntryIterator findByTitle(String path) { return new TestEntryIterator(inner.findByTitle(path)); }
138138

139+
public long getDirentCacheMaxSize() { return inner.getDirentCacheMaxSize(); }
140+
public long getDirentCacheCurrentSize() { return inner.getDirentCacheCurrentSize(); }
141+
public void setDirentCacheMaxSize(long nbDirents) { inner.setDirentCacheMaxSize(nbDirents); }
142+
139143
public void dispose() { inner.dispose(); }
140144
}

lib/src/test/test.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ private void testArchive(TestArchive archive)
220220
} catch(Exception e) {
221221
fail("ERROR: Must be a EntryNotFoundException.");
222222
}
223+
224+
long maxCacheSize = archive.getDirentCacheMaxSize();
225+
assertEquals(512, maxCacheSize);
226+
long currentCacheSize = archive.getDirentCacheCurrentSize();
227+
assertEquals(19, currentCacheSize);
228+
archive.setDirentCacheMaxSize(19);
223229
System.gc();
224230
System.runFinalization();
225231
}

0 commit comments

Comments
 (0)