cosmetics

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@478052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Wolfgang Hoschek 2006-11-22 06:28:02 +00:00
parent ad93748d49
commit 248ff4e963
1 changed files with 9 additions and 10 deletions

View File

@ -435,15 +435,13 @@ public class MemoryIndex {
/**
* Returns a reasonable approximation of the main memory [bytes] consumed by
* this instance. Useful for smart memory sensititve caches/pools. Assumes
* fieldNames are interned, whereas tokenized terms are memory-overlaid. For
* simplicity, assumes no VM word boundary alignment of instance vars.
* this instance. Useful for smart memory sensititive caches/pools. Assumes
* fieldNames are interned, whereas tokenized terms are memory-overlaid.
*
* @return the main memory consumption
*/
public int getMemorySize() {
// for example usage in a smart cache see nux.xom.pool.Pool
int PTR = VM.PTR;
int INT = VM.INT;
int size = 0;
@ -654,10 +652,11 @@ public class MemoryIndex {
public int[] toArray(int stride) {
int[] arr = new int[size() / stride];
if (stride == 1)
if (stride == 1) {
System.arraycopy(elements, 0, arr, 0, size); // fast path
else
} else {
for (int i=0, j=0; j < size; i++, j += stride) arr[i] = elements[j];
}
return arr;
}
@ -748,8 +747,7 @@ public class MemoryIndex {
j = -j -1;
i = 0;
if (j < sortedFields.length) getInfo(j).sortTerms();
}
else { // found
} else { // found
Info info = getInfo(j);
info.sortTerms();
i = Arrays.binarySearch(info.sortedTerms, term.text(), termComparator);
@ -1003,6 +1001,7 @@ public class MemoryIndex {
byte norm = Similarity.encodeNorm(n);
norms = new byte[] {norm};
// cache it for future reuse
cachedNorms = norms;
cachedFieldName = fieldName;
cachedSimilarity = sim;