Package cleo.search.store

Examples of cleo.search.store.StaticIntArrayPartition


  }
 
  protected IntArrayPartition initFilterStore() {
    long startTime = System.currentTimeMillis();
   
    IntArrayPartition p = new StaticIntArrayPartition(elementStore.getIndexStart(), elementStore.capacity());
   
    try {
      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));
        }
      }
    } catch(Exception e) {
      getLogger().error("failed to initialize filter store");
    }
View Full Code Here


  }
 
  protected IntArrayPartition initFilterStore() {
    long startTime = System.currentTimeMillis();
   
    IntArrayPartition p = new StaticIntArrayPartition(elementStore.getIndexStart(), elementStore.capacity());
   
    try {
      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));
        }
      }
    } catch(Exception e) {
      getLogger().error("failed to initialize filter store");
    }
View Full Code Here

  public void testMinMaxOnIntArrayPartition() {
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
   
    // Normal case
    IntArrayPartition p = new StaticIntArrayPartition(rand.nextInt(1000), 1000);
    for(int i = p.getIndexStart(), end = p.getIndexEnd(); i < end; i++) {
      int val = rand.nextInt();
      if(val > max) max = val;
      if(val < min) min = val;
      p.set(i, val);
    }
   
    assertEquals(max, Stores.max(p));
    assertEquals(min, Stores.min(p));
   
    // Corner cases
    p = null;
    assertEquals(0, Stores.max(p));
    assertEquals(0, Stores.min(p));
   
    p = new StaticIntArrayPartition(rand.nextInt(1000), 0);
    assertEquals(0, Stores.max(p));
    assertEquals(0, Stores.min(p));
  }
View Full Code Here

  public void testStaticIntArrayPartition() {
    int indexStart = rand.nextInt(10000);
    int capacity = Math.max(1000, rand.nextInt(10000));
    int indexEnd = indexStart + capacity;
   
    StaticIntArrayPartition p = new StaticIntArrayPartition(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);
      int value = rand.nextInt();
     
      p.set(index, value);
      assertEquals(value, p.get(index));
    }
   
    try {
      p.set(indexStart - 1, rand.nextInt());
    } catch(Exception e) {
      assertTrue(e.getClass() == ArrayIndexOutOfBoundsException.class);
    }
   
    try {
      p.set(indexEnd, rand.nextInt());
    } 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.StaticIntArrayPartition

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.