Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ public Map<String, Collection<AtlasJanusVertex>> getAtlasVertexMap() {
ret = new HashMap<>(map.size());

for (Object key : map.keySet()) {
if (!(key instanceof String)) {
continue;
}
LOG.info("Printing Key DataType: {}", key.getClass());

// Non-string keys are now converted to String // Use case: DSL search — groupBy(createTime) was failing earlier.
// Example: DSL query "earlier" failing - Table groupBy(createTime) select owner, name, max(createTime)
//Exampled: DSL query passing - Table groupBy(owner) select owner, count()
// So non-string key(createTime) were earlier not getting results
String keyStr = (key instanceof String) ? (String) key : String.valueOf(key);

Object value = map.get(key);

Expand All @@ -131,7 +135,7 @@ public Map<String, Collection<AtlasJanusVertex>> getAtlasVertexMap() {
}
}

ret.put((String) key, values);
ret.put(keyStr, values);
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void testGetAtlasVertexMapWithNonStringKey() throws Exception {
List<Vertex> vertexList = new ArrayList<>();
vertexList.add(mock(Vertex.class));

mapResult.put(123, vertexList); // Non-string key
mapResult.put(123, vertexList); // Non-string key (Integer)
mapResult.put("validKey", vertexList);
resultList.add(mapResult);

Expand All @@ -234,8 +234,9 @@ public void testGetAtlasVertexMapWithNonStringKey() throws Exception {

Map<String, Collection<AtlasJanusVertex>> vertexMap = traversal.getAtlasVertexMap();
assertNotNull(vertexMap);
assertEquals(vertexMap.size(), 1); // Only string keys should be included
assertEquals(vertexMap.size(), 2);
assertNotNull(vertexMap.get("validKey"));
assertNotNull(vertexMap.get("123")); // Integer key converted to String
}

@Test
Expand Down Expand Up @@ -271,6 +272,44 @@ public void testGetAtlasVertexMapEmpty() throws Exception {
assertTrue(vertexMap.isEmpty());
}

@Test
public void testGetAtlasVertexMapWithLongKeysForDSLGroupByCreateTime() throws Exception {
List<Object> resultList = new ArrayList<>();
Map<Object, Object> mapResult = new HashMap<>();

// Create mock vertices for different timestamp groups
List<Vertex> group1Vertices = new ArrayList<>();
group1Vertices.add(mock(Vertex.class));
group1Vertices.add(mock(Vertex.class));

List<Vertex> group2Vertices = new ArrayList<>();
group2Vertices.add(mock(Vertex.class));

List<Vertex> group3Vertices = new ArrayList<>();
group3Vertices.add(mock(Vertex.class));
group3Vertices.add(mock(Vertex.class));
group3Vertices.add(mock(Vertex.class));

// Add groups with Long keys (simulating createTime timestamps)
mapResult.put(1700000000000L, group1Vertices); // Timestamp 1
mapResult.put(1710000000000L, group2Vertices); // Timestamp 2
mapResult.put(1720000000000L, group3Vertices); // Timestamp 3

resultList.add(mapResult);
setResultList(traversal, resultList);

Map<String, Collection<AtlasJanusVertex>> vertexMap = traversal.getAtlasVertexMap();
// Verify results
assertNotNull(vertexMap);
assertEquals(vertexMap.size(), 3); // All Long keys converted to String
assertNotNull(vertexMap.get("1700000000000")); // Verify Long converted to String
assertNotNull(vertexMap.get("1710000000000"));
assertNotNull(vertexMap.get("1720000000000"));
assertEquals(vertexMap.get("1700000000000").size(), 2); // 2 vertices in group1
assertEquals(vertexMap.get("1710000000000").size(), 1); // 1 vertex in group2
assertEquals(vertexMap.get("1720000000000").size(), 3); // 3 vertices in group3
}

@Test
public void testGetAtlasEdgeSetWithEdges() throws Exception {
// Setup mock edges
Expand Down