Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
# so the server checks its own side of every exchange. (main.c itself is
# compiled at the Makefile's default RELEASE_CFLAGS either way. `-DDEBUG`
# reaches no struct in the public header — only the RAY_ASSERT_VALUE macro
# at rayforce.h:242 — so the two agree on layout.)
# at rayforce.h:246 — so the two agree on layout.)
#
# The three make variables are read back out of build.rs rather than
# restated, the way scripts/check-vendored-pin.sh already reads them: the
Expand All @@ -111,12 +111,20 @@ jobs:
# binary instead of the core's.
- name: Build the core server binary
run: |
cargo build --workspace --tests
# Absolute: cargo runs each test binary with the cwd set to its own
# crate root, so a workspace-relative RAYFORCE_BINARY would not resolve.
CORE=$(ls -dt "$PWD"/target/debug/build/rayforce-sys-*/out/core 2>/dev/null | head -1)
if [ ! -f "$CORE/librayforce.a" ]; then
echo "::error::no staged core under target/debug/build — did build.rs run?"; exit 1
# The staged core is rayforce-sys's OUT_DIR/core. Cargo names that
# OUT_DIR in its build-script-executed message, fresh build or not;
# globbing target/ for it instead broke when cargo 1.100 moved
# build/<pkg>-<hash>/out to build/<pkg>/<hash>/out, a layout cargo
# documents as its own implementation detail. The JSON goes to a
# file, not a pipe, so a failed build still fails this step.
cargo build --workspace --tests --message-format=json-render-diagnostics > "$RUNNER_TEMP/build.jsonl"
OUT=$(jq -r 'select(.reason == "build-script-executed" and (.package_id | contains("rayforce-sys"))) | .out_dir' "$RUNNER_TEMP/build.jsonl" | tail -1)
# Absolute, as cargo reports it: cargo runs each test binary with the
# cwd set to its own crate root, so a workspace-relative
# RAYFORCE_BINARY would not resolve.
CORE="$OUT/core"
if [ -z "$OUT" ] || [ ! -f "$CORE/librayforce.a" ]; then
echo "::error::cargo reported no rayforce-sys OUT_DIR holding core/librayforce.a"; exit 1
fi
field() { sed -n "s/^const $1: &str = \"\(.*\)\";\$/\1/p" rayforce-sys/build.rs; }
make -C "$CORE" release \
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["rayforce-sys", "rayforce"]

[workspace.package]
version = "1.4.0"
version = "1.5.0"
edition = "2021"
license = "MIT"
authors = ["RayforceDB"]
Expand All @@ -16,4 +16,4 @@ categories = ["database", "api-bindings"]
rust-version = "1.74"

[workspace.dependencies]
rayforce-sys = { path = "rayforce-sys", version = "1.4.0" }
rayforce-sys = { path = "rayforce-sys", version = "1.5.0" }
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ To move the pin, move both:

```sh
git -C rayforce-sys/vendor/rayforce fetch --tags
git -C rayforce-sys/vendor/rayforce checkout v3.0.1
git -C rayforce-sys/vendor/rayforce checkout v3.0.2
git add rayforce-sys/vendor/rayforce

git -C rayforce-sys/vendor/rayforce rev-parse --short=7 HEAD # CORE_COMMIT
Expand All @@ -137,6 +137,11 @@ $EDITOR rayforce-sys/build.rs # CORE_VERSION, C
cargo test --workspace
```

The pin may also be a commit of the core's `dev` branch, between releases. Then
`CORE_VERSION` is the newest release that commit contains, what the core's own Makefile
stamps on it (release tags sit on `master`, so `git describe` would name an older one), and
the check asserts that it is.

