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
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Return an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
|
Create an SPL |
Classes
SPL native timestamp type with nanosecond resolution. |
-
class
streamsx.spl.types.Timestamp¶ Bases:
streamsx.spl.runtime.TimestampSPL 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.
A Timestamp acts as a
datetime.datetimeinstance (duck typing) with the exception of:time()- returns anintinstead ofdatetime.timedatetime.datetimeoperations (+,-,<) are not supportedstring representation (uses
Timestamprepresentation)is not an instance of
datetime.datetime
The value of the equivalent
datetime.datetimeis identical to the instance returned bydatetime().-
seconds¶ Seconds since epoch.
- Type
int
-
nanoseconds¶ Nanosecond component.
- Type
int
-
machine_id¶ Optional machine identifier, defaults to zero.
- Type
int
Warning
Implementation of Timestamp changed with 1.8.3 to be a namedtuple maintaining the existing class API.
Changed in version 1.14:
Timestampacts as adatetime.datetime.-
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.
- Parameters
dt (datetime.datetime) – Datetime to be converted.
machine_id (int) – Machine identifier.
- Returns
Datetime converted to Timestamp.
- Return type
-
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.
-
property
machine_id Alias for field number 2
-
property
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
New in version 1.8.3.
-
property
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.int8(value)¶ Create an SPL
int8value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.int16(value)¶ Create an SPL
int16value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.int32(value)¶ Create an SPL
int32value.- Returns
Expression representing the value.
- Return type
- Parameters
value (int) – Value to be types as
int32.
-
streamsx.spl.types.int64(value)¶ Create an SPL
int64value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.uint8(value)¶ Create an SPL
uint8value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.uint16(value)¶ Create an SPL
uint16value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.uint32(value)¶ Create an SPL
uint32value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.uint64(value)¶ Create an SPL
uint64value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.float32(value)¶ Create an SPL
float32value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.float64(value)¶ Create an SPL
float64value.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.rstring(value)¶ Create an SPL
rstringvalue.- Returns
Expression representing the value.
- Return type
-
streamsx.spl.types.null()¶ Return an SPL
null.- Returns
Expression representing an SPL null value.
- Return type
New in version 1.10.