Commit fa2c3e2c by Sarath Subramanian

ATLAS-3070: Create patch framework to persist typedef patches applied to atlas…

ATLAS-3070: Create patch framework to persist typedef patches applied to atlas #2 fix getPatches() method
parent 3addc237
......@@ -484,23 +484,31 @@ public class AtlasGraphUtilsV2 {
}
public static AtlasPatches getPatches() {
List<AtlasPatch> patches = new ArrayList<>();
String indexQuery = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : (*)";
Iterator<Result<Object, Object>> results = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, indexQuery).vertices();
List<AtlasPatch> ret = new ArrayList<>();
String idxQueryString = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : (*)";
AtlasIndexQuery idxQuery = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, idxQueryString);
Iterator<Result<Object, Object>> results;
try {
results = idxQuery.vertices();
while (results != null && results.hasNext()) {
AtlasVertex patchVertex = results.next().getVertex();
AtlasPatch patch = toAtlasPatch(patchVertex);
patches.add(patch);
ret.add(patch);
}
// Sort the patches based on patch id
if (CollectionUtils.isNotEmpty(patches)) {
Collections.sort(patches, (p1, p2) -> p1.getId().compareTo(p2.getId()));
if (CollectionUtils.isNotEmpty(ret)) {
Collections.sort(ret, (p1, p2) -> p1.getId().compareTo(p2.getId()));
}
} catch (Throwable t) {
// first time idx query is fired, returns no field exists in solr exception
LOG.warn("getPatches() returned empty result!");
}
return new AtlasPatches(patches);
return new AtlasPatches(ret);
}
private static AtlasPatch toAtlasPatch(AtlasVertex vertex) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment