public void repair(final ODatabaseSession graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Repair of graph '" + graph.getURL() + "' is started ...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, false); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, false); message(outputListener, "Repair of graph '" + graph.getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " removedEdges.....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " removedLinks.....: " + stats.removedLinks + "\n"); message(outputListener, " repairedVertices.: " + stats.repairedVertices + "\n"); }
message(outputListener, "Scanning " + countVertices + " vertices...\n"); message(outputListener, "+ vertices: scanned " + stats.scannedVertices + ", repaired " + stats.repairedVertices + " (estimated remaining time " + remaining + " secs)\n"); final OPair<ODirection, String> connection = getConnection(db, ODirection.BOTH, fieldName, null); if (connection == null) if (isEdgeBroken(vertex, fieldName, connection.getKey(), (OIdentifiable) fieldValue, stats, true)) { vertexCorrupted = true; if (!checkOnly) { vertex.field(fieldName, (Object) null); } else message(outputListener, "+ found corrupted vertex " + vertex + " the property " + fieldName + " could be removed\n"); if (isEdgeBroken(vertex, fieldName, connection.getKey(), (OIdentifiable) o, stats, true)) { vertexCorrupted = true; if (!checkOnly) { it.remove(); } else message(outputListener, "+ found corrupted vertex " + vertex + " the edge should be removed from property " + fieldName + " (collection)\n"); if (isEdgeBroken(vertex, fieldName, connection.getKey(), (OIdentifiable) o, stats, true)) { vertexCorrupted = true; if (!checkOnly) { it.remove();
private boolean isEdgeBroken(final OIdentifiable vertex, final String fieldName, final ODirection direction, final OIdentifiable edgeRID, final ORepairStats stats, final boolean useVertexFieldsForEdgeLabels) { onScannedLink(stats, edgeRID); if (immutableClass.isVertexType()) { final String inverseFieldName = getInverseConnectionFieldName(fieldName, useVertexFieldsForEdgeLabels); onRemovedLink(stats, edgeRID); return true;
new OGraphRepair().repair(currentDatabase, this, options);
String connClass = getConnectionClass(ODirection.OUT, iFieldName); if (iClassNames == null || iClassNames.length == 0) return new OPair<ODirection, String>(ODirection.OUT, connClass); String connClass = getConnectionClass(ODirection.IN, iFieldName); if (iClassNames == null || iClassNames.length == 0) return new OPair<ODirection, String>(ODirection.IN, connClass);
message(outputListener, "Scanning " + countEdges + " edges (skipEdges=" + skipEdges + ")...\n"); final long remaining = (countEdges - parsedEdges) / speedPerSecond; message(outputListener, "+ edges: scanned " + stats.scannedEdges + ", removed " + stats.removedEdges + " (estimated remaining time " + remaining + " secs)\n"); try { if (!checkOnly) { message(outputListener, "+ deleting corrupted edge " + edge + " because " + removalReason + "\n"); edge.delete(); } else message(outputListener, "+ found corrupted edge " + edge + " because " + removalReason + "\n"); message(outputListener, "Error on deleting edge " + edge.getIdentity() + " (" + e.getMessage() + ")"); message(outputListener, "Scanning edges completed\n");
public void check(final ODatabaseSession graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Check of graph '" + graph.getURL() + "' is started...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, true); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, true); message(outputListener, "Check of graph '" + graph.getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " edgesToRemove....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " linksToRemove....: " + stats.removedLinks + "\n"); message(outputListener, " verticesToRepair.: " + stats.repairedVertices + "\n"); }