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 { ...@@ -484,23 +484,31 @@ public class AtlasGraphUtilsV2 {
} }
public static AtlasPatches getPatches() { public static AtlasPatches getPatches() {
List<AtlasPatch> patches = new ArrayList<>(); List<AtlasPatch> ret = new ArrayList<>();
String indexQuery = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : (*)"; String idxQueryString = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : (*)";
Iterator<Result<Object, Object>> results = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, indexQuery).vertices(); AtlasIndexQuery idxQuery = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, idxQueryString);
Iterator<Result<Object, Object>> results;
while (results != null && results.hasNext()) { try {
AtlasVertex patchVertex = results.next().getVertex(); results = idxQuery.vertices();
AtlasPatch patch = toAtlasPatch(patchVertex);
patches.add(patch); while (results != null && results.hasNext()) {
} AtlasVertex patchVertex = results.next().getVertex();
AtlasPatch patch = toAtlasPatch(patchVertex);
// Sort the patches based on patch id ret.add(patch);
if (CollectionUtils.isNotEmpty(patches)) { }
Collections.sort(patches, (p1, p2) -> p1.getId().compareTo(p2.getId()));
// Sort the patches based on patch id
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) { 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