Github user akashrn5 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2269#discussion_r186694178
--- Diff:
datamap/lucene/src/main/java/org/apache/carbondata/datamap/lucene/LuceneFineGrainDataMap.java
---
@@ -302,9 +302,20 @@ public boolean isScanRequired(FilterResolverIntf
filterExp) {
/**
* Clear complete index table and release memory.
*/
- @Override
- public void clear() {
-
+ @Override public void clear() {
+ if (null != indexReader) {
+ try {
+ int referenceCount = indexReader.getRefCount();
+ if (referenceCount > 0) {
+ indexReader.decRef();
--- End diff --
close index reader will internally call decRef() where it will check for
reference count and once all the references comes decreases to zero it closes
the reader.
If you directly call the close , it will call decRef() which can throw
"this IndexReader is already closed" Exception if the reference count is zero,
they it is recommended from lucene that , first get reference count and then we
can close the reader.
and it is therad safe
(Reference:https://lucene.apache.org/core/6_0_1/core/org/apache/lucene/index/IndexReader.html)
---