-
- All Superinterfaces:
Named,PhysicalInputPort,PhysicalPort,RecordTyped,RecordValued,SteppableRecordValued,TokenTyped,TokenValued
public interface RecordInput extends PhysicalInputPort, SteppableRecordValued
An input port on a record data flow. A record output is a collection of outputScalarInputFieldfields, one for each field of the record, indexed both by name and position, as determined by the schema of the input'sRecordTokenType.As with other ports, the input maintains a position in the flow. However, the position in the flow is only advanced by calling methods on the
RecordInputitself; the component input fields cannot advance the position. When the port is positioned on a token, the input fields contain the field values of the current record.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddetach()Detaches the input port from its data flow.ScalarInputFieldgetField(int index)Gets the input field at the given position.ScalarInputFieldgetField(String fieldName)Gets the input field with the given name.ScalarInputField[]getFields()Gets all input fields of this record port.longgetPosition()Retrieves the position of the port.InputStatisticsgetStats()Retrieves the run-time statistics gathered for this input.RecordTokenTypegetType()Gets the type of tokens in the underlying flow.booleanisAttached()Tests if the port is attached to a data flow.booleanisOnToken()Tests if the port is positioned on a token.booleanstepNext()Advances the cursor position of this input by one token.booleanstepNext(long n)Advances the cursor position of this input by the specified number of tokens.longstepUntil(long n, Timeout timeout)Advances the cursor position as many tokens as possible up to the specified number of tokens, within a given amount of time.longstepUntil(Timeout timeout)Advances the cursor position of this input by one token, if it can be be done in a given amount of time.booleantransfer(TokenAppendable out)Transfers the current token value of the input port to the target.booleantransfer(TokenAppendable out, boolean startWithNextToken)Transfers a token value from the input port to the given target, transferring either the current token (that is, push, then step) or the next token (that is, step, then push).booleantransfer(TokenAppendable out, long n)Transfers multiple tokens of the input port starting at the current token to the given target.booleantransfer(TokenAppendable out, long n, boolean startWithNextToken)Transfers multiple tokens from the input port, beginning either with the current token or the next token.voidtransferAll(TokenAppendable out)Transfers all remaining tokens from the input port starting at the current token to the given target.voidtransferAll(TokenAppendable out, boolean startWithNextToken)Transfers all remaining tokens from the input port, beginning either with the current token or the next token.-
Methods inherited from interface com.pervasive.datarush.tokens.record.RecordValued
containsNull, newFieldIterator, newFieldIterator, newFieldIterator, size
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Method Detail
-
getType
RecordTokenType getType()
Description copied from interface:PhysicalPortGets the type of tokens in the underlying flow.- Specified by:
getTypein interfacePhysicalPort- Specified by:
getTypein interfaceRecordTyped- Specified by:
getTypein interfaceRecordValued- Specified by:
getTypein interfaceTokenTyped- Specified by:
getTypein interfaceTokenValued- Returns:
- the token type for this port.
-
getFields
ScalarInputField[] getFields()
Gets all input fields of this record port.- Specified by:
getFieldsin interfaceRecordValued- Returns:
- the input fields of this port
-
getField
ScalarInputField getField(String fieldName)
Gets the input field with the given name.- Specified by:
getFieldin interfaceRecordValued- Parameters:
fieldName- name of the field- Returns:
- the field with the given name
-
getField
ScalarInputField getField(int index)
Gets the input field at the given position.- Specified by:
getFieldin interfaceRecordValued- Specified by:
getFieldin interfaceSteppableRecordValued- Parameters:
index- zero-based index into the field list- Returns:
- the field at the given position
-
stepNext
boolean stepNext()
Advances the cursor position of this input by one token. This method may block until more data is available or end of data on the port is encountered.- Specified by:
stepNextin interfaceSteppableRecordValued- Returns:
trueif the cursor was advanced and resides on a valid token,falseif end of data was encountered.
-
stepNext
boolean stepNext(long n)
Advances the cursor position of this input by the specified number of tokens. This method may block until more data is available or end of data on the port is encountered.- Parameters:
n- the number of tokens to advance- Returns:
trueif the cursor was advanced the specified number of tokens and resides on a valid token,falseif end of data was encountered.
-
stepUntil
long stepUntil(Timeout timeout)
Advances the cursor position of this input by one token, if it can be be done in a given amount of time. The time bound is honored on a best effort basis; it may be violated as necessary to ensure data consistency.- Parameters:
timeout- the maximum amount of time to block for data. Using a value of0will block indefinitely, asstepNext()does.- Returns:
- the number of tokens advanced. If end of data was encountered,
-1is be returned.
-
stepUntil
long stepUntil(long n, Timeout timeout)Advances the cursor position as many tokens as possible up to the specified number of tokens, within a given amount of time. The time bound is honored on a best effort basis; it may be violated as necessary to ensure data consistency.- Parameters:
n- the number of tokens to advancetimeout- the maximum amount of time to block for data. Using a value of0will block indefinitely, asstepNext(long)does.- Returns:
- the actual number of tokens advanced. If end of data was encountered, the
return value will be negative and is expressed as
-(tokensAdvanced + 1), wheretokensAdvancedis the number of tokens advanced at the point when end of data was hit.
-
transfer
boolean transfer(TokenAppendable out)
Transfers the current token value of the input port to the target. On return, the port will be on the next token.The port and the given target must have compatible types for transfer.
- Parameters:
out- target onto which to push the current token. This can be any appendable sequence of tokens, such as an output port.- Returns:
trueif the input port is positioned on a valid token upon completion,falseif it is at end of data.- See Also:
stepNext()
-
transfer
boolean transfer(TokenAppendable out, long n)
Transfers multiple tokens of the input port starting at the current token to the given target. The port will be advanced the given number of tokens.The port and the given output port must have compatible types for transfer. Fewer tokens than the given count may be transferred if this port encounters end of data during the transfer.
- Parameters:
out- target onto which to push tokens. This can be any appendable sequence of tokens, such as an output port.n- number of tokens to transfer- Returns:
trueif the input port is positioned on a valid token upon completion,falseif it is at end of data.- See Also:
stepNext(long)
-
transferAll
void transferAll(TokenAppendable out)
Transfers all remaining tokens from the input port starting at the current token to the given target. The port will be advanced until end of data is encountered. The port and the given output port must have compatible types for transfer.- Parameters:
out- target onto which to push all remaining tokens. This can be any appendable sequence of tokens, such as an output port.
-
transfer
boolean transfer(TokenAppendable out, boolean startWithNextToken)
Transfers a token value from the input port to the given target, transferring either the current token (that is, push, then step) or the next token (that is, step, then push). In either case, on return the port will be advanced to the next token.This input port and the given output port must have compatible types for transfer. If transferring the current token, the token cursor for this port must be positioned on a token. When transferring the next token, it is possible that no token gets transferred if the next position is end of data.
- Parameters:
out- target onto which to push the token value. This can be any appendable sequence of tokens, such as an output port.startWithNextToken- indicates whether the current token or the next token is pushed onto the target.- Returns:
trueif the input port is positioned on a valid token upon completion,falseif it is at end of data.- See Also:
stepNext(),transfer(TokenAppendable)
-
transfer
boolean transfer(TokenAppendable out, long n, boolean startWithNextToken)
Transfers multiple tokens from the input port, beginning either with the current token or the next token. In either case, the port is advanced by the given number of tokens.This input port and the given target must have compatible types for transfer. If transferring starting with the current token, the token cursor for the port must be positioned on a token. Fewer tokens than requested (possibly none) may be transferred if the port encounters end of data during the transfer.
- Specified by:
transferin interfaceSteppableRecordValued- Parameters:
out- target onto which to push tokens. This can be anyn- number of tokens to transferstartWithNextToken- indicates whether to start the transfer with the current token or the next token.- Returns:
trueif the input port is positioned on a valid token upon completion,falseif it is at end of data.- See Also:
stepNext(long),transfer(TokenAppendable, long)
-
transferAll
void transferAll(TokenAppendable out, boolean startWithNextToken)
Transfers all remaining tokens from the input port, beginning either with the current token or the next token. The port will be advanced until end of data is encountered.The port and the given target must have compatible types for transfer.
- Parameters:
out- target onto which to push all remaining tokens. This can be any appendable sequence of tokens, such as an output port.startWithNextToken- indicates whether to start the transfer with the current token or the next token.- See Also:
transferAll(TokenAppendable)
-
detach
void detach()
Detaches the input port from its data flow. Once detached, the port behaves as if end of data were encountered.Detaching a port frees resources. If an input port is no longer needed and end of data has not been reached, it is a good idea to detach it.
- Specified by:
detachin interfacePhysicalPort- See Also:
isAttached()
-
getPosition
long getPosition()
Retrieves the position of the port. That is, how many tokens have been stepped by callingstepNext()andstepNext(long). Once end of data has been encountered, this value will be exactly the number of tokens which were on the flow.The position is zero based. The position acts as a cursor in that the position lies between the current element and the next element. Thus a position of zero indicates that no element has been addressed from the port. This is similar to the cursor semantics in the
ListIteratorinterface.- Specified by:
getPositionin interfaceSteppableRecordValued- Returns:
- the position of the port.
-
isAttached
boolean isAttached()
Tests if the port is attached to a data flow. A port starts initially attached and becomes detached if one of the following occurs:- end of data (EOD)is encountered on the port
- the port is explicitly detached using
detach()
If a port is attached, the port can be safely advanced (using
stepNext(), etc.). However, this does not indicate the port is positioned on a token, so attempting to access the current token value may fail with an exception.If a port is not attached, any attempt to advance the port or access the current value will throw an exception.
- Specified by:
isAttachedin interfacePhysicalPort- Returns:
- the attached state of the port
- See Also:
isOnToken()
-
isOnToken
boolean isOnToken()
Tests if the port is positioned on a token. Initially, a port is not positioned on a token. Advancing the position will either encounter end of data or leave the port on a token.While positioned on a token, the current value can be safely accessed without error. But if not positioned on a token, all attempts to access the current value will throw an exception.
- Returns:
- the positional state of the port
- See Also:
isAttached()
-
getStats
InputStatistics getStats()
Retrieves the run-time statistics gathered for this input.- Specified by:
getStatsin interfacePhysicalPort- Returns:
PortStatsgathered during execution ornullif the configuration did not specify collecting statistics
-
-