Skip to content

Commit 6eda1d3

Browse files
author
DvirDukhan
authored
Merge pull request #39 from RedisGraph/new-resultset-structure
graph entity property names are available. modified package structure
2 parents 4eadb76 + 45399e3 commit 6eda1d3

File tree

10 files changed

+30
-20
lines changed

10 files changed

+30
-20
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RedisGraph Java client
2222
```
2323

2424
### Snapshots
25+
To be used with RedisGraph 2.0 (not officially released)
2526

2627
```xml
2728
<repositories>
@@ -39,7 +40,7 @@ and
3940
<dependency>
4041
<groupId>com.redislabs</groupId>
4142
<artifactId>jredisgraph</artifactId>
42-
<version>1.0.5-SNAPSHOT</version>
43+
<version>2.0.0-SNAPSHOT</version>
4344
</dependency>
4445
</dependencies>
4546
```

src/main/java/com/redislabs/redisgraph/RedisGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.redislabs.redisgraph;
22

3-
import com.redislabs.redisgraph.impl.GraphCache;
3+
import com.redislabs.redisgraph.impl.graph_cache.GraphCache;
44
import com.redislabs.redisgraph.impl.ResultSetImpl;
55
import org.apache.commons.text.translate.AggregateTranslator;
66
import org.apache.commons.text.translate.CharSequenceTranslator;

src/main/java/com/redislabs/redisgraph/impl/Edge.java renamed to src/main/java/com/redislabs/redisgraph/graph_entities/Edge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.graph_entities;
22

33
import java.util.Objects;
44

src/main/java/com/redislabs/redisgraph/impl/GraphEntity.java renamed to src/main/java/com/redislabs/redisgraph/graph_entities/GraphEntity.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.graph_entities;
22

33

44
import com.redislabs.redisgraph.ResultSet.ResultSetScalarTypes;
@@ -51,6 +51,14 @@ public void addProperty(String name, ResultSetScalarTypes type, Object value){
5151

5252
}
5353

54+
/**
55+
*
56+
* @return Entity's property names, as a Set
57+
*/
58+
public Set<String> getEntityPropertyNames(){
59+
return propertyMap.keySet();
60+
}
61+
5462
/**
5563
* Add a property to the entity
5664
* @param property

src/main/java/com/redislabs/redisgraph/impl/Node.java renamed to src/main/java/com/redislabs/redisgraph/graph_entities/Node.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.graph_entities;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/com/redislabs/redisgraph/impl/Property.java renamed to src/main/java/com/redislabs/redisgraph/graph_entities/Property.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.graph_entities;
22

33
import com.redislabs.redisgraph.ResultSet;
44

src/main/java/com/redislabs/redisgraph/impl/ResultSetImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.redislabs.redisgraph.impl;
22

3-
import com.redislabs.redisgraph.Header;
4-
import com.redislabs.redisgraph.Record;
5-
import com.redislabs.redisgraph.ResultSet;
6-
import com.redislabs.redisgraph.Statistics;
3+
import com.redislabs.redisgraph.*;
4+
import com.redislabs.redisgraph.graph_entities.Edge;
5+
import com.redislabs.redisgraph.graph_entities.GraphEntity;
6+
import com.redislabs.redisgraph.graph_entities.Node;
7+
import com.redislabs.redisgraph.graph_entities.Property;
8+
import com.redislabs.redisgraph.impl.graph_cache.GraphCache;
79
import redis.clients.jedis.util.SafeEncoder;
810

911
import java.util.ArrayList;

src/main/java/com/redislabs/redisgraph/impl/GraphCache.java renamed to src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.impl.graph_cache;
22

33
import com.redislabs.redisgraph.RedisGraph;
44

src/main/java/com/redislabs/redisgraph/impl/GraphCacheList.java renamed to src/main/java/com/redislabs/redisgraph/impl/graph_cache/GraphCacheList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redislabs.redisgraph.impl;
1+
package com.redislabs.redisgraph.impl.graph_cache;
22

33
import com.redislabs.redisgraph.Record;
44
import com.redislabs.redisgraph.RedisGraph;

src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import java.util.stream.Collectors;
88
import java.util.stream.IntStream;
99

10-
import com.redislabs.redisgraph.impl.Edge;
11-
import com.redislabs.redisgraph.impl.Node;
12-
import com.redislabs.redisgraph.impl.Property;
10+
import com.redislabs.redisgraph.graph_entities.Edge;
11+
import com.redislabs.redisgraph.graph_entities.Node;
12+
import com.redislabs.redisgraph.graph_entities.Property;
1313
import org.junit.After;
1414
import org.junit.Assert;
1515
import org.junit.Before;
@@ -280,6 +280,10 @@ public void testRecord(){
280280
place, since, doubleValue, false, null),
281281
record.values());
282282

283+
Node a = record.getValue("a");
284+
for (String propertyName : expectedNode.getEntityPropertyNames()){
285+
Assert.assertEquals(expectedNode.getProperty(propertyName) ,a.getProperty(propertyName));
286+
}
283287

284288
Assert.assertEquals( "roi", record.getString(2));
285289
Assert.assertEquals( "32", record.getString(3));
@@ -407,11 +411,6 @@ public void testAdditionToProcedures(){
407411
Assert.assertNotNull(api.query("social", "CREATE (:person{name:'amit',age:30})"));
408412
Assert.assertNotNull(api.query("social", "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)"));
409413

410-
411-
List<ResultSet> resultSets = IntStream.range(0,16).parallel().
412-
mapToObj(i-> api.query("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r")).
413-
collect(Collectors.toList());
414-
415414
//expected objects init
416415
Property nameProperty = new Property("name", ResultSet.ResultSetScalarTypes.PROPERTY_STRING, "roi");
417416
Property ageProperty = new Property("age", ResultSet.ResultSetScalarTypes.PROPERTY_INTEGER, 32);

0 commit comments

Comments
 (0)