コード例 #1
0
  /*
   * Estimates the "weight" (a unitless value) of the given item.  This is
   * counted as 1 per content and metadata file in the item, plus 100 per
   * gigabyte of streamed data (so that files of 1GB or more cause the batch
   * to end).
   */
  private final int weight(final BulkImportItem<BulkImportItemVersion> item) {
    int result = 0;

    for (final BulkImportItemVersion version : item.getVersions()) {
      result++;

      if (version.hasContent() && !version.contentIsInPlace()) {
        result += (int) ((float) item.sizeInBytes() / ONE_GIGABYTE * 100);
      }
    }

    return (result);
  }