Skip to content

Conversation

@karminski
Copy link

Add lua binding and examples/simple-lua as demo.

Comment on lines +16 to +17
echo "Error: lsqlite3 module is not installed"
echo "Install it with: luarocks install lsqlite3"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to print errors to stderr:

Suggested change
echo "Error: lsqlite3 module is not installed"
echo "Install it with: luarocks install lsqlite3"
echo "Error: lsqlite3 module is not installed" >&2
echo "Help: luarocks install lsqlite3" >&2

@reneleonhardt
Copy link

Great contribution, I hope it gets reviewed ❤️

Would a small unit test be possible?

vlasky added a commit to vlasky/sqlite-vec that referenced this pull request Jan 4, 2026
/examples/simple-lua/ contains a demo script and runner.

Incorporates upstream PR asg017#237 with the following bugfixes:

Extension loading:
- Fix return value check: lsqlite3's load_extension returns true on
  success, not sqlite3.OK (which is 0). Changed from `if ok then` to
  `if ok and result then` to properly detect successful loads.
- Add vec0 naming paths alongside sqlite-vec paths for this fork.

IEEE 754 float serialization (float_to_bytes):
- Switch from half-round-up to round-half-to-even (banker's rounding)
  for IEEE 754 compliance. This prevents systematic bias when
  processing large datasets where half-values accumulate.
- Handle special cases: NaN, Inf, -Inf, and -0.0 which the original
  implementation did not support.
- Fix subnormal number encoding: corrected formula from 2^(exp+126)
  to 2^(exp+127) so minimum subnormal 2^(-149) encodes correctly.
- Add mantissa overflow carry: when rounding causes mantissa >= 2^23,
  carry into exponent field.
- Add exponent overflow handling: values too large now return ±Inf
  instead of producing corrupted output.
- Use epsilon comparison (1e-9) for 0.5 tie detection to handle
  floating-point precision issues.

JSON serialization (serialize_json):
- Error on NaN and Infinity values which are not valid JSON.
- Convert -0.0 to 0.0 for JSON compatibility.

Co-Authored-By: asr1 <noreply@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vlasky
Copy link

vlasky commented Jan 4, 2026

@karminski I've made a tweak to your PR and incorporated it into version v0.2.4-alpha of my fork.

vlasky added a commit to vlasky/sqlite-vec that referenced this pull request Jan 4, 2026
/examples/simple-lua/ contains a demo script and runner.

Incorporates upstream PR asg017#237 with the following bugfixes:

Extension loading:
- Fix return value check: lsqlite3's load_extension returns true on
  success, not sqlite3.OK (which is 0). Changed from `if ok then` to
  `if ok and result then` to properly detect successful loads.
- Add vec0 naming paths alongside sqlite-vec paths for this fork.

IEEE 754 float serialization (float_to_bytes):
- Switch from half-round-up to round-half-to-even (banker's rounding)
  for IEEE 754 compliance. This prevents systematic bias when
  processing large datasets where half-values accumulate.
- Handle special cases: NaN, Inf, -Inf, and -0.0 which the original
  implementation did not support.
- Fix subnormal number encoding: corrected formula from 2^(exp+126)
  to 2^(exp+127) so minimum subnormal 2^(-149) encodes correctly.
- Add mantissa overflow carry: when rounding causes mantissa >= 2^23,
  carry into exponent field.
- Add exponent overflow handling: values too large now return ±Inf
  instead of producing corrupted output.
- Use epsilon comparison (1e-9) for 0.5 tie detection to handle
  floating-point precision issues.

JSON serialization (serialize_json):
- Error on NaN and Infinity values which are not valid JSON.
- Convert -0.0 to 0.0 for JSON compatibility.

Co-Authored-By: karminski <code.karminski@outlook.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mceachen pushed a commit to mceachen/sqlite-vec that referenced this pull request Jan 4, 2026
/examples/simple-lua/ contains a demo script and runner.

Incorporates upstream PR asg017#237 with the following bugfixes:

Extension loading:
- Fix return value check: lsqlite3's load_extension returns true on
  success, not sqlite3.OK (which is 0). Changed from `if ok then` to
  `if ok and result then` to properly detect successful loads.
- Add vec0 naming paths alongside sqlite-vec paths for this fork.

IEEE 754 float serialization (float_to_bytes):
- Switch from half-round-up to round-half-to-even (banker's rounding)
  for IEEE 754 compliance. This prevents systematic bias when
  processing large datasets where half-values accumulate.
- Handle special cases: NaN, Inf, -Inf, and -0.0 which the original
  implementation did not support.
- Fix subnormal number encoding: corrected formula from 2^(exp+126)
  to 2^(exp+127) so minimum subnormal 2^(-149) encodes correctly.
- Add mantissa overflow carry: when rounding causes mantissa >= 2^23,
  carry into exponent field.
- Add exponent overflow handling: values too large now return ±Inf
  instead of producing corrupted output.
- Use epsilon comparison (1e-9) for 0.5 tie detection to handle
  floating-point precision issues.

JSON serialization (serialize_json):
- Error on NaN and Infinity values which are not valid JSON.
- Convert -0.0 to 0.0 for JSON compatibility.

Co-Authored-By: karminski <code.karminski@outlook.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants