Package it.unimi.dsi.mg4j.query.nodes

Examples of it.unimi.dsi.mg4j.query.nodes.Query


    assertFalse( intervalIterator.hasNext() );
    assertFalse( documentIterator.hasNext() );
  }

  public void testQuery() throws IOException, QueryBuilderVisitorException {
    Query query = new Consecutive( new Term( "a" ), new Remap( new Select( "index1", new Term( "b" ) ), new CharSequence[] { "index1" }, new CharSequence[] { "index0" } ) );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( indexMap, index0, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertTrue( documentIterator.hasNext() );
    assertEquals( 0, documentIterator.nextDocument() );
    IntervalIterator intervalIterator = documentIterator.intervalIterator( index0 );
    assertEquals( it.unimi.dsi.util.Interval.valueOf( 0, 1 ), intervalIterator.nextInterval() );
    assertFalse( intervalIterator.hasNext() );
View Full Code Here


    assertFalse( documentIterator.hasNext() );
  }

 
  public void testDoubleRemapping() throws IOException, QueryBuilderVisitorException {
    Query query = new Remap( new Or( new Term( "a" ), new Select( "index1", new Term( "b" ) ) ), new CharSequence[] { "index0", "index1" }, new CharSequence[] { "index2", "index3" } );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( indexMap, index0, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    IntervalIterator intervalIterator;
   
    assertTrue( documentIterator.hasNext() );

    assertEquals( 0, documentIterator.nextDocument() );
View Full Code Here

    String basename = File.createTempFile( getClass().getSimpleName(), "test" ).getCanonicalPath();
    new IndexBuilder( basename, new StringArrayDocumentCollection( "a a b c d e" ) ).run();
    index = DiskBasedIndex.getInstance( basename + "-text", true, true );
    simpleParser = new SimpleParser( index.termProcessor );

    Query query = simpleParser.parse( "(a|b|d)<(a|b|d)" );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    documentIterator.nextDocument();
    IntervalIterator intervalIterator = documentIterator.intervalIterator();
    assertEquals( Interval.valueOf( 0, 1 ), intervalIterator.nextInterval() );
    assertEquals( Interval.valueOf( 1, 2 ), intervalIterator.nextInterval() );
    assertEquals( Interval.valueOf( 2, 4 ), intervalIterator.nextInterval() );
View Full Code Here

    simpleParser = new SimpleParser( index.termProcessor );
  }


  public void testSkipBug() throws QueryParserException, QueryBuilderVisitorException, IOException {
    Query query = simpleParser.parse( "a + b + c" );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( 2, documentIterator.skipTo( 2 ) );
    documentIterator.dispose();
  }
View Full Code Here

    for( File f: new File( basename ).getParentFile().listFiles( (FileFilter)new PrefixFileFilter( new File( basename ).getName() ) ) )  f.delete();
  }

 
  public void testSkipBug() throws QueryParserException, QueryBuilderVisitorException, IOException {
    Query query = simpleParser.parse( "a | b | c" );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( 2, documentIterator.skipTo( 2 ) );
    documentIterator.dispose();
  }
View Full Code Here

  public void tearDown() {
    for( File f: new File( basename ).getParentFile().listFiles( (FileFilter)new PrefixFileFilter( new File( basename ).getName() ) ) )  f.delete();
  }

  public void testWeights() throws QueryBuilderVisitorException, IOException {
    Query query = new Weight( 0.5, new And( new Term( "a" ), new Term( "b" ) ) );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( .5, documentIterator.weight(), 0 );
    documentIterator.dispose();

    query = new Weight( .1, new Weight( 0.5, new And( new Weight( .2, new Term( "a" ) ), new Term( "b" ) ) ) );
    documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( .5, documentIterator.weight(), 0 );
    documentIterator.dispose();
}
View Full Code Here

TOP

Related Classes of it.unimi.dsi.mg4j.query.nodes.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.