GH-2501 - Use more performant operations to store mapped records.
This commit is contained in:
@@ -755,7 +755,8 @@ final class DefaultNeo4jEntityConverter implements Neo4jEntityConverter {
|
||||
private final Lock write = lock.writeLock();
|
||||
|
||||
private final Map<Long, Object> internalIdStore = new HashMap<>();
|
||||
private final Map<Long, Boolean> internalNextRecord = new HashMap<>();
|
||||
private final Map<Long, Boolean> internalCurrentRecord = new HashMap<>();
|
||||
private final Set<Long> previousRecords = new HashSet<>();
|
||||
private final Set<Long> idsInCreation = new HashSet<>();
|
||||
|
||||
private void storeObject(@Nullable Long internalId, Object object) {
|
||||
@@ -766,7 +767,7 @@ final class DefaultNeo4jEntityConverter implements Neo4jEntityConverter {
|
||||
write.lock();
|
||||
idsInCreation.remove(internalId);
|
||||
internalIdStore.put(internalId, object);
|
||||
internalNextRecord.put(internalId, false);
|
||||
internalCurrentRecord.put(internalId, false);
|
||||
} finally {
|
||||
write.unlock();
|
||||
}
|
||||
@@ -837,23 +838,19 @@ final class DefaultNeo4jEntityConverter implements Neo4jEntityConverter {
|
||||
|
||||
read.lock();
|
||||
|
||||
Boolean nextRecord = internalNextRecord.get(internalId);
|
||||
|
||||
if (nextRecord != null) {
|
||||
return nextRecord;
|
||||
}
|
||||
return previousRecords.contains(internalId) || internalCurrentRecord.get(internalId);
|
||||
|
||||
} finally {
|
||||
read.unlock();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark all currently existing objects as mapped.
|
||||
*/
|
||||
private void nextRecord() {
|
||||
internalNextRecord.replaceAll((x, y) -> true);
|
||||
previousRecords.addAll(internalCurrentRecord.keySet());
|
||||
internalCurrentRecord.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user