Ejemplo n.º 1
0
  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);
      }
    }
  }
Ejemplo n.º 2
0
 public List<Segment> getSortedSegments() {
   return Segment.getSegments(root, getSegmentsPath(), true);
 }
Ejemplo n.º 3
0
 public List<Segment> getSegments() {
   return Segment.getSegments(root, getSegmentsPath());
 }
Ejemplo n.º 4
0
 public List<Segment> getOptimizedSegments() {
   return Segment.getSegments(root, getOptimizedPath());
 }