Пример #1
0
 private void testTwoIntersects(long key, Operator plan) {
   Cursor cursor = cursor(plan, queryContext, queryBindings);
   cursor.openTopLevel();
   Row row = cursor.next();
   assertEquals(Long.valueOf(key), getLong(row, 0));
   assertNull(cursor.next());
 }
Пример #2
0
 public long indexRows(Cursor cursor) throws IOException {
   documentCount = 0;
   cursor.openTopLevel();
   Row row;
   do {
     row = cursor.next();
     indexRow(row);
   } while (row != null);
   cursor.closeTopLevel();
   return documentCount;
 }
Пример #3
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));
   }
 }
Пример #4
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));
   }
 }