synchronized void sort(boolean now) throws TException, IOException { List<Segment> unsortedSegments = Segment.getSegments(root, getSegmentsPath(), false); if (!unsortedSegments.isEmpty()) { now = now || unsortedSegments.size() > 30; now = now || totalSize(unsortedSegments) > segmentSize; if (now) { // we should sort now Segment sorted = Segment.createSortedSegment( root, getSegmentsPath(), unsortedSegments.get(0).timestamp, unsortedSegments); // and now delete the replaced segments for (Segment segment : unsortedSegments) { segment.delete(); } logger.info("Sorted %d unsorted segments into %s", unsortedSegments.size(), sorted); } } }
public List<Segment> getSortedSegments() { return Segment.getSegments(root, getSegmentsPath(), true); }
public List<Segment> getSegments() { return Segment.getSegments(root, getSegmentsPath()); }
public List<Segment> getOptimizedSegments() { return Segment.getSegments(root, getOptimizedPath()); }