Skip to content

Implement open_cursor() with minimal features#14

Merged
kou merged 1 commit into
groonga:mainfrom
abetomo:select
Jun 30, 2026
Merged

Implement open_cursor() with minimal features#14
kou merged 1 commit into
groonga:mainfrom
abetomo:select

Conversation

@abetomo

@abetomo abetomo commented Jun 30, 2026

Copy link
Copy Markdown
Member

Getting the other field values will be implemented later.

Copilot AI review requested due to automatic review settings June 30, 2026 01:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an initial Table.select() implementation to iterate over table record IDs using a Groonga table cursor, with a small test to validate basic behavior. This is a foundational API addition intended to be extended later with query/search and additional options.

Changes:

  • Add Table.select() generator that opens a Groonga table cursor and yields record IDs.
  • Expose Groonga table cursor APIs in grn_table.pxd for Cython usage.
  • Add a new test verifying select() returns IDs in expected order for a simple table.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
testing/test_table.py Adds a basic test asserting select() yields record IDs [1, 2].
grnpy/table.pyx Implements Table.select() using grn_table_cursor_open/next/close.
grnpy/grn_table.pxd Declares Groonga table cursor types/constants/functions needed by select().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread grnpy/table.pyx Outdated
Comment thread grnpy/table.pyx Outdated
return id

# TODO: Searching using `query` and adding options (e.g. `limit`).
def select(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should not use select for grn_table_cursor_open() based API.

We should use it for grn_table_select().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since it was an iterator rather than a select, I changed the name.

@abetomo abetomo changed the title Implement select() with minimal features Implement record iterator with minimal features Jun 30, 2026
Comment thread grnpy/grn_table.pxd Outdated
ctypedef struct grn_table_cursor:
pass

cdef int BY_ID "GRN_CURSOR_BY_ID"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we define this in grn_table_cursor not grn_table?

Comment thread grnpy/table.pyx Outdated
def set(self, grn_id id, value):
self._set_value(id, value)

def __iter__(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we specify options such as offset and limit with this API?

How about with table.open_cursor as cursor or something?

@abetomo abetomo changed the title Implement record iterator with minimal features Implement open_cursor() with minimal features Jun 30, 2026
Comment thread grnpy/table_cursor.pyx Outdated
Comment on lines +75 to +80
cdef Context context
if self._cursor is NULL:
return
context = self._context
grn_table_cursor_close(context.unwrap(), self._cursor)
self._cursor = NULL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we call close() here?

Getting the other field values will be implemented later.
@kou
kou merged commit 125bba3 into groonga:main Jun 30, 2026
5 checks passed
@abetomo
abetomo deleted the select branch June 30, 2026 07:24
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