Class StringSort
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.sort.StringSort
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Iterable<java.lang.String>
public class StringSort extends java.lang.Object implements java.lang.Iterable<java.lang.String>, java.io.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, java.util.Comparator<java.lang.String> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String id)
void
close()
java.util.Iterator<java.lang.String>
getIds()
long
getSize()
boolean
isEmpty()
java.util.Iterator<java.lang.String>
iterator()
void
sort()
boolean
usingFile()
-
-
-
Field Detail
-
BATCH_SIZE
public static final int BATCH_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(java.lang.String id) throws java.io.IOException
- Throws:
java.io.IOException
-
sort
public void sort() throws java.io.IOException
- Throws:
java.io.IOException
-
getIds
public java.util.Iterator<java.lang.String> getIds() throws java.io.IOException
- Throws:
java.io.IOException
-
getSize
public long getSize()
-
isEmpty
public boolean isEmpty()
-
usingFile
public boolean usingFile()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
-
-