Class StringSort
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.sort.StringSort
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<String>
public class StringSort extends Object implements Iterable<String>, Closeable
Utility class to store a list of string and perform sort on that. For small size the list would be maintained in memory. If the size crosses the required threshold then the sorting would be performed externally
-
-
Field Summary
Fields Modifier and Type Field Description static int
BATCH_SIZE
-
Constructor Summary
Constructors Constructor Description StringSort(int overflowToDiskThreshold, Comparator<String> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String id)
void
close()
Iterator<String>
getIds()
long
getSize()
boolean
isEmpty()
Iterator<String>
iterator()
void
sort()
boolean
usingFile()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
BATCH_SIZE
public static final int BATCH_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StringSort
public StringSort(int overflowToDiskThreshold, Comparator<String> comparator)
-
-
Method Detail
-
add
public void add(String id) throws IOException
- Throws:
IOException
-
sort
public void sort() throws IOException
- Throws:
IOException
-
getIds
public Iterator<String> getIds() throws IOException
- Throws:
IOException
-
getSize
public long getSize()
-
isEmpty
public boolean isEmpty()
-
usingFile
public boolean usingFile()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-