From 2b97f80b467d0924478dffdcabc25898af2ba028 Mon Sep 17 00:00:00 2001 From: Andrei Dulvac Date: Tue, 7 Apr 2015 13:56:55 +0200 Subject: [PATCH] TarReader fix for precomputed graph --- .../oak/plugins/segment/file/TarReader.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java index 2b9de3d..197d24e 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/TarReader.java @@ -476,14 +476,11 @@ class TarReader { private final ByteBuffer index; - private final ByteBuffer graph; - private TarReader(File file, FileAccess access, ByteBuffer index) throws IOException { this.file = file; this.access = access; this.index = index; - this.graph = loadGraph(file, access, index); } long size() { @@ -623,8 +620,9 @@ class TarReader { synchronized TarReader cleanup(Set referencedIds, CompactionMap cm) throws IOException { Set cleaned = newHashSet(); Map> graph = null; - if (this.graph != null) { - graph = parseGraph(); + ByteBuffer graphByteBuffer = loadGraph(this.file, this.access, this.index); + if (graphByteBuffer != null) { + graph = parseGraph(graphByteBuffer); } TarEntry[] sorted = new TarEntry[index.remaining() / 24]; int position = index.position(); @@ -779,18 +777,19 @@ class TarReader { //-----------------------------------------------------------< private >-- Map> getGraph() throws IOException { + ByteBuffer graph = loadGraph(this.file, this.access, this.index); if (graph == null) { return emptyMap(); } else { - return parseGraph(); + return parseGraph(graph); } } - private Map> parseGraph() throws IOException { - int count = graph.getInt(graph.limit() - 12); + private Map> parseGraph(ByteBuffer graphByteBuffer) throws IOException { + int count = graphByteBuffer.getInt(graphByteBuffer.limit() - 12); - ByteBuffer buffer = graph.duplicate(); - buffer.limit(graph.limit() - 16); + ByteBuffer buffer = graphByteBuffer.duplicate(); + buffer.limit(graphByteBuffer.limit() - 16); List uuids = newArrayListWithCapacity(count); for (int i = 0; i < count; i++) { -- 1.8.2