Skip to content

Commit

Permalink
[MOD] Adapted poms to point to sirixdb/sirix repository plus simple
Browse files Browse the repository at this point in the history
changes.
  • Loading branch information
Johannes Lichtenberger committed Aug 22, 2013
1 parent 3df2715 commit 13d20f0
Show file tree
Hide file tree
Showing 43 changed files with 512 additions and 449 deletions.
35 changes: 25 additions & 10 deletions bundles/sirix-core/src/main/java/org/sirix/cache/PageBinding.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,25 +27,32 @@


package org.sirix.cache; package org.sirix.cache;


import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.annotation.Nullable; import javax.annotation.Nullable;


import org.sirix.access.conf.ResourceConfiguration; import org.sirix.access.conf.ResourceConfiguration;
import org.sirix.api.PageReadTrx; import org.sirix.api.PageReadTrx;
import org.sirix.page.PagePersistenter; import org.sirix.page.PagePersistenter;
import org.sirix.page.interfaces.Page; import org.sirix.page.interfaces.Page;
import org.sirix.utils.LogWrapper;
import org.slf4j.LoggerFactory;


import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sleepycat.bind.tuple.TupleBinding; import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput; import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.bind.tuple.TupleOutput;


/** /**
* Binding for {@link RecordPageContainer} reference. * Binding for {@link RecordPageContainer} reference.
*/ */
public class PageBinding extends TupleBinding<Page> { public final class PageBinding extends TupleBinding<Page> {


private static final LogWrapper LOGGER = new LogWrapper(LoggerFactory.getLogger(PageBinding.class));

/** {@link ResourceConfiguration} instance. */ /** {@link ResourceConfiguration} instance. */
private final PageReadTrx mPageReadTrx; private final PageReadTrx mPageReadTrx;


Expand All @@ -65,19 +72,27 @@ public Page entryToObject(final @Nullable TupleInput input) {
if (input == null) { if (input == null) {
return null; return null;
} }
final ByteArrayDataInput source = ByteStreams.newDataInput(input try {
.getBufferBytes()); return PagePersistenter.deserializePage(new DataInputStream(input),
return PagePersistenter.deserializePage(source, mPageReadTrx); mPageReadTrx);
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
return null;
}
} }


@Override @Override
public void objectToEntry(final @Nullable Page page, public void objectToEntry(final @Nullable Page page,
final @Nullable TupleOutput output) { final @Nullable TupleOutput output) {
if (page != null && output != null) { if (page != null && output != null) {
final ByteArrayDataOutput target = ByteStreams.newDataOutput(); final OutputStream target = new ByteArrayOutputStream();
final byte[] bytes = output.getBufferBytes(); final byte[] bytes = output.getBufferBytes();
target.write(bytes, 0, bytes.length); try {
page.serialize(target); target.write(bytes, 0, bytes.length);
page.serialize(new DataOutputStream(target));
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
}
} }
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,25 +27,33 @@


package org.sirix.cache; package org.sirix.cache;


import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

import javax.annotation.Nullable; import javax.annotation.Nullable;


import org.sirix.access.conf.ResourceConfiguration; import org.sirix.access.conf.ResourceConfiguration;
import org.sirix.api.PageReadTrx; import org.sirix.api.PageReadTrx;
import org.sirix.page.PagePersistenter; import org.sirix.page.PagePersistenter;
import org.sirix.page.interfaces.KeyValuePage; import org.sirix.page.interfaces.KeyValuePage;
import org.sirix.utils.LogWrapper;
import org.slf4j.LoggerFactory;


import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.sleepycat.bind.tuple.TupleBinding; import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput; import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.bind.tuple.TupleOutput;


/** /**
* Binding for {@link RecordPageContainer} reference. * Binding for {@link RecordPageContainer} reference.
*/ */
public class PageContainerBinding<T extends KeyValuePage<?, ?>> extends public final class PageContainerBinding<T extends KeyValuePage<?, ?>> extends
TupleBinding<RecordPageContainer<T>> { TupleBinding<RecordPageContainer<T>> {


/** Logger. */
private static final LogWrapper LOGGER = new LogWrapper(
LoggerFactory.getLogger(PageContainerBinding.class));

/** {@link ResourceConfiguration} instance. */ /** {@link ResourceConfiguration} instance. */
private final PageReadTrx mPageReadTrx; private final PageReadTrx mPageReadTrx;


Expand All @@ -60,24 +68,29 @@ public PageContainerBinding(final PageReadTrx pageReadTrx) {
mPageReadTrx = pageReadTrx; mPageReadTrx = pageReadTrx;
} }



@Override @Override
public RecordPageContainer<T> entryToObject( public RecordPageContainer<T> entryToObject(final @Nullable TupleInput input) {
final @Nullable TupleInput input) {
if (input == null) { if (input == null) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final RecordPageContainer<T> emptyInstance = (RecordPageContainer<T>) RecordPageContainer.EMPTY_INSTANCE; final RecordPageContainer<T> emptyInstance = (RecordPageContainer<T>) RecordPageContainer.EMPTY_INSTANCE;
return emptyInstance; return emptyInstance;
} }
final ByteArrayDataInput source = ByteStreams.newDataInput(input final DataInputStream source = new DataInputStream(
.getBufferBytes()); new ByteArrayInputStream(input.getBufferBytes()));
@SuppressWarnings("unchecked") try {
final T current = (T) PagePersistenter @SuppressWarnings("unchecked")
.deserializePage(source, mPageReadTrx); final T current = (T) PagePersistenter.deserializePage(source,
@SuppressWarnings("unchecked") mPageReadTrx);
final T modified = (T) PagePersistenter @SuppressWarnings("unchecked")
.deserializePage(source, mPageReadTrx); final T modified = (T) PagePersistenter.deserializePage(source,
return new RecordPageContainer<T>(current, modified); mPageReadTrx);
return new RecordPageContainer<T>(current, modified);
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
@SuppressWarnings("unchecked")
final RecordPageContainer<T> emptyInstance = (RecordPageContainer<T>) RecordPageContainer.EMPTY_INSTANCE;
return emptyInstance;
}
} }


@Override @Override
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@


package org.sirix.cache; package org.sirix.cache;


import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.annotation.Nullable; import javax.annotation.Nullable;


import org.sirix.page.PagePersistenter; import org.sirix.page.PagePersistenter;
import org.sirix.page.UnorderedKeyValuePage; import org.sirix.page.UnorderedKeyValuePage;
import org.sirix.page.interfaces.KeyValuePage; import org.sirix.page.interfaces.KeyValuePage;
import org.sirix.utils.LogWrapper;
import org.slf4j.LoggerFactory;


import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.bind.tuple.TupleOutput;


/** /**
Expand All @@ -61,6 +65,9 @@
*/ */
public final class RecordPageContainer<T extends KeyValuePage<?, ?>> { public final class RecordPageContainer<T extends KeyValuePage<?, ?>> {


/** Logger. */
private static final LogWrapper LOGGER = new LogWrapper(LoggerFactory.getLogger(RecordPageContainer.class));

/** /**
* {@link UnorderedKeyValuePage} reference, which references the complete * {@link UnorderedKeyValuePage} reference, which references the complete
* key/value page. * key/value page.
Expand Down Expand Up @@ -149,9 +156,14 @@ public T getModified() {
* for serialization * for serialization
*/ */
public void serialize(final TupleOutput out) { public void serialize(final TupleOutput out) {
final ByteArrayDataOutput sink = ByteStreams.newDataOutput(); final ByteArrayOutputStream sink = new ByteArrayOutputStream();
PagePersistenter.serializePage(sink, mComplete); final DataOutputStream dataOut = new DataOutputStream(sink);
PagePersistenter.serializePage(sink, mModified); try {
PagePersistenter.serializePage(dataOut, mComplete);
PagePersistenter.serializePage(dataOut, mModified);
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e);
}
out.write(sink.toByteArray()); out.write(sink.toByteArray());
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sirix.index.bplustree; package org.sirix.index.bplustree;


import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
Expand Down Expand Up @@ -103,7 +105,8 @@ public BPlusInnerNodePage(final @Nonnegative long recordPageKey,
*/ */
protected BPlusInnerNodePage(final ByteArrayDataInput in, protected BPlusInnerNodePage(final ByteArrayDataInput in,
final PageReadTrx pageReadTrx) { final PageReadTrx pageReadTrx) {
mDelegate = new PageDelegate(Constants.INP_REFERENCE_COUNT, in); mDelegate = null;
// mDelegate = new PageDelegate(Constants.INP_REFERENCE_COUNT, in);
mRecordPageKey = in.readLong(); mRecordPageKey = in.readLong();
final int size = in.readInt(); final int size = in.readInt();
mRecords = new TreeMap<>(); mRecords = new TreeMap<>();
Expand Down Expand Up @@ -132,7 +135,7 @@ public void setRightPage(final Optional<PageReference> rightPage) {
} }


@Override @Override
public void serialize(final ByteArrayDataOutput out) { public void serialize(final DataOutputStream out) throws IOException {
super.serialize(out); super.serialize(out);
out.writeLong(mRecordPageKey); out.writeLong(mRecordPageKey);
out.writeInt(mRecords.size()); out.writeInt(mRecords.size());
Expand All @@ -147,7 +150,7 @@ public void serialize(final ByteArrayDataOutput out) {
} }


private void serializePointer(final Optional<PageReference> page, private void serializePointer(final Optional<PageReference> page,
final ByteArrayDataOutput out) { final DataOutputStream out) throws IOException {
if (page.isPresent()) { if (page.isPresent()) {
out.writeBoolean(page.get().getKey() == org.sirix.settings.Constants.NULL_ID ? false out.writeBoolean(page.get().getKey() == org.sirix.settings.Constants.NULL_ID ? false
: true); : true);
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sirix.index.bplustree; package org.sirix.index.bplustree;


import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
Expand Down Expand Up @@ -131,7 +133,7 @@ public void setRightPage(final Optional<PageReference> rightPage) {
} }


@Override @Override
public void serialize(final ByteArrayDataOutput out) { public void serialize(final DataOutputStream out) throws IOException {
out.writeLong(mRecordPageKey); out.writeLong(mRecordPageKey);
serializePointer(mLeftPage, out); serializePointer(mLeftPage, out);
serializePointer(mRightPage, out); serializePointer(mRightPage, out);
Expand All @@ -144,7 +146,7 @@ public void serialize(final ByteArrayDataOutput out) {
} }


private void serializePointer(final Optional<PageReference> page, private void serializePointer(final Optional<PageReference> page,
final ByteArrayDataOutput out) { final DataOutputStream out) throws IOException {
if (page.isPresent()) { if (page.isPresent()) {
out.writeBoolean(page.get().getKey() == org.sirix.settings.Constants.NULL_ID ? false out.writeBoolean(page.get().getKey() == org.sirix.settings.Constants.NULL_ID ? false
: true); : true);
Expand Down
11 changes: 6 additions & 5 deletions bundles/sirix-core/src/main/java/org/sirix/index/name/Names.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@


import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;


import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;


import org.sirix.settings.Constants; import org.sirix.settings.Constants;


import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;


/** /**
* Names index structure. * Names index structure.
Expand Down Expand Up @@ -40,7 +41,7 @@ private Names() {
* @param in * @param in
* the persistent storage * the persistent storage
*/ */
private Names(final ByteArrayDataInput in) { private Names(final DataInputStream in) throws IOException {
final int mapSize = in.readInt(); final int mapSize = in.readInt();
mNameMap = HashBiMap.create(mapSize); mNameMap = HashBiMap.create(mapSize);
mCountNameMapping = new HashMap<>(mapSize); mCountNameMapping = new HashMap<>(mapSize);
Expand All @@ -62,7 +63,7 @@ private Names(final ByteArrayDataInput in) {
* @param out * @param out
* the persistent storage * the persistent storage
*/ */
public void serialize(final ByteArrayDataOutput out) { public void serialize(final DataOutputStream out) throws IOException {
out.writeInt(mNameMap.size()); out.writeInt(mNameMap.size());
for (final Entry<Integer, byte[]> entry : mNameMap.entrySet()) { for (final Entry<Integer, byte[]> entry : mNameMap.entrySet()) {
out.writeInt(entry.getKey()); out.writeInt(entry.getKey());
Expand Down Expand Up @@ -179,7 +180,7 @@ public static Names getInstance() {
* input source, the persistent storage * input source, the persistent storage
* @return cloned index * @return cloned index
*/ */
public static Names clone(final ByteArrayDataInput in) { public static Names clone(final DataInputStream in) throws IOException {
return new Names(in); return new Names(in);
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@


package org.sirix.io.berkeley.binding; package org.sirix.io.berkeley.binding;


import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.sirix.api.PageReadTrx; import org.sirix.api.PageReadTrx;
import org.sirix.exception.SirixIOException;
import org.sirix.io.bytepipe.ByteHandlePipeline; import org.sirix.io.bytepipe.ByteHandlePipeline;
import org.sirix.page.PagePersistenter; import org.sirix.page.PagePersistenter;
import org.sirix.page.delegates.PageDelegate; import org.sirix.page.delegates.PageDelegate;
import org.sirix.page.interfaces.Page; import org.sirix.page.interfaces.Page;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sleepycat.bind.tuple.TupleBinding; import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput; import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.bind.tuple.TupleOutput;
Expand Down Expand Up @@ -71,7 +72,7 @@ public PageBinding(final PageBinding pageBinding) {
mByteHandler = new ByteHandlePipeline(pageBinding.mByteHandler); mByteHandler = new ByteHandlePipeline(pageBinding.mByteHandler);
mPageReadTrx = pageBinding.mPageReadTrx; mPageReadTrx = pageBinding.mPageReadTrx;
} }

/** /**
* Constructor. * Constructor.
* *
Expand All @@ -89,7 +90,7 @@ public PageBinding(final ByteHandlePipeline byteHandler) {
* @param byteHandler * @param byteHandler
* byte handler pipleine * byte handler pipleine
* @param pageReadTrx * @param pageReadTrx
* page reading transaction * page reading transaction
*/ */
public PageBinding(final ByteHandlePipeline byteHandler, public PageBinding(final ByteHandlePipeline byteHandler,
final PageReadTrx pageReadTrx) { final PageReadTrx pageReadTrx) {
Expand All @@ -100,23 +101,23 @@ public PageBinding(final ByteHandlePipeline byteHandler,


@Override @Override
public Page entryToObject(final TupleInput input) { public Page entryToObject(final TupleInput input) {
byte[] deserialized = new byte[0];
try { try {
deserialized = mByteHandler.deserialize(input.getBufferBytes()); return PagePersistenter.deserializePage(
} catch (final SirixIOException e) { new DataInputStream(mByteHandler.deserialize(input)), mPageReadTrx);
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e); LOGGER.error(e.getMessage(), e);
return null;
} }
return PagePersistenter.deserializePage( }
ByteStreams.newDataInput(deserialized), mPageReadTrx);
}


@Override @Override
public void objectToEntry(final Page page, final TupleOutput output) { public void objectToEntry(final Page page, final TupleOutput output) {
final ByteArrayDataOutput outputData = ByteStreams.newDataOutput();
PagePersistenter.serializePage(outputData, page);
try { try {
output.write(mByteHandler.serialize(outputData.toByteArray())); final DataOutputStream outputData = new DataOutputStream(output);
} catch (final SirixIOException e) { PagePersistenter.serializePage(outputData, page);
mByteHandler.serialize(outputData);
output.close();
} catch (final IOException e) {
LOGGER.error(e.getMessage(), e); LOGGER.error(e.getMessage(), e);
} }
} }
Expand Down
Loading

0 comments on commit 13d20f0

Please sign in to comment.