Skip to content

Commit

Permalink
Solved test failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-niestadt committed Mar 20, 2017
1 parent 582e9f7 commit e0a61c0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -12,3 +12,6 @@ target

# vi temporary files
*.swp

# log files, such as JVM crash files
*.log
12 changes: 6 additions & 6 deletions core/src/main/java/nl/inl/blacklab/forwardindex/TermsImplV3.java
Expand Up @@ -47,11 +47,10 @@ class TermsImplV3 extends Terms {
/** We set this to a lower value on Windows because we can't properly
* truncate the file due to the file still being mapped (there is no clean way to unmap a mapped file in Java,
* and Windows doesn't allow truncating a mapped file). The lower value on Windows prevents too much wasted space. */
private static final int MAX_MAP_SIZE = File.separatorChar == '\\' ? 100000000 : Integer.MAX_VALUE;
private static final int DEFAULT_MAX_MAP_SIZE = File.separatorChar == '\\' ? 100000000 : Integer.MAX_VALUE - 100;

/** Maximum size for blocks of terms. Because we also store offsets, and offsets and string data have to fit into
* a single mapped area, this should always be significantly smaller than MAX_MAP_SIZE. */
private static final int DEFAULT_MAX_BLOCK_SIZE = MAX_MAP_SIZE * 2 / 3;
/** Maximum size for blocks of term strings. */
private static final int DEFAULT_MAX_BLOCK_SIZE = DEFAULT_MAX_MAP_SIZE;

/** Number of sort buffers we store in the terms file (case-sensitive/insensitive and inverted buffers for both as well) */
private static final int NUM_SORT_BUFFERS = 4;
Expand Down Expand Up @@ -154,7 +153,7 @@ public int numberOfTerms() {
* Ususally around the limit of 2GB, but for testing, we can set this to
* a lower value. Note that this should be significantly larger than maxBlockSize,
* because we also need to store offsets. */
private int maxMapSize = Math.max(MAX_MAP_SIZE, maxBlockSize * 3 / 2);
private int maxMapSize = DEFAULT_MAX_MAP_SIZE;

TermsImplV3(boolean indexMode, Collator collator, File termsFile, boolean useBlockBasedTermsFile) {
this.indexMode = indexMode;
Expand Down Expand Up @@ -543,8 +542,9 @@ protected void setBlockBasedFile(boolean useBlockBasedTermsFile) {
}

public void setMaxBlockSize(int maxBlockSize) {
if ((long)maxBlockSize > ((long)DEFAULT_MAX_MAP_SIZE))
throw new RuntimeException("Max. block size too large, max. " + DEFAULT_MAX_MAP_SIZE );
this.maxBlockSize = maxBlockSize;
maxMapSize = Math.max(MAX_MAP_SIZE, maxBlockSize * 3 / 2);
}

}
Expand Up @@ -81,9 +81,9 @@ public int numberOfProperties() {
public ForwardIndexAccessorLeafReader getForwardIndexAccessorLeafReader(LeafReader reader) {
return new ForwardIndexAccessorLeafReaderImpl(reader);
}

class ForwardIndexAccessorLeafReaderImpl extends ForwardIndexAccessorLeafReader {

private List<DocIntFieldGetter> fiidGetters;

ForwardIndexAccessorLeafReaderImpl(LeafReader reader) {
Expand All @@ -92,7 +92,7 @@ class ForwardIndexAccessorLeafReaderImpl extends ForwardIndexAccessorLeafReader
for (int i = 0; i < getNumberOfProperties(); i++)
fiidGetters.add(null);
}

DocIntFieldGetter fiidGetter(int propIndex) {
DocIntFieldGetter g = fiidGetters.get(propIndex);
if (g == null) {
Expand All @@ -104,13 +104,12 @@ DocIntFieldGetter fiidGetter(int propIndex) {
}
return g;
}

/**
* Get a token source, which we can use to get tokens from a document
* Get a token source, which we can use to get tokens from a document
* for different properties.
*
* @param docId Lucene document id
* @param reader the index reader
*
* @param id Lucene document id
* @return the token source
*/
@Override
Expand All @@ -124,12 +123,12 @@ public int getDocLength(int docId) {
}

int[] starts = {0}, ends = {0};

@Override
public int[] getChunk(int propIndex, int docId, int start, int end) {
starts[0] = start;
ends[0] = end;
int fiid = fiidGetter(propIndex).getFieldValue(docId);
int fiid = fiidGetter(propIndex).getFieldValue(docId);
return fis.get(propIndex).retrievePartsInt(fiid, starts, ends).get(0);
}

Expand Down
Expand Up @@ -15,7 +15,6 @@
import nl.inl.blacklab.queryParser.corpusql.ParseException;
import nl.inl.blacklab.search.lucene.BLSpanTermQuery;
import nl.inl.blacklab.search.lucene.SpanQueryFiltered;
import nl.inl.blacklab.search.lucene.SpanQuerySequence;

public class TestSearches {

Expand Down
Expand Up @@ -3,18 +3,13 @@
import java.util.Arrays;
import java.util.List;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import nl.inl.blacklab.TestIndex;
import nl.inl.blacklab.queryParser.corpusql.ParseException;
import nl.inl.blacklab.search.lucene.BLSpanTermQuery;
import nl.inl.blacklab.search.lucene.SpanQueryFiltered;
import nl.inl.blacklab.search.lucene.SpanQuerySequence;

public class TestSearchesNfa {
Expand Down

0 comments on commit e0a61c0

Please sign in to comment.