Skip to content

Commit

Permalink
add getters/setters to all Resultset classes and dependencies - issue R…
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrelambert committed Nov 6, 2020
1 parent 5b46052 commit 8c718f6
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/redislabs/redisgraph/ResultSet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redislabs.redisgraph;

import java.util.Iterator;
import java.util.List;

/**
* Hold a query result
Expand All @@ -13,4 +14,6 @@ public interface ResultSet extends Iterator<Record> {

Header getHeader();

List<Record> getResults();

}
6 changes: 6 additions & 0 deletions src/main/java/com/redislabs/redisgraph/Statistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static Label getEnum(String value) {
}
return null;
}

public String getText() {
return text;
}
}

/**
Expand All @@ -67,5 +71,7 @@ public static Label getEnum(String value) {

int propertiesSet();

String queryExecutionTime();

boolean cachedExecution();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public abstract class GraphEntity {

//setters & getters

public Map<String, Property<?>> getPropertyMap() {
return propertyMap;
}

/**
* @return entity id
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@

public class RecordImpl implements Record {

private final List<String> header;
private final List<Object> values;
private final List<String> header;
private final List<Object> values;

RecordImpl(List<String> header, List<Object> values){
public RecordImpl(List<String> header, List<Object> values){
this.header=header;
this.values = values;
}

public List<String> getHeader() {
return header;
}

public List<Object> getValues() {
return values;
}

@Override
public <T> T getValue(int index) {
return (T)this.values.get(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public Header getHeader() {
return header;
}

@Override
public List<Record> getResults() {
return results;
}

/**
* @param rawNodeData - raw node object in the form of list of object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public StatisticsImpl(){}
* @param raw a raw representation of the query execution statistics
*/
public StatisticsImpl(List<byte[]> raw){
this.raw = raw;
this.raw = raw;
}


Expand All @@ -43,10 +43,10 @@ public String getStringValue(Statistics.Label label) {
/**
* Lazy parse statistics on first call
*/
private Map<Statistics.Label, String> getStatistics(){
public Map<Statistics.Label, String> getStatistics(){
if(statistics.size() == 0 && this.raw != null) {
for(byte[] tuple : this.raw) {
String text = SafeEncoder.encode(tuple);
String text = SafeEncoder.encode(tuple);
String[] rowTuple = text.split(":");
if(rowTuple.length == 2) {
Statistics.Label label = Statistics.Label.getEnum(rowTuple[0]);
Expand Down Expand Up @@ -145,6 +145,15 @@ public boolean cachedExecution() {
return getIntValue(Label.CACHED_EXECUTION) == 1;
}

/**
*
* @return The execution time for the Query.
*/
@Override
public String queryExecutionTime() {
return getStringValue(Label.QUERY_INTERNAL_EXECUTION_TIME);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down

0 comments on commit 8c718f6

Please sign in to comment.