Skip to content
New issue

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

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

Already on GitHub? # to your account

Add Object&Array Element Deletion #72

Merged
merged 3 commits into from
Oct 17, 2022

Conversation

klauspost
Copy link
Collaborator

@klauspost klauspost commented Sep 7, 2022

Also upgrade CI and dependencies

It is possible to delete one or more elements in an object.

(*Object).DeleteElems(fn, onlyKeys) will call back fn for each key+ value.

If true is returned, the key+value is deleted. A key filter can be provided for optional filtering.
If the callback function is nil all elements matching the filter will be deleted.
If both are nil all elements are deleted.

Example:

	// The object we are modifying
	var obj *simdjson.Object

	// Delete all entries where the key is "unwanted":
	err = obj.DeleteElems(func(key []byte, i Iter) bool {
		return string(key) == "unwanted")
	}, nil)

	// Alternative version with prefiltered keys:
	err = obj.DeleteElems(nil, map[string]struct{}{"unwanted": {}})

(*Array).DeleteElems(fn func(i Iter) bool) will call back fn for each array value.
If the function returns true the element is deleted in the array.

	// The array we are modifying
	var array *simdjson.Array

	// Delete all entries that are strings.
	array.DeleteElems(func(i Iter) bool {
		return i.Type() == TypeString
	})

Also upgrade CI and dependencies
@klauspost klauspost marked this pull request as draft September 7, 2022 14:27
@klauspost klauspost changed the title Add Object Element Deletion Add Object&Array Element Deletion Sep 7, 2022
@klauspost klauspost marked this pull request as ready for review September 7, 2022 14:40
@klauspost klauspost mentioned this pull request Sep 7, 2022
@harshavardhana harshavardhana merged commit 2ba2c3c into minio:master Oct 17, 2022
@klauspost klauspost deleted the add-object-element-deletion branch October 17, 2022 07:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants