Class SortedJoinPipe<K,L,R>
- java.lang.Object
-
- org.pipecraft.pipes.sync.inter.join.SortedJoinPipe<K,L,R>
-
- Type Parameters:
K- The type of the key used for matching recordsL- The type of left side recordsR- The type of right side records
- All Implemented Interfaces:
Closeable,AutoCloseable,BasePipe,Pipe<JoinRecord<K,L,R>>
public class SortedJoinPipe<K,L,R> extends Object implements Pipe<JoinRecord<K,L,R>>
A pipe performing a join operation between a 'left' pipe of type L, and a list of 'right' pipes of type R. Both left and right pipes must be ordered by some key, and may have duplicates. The output type for this pipe isJoinRecord, which consists of the key, the left matches and the right matches. The join can work in LEFT/INNER/FULL_INNER/OUTER mode. SeeJoinModefor more details.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description SortedJoinPipe(List<? extends Pipe<R>> rightPipes, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator)Constructor A constructor for the case of no left pipe.SortedJoinPipe(Pipe<L> leftPipe, FailableFunction<L,K,PipeException> leftKeyExtractor, List<? extends Pipe<R>> rightPipes, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator, JoinMode joinMode)ConstructorSortedJoinPipe(Pipe<L> leftPipe, FailableFunction<L,K,PipeException> leftKeyExtractor, Pipe<R> rightPipe, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator, JoinMode joinMode)Constructor To be used when there's a single right pipe.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()floatgetProgress()JoinRecord<K,L,R>next()JoinRecord<K,L,R>peek()voidstart()Performs pre-processing prior to item flow throw the pipe.
-
-
-
Constructor Detail
-
SortedJoinPipe
public SortedJoinPipe(Pipe<L> leftPipe, FailableFunction<L,K,PipeException> leftKeyExtractor, List<? extends Pipe<R>> rightPipes, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator, JoinMode joinMode)
Constructor- Parameters:
leftPipe- The left side pipe in the join operationleftKeyExtractor- The extractor of the key from the data type of the left piperightPipes- The list of right side pipes. The order is important, and determines the ids given to the pipes in the iteration outputs (SeeJoinRecord).rightKeyExtractor- The extractor of the key from the data type of the right pipeskeyComparator- The total order definition to use when merging the data from the different input pipes.joinMode- The policy for performing the join. SeeJoinMode.
-
SortedJoinPipe
public SortedJoinPipe(Pipe<L> leftPipe, FailableFunction<L,K,PipeException> leftKeyExtractor, Pipe<R> rightPipe, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator, JoinMode joinMode)
Constructor To be used when there's a single right pipe.- Parameters:
leftPipe- The left side pipe in the join operationleftKeyExtractor- The extractor of the key from the data type of the left piperightPipe- The right side piperightKeyExtractor- The extractor of the key from the data type of the right pipeskeyComparator- The total order definition to use when merging the data from the different input pipes.joinMode- The policy for performing the join. SeeJoinMode.
-
SortedJoinPipe
public SortedJoinPipe(List<? extends Pipe<R>> rightPipes, FailableFunction<R,K,PipeException> rightKeyExtractor, Comparator<? super K> keyComparator)
Constructor A constructor for the case of no left pipe. Assumes join type OUTER among the right pipes.- Parameters:
rightPipes- The list of right side pipes. The order is important, and determines the ids given to the pipes in the iteration outputs (SeeJoinRecord).rightKeyExtractor- The extractor of the key from the data type of the right pipeskeyComparator- The total order definition to use when merging the data from the different input pipes.
-
-
Method Detail
-
start
public void start() throws PipeException, InterruptedExceptionDescription copied from interface:BasePipePerforms pre-processing prior to item flow throw the pipe. Implementations must call the same method for all their input pipes before accessing their items. This is typically done here.- Specified by:
startin interfaceBasePipe- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream.InterruptedException- In case that the operation has been interrupted by another thread.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
next
public JoinRecord<K,L,R> next() throws PipeException, InterruptedException
- Specified by:
nextin interfacePipe<K>- Returns:
- The next item in this pipe output, or null if the output end has been reached. May be a blocking operation.
- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream while trying to prepare next item to return.InterruptedException- In case that the operation has been interrupted by another thread.
-
peek
public JoinRecord<K,L,R> peek()
-
getProgress
public float getProgress()
- Specified by:
getProgressin interfaceBasePipe- Returns:
- The pipe flow progress, as a floating number between 0.0 and 1.0. Important implementation rules: 1) Calling this method before start() call is complete isn't allowed and has an undefined behavior. 2) Implementation should do best effort to provide an estimate of the progress this pipe has made (0.0 - 1.0) 3) When the pipe is fully consumed, getProgress() should return 1.0. 4) Results must be monotonous, i.e. results of consecutive calls may never be decreasing. 5) Thread safety: progress may be maintained by some thread/s but monitoring by other threads. Implementations must be thread safe.
-
-