Skip to content

Commit

Permalink
RelVal and QuerySummary done
Browse files Browse the repository at this point in the history
  • Loading branch information
KasunaStony committed Jun 7, 2023
1 parent 89d0198 commit c3c283a
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 25 deletions.
4 changes: 2 additions & 2 deletions tools/java_api/KuzuDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void destory() {
destroyed = true;
}

public void setLoggingLevel(String logging_level, KuzuDatabase db) {
public void setLoggingLevel(String logging_level) {
checkNotdestroyed();
KuzuNative.kuzu_database_set_logging_level(logging_level ,db);
KuzuNative.kuzu_database_set_logging_level(logging_level ,this);
}
}
2 changes: 1 addition & 1 deletion tools/java_api/KuzuNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected static native void kuzu_node_val_add_property(
KuzuNodeValue node_val, String key, KuzuValue value);
protected static native String kuzu_node_val_to_string(KuzuNodeValue node_val);

protected static native KuzuRelValue kuzu_rel_val_create(
protected static native long kuzu_rel_val_create(
KuzuInternalID src_id, KuzuInternalID dst_id, String label);
protected static native KuzuRelValue kuzu_rel_val_clone(KuzuRelValue rel_val);
protected static native void kuzu_rel_val_destroy(KuzuRelValue rel_val);
Expand Down
9 changes: 6 additions & 3 deletions tools/java_api/KuzuNodeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
public class KuzuNodeValue {
long nv_ref;
boolean destroyed = false;
boolean isOwnedByCPP = false;

private void checkNotdestroyed() {
assert !destroyed: "PreparedStatement has been destoryed.";
assert !destroyed: "KuzuNodeValue has been destoryed.";
}

public KuzuNodeValue(KuzuInternalID id, String label) {
Expand All @@ -19,8 +20,10 @@ public KuzuNodeValue clone() {

public void destroy() {
checkNotdestroyed();
KuzuNative.kuzu_node_val_destroy(this);
destroyed = true;
if (!isOwnedByCPP) {
KuzuNative.kuzu_node_val_destroy(this);
destroyed = true;
}
}

public KuzuValue getIDVal() {
Expand Down
21 changes: 21 additions & 0 deletions tools/java_api/KuzuQuerySummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,25 @@

public class KuzuQuerySummary {
long qs_ref;
boolean destroyed = false;

private void checkNotdestroyed () {
assert !destroyed: "KuzuValue has been destroyed.";
}

public void destroy() {
checkNotdestroyed();
KuzuNative.kuzu_query_summary_destroy(this);
destroyed = true;
}

public double getCompilingTime() {
checkNotdestroyed();
return KuzuNative.kuzu_query_summary_get_compiling_time(this);
}

public double getExecutionTime() {
checkNotdestroyed();
return KuzuNative.kuzu_query_summary_get_execution_time(this);
}
}
75 changes: 74 additions & 1 deletion tools/java_api/KuzuRelValue.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,78 @@
package tools.java_api;

public class KuzuRelValue {

long rv_ref;
boolean destroyed = false;
boolean isOwnedByCPP = false;

private void checkNotdestroyed() {
assert !destroyed: "KuzuRelValue has been destoryed.";
}

public KuzuRelValue(KuzuInternalID src_id, KuzuInternalID dst_id, String label) {
rv_ref = KuzuNative.kuzu_rel_val_create(src_id, dst_id, label);
}

public KuzuRelValue clone() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_clone(this);
}

public void destroy() {
checkNotdestroyed();
if (!isOwnedByCPP) {
KuzuNative.kuzu_rel_val_destroy(this);
destroyed = true;
}
}

public KuzuValue getSrcIDVal() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_src_id_val(this);
}

public KuzuValue getDstIDVal() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_dst_id_val(this);
}

public KuzuInternalID getSrcID() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_src_id(this);
}

public KuzuInternalID getDstID() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_dst_id(this);
}

public String getLabelName() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_label_name(this);
}

public long getPropertySize() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_property_size(this);
}

public String getPropertyNameAt(long index) {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_property_name_at(this, index);
}

public KuzuValue getPropertyValueAt(long index) {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_get_property_value_at(this, index);
}

public void addProperty(String key, KuzuValue value) {
checkNotdestroyed();
KuzuNative.kuzu_rel_val_add_property(this, key, value);
}

public String toString() {
checkNotdestroyed();
return KuzuNative.kuzu_rel_val_to_string(this);
}
}
2 changes: 1 addition & 1 deletion tools/java_api/KuzuValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class KuzuValue {
boolean isOwnedByCPP = false;

private void checkNotdestroyed () {
assert !destroyed: "FlatTuple has been destroyed.";
assert !destroyed: "KuzuValue has been destroyed.";
}

public <T> KuzuValue (T val) {
Expand Down
Loading

0 comments on commit c3c283a

Please sign in to comment.