`rayforce-sys/vendor/rayforce-q` works the same way, minus the constants — nothing is
stamped from it. The build script needs rayforce-q 2.5.0 or later, the first with
`q_decode_cols`, and names the version when a checkout is older.
Expand Down
97 changes: 96 additions & 1 deletion docs/docs/content/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to `rayforce` are documented here. This project adheres to
[Semantic Versioning](https://semver.org).

## Unreleased
## 1.5.0

### Added

Expand All @@ -15,6 +15,101 @@ All notable changes to `rayforce` are documented here. This project adheres to
C side reads 0 as no timeout or as the default keepalive, and so is either
past `i32::MAX` milliseconds. `rayforce-sys` binds `q_connect_opts` and the
`Q_KEEPALIVE_*` constants.
- **Timespan values.** The core's `TIMESPAN` (type 16), a signed duration in
nanoseconds, is what subtracting two timestamps yields. `Value::timespan_nanos`
builds an atom and `as_timespan_nanos` reads one; `timespan_nanos_slice`
views a vector's `&[i64]`. With the `chrono` feature, `chrono::Duration`
converts both ways; past the ±~292 years an i64 of nanoseconds holds, it
saturates to that limit, never to `i64::MIN`, which is the null. A null
timespan atom is `None` as `Option<chrono::Duration>`.

### Changed

- **Native IPC speaks wire version 4 and refuses 3: upgrade both ends
together.** The core now sends a remote error's message across the wire
with its code (core #1107), so a `TcpClient` error reads as the server's
(`type: cannot add i64 and sym`, where it carried the code alone). The
handshake requires the same version on both sides, so a `TcpClient` built on
this release cannot connect to a v3.0.x or older server, failing with
`wire version mismatch`, and a client on an older core cannot connect to
`Poll::serve_ipc`. The Q wire is unaffected.

- **The vendored core is dev `e6deb32`, from v3.0.1 (`0aa2d6a`).** The core
has released nothing since v3.0.2, so this pins a commit of its `dev` branch:
v3.0.2 plus 248 commits, 32 features, 54 performance changes and 176 fixes
past v3.0.1's sources. `CORE_VERSION` is `3.0.2`, the newest release the
commit contains, which is what the core's own Makefile stamps on it, so
`.sys.build` reports version 3.0.2.
`scripts/check-vendored-pin.sh` and CI accept such a pin, and still refuse a
`CORE_VERSION` the commit does not contain or one older than a release it
does. What reaches this crate besides the wire version:
- A native connection to a server on the same host moves from TCP to
shared-memory rings once the handshake agrees (core #1046), and across
hosts to RDMA where both sides have it. `TcpClient` connections do this by
default, as the suite now exercises; `rt.eval("(.ipc.transport 'tcp)")`
keeps this process on TCP. The RDMA transport is compiled in when `make
lib` finds the verbs headers (`libibverbs-dev`) and then `dlopen`s the
library, so `rayforce-sys` now links `-ldl` on Linux, as the core's own
Makefile does (glibc 2.34 and later have it in libc).
- `include/rayforce.h` grows: `RAY_ERR_ACCESS`, an evaluation refused in
restricted mode (`ErrorCode::Other`, code string `access`); the heap's
anon watermark (`ray_heap_set_anon_watermark`, `ray_heap_anon_watermark`,
`ray_heap_anon_peak`); one password for every listener on a poll
(`ray_poll_auth_set`, `ray_poll_auth_check`, `ray_poll_auth_restricted`,
`RAY_POLL_AUTH_API`); and `ray_error_msg_set`, `ray_error_usage` and
`ray_error_usage_set`. `rayforce-sys` binds them all; the safe crate wraps
none yet. Of the private layouts the bindings carry, `ray_selector` gains
three trailing transport fields and `ray_ipc_tx_info_t` a `transport` byte.
The nineteen `INTERNAL_FNS` signatures are unchanged.
- Rayfall changes a caller can see: `TIME - TIME` is a timespan; a builtin
called with the wrong arguments names the ones it expects; a `try` handler
gets `{code msg}` for an engine error, not 0; an explicit cast to I16,
I32, DATE or TIME that lands on the minimum is null.
- Engine highlights: `.json.parse`/`.json.get`/`.json.format`; `mmu`,
`inv`, `lsq` and `gram` on lists of numeric rows; parquet LZ4, UINT64 and
DECIMAL columns and multi-file `.parquet.parted`; `union-all` over parted
tables; timestamp partition keys and partition pruning by column
statistics; a GUID hash index; `.sys.profile` and `.sys.trust`; and
faster grouping, joins, finds and parquet imports.

- **rayforce-q is 2.7.0 (`8bab7ec`), from 2.6.0 (`69b4210`).** What reaches
this crate:
- A q timespan decodes to a timespan, and a timespan encodes as q's. Before,
`q::decode_response` and `QConnection::execute` refused a message holding
one (`q: unsupported wire type`), and `q::encode` could not send one.
- **A table's text column decodes as a string vector** (`RAY_STR`, type 13)
where it was a list of string atoms (type 0). `get(i)` still yields string
atoms, but `is_list()` is now false, so **code that read a q text column as
a list needs updating**. A text column whose every cell is one character,
which q sends as one char vector, now decodes instead of failing.
- `q::decode_response_cols` returns text columns as `decode_response` does.
rayforce-q 2.7.0's `q_decode_cols` skips that conversion, so this crate
applies it to the projected table: plain, or a keyed table's value side.
One shape it cannot repair: a kept one-character text column still fails
inside rayforce-q (`domain: table add_col: column must be
list/vector-like`), though `decode_response` decodes it. A fix is on
rayforce-q branch `fix/decode-cols-text-columns`.
- A `Poll::serve_q` listener sends an error's text to the q client
(`'type: cannot add i64 and str`, and a raised value as raised), where only
the category went. An empty request is answered with `(::)` rather than a
parse error. A sync request is evaluated as data, with every list argument
quoted, so a list argument whose head names a function reaches the handler
as the list, where it used to be called. Replies are written directly, with
`TCP_NODELAY`, and a hard send failure closes the connection.
- `QConnection::connect_with` with an empty user and a password sends
`:password`, where it sent the anonymous handshake.
- rayforce-q's hooks, `.q.post`, `.q.readonly` and `q_serve_at` are not
exposed here.

### Fixed

- **A timespan vector is a vector.** `Value::is_vec` stopped at type 13 while
the core's `ray_is_vector_type` also counts 16, so a timespan vector reported
`len() == 0`, `get` refused it as "not a vector or list", and
`is_null_at` was always false. All three now treat it as the core does, and
an `i64::MIN` timespan atom is `is_atom_null`. Rayfall could already produce
one since core v3.0.1 (1.4.0); with rayforce-q 2.7.0 a q timespan decodes to
one too.

## 1.4.0

Expand Down
1 change: 1 addition & 0 deletions docs/docs/content/documentation/data-types/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The atom code and its vector code are mirror images: an `I64` atom is `-5`, an
| [GUID](guid.md) | 11 | `Value::guid(&[u8;16])` | — | `as_guid` |
| [Symbol](symbol.md) | 12 | `Value::sym(&str)` | `Value::sym_vec(&[..])` | `as_sym` |
| [String](string.md) | 13 | `Value::string(&str)` | `Value::str_vec(&[..])` | `as_string` |
| [Timespan](temporal.md) | 16 | `Value::timespan_nanos(i64)` | — | `as_timespan_nanos` / `timespan_nanos_slice` |
| [List](list.md) | 0 | `Value::list(&[..])` | — | `get` |
| [Dict](dict.md) | 99 | `Value::dict(keys, values)` | — | `dict_get` |
| [Table](../table/overview.md) | 98 | `Table::new(..)` | — | `column(..)` |
Expand Down
21 changes: 16 additions & 5 deletions docs/docs/content/documentation/data-types/temporal.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# :material-clock-outline: Temporal

Rayforce has three temporal types, all measured against a **2000-01-01** epoch:
Rayforce has three temporal types measured against a **2000-01-01** epoch, and
a timespan, a signed duration:

| Type | Unit | Atom constructor | Reader | Slice reader |
|------|------|------------------|--------|--------------|
| `Date` | days since 2000-01-01 | `Value::date_days(i32)` | `as_date_days` | `date_days_slice` |
| `Time` | milliseconds since midnight | `Value::time_millis(i32)` | `as_time_millis` | `time_millis_slice` |
| `Timestamp` | nanoseconds since 2000-01-01 UTC | `Value::timestamp_nanos(i64)` | `as_timestamp_nanos` | `timestamp_nanos_slice` |
| `Timespan` | nanoseconds, signed | `Value::timespan_nanos(i64)` | `as_timespan_nanos` | `timespan_nanos_slice` |

!!! note "Assume a live runtime"
```rust
Expand All @@ -27,10 +29,14 @@ assert_eq!(
Value::timestamp_nanos(1_000_000_000).as_timestamp_nanos()?,
1_000_000_000,
);
assert_eq!(Value::timespan_nanos(-1_500).as_timespan_nanos()?, -1_500);
```

Note the widths: `Date` and `Time` carry an `i32` offset, while `Timestamp`
carries an `i64` (nanoseconds need the extra range).
and `Timespan` carry an `i64` (nanoseconds need the extra range).

A timespan is what subtracting two timestamps yields, and what a q timespan
decodes to. Its null is `i64::MIN`, as for a timestamp.

## Chrono conversions

Expand All @@ -49,10 +55,15 @@ assert_eq!(t.to_value().extract::<NaiveTime>()?, t);

let ts = Utc.with_ymd_and_hms(2021, 6, 15, 13, 30, 45).unwrap();
assert_eq!(ts.to_value().extract::<chrono::DateTime<Utc>>()?, ts);

let span = chrono::Duration::milliseconds(-250);
assert_eq!(span.to_value().extract::<chrono::Duration>()?, span);
```

The mapping is `NaiveDate` ↔ `Date`, `NaiveTime` ↔ `Time`, and
`DateTime<Utc>` ↔ `Timestamp`.
The mapping is `NaiveDate` ↔ `Date`, `NaiveTime` ↔ `Time`,
`DateTime<Utc>` ↔ `Timestamp`, and `chrono::Duration` ↔ `Timespan`. A
`chrono::Duration` past the ±~292 years an i64 of nanoseconds holds
saturates to that limit.

## Slice readers

Expand All @@ -66,7 +77,7 @@ assert!(v.timestamp_nanos_slice().is_err());
```

- `date_days_slice()` and `time_millis_slice()` return `&[i32]`.
- `timestamp_nanos_slice()` returns `&[i64]`.
- `timestamp_nanos_slice()` and `timespan_nanos_slice()` return `&[i64]`.

!!! tip "Everything is relative to 2000-01-01"
Unlike Unix time (epoch 1970), Rayforce dates and timestamps count from
Expand Down
22 changes: 15 additions & 7 deletions docs/docs/content/get-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ places that must agree:
| The core sources | the `rayforce-sys/vendor/rayforce` submodule |
| The version stamped into the library | `CORE_VERSION` / `CORE_COMMIT` in `rayforce-sys/build.rs` |

The constants exist because the core's `Makefile` normally resolves its version
from `git describe`, and a crate unpacked from crates.io has no git history to
read. `scripts/check-vendored-pin.sh` asserts the two agree, and CI runs it on
every push.
The constants exist because the core's `Makefile` normally takes its version
from the newest `vX.Y.Z` tag of its repository, and a crate unpacked from
crates.io has no git history to read. `scripts/check-vendored-pin.sh` asserts
the two agree, and CI runs it on every push.

As a consumer you get the core that matches the `rayforce` version you depend
on — pick a different core by picking a different `rayforce` release. The two
Expand Down Expand Up @@ -77,19 +77,19 @@ Moving the pin means moving the submodule and the constants together:
```sh
# 1. Move the submodule to the new tag.
git -C rayforce-sys/vendor/rayforce fetch --tags
git -C rayforce-sys/vendor/rayforce checkout v3.0.1
git -C rayforce-sys/vendor/rayforce checkout v3.0.2
git add rayforce-sys/vendor/rayforce

# 2. Read back the values build.rs must stamp.
git -C rayforce-sys/vendor/rayforce describe --tags --exact-match # -> v3.0.1
git -C rayforce-sys/vendor/rayforce describe --tags --exact-match # -> v3.0.2
git -C rayforce-sys/vendor/rayforce rev-parse --short=7 HEAD # -> e.g. 1a2b3c4
```

Then edit `rayforce-sys/build.rs` to match — `CORE_VERSION` is the tag without
its leading `v`:

```rust
const CORE_VERSION: &str = "3.0.1";
const CORE_VERSION: &str = "3.0.2";
const CORE_COMMIT: &str = "1a2b3c4";
```

Expand All @@ -100,6 +100,14 @@ And check the result:
cargo test --workspace
```

Between releases the pin can be a commit of the core's `dev` branch instead of
a tag. `CORE_COMMIT` is that commit, and `CORE_VERSION` the newest release it
contains, which is what the core's own `Makefile` stamps on it. Release tags
sit on `master`, so a release counts as contained when its commit is an
ancestor of the pin, or when the release commit's parent with the same tree is:
a `dev` → `master` merge before the core merges it back. The check fails when
the pin contains no release under `CORE_VERSION`, or contains a newer one.

The same applies to `rayforce-sys/vendor/rayforce-q`, minus the constants —
nothing is stamped from it, so moving the submodule is the whole change.

Expand Down
3 changes: 2 additions & 1 deletion docs/docs/content/get-started/technical-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ Runtime::scope(|_rt| {
```

The same applies to the typed slice readers for temporal and boolean columns
(`date_days_slice`, `time_millis_slice`, `timestamp_nanos_slice`, `bool_slice`).
(`date_days_slice`, `time_millis_slice`, `timestamp_nanos_slice`,
`timespan_nanos_slice`, `bool_slice`).

## :material-arrow-right: Next steps

Expand Down
Loading
Loading