![JAR search and dependency download from the Maven repository](/logo.png)
test.it.unimi.dsi.big.mg4j.search.TrueFalseDocumentIteratorTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mg4j-big Show documentation
Show all versions of mg4j-big Show documentation
MG4J (Managing Gigabytes for Java) is a free full-text search engine for large document collections written in Java. The big version is a fork of the original MG4J that can handle more than 2^31 terms and documents.
The newest version!
package it.unimi.dsi.big.mg4j.search;
import static org.junit.Assert.assertEquals;
import it.unimi.dsi.big.mg4j.document.StringArrayDocumentCollection;
import it.unimi.dsi.big.mg4j.index.BitStreamIndex;
import it.unimi.dsi.big.mg4j.index.DiskBasedIndex;
import it.unimi.dsi.big.mg4j.tool.IndexBuilder;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.io.filefilter.PrefixFileFilter;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class TrueFalseDocumentIteratorTest {
private static BitStreamIndex index;
private static String basename;
@BeforeClass
public static void setUp() throws ConfigurationException, SecurityException, IOException, URISyntaxException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
basename = File.createTempFile( TrueFalseDocumentIteratorTest.class.getSimpleName(), "test" ).getCanonicalPath();
new IndexBuilder( basename, new StringArrayDocumentCollection( "a", "b", "c" ) ).run();
index = DiskBasedIndex.getInstance( basename + "-text", true, true );
}
@AfterClass
public static void tearDown() {
for( File f: new File( basename ).getParentFile().listFiles( (FileFilter)new PrefixFileFilter( new File( basename ).getName() ) ) ) f.delete();
}
@Test
public void testTrue() {
TrueDocumentIterator trueDocumentIterator = TrueDocumentIterator.getInstance( index );
assertEquals( 0, trueDocumentIterator.nextDocument() );
assertEquals( IntervalIterators.TRUE, trueDocumentIterator.intervalIterator() );
assertEquals( 1, trueDocumentIterator.nextDocument() );
assertEquals( IntervalIterators.TRUE, trueDocumentIterator.intervalIterator() );
assertEquals( 2, trueDocumentIterator.nextDocument() );
assertEquals( IntervalIterators.TRUE, trueDocumentIterator.intervalIterator() );
assertEquals( -1, trueDocumentIterator.nextDocument() );
assertEquals( -1, trueDocumentIterator.nextDocument() );
}
@Test
public void testFalse() {
FalseDocumentIterator falseDocumentIterator = FalseDocumentIterator.getInstance( index );
assertEquals( -1, falseDocumentIterator.nextDocument() );
assertEquals( -1, falseDocumentIterator.nextDocument() );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy