Examples of BigArrayImpl


Examples of com.leansoft.bigqueue.BigArrayImpl

            String path,
            String name,
            int gcPeriodInSec,
            SerDe<E> serDe,
            long sizeLimit) throws IOException {
        innerArray = new BigArrayImpl(path, name);
        // the ttl does not matter here since queue front index page is always cached
        this.queueFrontIndexPageFactory = new MappedPageFactoryImpl(QUEUE_FRONT_INDEX_PAGE_SIZE,
                ((BigArrayImpl)innerArray).getArrayDirectory() + QUEUE_FRONT_INDEX_PAGE_FOLDER,
                10 * 1000/*does not matter*/);
        IMappedPage queueFrontIndexPage = this.queueFrontIndexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

  private String testDir = TestUtil.TEST_BASE_DIR + "bigarray/unit";
  private IBigArray bigArray;

  @Test
  public void simpleTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "simple_test");
    assertNotNull(bigArray);
   
    for(int i = 1; i <= 3; i++) {
      assertTrue(bigArray.getTailIndex() == 0L);
      assertTrue(bigArray.getHeadIndex() == 0L);
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    }
  }
 
  @Test
  public void removeBeforeIndexTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "remove_before_index_test");
    assertNotNull(bigArray);
   
    int loop = 5000000;
    for(int i = 0; i < loop; i++) {
      bigArray.append(("" + i).getBytes());
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    }
  }
 
  @Test
  public void removeBeforeTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "remove_before_test");
    assertNotNull(bigArray);
   
    int loop = 5000000;
    for(int i = 0; i < loop; i++) {
      bigArray.append(("" + i).getBytes());
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

   
  }
 
  @Test
  public void bigLoopTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "big_loop_test");
    assertNotNull(bigArray);
   
    int loop = 1000000;
    long lastAppendTime = System.currentTimeMillis();
    for(int i = 0; i < loop; i++) {
      bigArray.append(("" + i).getBytes());
      assertTrue(bigArray.getTailIndex() == 0L);
      assertTrue(bigArray.getHeadIndex() == i + 1L);
      assertTrue(bigArray.size() == i + 1L);
      assertTrue(!bigArray.isEmpty());
      assertTrue(!bigArray.isFull());
      long currentTime = System.currentTimeMillis();
      long justAppendTime = bigArray.getTimestamp(i);
      assertTrue(justAppendTime <= currentTime);
      assertTrue(justAppendTime >=lastAppendTime);
      lastAppendTime = justAppendTime;
    }
   
    try {
      bigArray.get(loop);
      fail("IndexOutOfBoundsException should be thrown here");
    } catch (IndexOutOfBoundsException ex) {
    }
   
    assertTrue(bigArray.getTailIndex() == 0L);
    assertTrue(bigArray.getHeadIndex() == loop);
    assertTrue(bigArray.size() == loop);
    assertTrue(!bigArray.isEmpty());
    assertTrue(!bigArray.isFull());
    bigArray.close();
   
    // create a new instance on exiting array
      bigArray = new BigArrayImpl(testDir, "big_loop_test");
    assertTrue(bigArray.getTailIndex() == 0L);
    assertTrue(bigArray.getHeadIndex() == loop);
    assertTrue(bigArray.size() == loop);
    assertTrue(!bigArray.isEmpty());
    assertTrue(!bigArray.isFull());
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    assertTrue(!bigArray.isFull());
  }
 
  @Test
  public void loopTimingTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "loop_timing_test");
    assertNotNull(bigArray);
   
    int loop = 1000000;
    long begin = System.currentTimeMillis();
    for(int i = 0; i < loop; i++) {
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    System.out.println("Time used to randomly read " + loop + " items : " + timeInSeconds + " seconds.");
  }
 
  @Test
  public void getClosestIndexTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "get_closest_index_test");
    assertNotNull(bigArray);
   
    assertTrue(IBigArray.NOT_FOUND == bigArray.findClosestIndex(System.currentTimeMillis()));
   
    int loop = 2000000;
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    assertTrue(closestTimeAfter >= closestTime);   
  }
 
  @Test
  public void getBackFileSizeTest() throws IOException {
      bigArray = new BigArrayImpl(testDir, "get_back_file_size_test");
    assertNotNull(bigArray);
   
    assertTrue(bigArray.getBackFileSize() == 0);
   
    bigArray.append("hello".getBytes());
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    assertTrue(bigArray.getBackFileSize() == 0);
  }
 
  @Test
  public void limitBackFileSize() throws IOException {
      bigArray = new BigArrayImpl(testDir, "limit_back_file_size_test");
    assertNotNull(bigArray);
   
    assertTrue(bigArray.getBackFileSize() == 0);
   
    bigArray.append("hello".getBytes());
View Full Code Here

Examples of com.leansoft.bigqueue.BigArrayImpl

    assertTrue(bigArray.getHeadIndex() == loop + 2);
  }
 
  @Test
  public void getItemLength() throws IOException {
    bigArray = new BigArrayImpl(testDir, "get_data_length_test");
    assertNotNull(bigArray);
   
    for(int i = 1; i <= 100; i++) {
      bigArray.append(TestUtil.randomString(i).getBytes());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.