private Set<DomainVersion> detectCachedVersions(SortedSet<CueballFilePath> cachedFiles) throws IOException { Set<DomainVersion> cachedVersions = new HashSet<DomainVersion>(); for (CueballFilePath file : cachedFiles) { DomainVersion version = domain.getVersion(file.getVersion()); if (version != null) { cachedVersions.add(version); } } return cachedVersions; }
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()); }