Class SortingReader
A proxy that sorts records.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionSortingReader(DataReader reader) Creates a reader that sorts all records in memory, without overflowing to disk.SortingReader(DataReader reader, long bufferSize) -
Method Summary
Modifier and TypeMethodDescriptionAdds an ascending sort on the given field name orFieldPathexpression, after any fields already added.Adds an ascending or descending sort on the given field name orFieldPathexpression, after any fields already added.Adds a sort on the given field name orFieldPathexpression that uses the collator for string values, after any fields already added.Adds an ascending sort on the given field name orFieldPathexpression, after any fields already added.voidclose()Indicates that this endpoint has finished reading or writing.static voidcopy(DataReader source, DataWriter sink) Writes every remaining record from the source to the sink without opening or closing either.Adds a descending sort on the given field name orFieldPathexpression, after any fields already added.Returns theDataReaderheld inside this one ornullif there isn't one.Returns the reader actually being proxied: the original until the first read, then one over the sorted records (getNestedReader()always returns the original).getOrder()Returns the comparator that defines the sort order; with no fields added, records are compared on all their fields.booleanvoidopen()Makes this endpoint ready for reading or writing.protected RecordreadImpl()Overridden by subclasses to read the next record from thisDataReader.setCacheFieldIndexes(boolean cacheFieldIndexes) Methods inherited from class com.northconcepts.datapipeline.core.ProxyReader
addExceptionProperties, available, interceptRecord, map, map, setNestedDataReader, setNestedDataReaderMethods inherited from class com.northconcepts.datapipeline.core.DataReader
addLineage, getBufferSize, getNestedEndpoint, getReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Constructor Details
-
SortingReader
- Parameters:
reader-bufferSize- memory buffer in bytes
-
SortingReader
Creates a reader that sorts all records in memory, without overflowing to disk.
-
-
Method Details
-
getNestedReader
Description copied from class:DataReaderReturns theDataReaderheld inside this one ornullif there isn't one.- Overrides:
getNestedReaderin classProxyReader
-
getNestedReader0
Returns the reader actually being proxied: the original until the first read, then one over the sorted records (getNestedReader()always returns the original). -
isCacheFieldIndexes
public boolean isCacheFieldIndexes() -
setCacheFieldIndexes
-
getOrder
Returns the comparator that defines the sort order; with no fields added, records are compared on all their fields. -
add
Adds an ascending sort on the given field name orFieldPathexpression, after any fields already added. -
add
Adds an ascending or descending sort on the given field name orFieldPathexpression, after any fields already added. -
asc
Adds an ascending sort on the given field name orFieldPathexpression, after any fields already added. -
desc
Adds a descending sort on the given field name orFieldPathexpression, after any fields already added. -
add
Adds a sort on the given field name orFieldPathexpression that uses the collator for string values, after any fields already added. -
open
public void open()Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classProxyReader
-
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classProxyReader- Throws:
DataException
-
readImpl
Description copied from class:DataReaderOverridden by subclasses to read the next record from thisDataReader. The default implementation ofDataReader.read()now insures that this method will not be called again after it returns anull.If no record is available,
nullwill be returned.Contract for subclasses (see also
docs/authoring/DataReader.md):- Return
nullexactly once to signal end-of-stream. - Do not call this method directly —
DataReader.read()is the template method that wraps exceptions, increments the record count, and tracks lineage. - Do not call
DataEndpoint.incrementRecordCount()here;DataReader.read()already does. - Throw raw exceptions;
DataReader.read()wraps them viaexception(throwable).
- Overrides:
readImplin classProxyReader- Throws:
Throwable
- Return
-
copy
Writes every remaining record from the source to the sink without opening or closing either.- Throws:
Throwable
-