-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1768 from kuzudb/java-struct
Add struct support for Java API
- Loading branch information
Showing
8 changed files
with
196 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 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 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
13 changes: 13 additions & 0 deletions
13
tools/java_api/src/main/java/com/kuzudb/KuzuValueListUtil.java
This file contains 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,13 @@ | ||
package com.kuzudb; | ||
|
||
public class KuzuValueListUtil { | ||
public static long getListSize(KuzuValue value) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
return KuzuNative.kuzu_value_get_list_size(value); | ||
} | ||
|
||
public static KuzuValue getListElement(KuzuValue value, long index) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
return KuzuNative.kuzu_value_get_list_element(value, index); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...c/main/java/com/kuzudb/KuzuNodeValue.java → ...in/java/com/kuzudb/KuzuValueNodeUtil.java
This file contains 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
2 changes: 1 addition & 1 deletion
2
...rc/main/java/com/kuzudb/KuzuRelValue.java → ...ain/java/com/kuzudb/KuzuValueRelUtil.java
This file contains 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
35 changes: 35 additions & 0 deletions
35
tools/java_api/src/main/java/com/kuzudb/KuzuValueStructUtil.java
This file contains 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,35 @@ | ||
package com.kuzudb; | ||
|
||
public class KuzuValueStructUtil { | ||
public static long getNumFields(KuzuValue value) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
return KuzuNative.kuzu_value_get_list_size(value); | ||
} | ||
|
||
public static long getIndexByFieldName(KuzuValue value, String fieldName) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
return KuzuNative.kuzu_value_get_struct_index(value, fieldName); | ||
} | ||
|
||
public static String getFieldNameByIndex(KuzuValue value, long index) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
return KuzuNative.kuzu_value_get_struct_field_name(value, index); | ||
} | ||
|
||
public static KuzuValue getValueByFieldName(KuzuValue value, String fieldName) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
long index = getIndexByFieldName(value, fieldName); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return getValueByIndex(value, index); | ||
} | ||
|
||
public static KuzuValue getValueByIndex(KuzuValue value, long index) throws KuzuObjectRefDestroyedException { | ||
value.checkNotDestroyed(); | ||
if (index < 0 || index >= getNumFields(value)) { | ||
return null; | ||
} | ||
return KuzuNative.kuzu_value_get_list_element(value, index); | ||
} | ||
} |
This file contains 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