public static CueballFilePath getCueballFilePathForVersion(
     DomainVersion version,
     DomainVersion currentVersion,
     String localPartitionRoot,
     String localPartitionRootCache,
     boolean isBase) {
   if (currentVersion != null && currentVersion.equals(version)) {
     // If version is current version, data is in root
     return new CueballFilePath(
         localPartitionRoot + "/" + Cueball.getName(version.getVersionNumber(), isBase));
   } else {
     // Otherwise, version must be in cache
     return new CueballFilePath(
         localPartitionRootCache + "/" + Cueball.getName(version.getVersionNumber(), isBase));
   }
 }
 public static boolean isEmptyVersion(
     PartitionRemoteFileOps partitionRemoteFileOps, DomainVersion domainVersion)
     throws IOException {
   return !partitionRemoteFileOps.exists(Cueball.getName(domainVersion.getVersionNumber(), true))
       && !partitionRemoteFileOps.exists(Cueball.getName(domainVersion.getVersionNumber(), false));
 }
  public static void runUpdateCore(
      DomainVersion currentVersion,
      DomainVersion updatingToVersion,
      IncrementalUpdatePlan updatePlan,
      String updateWorkRoot,
      String localPartitionRoot,
      String localPartitionRootCache,
      ICueballMerger cueballMerger,
      int keyHashSize,
      int valueSize,
      int hashIndexBits,
      CueballCompressionCodec compressionCodec,
      ValueTransformer valueTransformer,
      PartitionUpdateTaskStatistics statistics)
      throws IOException {

    // Determine new base path
    String newBasePath =
        updateWorkRoot + "/" + Cueball.getName(updatingToVersion.getVersionNumber(), true);

    // Determine files from versions
    CueballFilePath base =
        getCueballFilePathForVersion(
            updatePlan.getBase(),
            currentVersion,
            localPartitionRoot,
            localPartitionRootCache,
            true);
    List<CueballFilePath> deltas = new ArrayList<CueballFilePath>();
    for (DomainVersion delta : updatePlan.getDeltasOrdered()) {
      deltas.add(
          getCueballFilePathForVersion(
              delta, currentVersion, localPartitionRoot, localPartitionRootCache, false));
    }

    // Check that all required files are available
    checkRequiredFileExists(base.getPath());
    for (CueballFilePath delta : deltas) {
      checkRequiredFileExists(delta.getPath());
    }

    HankTimer timer = new HankTimer();
    // If there are no deltas, simply move the required base to the target version.
    // Otherwise, perform merging.
    if (deltas.size() == 0) {
      if (!new File(base.getPath()).renameTo(new File(newBasePath))) {
        throw new IOException(
            "Failed to rename Cueball base: " + base.getPath() + " to: " + newBasePath);
      }
    } else {
      cueballMerger.merge(
          base,
          deltas,
          newBasePath,
          keyHashSize,
          valueSize,
          valueTransformer,
          hashIndexBits,
          compressionCodec);
    }
    statistics.getDurationsMs().put("Cueball merge", timer.getDurationMs());
  }