/** * Returns a new <code>Pair</code> instance * with the given left-side and right-side objects. */ public static <V, W> Pair<V, W> create(V v, W w) { return new Pair<V, W>(v, w); }
/** * Returns a textual summary of the top numQueries queries ordered by total time. */ @Override public synchronized String getTopQueriesByTotalTime(int numQueries) { List<Pair<Long, SqlCallStats>> entries = new ArrayList<Pair<Long, SqlCallStats>>(); for (SqlCallStats stats : statsByName.values()) { entries.add(new Pair<Long, SqlCallStats>(stats.getTotalTime(), stats)); } entries.sort(Pair.compareLhSide()); Collections.reverse(entries); StringBuilder sb = new StringBuilder(); for (int i = 0; i < Math.min(entries.size(), numQueries); ++i) { long totalTimeMs = entries.get(i).lhSide; SqlCallStats stats = entries.get(i).rhSide; String line = String.format( "total_time_ms=%-15d total_calls=%-10d query=%s%n", //$NON-NLS-1$ totalTimeMs, stats.getTotalCalls(), stats.getQueryName()); sb.append(line); } return sb.toString(); }
@SuppressWarnings("unchecked") private Pair<List<List<Cell>>, SweepResults> runSweep(CellsSweeper cellsSweeper, SweepTaskRunner spiedSweepRunner, int maxCellTsPairsToExamine, int candidateBatchSize, int deleteBatchSize) { sweepTimestamp.set(Long.MAX_VALUE); List<List<Cell>> sweptCells = Lists.newArrayList(); doAnswer((invocationOnMock) -> { Object[] arguments = invocationOnMock.getArguments(); Collection<Cell> sentinelsToAdd = (Collection<Cell>) arguments[2]; sweptCells.add(new ArrayList(sentinelsToAdd)); return null; }).when(cellsSweeper).sweepCells(eq(TABLE_NAME), any(), any()); SweepResults sweepResults = spiedSweepRunner.run(TABLE_NAME, ImmutableSweepBatchConfig.builder() .maxCellTsPairsToExamine(maxCellTsPairsToExamine) .candidateBatchSize(candidateBatchSize) .deleteBatchSize(deleteBatchSize) .build(), PtBytes.EMPTY_BYTE_ARRAY); return new Pair(sweptCells, sweepResults); }
locksAtSomePoint.add(new Pair(invokeEvent, event)); lastHeldLock.put(process, event); break;
/** * Returns a new <code>Pair</code> instance * with the given left-side and right-side objects. */ public static <V, W> Pair<V, W> create(V v, W w) { return new Pair<V, W>(v, w); }
/** * Returns a textual summary of the top numQueries queries ordered by total time. */ @Override public synchronized String getTopQueriesByTotalTime(int numQueries) { List<Pair<Long, SqlCallStats>> entries = new ArrayList<Pair<Long, SqlCallStats>>(); for (SqlCallStats stats : statsByName.values()) { entries.add(new Pair<Long, SqlCallStats>(stats.getTotalTime(), stats)); } entries.sort(Pair.compareLhSide()); Collections.reverse(entries); StringBuilder sb = new StringBuilder(); for (int i = 0; i < Math.min(entries.size(), numQueries); ++i) { long totalTimeMs = entries.get(i).lhSide; SqlCallStats stats = entries.get(i).rhSide; String line = String.format( "total_time_ms=%-15d total_calls=%-10d query=%s%n", //$NON-NLS-1$ totalTimeMs, stats.getTotalCalls(), stats.getQueryName()); sb.append(line); } return sb.toString(); }
@SuppressWarnings("unchecked") private Pair<List<List<Cell>>, SweepResults> runSweep(CellsSweeper cellsSweeper, SweepTaskRunner spiedSweepRunner, int maxCellTsPairsToExamine, int candidateBatchSize, int deleteBatchSize) { sweepTimestamp.set(Long.MAX_VALUE); List<List<Cell>> sweptCells = Lists.newArrayList(); doAnswer((invocationOnMock) -> { Object[] arguments = invocationOnMock.getArguments(); Collection<Cell> sentinelsToAdd = (Collection<Cell>) arguments[2]; sweptCells.add(new ArrayList(sentinelsToAdd)); return null; }).when(cellsSweeper).sweepCells(eq(TABLE_NAME), any(), any()); SweepResults sweepResults = spiedSweepRunner.run(TABLE_NAME, ImmutableSweepBatchConfig.builder() .maxCellTsPairsToExamine(maxCellTsPairsToExamine) .candidateBatchSize(candidateBatchSize) .deleteBatchSize(deleteBatchSize) .build(), PtBytes.EMPTY_BYTE_ARRAY); return new Pair(sweptCells, sweepResults); }