[hg] main-silver: #225674:Optimise DocumentIndex for indexer sto...

  • From: Tomas Zezula < >
  • To:
  • Subject: [hg] main-silver: #225674:Optimise DocumentIndex for indexer sto...
  • Date: Mon, 04 Feb 2013 08:08:52 -0800

changeset 9df22a1b4db6 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/9df22a1b4db6
description:
        #225674:Optimise DocumentIndex for indexer storing large number of 
small documents

diffstat:

 
parsing.api/src/org/netbeans/modules/parsing/impl/indexing/ClusteredIndexables.java
 |  21 ++++++++-
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (64 lines):

diff --git 
a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/ClusteredIndexables.java
 
b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/ClusteredIndexables.java
--- 
a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/ClusteredIndexables.java
+++ 
b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/ClusteredIndexables.java
@@ -324,13 +324,13 @@
             if (!(document instanceof DocumentStore.MemoryIndexDocument)) {
                 throw new 
IllegalArgumentException(document.getClass().getName());
             }
-            final boolean shouldFlush = init();
+            boolean shouldFlush = init();
             handleDelete(
                 indexIndexables,
                 deleteFromIndex,
                 toDeleteOutOfOrder,
                 document.getPrimaryKey());
-            toAdd.add(document);
+            shouldFlush |= toAdd.addDocument(document);
             return shouldFlush;
         }
 
@@ -682,6 +682,7 @@
 
         private static final int INITIAL_DOC_COUNT = 100;
         private static final int INITIAL_DATA_SIZE = 1<<10;
+        private static final long DATA_CACHE_SIZE = (long) 
(Runtime.getRuntime().maxMemory() * 0.1);
 
         private final Map<String,Integer> fieldNames;
         private int[] docs;
@@ -700,6 +701,12 @@
 
         @Override
         public boolean add(@NonNull final IndexDocument doc) {
+            addDocument(doc);
+            return true;
+        }
+        
+        boolean addDocument(@NonNull final IndexDocument doc) {
+            boolean res = false;
             if (!(doc instanceof MemoryIndexDocument)) {
                 throw new IllegalArgumentException();
             }
@@ -730,6 +737,14 @@
                     char[] newdata = new char[data.length << 1];
                     System.arraycopy(data, 0, newdata, 0, data.length);
                     data = newdata;
+                    res = data.length<<1 > DATA_CACHE_SIZE;
+                    LOG.log(
+                        Level.FINE,
+                        "New data size: {0}, flush: {1}",   //NOI18N
+                        new Object[] {
+                            newdata.length,
+                            res
+                        });
                 }
                 fldValue.getChars(0, fldValue.length(), data, dataPointer);
                 dataPointer += fldValue.length();
@@ -740,7 +755,7 @@
                 docs = newdocs;
             }
             docs[docsPointer++] = 0;
-            return true;
+            return res;
         }
 
         @Override

[hg] main-silver: #225674:Optimise DocumentIndex for indexer sto...

Tomas Zezula 02/03/2013

<Possible follow-up(s)>

[hg] main-silver: #225674:Optimise DocumentIndex for indexer sto...

Tomas Zezula 02/04/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close