Package cleo.search.store

Examples of cleo.search.store.StaticLongArrayPartition


  }
 
  protected LongArrayPartition initFilterStore() {
    long startTime = System.currentTimeMillis();
   
    LongArrayPartition p = new StaticLongArrayPartition(elementStore.getIndexStart(), elementStore.capacity());
    for(int i = p.getIndexStart(), end = p.getIndexEnd(); i < end; i++) {
      E element = elementStore.getElement(i);
      if(element != null) {
        p.set(i, bloomFilter.computeIndexFilter(element));
      }
    }
   
    long totalTime = System.currentTimeMillis() - startTime;
    logger.info(getName() + " init filter store: " + totalTime + " ms");
View Full Code Here


  public void testStaticLongArrayPartition() {
    int indexStart = rand.nextInt(10000);
    int capacity = Math.max(1000, rand.nextInt(10000));
    int indexEnd = indexStart + capacity;
   
    StaticLongArrayPartition p = new StaticLongArrayPartition(indexStart, capacity);

    assertEquals(indexStart, p.getIndexStart());
    assertEquals(indexEnd, p.getIndexEnd());
    assertEquals(capacity, p.capacity());
   
    assertTrue(p.hasIndex(p.getIndexStart()));
    assertFalse(p.hasIndex(p.getIndexStart() - 1));
   
    assertTrue(p.hasIndex(p.getIndexEnd() - 1));
    assertFalse(p.hasIndex(p.getIndexEnd()));
   
    for(int i = 0, cnt = rand.nextInt(p.capacity()); i < cnt; i++) {
      int index = indexStart + rand.nextInt(capacity);
      long value = rand.nextLong();
     
      p.set(index, value);
      assertEquals(value, p.get(index));
    }
   
    try {
      p.set(indexStart - 1, rand.nextLong());
    } catch(Exception e) {
      assertTrue(e.getClass() == ArrayIndexOutOfBoundsException.class);
    }
   
    try {
      p.set(indexEnd, rand.nextLong());
    } catch(Exception e) {
      assertTrue(e.getClass() == ArrayIndexOutOfBoundsException.class);
    }
   
    p.clear();
    for(int i = indexStart; i < indexEnd; i++) {
      assertEquals(0, p.get(i));
    }
  }
View Full Code Here

TOP

Related Classes of cleo.search.store.StaticLongArrayPartition

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.