org.sirix.io.bytepipe.ByteHandlePipeline Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package org.sirix.io.bytepipe;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Pipeline to handle bytes before stored in the backend.
*
* @author Sebastian Graf, University of Konstanz
*
*/
public final class ByteHandlePipeline implements ByteHandler {
/** Pipeline for all byte handlers. */
private final List byteHandlers;
/**
* Copy constructor.
*
* @param pipeline pipeline to copy
*/
public ByteHandlePipeline(final ByteHandlePipeline pipeline) {
byteHandlers = new ArrayList<>(pipeline.byteHandlers.size());
for (final ByteHandler handler : pipeline.byteHandlers) {
byteHandlers.add(handler.getInstance());
}
}
/**
*
* Constructor.
*
* @param parts to be stored, Order is important!
*/
public ByteHandlePipeline(final ByteHandler... parts) {
byteHandlers = new ArrayList<>();
if (parts != null) {
Collections.addAll(byteHandlers, parts);
}
}
@Override
public OutputStream serialize(final OutputStream toSerialize) {
OutputStream pipeData = toSerialize;
for (final ByteHandler byteHandler : byteHandlers) {
pipeData = byteHandler.serialize(pipeData);
}
return pipeData;
}
@Override
public InputStream deserialize(final InputStream toDeserialize) {
InputStream pipeData = toDeserialize;
for (final ByteHandler part : byteHandlers) {
pipeData = part.deserialize(pipeData);
}
return pipeData;
}
/**
* Get byte handler components.
*
* @return all components
*/
public List getComponents() {
return Collections.unmodifiableList(byteHandlers);
}
@Override
public ByteHandler getInstance() {
return new ByteHandlePipeline();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy