Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to insert list in ets:insert, ets:lookup refactor #1405

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TheSobkiewicz
Copy link
Contributor

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Changes:

  • Enabled ets:insert/2 to accept lists for bulk insertion.
  • Extracted helper functions for ets:lookup/2 and ets:insert/2 that do not apply table locks.

Use Cases for the Helper Functions:

The new helper functions can be utilized in the following ETS operations to reduce code duplication:

  • ets:update_element/3
  • ets:insert_new/2
  • ets:update_counter/3
  • ets:update_counter/4
  • ets:take/2
  • ets:delete_object/2

Every mentioned function will be implemented after merging of this PR.

src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
tests/erlang_tests/test_ets.erl Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch 4 times, most recently from 76774f0 to 6ac7831 Compare January 9, 2025 15:44
src/libAtomVM/ets.c Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Show resolved Hide resolved
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch 3 times, most recently from f54ef62 to 45eccdc Compare January 15, 2025 16:13
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch from 45eccdc to e5908a2 Compare January 16, 2025 12:56
Copy link
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

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

Still few minor changes are required, thanks for this work so far.

CHANGELOG.md Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.h Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch 3 times, most recently from 387dc1c to 54951ff Compare January 20, 2025 14:25
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
@bettio
Copy link
Collaborator

bettio commented Jan 22, 2025

I'm sorry about this additional round of comments, hope they can be somehow interesting to you and not just boring nitpicking.
Thanks for the contribution so far ❤️.

@TheSobkiewicz
Copy link
Contributor Author

I'm sorry about this additional round of comments, hope they can be somehow interesting to you and not just boring nitpicking. Thanks for the contribution so far ❤️.

Don't worry, thank you for your patience when reviewing it ❤️

@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch 3 times, most recently from 6e249eb to 0f71f40 Compare January 22, 2025 17:39
@bettio
Copy link
Collaborator

bettio commented Jan 25, 2025

I resolved open points I believe are still open. After that we are good I think. I would appreciate also a check from @jakub-gonet

src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Outdated Show resolved Hide resolved
src/libAtomVM/ets_hashtable.c Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
src/libAtomVM/ets.c Outdated Show resolved Hide resolved
@jakub-gonet
Copy link
Contributor

@bettio done. Found mostly nits and one missing free.

@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch 2 times, most recently from 9c15459 to 74dd710 Compare January 27, 2025 10:35
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch from 74dd710 to 4d84859 Compare January 27, 2025 10:36
@TheSobkiewicz TheSobkiewicz force-pushed the thesobkiewicz/nifs/ets/refactor_insert branch from 4d84859 to 8103fe7 Compare January 27, 2025 13:31
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