Example #1
0
 private void intersect(int runs, int leftIndexKey, int rightIndexKey, String label) {
   Ordering ordering = new Ordering();
   ordering.append(field(indexRowType, 1), true);
   ordering.append(field(indexRowType, 2), true);
   ordering.append(field(indexRowType, 3), true);
   ordering.append(field(indexRowType, 4), true);
   ordering.append(field(indexRowType, 5), true);
   IndexBound leftBound =
       new IndexBound(row(indexRowType, leftIndexKey), new SetColumnSelector(0));
   IndexKeyRange leftKeyRange =
       IndexKeyRange.bounded(indexRowType, leftBound, true, leftBound, true);
   IndexBound rightBound =
       new IndexBound(row(indexRowType, rightIndexKey), new SetColumnSelector(0));
   IndexKeyRange rightKeyRange =
       IndexKeyRange.bounded(indexRowType, rightBound, true, rightBound, true);
   Operator leftSetup = indexScan_Default(indexRowType, leftKeyRange, ordering);
   Operator rightSetup = indexScan_Default(indexRowType, rightKeyRange, ordering);
   TimeOperator timeLeftSetup = new TimeOperator(leftSetup);
   TimeOperator timeRightSetup = new TimeOperator(rightSetup);
   Operator intersect =
       intersect_Ordered(
           timeLeftSetup,
           timeRightSetup,
           indexRowType,
           indexRowType,
           5,
           5,
           5,
           JoinType.INNER_JOIN,
           IntersectOption.OUTPUT_LEFT,
           null);
   long start = System.nanoTime();
   for (int r = 0; r < runs; r++) {
     Cursor cursor = cursor(intersect, queryContext, queryBindings);
     cursor.openTopLevel();
     while (cursor.next() != null) ;
   }
   long stop = System.nanoTime();
   long intersectNsec = stop - start - timeLeftSetup.elapsedNsec() - timeRightSetup.elapsedNsec();
   if (label != null) {
     // Report the difference
     double averageUsecPerRow = intersectNsec / (1000.0 * runs * 2 * ROWS);
     System.out.println(String.format("%s: %s usec/row", label, averageUsecPerRow));
   }
 }
Example #2
0
 private void run(int runs, int innerRows, boolean report) {
   Operator setupOuter = groupScan_Default(group);
   TimeOperator timeSetupOuter = new TimeOperator(setupOuter);
   Operator setupInner = limit_Default(groupScan_Default(group), innerRows);
   TimeOperator timeSetupInner = new TimeOperator(setupInner);
   Operator plan = map_NestedLoops(timeSetupOuter, timeSetupInner, 0, pipelineMap(), 1);
   long start = System.nanoTime();
   for (int r = 0; r < runs; r++) {
     Cursor cursor = cursor(plan, queryContext, queryBindings);
     cursor.openTopLevel();
     while (cursor.next() != null) ;
   }
   long stop = System.nanoTime();
   long mapNsec = stop - start - timeSetupInner.elapsedNsec() - timeSetupOuter.elapsedNsec();
   if (report) {
     // Report the difference
     double averageUsecPerRow = mapNsec / (1000.0 * runs * (OUTER_ROWS * (innerRows + 1)));
     System.out.println(
         String.format("inner/outer = %s: %s usec/row", innerRows, averageUsecPerRow));
   }
 }