Skip to content

Commit 235a160

Browse files
JohannesLichtenbergerJohannes Lichtenberger
and
Johannes Lichtenberger
authored
Minor refactorings (#612)
* Fix GC issue * Disable tests and delete everything during setup * Fix bug regarding concurrent/parallel access. * Minor refactorings * Disabled tests * Update build.gradle --------- Co-authored-by: Johannes Lichtenberger <[email protected]>
1 parent b92def6 commit 235a160

19 files changed

+134
-285
lines changed

bundles/sirix-core/src/main/java/org/sirix/access/ResourceConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.sirix.io.bytepipe.ByteHandler;
4141
import org.sirix.io.bytepipe.ByteHandlerKind;
4242
import org.sirix.io.bytepipe.ByteHandlerPipeline;
43-
import org.sirix.io.bytepipe.SnappyCompressor;
43+
import org.sirix.io.bytepipe.LZ4Compressor;
4444
import org.sirix.node.NodeSerializerImpl;
4545
import org.sirix.node.interfaces.RecordSerializer;
4646
import org.sirix.settings.VersioningType;
@@ -723,7 +723,7 @@ public Builder(final String resource) {
723723
this.resource = requireNonNull(resource);
724724
pathSummary = true;
725725
storeChildCount = true;
726-
byteHandler = new ByteHandlerPipeline(new SnappyCompressor());//new LZ4Compressor()); // new Encryptor(path));
726+
byteHandler = new ByteHandlerPipeline(new LZ4Compressor()); // new Encryptor(path));
727727
}
728728

729729
/**

bundles/sirix-core/src/main/java/org/sirix/io/AbstractReader.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ public AbstractReader(ByteHandler byteHandler, PagePersister pagePersister, Seri
3434
public Page deserialize(PageReadOnlyTrx pageReadTrx, byte[] page) throws IOException {
3535
// perform byte operations
3636
final var inputStream = byteHandler.deserialize(new ByteArrayInputStream(page));
37-
byte[] bytes = inputStream.readAllBytes();
38-
var input = Bytes.elasticByteBuffer(10_000);
39-
BytesUtils.doWrite(input, bytes);
40-
final var deserializedPage = pagePersister.deserializePage(pageReadTrx, input, type);
41-
input.clear();
42-
return deserializedPage;
37+
return pagePersister.deserializePage(pageReadTrx, Bytes.wrapForRead(inputStream.readAllBytes()), type);
4338
}
4439

4540
@Override

bundles/sirix-core/src/main/java/org/sirix/io/bytepipe/LZ4Compressor.java

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
11
package org.sirix.io.bytepipe;
22

3-
import net.jpountz.lz4.LZ4FrameInputStream;
4-
import net.jpountz.lz4.LZ4FrameOutputStream;
3+
import net.jpountz.lz4.LZ4BlockInputStream;
4+
import net.jpountz.lz4.LZ4BlockOutputStream;
55

6-
import java.io.IOException;
76
import java.io.InputStream;
87
import java.io.OutputStream;
9-
import java.io.UncheckedIOException;
108

119
/**
1210
* LZ4 compression/decompression.
1311
*
1412
* @author Johannes Lichtenberger, University of Konstanz
15-
*
1613
*/
1714
public final class LZ4Compressor implements ByteHandler {
1815

1916
@Override
2017
public OutputStream serialize(final OutputStream toSerialize) {
21-
try {
22-
return new LZ4FrameOutputStream(toSerialize);
23-
} catch (IOException e) {
24-
throw new UncheckedIOException(e);
25-
}
18+
return new LZ4BlockOutputStream(toSerialize);
2619
}
2720

2821
@Override
2922
public InputStream deserialize(final InputStream toDeserialize) {
30-
try {
31-
return new LZ4FrameInputStream(toDeserialize);
32-
} catch (IOException e) {
33-
throw new UncheckedIOException(e);
34-
}
23+
return new LZ4BlockInputStream(toDeserialize);
3524
}
3625

3726
@Override

bundles/sirix-core/src/main/java/org/sirix/io/directio/FileChannelWriter.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ private FileChannelWriter writePageReference(final PageReadOnlyTrx pageReadOnlyT
164164

165165
final byte[] serializedPage;
166166

167-
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length);
168-
final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
169-
dataOutput.write(byteArray);
170-
dataOutput.flush();
167+
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length)) {
168+
try (final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
169+
dataOutput.write(byteArray);
170+
dataOutput.flush();
171+
}
171172
serializedPage = output.toByteArray();
172173
}
173174

bundles/sirix-core/src/main/java/org/sirix/io/file/FileWriter.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ private FileWriter writePageReference(final PageReadOnlyTrx pageReadOnlyTrx, fin
140140

141141
final byte[] serializedPage;
142142

143-
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(1_000);
144-
final DataOutputStream dataOutput = new DataOutputStream(reader.byteHandler.serialize(output))) {
145-
pagePersister.serializePage(pageReadOnlyTrx, byteBufferBytes, page, type);
146-
final var byteArray = byteBufferBytes.toByteArray();
147-
dataOutput.write(byteArray);
148-
dataOutput.flush();
143+
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(1_000)) {
144+
try (final DataOutputStream dataOutput = new DataOutputStream(reader.byteHandler.serialize(output))) {
145+
pagePersister.serializePage(pageReadOnlyTrx, byteBufferBytes, page, type);
146+
final var byteArray = byteBufferBytes.toByteArray();
147+
dataOutput.write(byteArray);
148+
dataOutput.flush();
149+
}
149150
serializedPage = output.toByteArray();
150151
}
151152

bundles/sirix-core/src/main/java/org/sirix/io/filechannel/FileChannelWriter.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ private FileChannelWriter writePageReference(final PageReadOnlyTrx pageReadOnlyT
158158

159159
final byte[] serializedPage;
160160

161-
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length);
162-
final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
163-
dataOutput.write(byteArray);
164-
dataOutput.flush();
161+
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length)) {
162+
try (final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
163+
dataOutput.write(byteArray);
164+
dataOutput.flush();
165+
}
165166
serializedPage = output.toByteArray();
166167
}
167168

bundles/sirix-core/src/main/java/org/sirix/io/iouring/IOUringWriter.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ private IOUringWriter writePage(PageReadOnlyTrx pageReadOnlyTrx, PageReference p
178178

179179
final byte[] serializedPage;
180180

181-
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length);
182-
final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
183-
dataOutput.write(byteArray);
184-
dataOutput.flush();
181+
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(byteArray.length)) {
182+
try (final DataOutputStream dataOutput = new DataOutputStream(reader.getByteHandler().serialize(output))) {
183+
dataOutput.write(byteArray);
184+
dataOutput.flush();
185+
}
185186
serializedPage = output.toByteArray();
186187
}
187188

0 commit comments

Comments
 (0)