-
Notifications
You must be signed in to change notification settings - Fork 7
[WIP] UDFs #303
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
Merged
[WIP] UDFs #303
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2004966
[WIP] UDFs
swilly22 05a880f
update udf docs
swilly22 fc05efa
Merge branch 'main' into udfs
swilly22 780b29c
address pr comments
swilly22 a294153
update wordlist
swilly22 7d73c9b
flex docs
swilly22 c9b603f
address pr comments
swilly22 ff2ed43
Update UDF command specifications in documentation
shahar-biron 12ae53a
Improve clarity and grammar in UDF documentation
shahar-biron 35bbb6c
Enhance FLEX documentation with package details
shahar-biron 2e25f5d
Update udfs/index.md
shahar-biron afdb75c
Merge branch 'main' into udfs
shahar-biron e082f2e
Fix grammar and clarity in UDFs introduction
shahar-biron 2ff2dff
Improve clarity in UDF documentation
shahar-biron 4a4fe9e
Revise FLEX Function Reference introduction
shahar-biron 200250e
Enhance date parsing patterns in documentation
shahar-biron d6579bd
Fix spellcheck failures in FLEX docs
shahar-biron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # bitwise.and | ||
|
|
||
| ## Description | ||
| Performs a bitwise AND operation on two integers. Each bit in the result is 1 only if the corresponding bits in both operands are 1. | ||
|
|
||
| ## Syntax | ||
| ```cypher | ||
| flex.bitwise.and(a, b) | ||
| ``` | ||
|
|
||
| ## Parameters | ||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `a` | number (integer) | Yes | First operand | | ||
| | `b` | number (integer) | Yes | Second operand | | ||
|
|
||
| ## Returns | ||
| **Type:** number (integer) | ||
|
|
||
| The result of the bitwise AND operation. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Basic AND Operation | ||
| ```cypher | ||
| RETURN flex.bitwise.and(12, 10) AS result | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| result | ||
| ------ | ||
| 8 | ||
| ``` | ||
| (Binary: 1100 AND 1010 = 1000 = 8) | ||
|
|
||
| ### Example 2: Checking Permission Flags | ||
| ```cypher | ||
| WITH 7 AS userPermissions // 0111 (read=1, write=2, execute=4) | ||
| WITH userPermissions, 2 AS writeFlag | ||
| RETURN flex.bitwise.and(userPermissions, writeFlag) > 0 AS hasWrite | ||
| ``` | ||
|
|
||
| ### Example 3: Masking Bits | ||
| ```cypher | ||
| MATCH (d:Device) | ||
| WITH d, flex.bitwise.and(d.flags, 15) AS lowerNibble | ||
| RETURN d.id, lowerNibble | ||
| ``` | ||
|
|
||
| ## Notes | ||
| - Operates on 32-bit signed integers in JavaScript | ||
| - Both operands are converted to integers if needed | ||
| - Commonly used for flag checking and bit masking | ||
|
|
||
| ## See Also | ||
| - [bitwise.or](./or.md) - Bitwise OR operation | ||
| - [bitwise.xor](./xor.md) - Bitwise XOR operation | ||
| - [bitwise.not](./not.md) - Bitwise NOT operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # bitwise.not | ||
|
|
||
| ## Description | ||
| Performs a bitwise NOT operation (one's complement) on an integer, inverting all bits. | ||
|
|
||
| ## Syntax | ||
| ```cypher | ||
| flex.bitwise.not(a) | ||
| ``` | ||
|
|
||
| ## Parameters | ||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `a` | number (integer) | Yes | The operand to invert | | ||
|
|
||
| ## Returns | ||
| **Type:** number (integer) | ||
|
|
||
| The result of the bitwise NOT operation (one's complement). | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Basic NOT Operation | ||
| ```cypher | ||
| RETURN flex.bitwise.not(5) AS result | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| result | ||
| ------ | ||
| -6 | ||
| ``` | ||
| (Binary: NOT 0101 = ...11111010 in 32-bit two's complement = -6) | ||
|
|
||
| ### Example 2: Inverting All Bits | ||
| ```cypher | ||
| RETURN flex.bitwise.not(0) AS result | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| result | ||
| ------ | ||
| -1 | ||
| ``` | ||
| (All bits become 1 in two's complement = -1) | ||
|
|
||
| ### Example 3: Double NOT Returns Original | ||
| ```cypher | ||
| WITH 42 AS value | ||
| RETURN flex.bitwise.not(flex.bitwise.not(value)) AS restored | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| restored | ||
| -------- | ||
| 42 | ||
| ``` | ||
|
|
||
| ## Notes | ||
| - Operates on 32-bit signed integers in JavaScript | ||
| - Result uses two's complement representation | ||
| - NOT operation inverts all bits including sign bit | ||
| - Formula: `~n = -(n + 1)` | ||
| - Less commonly used than AND, OR, XOR in typical applications | ||
|
|
||
| ## See Also | ||
| - [bitwise.and](./and.md) - Bitwise AND operation | ||
| - [bitwise.or](./or.md) - Bitwise OR operation | ||
| - [bitwise.xor](./xor.md) - Bitwise XOR operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # bitwise.or | ||
|
|
||
| ## Description | ||
| Performs a bitwise OR operation on two integers. Each bit in the result is 1 if at least one of the corresponding bits in the operands is 1. | ||
|
|
||
| ## Syntax | ||
| ```cypher | ||
| flex.bitwise.or(a, b) | ||
| ``` | ||
|
|
||
| ## Parameters | ||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `a` | number (integer) | Yes | First operand | | ||
| | `b` | number (integer) | Yes | Second operand | | ||
|
|
||
| ## Returns | ||
| **Type:** number (integer) | ||
|
|
||
| The result of the bitwise OR operation. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Basic OR Operation | ||
| ```cypher | ||
| RETURN flex.bitwise.or(12, 10) AS result | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| result | ||
| ------ | ||
| 14 | ||
| ``` | ||
| (Binary: 1100 OR 1010 = 1110 = 14) | ||
|
|
||
| ### Example 2: Combining Permission Flags | ||
| ```cypher | ||
| WITH 1 AS readFlag, 2 AS writeFlag | ||
| RETURN flex.bitwise.or(readFlag, writeFlag) AS readWritePermission | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| readWritePermission | ||
| ------------------- | ||
| 3 | ||
| ``` | ||
| (Binary: 01 OR 10 = 11 = 3) | ||
|
|
||
| ### Example 3: Setting Multiple Flags | ||
| ```cypher | ||
| MATCH (u:User {id: 123}) | ||
| SET u.permissions = flex.bitwise.or(u.permissions, 4) // Add execute permission | ||
| ``` | ||
|
|
||
| ## Notes | ||
| - Operates on 32-bit signed integers in JavaScript | ||
| - Both operands are converted to integers if needed | ||
| - Commonly used for combining flags and setting bits | ||
|
|
||
| ## See Also | ||
| - [bitwise.and](./and.md) - Bitwise AND operation | ||
| - [bitwise.xor](./xor.md) - Bitwise XOR operation | ||
| - [bitwise.not](./not.md) - Bitwise NOT operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # bitwise.shiftLeft | ||
|
|
||
| ## Description | ||
| Performs a left bit shift operation, moving all bits to the left by the specified number of positions. Zero bits are shifted in from the right. | ||
|
|
||
| ## Syntax | ||
| ```cypher | ||
| flex.bitwise.shiftLeft(a, positions) | ||
| ``` | ||
|
|
||
| ## Parameters | ||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `a` | number (integer) | Yes | The value to shift | | ||
| | `positions` | number (integer) | Yes | Number of positions to shift left | | ||
|
|
||
| ## Returns | ||
| **Type:** number (integer) | ||
|
|
||
| The result of shifting the bits left by the specified positions. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Basic Left Shift | ||
| ```cypher | ||
| RETURN flex.bitwise.shiftLeft(5, 2) AS result | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| result | ||
| ------ | ||
| 20 | ||
| ``` | ||
| (Binary: 0101 << 2 = 10100 = 20) | ||
|
|
||
| ### Example 2: Multiply by Power of Two | ||
| ```cypher | ||
| WITH 7 AS value | ||
| RETURN | ||
| flex.bitwise.shiftLeft(value, 1) AS times2, | ||
| flex.bitwise.shiftLeft(value, 2) AS times4, | ||
| flex.bitwise.shiftLeft(value, 3) AS times8 | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| times2 | times4 | times8 | ||
| -------|--------|------- | ||
| 14 | 28 | 56 | ||
| ``` | ||
| (Left shift by n is equivalent to multiplying by 2^n) | ||
|
|
||
| ### Example 3: Creating Bit Masks | ||
| ```cypher | ||
| RETURN flex.bitwise.shiftLeft(1, 3) AS mask | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| mask | ||
| ---- | ||
| 8 | ||
| ``` | ||
| (Creates mask with bit 3 set: 1000) | ||
|
|
||
| ## Notes | ||
| - Operates on 32-bit signed integers in JavaScript | ||
| - Left shift by n is equivalent to multiplying by 2^n | ||
| - Bits shifted off the left are discarded | ||
| - Zero bits are shifted in from the right | ||
| - Useful for multiplication by powers of 2 and creating bit masks | ||
|
|
||
| ## See Also | ||
| - [bitwise.shiftRight](./shiftRight.md) - Shift bits to the right | ||
| - [bitwise.and](./and.md) - Bitwise AND operation | ||
| - [bitwise.or](./or.md) - Bitwise OR operation |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix alphabetical ordering of new wordlist entries.
The entries "UDF" and "UDFs" are correctly placed alphabetically after "Trendshift", but "StringUtils" is out of order. It should be inserted in the 'S' section (around line 281-288 where other "Str*" entries like "str", "strList", and "substring" are located), not at the end of the file.
🔎 Proposed fix for alphabetical ordering
Move "StringUtils" to its correct alphabetical position in the 'S' section:
stopwords str + StringUtils strList subcommandsThen remove it from the end of the file:
Trendshift UDF UDFs - StringUtils UpperCaseOdd🤖 Prompt for AI Agents