Don't overwrite existing graphs in the graph database
@@ -128,7 +128,10 @@ public class RocksDao implements Closeable {
*/
public void saveToRocksDb(final long index, List<Long> nodes, int numInternal, final List<List<Long>> edges)
throws IOException, RocksDBException {
-
+ if (this.getGraphData(index) != null) {
+ logger.info("Graph with index {} is already in the database", index);
+ return;
+ }
var internalIds = new LongArrayList(numInternal);
var externalIds = new LongArrayList(nodes.size() - numInternal);
for (int i = 0; i < numInternal; i++) {
@@ -297,8 +300,7 @@ public class RocksDao implements Closeable {
* @return the directed graph stored in the database
* @throws RocksDBException if there was problem retrieving data from RocksDB
*/
- public DirectedGraph getGraphData(final long index)
- throws RocksDBException {
+ public DirectedGraph getGraphData(final long index) throws RocksDBException {
try {
final byte[] buffer = rocksDb.get(Longs.toByteArray(index));
final Input input = new Input(buffer);
