public static int getNumTasks(int numWorkUnits, int minUnitsPerThread, int maxExecutionThreads) {
    if (numWorkUnits <= minUnitsPerThread) {
      return 1;
    }
    if (maxExecutionThreads <= 0) {
      maxExecutionThreads = MAX_NUM_THREADS_PER_QUERY;
    }
    return Math.min((numWorkUnits + minUnitsPerThread - 1) / minUnitsPerThread, maxExecutionThreads);
  }
@Test
  public void testGetNumTasks() {
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(2, 3, 4), 1);
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(7, 3, 4), 3);
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(9, 3, 4), 3);
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(10, 3, 4), 4);
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(100, 3, 4), 4);
    int targetPerThread = 5;
    int numWorkUnits = QueryMultiThreadingUtils.MAX_NUM_THREADS_PER_QUERY * targetPerThread;
    Assert.assertEquals(QueryMultiThreadingUtils.getNumTasks(numWorkUnits + 10, targetPerThread, -1),
        QueryMultiThreadingUtils.MAX_NUM_THREADS_PER_QUERY);
  }