@Override public int compare(IndexComponentFileReference a, IndexComponentFileReference b) { int startCmp = -Long.compare(a.getSequenceStart(), b.getSequenceStart()); if (startCmp != 0) { return startCmp; } return -Long.compare(a.getSequenceEnd(), b.getSequenceEnd()); } }
public boolean isWithin(IndexComponentFileReference other) { return sequenceStart >= other.getSequenceStart() && sequenceEnd <= other.getSequenceEnd(); }
private void deleteIndexInvalidComponents(File index) throws IOException, ParseException { final File[] indexComponentFiles = index.listFiles(COMPONENT_FILES_FILTER); if (indexComponentFiles == null) { throw new IOException(index + " doesn't exist or an IO error occurred"); } final long validComponentSequence = getIndexCheckpointManager(index).getValidComponentSequence(); for (File componentFile : indexComponentFiles) { // delete any file with start sequence > valid component sequence final long fileStart = IndexComponentFileReference.of(componentFile.getName()).getSequenceStart(); if (fileStart > validComponentSequence) { LOGGER.info(() -> "Deleting invalid component file: " + componentFile.getAbsolutePath()); Files.delete(componentFile.toPath()); } } }
public static String getMergeSequence(String firstComponentName, String lastComponentName) { long mergeSequenceStart = IndexComponentFileReference.of(firstComponentName).getSequenceStart(); long mergeSequenceEnd = IndexComponentFileReference.of(lastComponentName).getSequenceEnd(); return mergeSequenceStart + DELIMITER + mergeSequenceEnd; } }