@Override public Deleter getDeleter(DiskPartitionAssignment assignment, int partitionNumber) throws IOException { String localDir = getTargetDirectory(assignment, partitionNumber); return new CurlyDeleter(localDir); }
@Override public RemoteDomainVersionDeleter getRemoteDomainVersionDeleter(RemoteLocation location) throws IOException { return new CurlyRemoteDomainVersionDeleter(domain, getRoot(location), partitionRemoteFileOpsFactory); }
@Override protected void fetchVersion(DomainVersion version, String fetchRoot) throws IOException { // Fetch Cueball version. fetchCueballVersion(version, fetchRoot); if (shouldFetchCurlyVersion(version)) { fetchCurlyVersion(version, fetchRoot); } }
private Compactor getCompactor(String localDir, int partitionNumber) throws IOException { return new CurlyCompactor(domain, getPartitionRemoteFileOps(RemoteLocation.DOMAIN_BUILDER, partitionNumber), localDir, new CurlyCompactingMerger(recordFileReadBufferBytes), new CueballStreamBufferMergeSort.Factory(keyHashSize, cueballValueNumBytes, hashIndexBits, getCompressionCodec(), null), new ICurlyReaderFactory() { @Override public ICurlyReader getInstance(CurlyFilePath curlyFilePath) throws IOException { // Note: key file reader is null as it will *not* be used return new CurlyReader(curlyFilePath, recordFileReadBufferBytes, null, 10L << 20, 1 << 10, blockCompressionCodec, offsetNumBytes, offsetInBlockNumBytes, true, 10 << 10); } } ); }
private CurlyFastPartitionUpdater getFastPartitionUpdater(String localDir, int partNum) throws IOException { return new CurlyFastPartitionUpdater(domain, getPartitionRemoteFileOps(RemoteLocation.PARTITION_SERVER, partNum), new CurlyMerger(), new CueballMerger(), keyHashSize, offsetNumBytes, offsetInBlockNumBytes, hashIndexBits, getCompressionCodec(), localDir); }
private Writer getWriter(DomainVersion domainVersion, PartitionRemoteFileOps partitionRemoteFileOps, int partitionNumber, Writer keyFileWriter) throws IOException { IncrementalDomainVersionProperties domainVersionProperties = getDomainVersionProperties(domainVersion); OutputStream outputStream = partitionRemoteFileOps.getOutputStream(getName(domainVersion.getVersionNumber(), domainVersionProperties.isBase())); return new CurlyWriter(outputStream, keyFileWriter, offsetNumBytes, valueFoldingCacheCapacity, blockCompressionCodec, compressedBlockSizeThreshold, offsetInBlockNumBytes); }
stooge1.print(new Moe()); // All three have overload for Moe, // so the overload from the dynamic type of stooge1 gets called stooge1.print(new Curly()); // Compiler thinks stooge1 is Larry, // so it does not know that it has an overload for Curly. // It uses the overload for Larry instead, because Curly is a Larry stooge1.print(new Larry()); // Same logic as above applies. stooge2.print(new Curly()); // Compiler thinks stooge2 is Moe, so its only overload // is for Moe. Since the dynamic type is Larry, first overload is invoked
@Override protected Set<DomainVersion> detectCachedDeltasCore() throws IOException { return detectCachedVersions(Cueball.getDeltas(localPartitionRootCache), Curly.getDeltas(localPartitionRootCache)); }
@Override protected Set<DomainVersion> detectCachedBasesCore() throws IOException { return detectCachedVersions(Cueball.getBases(localPartitionRootCache), Curly.getBases(localPartitionRootCache)); }
public CurlyFilePath getCurlyFilePathForVersion(DomainVersion version, DomainVersion currentVersion, boolean isBase) { if (currentVersion != null && currentVersion.equals(version)) { // If version is current version, data is in root return new CurlyFilePath(localPartitionRoot + "/" + Curly.getName(version.getVersionNumber(), isBase)); } else { // Otherwise, version must be in cache return new CurlyFilePath(localPartitionRootCache + "/" + Curly.getName(version.getVersionNumber(), isBase)); } } }
public AbstractCurlyPartitionUpdater(Domain domain, PartitionRemoteFileOps partitionRemoteFileOps, String localPartitionRoot) throws IOException { super(domain, localPartitionRoot, new CurlyUpdatePlanner(domain)); this.partitionRemoteFileOps = partitionRemoteFileOps; }
@Override public Writer getCompactorWriter(DomainVersion domainVersion, PartitionRemoteFileOps fileOps, int partitionNumber) throws IOException { Writer cueballWriter = cueballStorageEngine.getCompactorWriter(domainVersion, fileOps, partitionNumber); return getWriter(domainVersion, fileOps, partitionNumber, cueballWriter); }
@Override public Local initialValue() { return new Local(); } };
public static String getName(int versionNumber, boolean base) { String s = padVersionNumber(versionNumber) + "."; if (base) { s += "base"; } else { s += "delta"; } return s + ".curly"; }
@Override public ICurlyReader getInstance(CurlyFilePath curlyFilePath) throws IOException { // Note: key file reader is null as it will *not* be used return new CurlyReader(curlyFilePath, recordFileReadBufferBytes, null, 10L << 20, 1 << 10, blockCompressionCodec, offsetNumBytes, offsetInBlockNumBytes, true, 10 << 10); } }
@Override public RemoteDomainCleaner getRemoteDomainCleaner() throws IOException { return new CurlyRemoteDomainCleaner(domain, numRemoteLeafVersionsToKeep); }
public CurlyFilePath(String path) { super(path, Curly.parseVersionNumber(new File(path).getName())); } }
@Override public IncrementalUpdatePlanner getUpdatePlanner(Domain domain) { return new CurlyUpdatePlanner(domain); }
@Override public Writer getWriter(DomainVersion domainVersion, PartitionRemoteFileOps partitionRemoteFileOps, int partitionNumber) throws IOException { Writer cueballWriter = cueballStorageEngine.getWriter(domainVersion, partitionRemoteFileOps, partitionNumber); return getWriter(domainVersion, partitionRemoteFileOps, partitionNumber, cueballWriter); }