Package com.senseidb.indexing.activity

Examples of com.senseidb.indexing.activity.CompositeActivityValues


 
@Ignore
  @Test
  public void test1Perf10mInsertsAndUpdateAfterwards() throws Exception {
    Clock.setPredefinedTimeInMinutes(0);
    CompositeActivityValues activityValues = CompositeActivityValues.createCompositeValues(ActivityPersistenceFactory.getInstance(getDirPath()), Collections.EMPTY_LIST, Arrays.asList(new CompositeActivityManager.TimeAggregateInfo("likes", Arrays.asList("10m","5m", "2m"))) , ZoieConfig.DEFAULT_VERSION_COMPARATOR);
    TimeAggregatedActivityValues timeAggregatedActivityValues = (TimeAggregatedActivityValues) activityValues.getActivityValuesMap().get("likes");
    timeAggregatedActivityValues.getAggregatesUpdateJob().stop();
    long insertTime = System.currentTimeMillis();
    Map<String, Object> jsonActivityUpdate = new HashMap<String, Object>();
    jsonActivityUpdate.put("likes", "+1");
    int recordsCount = 1000000;
    int numOfEvents = 10;
    for (int i = 0; i < numOfEvents; i++) {
      Clock.setPredefinedTimeInMinutes(i);
      for (int j = 0; j < recordsCount; j ++) {
        activityValues.update((long)j, String.valueOf(i * recordsCount + j), jsonActivityUpdate);
        if (j % 100000 == 0) {
          System.out.println("Inserted next 100k events j = " + j);
        }
      }
      System.out.println("Updated event = " + i);
    }
    System.out.println("insertTime = " + (System.currentTimeMillis() - insertTime));
    activityValues.syncWithPersistentVersion(String.valueOf((numOfEvents - 1) * recordsCount + recordsCount - 1));
    System.out.println("persistentTime = " + (System.currentTimeMillis() - insertTime));
    assertEquals(numOfEvents, timeAggregatedActivityValues.getValuesMap().get("5m").fieldValues[50000]);
    assertEquals(numOfEvents, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[50000]);
    assertEquals(numOfEvents, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[90000]);
    long updateTime = System.currentTimeMillis();
    timeAggregatedActivityValues.getAggregatesUpdateJob().run();
    assertEquals(5, timeAggregatedActivityValues.getValuesMap().get("5m").fieldValues[50000]);
    assertEquals(10, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[50000]);
    assertEquals(10, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[90000]);
    System.out.println("updateTime = " + (System.currentTimeMillis() - updateTime));
    activityValues.flush();
    Thread.sleep(2000);
    activityValues.close();
   
     activityValues = CompositeActivityValues.createCompositeValues(ActivityPersistenceFactory.getInstance(getDirPath()), Collections.EMPTY_LIST, Arrays.asList(new CompositeActivityManager.TimeAggregateInfo("likes", Arrays.asList("10m","5m", "2m"))) , ZoieConfig.DEFAULT_VERSION_COMPARATOR);
    timeAggregatedActivityValues = (TimeAggregatedActivityValues) activityValues.getActivityValuesMap().get("likes");
    timeAggregatedActivityValues.getAggregatesUpdateJob().stop();
    assertEquals(5, timeAggregatedActivityValues.getValuesMap().get("5m").fieldValues[50000]);
    assertEquals(10, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[50000]);
    assertEquals(10, timeAggregatedActivityValues.getValuesMap().get("10m").fieldValues[90000]);
  }
View Full Code Here

TOP

Related Classes of com.senseidb.indexing.activity.CompositeActivityValues

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.