streamsx.spl.types¶
SPL type definitions.
Overview¶
SPL is strictly typed, thus when invoking SPL operators
using classes from streamsx.spl.op
then any parameters
must use the SPL type required by the operator.
Module contents¶
Functions
float32 |
Create an SPL float32 value. |
float64 |
Create an SPL float64 value. |
int16 |
Create an SPL int16 value. |
int32 |
Create an SPL int32 value. |
int64 |
Create an SPL int64 value. |
int8 |
Create an SPL int8 value. |
rstring |
Create an SPL rstring value. |
uint16 |
Create an SPL uint16 value. |
uint32 |
Create an SPL uint32 value. |
uint64 |
Create an SPL uint64 value. |
uint8 |
Create an SPL uint8 value. |
Classes
Timestamp |
SPL native timestamp type with nanosecond resolution. |
-
class
streamsx.spl.types.
Timestamp
¶ SPL native timestamp type with nanosecond resolution.
Common usage is to store the seconds and nanoseconds since the Unix Epoch (Jan 1, 1970), but this is not enforced by the Timestamp class.
Machine identifier is an optional application defined identifier for the machine the timestamp was created on. It is the responsibility of the application to set the machine identifier if required. The machine identifier may be used to detect if two timestamps were created on the same machine, as there may be variations in the clocks on different machines.
A instance can be created by passing seconds, nanoseconds and optionally machine identifier:
# Timestamp with the current time in seconds # discarding any fractional seconds. ts = Timestamp(time.time(), 0) # Timestamp set to a specific time with a machine identifier ts = Timestamp(1516500542, 9511447, 4)
A Timestamp is a namedtuple with three fields seconds, nanoseconds and machine_id.
-
seconds
¶ int – Seconds since epoch.
-
nanoseconds
¶ int – Nanosecond component.
-
machine_id
¶ int – Optional machine identifier, defaults to zero.
Warning
Implementation of Timestamp changed with 1.8.3 to be a namedtuple maintaining the existing class API.
-
count
(value) → integer -- return number of occurrences of value¶
-
datetime
()¶ Return the UTC datetime corresponding to the POSIX timestamp.
This is identical to
datetime.datetime.utcfromtimestamp(self.time())
. Nanosecond resolution may be lost.Returns: Timestamp converted to a datetime.datetime. Return type: datetime.datetime
-
static
from_datetime
(dt, machine_id=0)¶ Convert a datetime to an SPL Timestamp. :param dt: Datetime to be converted. :type dt: datetime.datetime :param machine_id: Machine identifier. :type machine_id: int
Returns: Datetime converted to Timestamp. Return type: Timestamp
-
static
from_time
(t, machine_id=0)¶ Convert seconds since epoch to a Timestamp.
The time argument matches the return from
time.time()
.Parameters: - t (float) – Time to be converted.
- machine_id (int) – Machine identifier.
Returns: Time converted to Timestamp.
Return type: New in version 1.8.3.
-
index
(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
machine_id
Alias for field number 2
-
nanoseconds
Alias for field number 1
-
static
now
(machine_id=0)¶ Timestamp representing the current time.
Parameters: machine_id (int) – Machine identifier. Returns: Current time. Return type: Timestamp New in version 1.8.3.
-
seconds
Alias for field number 0
-
time
()¶ Get the time in seconds since the epoch.
Returns: time in seconds since the epoch. Return type: float
-
-
streamsx.spl.types.
float32
(value)¶ Create an SPL
float32
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
float64
(value)¶ Create an SPL
float64
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
int16
(value)¶ Create an SPL
int16
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
int32
(value)¶ Create an SPL
int32
value.Returns: Expression representing the value. Return type: Expression Parameters: value (int) – Value to be types as int32
.
-
streamsx.spl.types.
int64
(value)¶ Create an SPL
int64
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
int8
(value)¶ Create an SPL
int8
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
rstring
(value)¶ Create an SPL
rstring
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
uint16
(value)¶ Create an SPL
uint16
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
uint32
(value)¶ Create an SPL
uint32
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
uint64
(value)¶ Create an SPL
uint64
value.Returns: Expression representing the value. Return type: Expression
-
streamsx.spl.types.
uint8
(value)¶ Create an SPL
uint8
value.Returns: Expression representing the value. Return type: Expression