Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
c6081ddc
Commit
c6081ddc
authored
8 years ago
by
Christian Rieck
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1875: updated gremlin search to include vertex id in the result
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
d9f62cb5
master
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
4 deletions
+47
-4
GraphBackedDiscoveryService.java
...he/atlas/discovery/graph/GraphBackedDiscoveryService.java
+21
-4
GraphBackedDiscoveryServiceTest.java
...ache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
+26
-0
No files found.
repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
View file @
c6081ddc
...
...
@@ -71,6 +71,22 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
private
final
DefaultGraphPersistenceStrategy
graphPersistenceStrategy
;
public
final
static
String
SCORE
=
"score"
;
/**
* Where the vertex' internal gremlin id is stored in the Map produced by extractResult()
*/
public
final
static
String
GREMLIN_ID_KEY
=
"id"
;
/**
* Where the id of an edge's incoming vertex is stored in the Map produced by extractResult()
*/
public
final
static
String
GREMLIN_INVERTEX_KEY
=
"inVertex"
;
/**
* Where the id of an edge's outgoing vertex is stored in the Map produced by extractResult()
*/
public
final
static
String
GREMLIN_OUTVERTEX_KEY
=
"outVertex"
;
/**
* Where an edge's label is stored in the Map produced by extractResult()
*/
public
final
static
String
GREMLIN_LABEL_KEY
=
"label"
;
@Inject
GraphBackedDiscoveryService
(
MetadataRepository
metadataRepository
,
AtlasGraph
atlasGraph
)
...
...
@@ -223,15 +239,16 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
oRow
.
put
(
key
,
propertyValue
.
toString
());
}
}
oRow
.
put
(
GREMLIN_ID_KEY
,
vertex
.
getId
().
toString
());
}
else
if
(
value
instanceof
String
)
{
oRow
.
put
(
""
,
value
.
toString
());
}
else
if
(
value
instanceof
AtlasEdge
)
{
AtlasEdge
edge
=
(
AtlasEdge
)
value
;
oRow
.
put
(
"id"
,
edge
.
getId
().
toString
());
oRow
.
put
(
"label"
,
edge
.
getLabel
());
oRow
.
put
(
"inVertex"
,
edge
.
getInVertex
().
getId
().
toString
());
oRow
.
put
(
"outVertex"
,
edge
.
getOutVertex
().
getId
().
toString
());
oRow
.
put
(
GREMLIN_ID_KEY
,
edge
.
getId
().
toString
());
oRow
.
put
(
GREMLIN_LABEL_KEY
,
edge
.
getLabel
());
oRow
.
put
(
GREMLIN_INVERTEX_KEY
,
edge
.
getInVertex
().
getId
().
toString
());
oRow
.
put
(
GREMLIN_OUTVERTEX_KEY
,
edge
.
getOutVertex
().
getId
().
toString
());
for
(
String
propertyKey
:
edge
.
getPropertyKeys
())
{
oRow
.
put
(
propertyKey
,
GraphHelper
.
getProperty
(
edge
,
propertyKey
).
toString
());
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
View file @
c6081ddc
...
...
@@ -227,6 +227,32 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
assertEquals
(
rows
.
length
(),
1
);
}
/*
* https://issues.apache.org/jira/browse/ATLAS-1875
*/
@Test
public
void
testGremlinSearchReturnVertexId
()
throws
Exception
{
List
<
Map
<
String
,
String
>>
gremlinResults
=
discoveryService
.
searchByGremlin
(
"g.V.range(0,0).collect()"
);
assertEquals
(
gremlinResults
.
size
(),
1
);
Map
<
String
,
String
>
properties
=
gremlinResults
.
get
(
0
);
Assert
.
assertTrue
(
properties
.
containsKey
(
GraphBackedDiscoveryService
.
GREMLIN_ID_KEY
));
}
/*
* https://issues.apache.org/jira/browse/ATLAS-1875
*/
@Test
public
void
testGremlinSearchReturnEdgeIds
()
throws
Exception
{
List
<
Map
<
String
,
String
>>
gremlinResults
=
discoveryService
.
searchByGremlin
(
"g.E.range(0,0).collect()"
);
assertEquals
(
gremlinResults
.
size
(),
1
);
Map
<
String
,
String
>
properties
=
gremlinResults
.
get
(
0
);
Assert
.
assertTrue
(
properties
.
containsKey
(
GraphBackedDiscoveryService
.
GREMLIN_INVERTEX_KEY
));
Assert
.
assertTrue
(
properties
.
containsKey
(
GraphBackedDiscoveryService
.
GREMLIN_OUTVERTEX_KEY
));
Assert
.
assertTrue
(
properties
.
containsKey
(
GraphBackedDiscoveryService
.
GREMLIN_LABEL_KEY
));
}
@Test
public
void
testSearchByDSLReturnsEntity
()
throws
Exception
{
String
dslQuery
=
"from Department"
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment