|
From: <tho...@us...> - 2010-07-26 19:32:06
|
Revision: 3299
http://bigdata.svn.sourceforge.net/bigdata/?rev=3299&view=rev
Author: thompsonbry
Date: 2010-07-26 19:31:59 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
Added explicit version control to a number of Externalizable implementations.
Modified Paths:
--------------
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/proc/AbstractKeyArrayIndexProcedure.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/mdi/IndexPartitionCause.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/SameVariableConstraint.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/DefaultRuleTaskFactory.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteAsynchronousIteratorImpl.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteChunk.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/sparse/AbstractAtomicRowReadOrWrite.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/axioms/BaseAxioms.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/vocab/BaseVocabulary.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOValueCoders.java
Removed Paths:
-------------
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/FastRDFValueCoder.java
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/proc/AbstractKeyArrayIndexProcedure.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/proc/AbstractKeyArrayIndexProcedure.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/proc/AbstractKeyArrayIndexProcedure.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -677,6 +677,16 @@
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
final InputBitStream ibs = new InputBitStream((InputStream) in,
0/* unbuffered */, false/* reflectionTest */);
@@ -699,6 +709,8 @@
public void writeExternal(final ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
+
final OutputBitStream obs = new OutputBitStream((OutputStream) out,
0/* unbuffered! */, false/*reflectionTest*/);
@@ -716,6 +728,16 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
}
/**
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/mdi/IndexPartitionCause.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/mdi/IndexPartitionCause.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/mdi/IndexPartitionCause.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -189,9 +189,24 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+ final byte version = in.readByte();
+
+ if (version != VERSION0)
+ throw new UnsupportedOperationException("version=" + version);
+
cause = CauseEnum.valueOf(in.readByte());
synchronousOverflowCounter = in.readLong();
@@ -202,6 +217,7 @@
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
out.writeByte(cause.code);
out.writeLong(synchronousOverflowCounter);
out.writeLong(lastCommitTime);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/SameVariableConstraint.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/SameVariableConstraint.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/SameVariableConstraint.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -183,10 +183,30 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+ final short version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
p = (IPredicate<E>) in.readObject();
final int len = (int) LongPacker.unpackLong(in);
@@ -203,6 +223,8 @@
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
+
out.writeObject(p);
LongPacker.packLong(out, indices.length);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/DefaultRuleTaskFactory.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/DefaultRuleTaskFactory.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/DefaultRuleTaskFactory.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -134,15 +134,37 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
subquery = in.readBoolean();
}
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
+
out.writeBoolean(subquery);
}
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteAsynchronousIteratorImpl.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteAsynchronousIteratorImpl.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteAsynchronousIteratorImpl.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -195,8 +195,28 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
ser = (IStreamSerializer<E>) in.readObject();
@@ -206,6 +226,8 @@
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
+
out.writeObject(ser);
ser.serialize(out, e);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteChunk.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteChunk.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/service/proxy/RemoteChunk.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -89,8 +89,28 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
// true iff exhausted.
exhausted = in.readBoolean();
@@ -114,6 +134,8 @@
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeByte(VERSION);
+
out.writeBoolean(exhausted);
// true iff there are any elements in this chunk.
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/sparse/AbstractAtomicRowReadOrWrite.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/sparse/AbstractAtomicRowReadOrWrite.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/sparse/AbstractAtomicRowReadOrWrite.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -426,9 +426,29 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
schema = (Schema) in.readObject();
primaryKey = in.readObject();
@@ -442,7 +462,9 @@
}
public void writeExternal(ObjectOutput out) throws IOException {
-
+
+ out.writeByte(VERSION);
+
out.writeObject(schema);
out.writeObject(primaryKey);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/axioms/BaseAxioms.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/axioms/BaseAxioms.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/axioms/BaseAxioms.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -294,8 +294,29 @@
}
- public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
-
+ /**
+ * The initial version.
+ */
+ private static final transient byte VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient byte VERSION = VERSION0;
+
+ public void readExternal(final ObjectInput in) throws IOException,
+ ClassNotFoundException {
+
+ final byte version = in.readByte();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
final long naxioms = LongPacker.unpackLong(in);
if (naxioms < 0 || naxioms > Integer.MAX_VALUE)
@@ -332,6 +353,8 @@
if (btree == null)
throw new IllegalStateException();
+ out.writeByte(VERSION);
+
final long naxioms = btree.rangeCount();
LongPacker.packLong(out, naxioms);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -70,8 +70,28 @@
}
+ /**
+ * The initial version.
+ */
+ private static final transient short VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient short VERSION = VERSION0;
+
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ final short version = in.readShort();
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
// rdfType = LongPacker.unpackLong(in);
//
// rdfsResource = LongPacker.unpackLong(in);
@@ -84,6 +104,8 @@
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeShort(VERSION);
+
// LongPacker.packLong(out,rdfType);
//
// LongPacker.packLong(out,rdfsResource);
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -48,6 +48,8 @@
package com.bigdata.rdf.lexicon;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Properties;
import org.openrdf.model.Value;
import com.bigdata.btree.DefaultTupleSerializer;
@@ -55,6 +57,8 @@
import com.bigdata.btree.keys.DefaultKeyBuilderFactory;
import com.bigdata.btree.keys.IKeyBuilderFactory;
import com.bigdata.btree.keys.KeyBuilder;
+import com.bigdata.btree.keys.ThreadLocalKeyBuilderFactory;
+import com.bigdata.btree.raba.codec.IRabaCoder;
import com.bigdata.io.DataOutputBuffer;
import com.bigdata.rawstore.Bytes;
import com.bigdata.rdf.internal.IV;
@@ -205,4 +209,33 @@
}
+ /**
+ * The initial version (no additional persistent state).
+ */
+ private final static transient int VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private final static transient int VERSION = VERSION0;
+
+ public void readExternal(final ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ super.readExternal(in);
+ final short version = in.readShort();
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
+ }
+
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ out.writeShort(VERSION);
+ }
+
}
Deleted: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/FastRDFValueCoder.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/FastRDFValueCoder.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/FastRDFValueCoder.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -1,474 +0,0 @@
-package com.bigdata.rdf.spo;
-
-import it.unimi.dsi.io.InputBitStream;
-import it.unimi.dsi.io.OutputBitStream;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.OutputStream;
-
-import org.apache.log4j.Logger;
-
-import com.bigdata.btree.BytesUtil;
-import com.bigdata.btree.raba.IRaba;
-import com.bigdata.btree.raba.codec.AbstractCodedRaba;
-import com.bigdata.btree.raba.codec.IRabaCoder;
-import com.bigdata.btree.raba.codec.ICodedRaba;
-import com.bigdata.io.AbstractFixedByteArrayBuffer;
-import com.bigdata.io.DataOutputBuffer;
-import com.bigdata.rawstore.Bytes;
-import com.bigdata.rdf.model.StatementEnum;
-import com.bigdata.rdf.store.AbstractTripleStore;
-
-/**
- * Coder for statement index with inference enabled but without SIDS. We encode
- * the value in 3 bits per statement. The 1st bit is the override flag. The
- * remaining two bits are the statement type {inferred, explicit, or axiom}. The
- * bit sequence <code>111</code> is used as a place holder for a
- * <code>null</code> value and de-serializes to a [null].
- * <p>
- * Note: the 'override' flag is NOT stored in the statement indices, but it is
- * passed by the procedure that writes on the statement indices so that we can
- * decide whether or not to override the type when the statement is pre-existing
- * in the index.
- * <p>
- * Note: this procedure can not be used if
- * {@link AbstractTripleStore.Options#STATEMENT_IDENTIFIERS} are enabled.
- *
- * @see StatementEnum
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- *
- * @deprecated by {@link FastRDFValueCoder2}
- */
-public class FastRDFValueCoder implements Externalizable, IRabaCoder {
-
- protected static final Logger log = Logger
- .getLogger(FastRDFValueCoder.class);
-
- /**
- *
- */
- private static final long serialVersionUID = 1933430721504168533L;
-
- /**
- * The only version defined so far.
- */
- private static transient final byte VERSION0 = 0x00;
-
- /**
- * The bit offset of the start of the coded values. Each value is 3 bits.
- */
- private static transient final long O_values = (1/* version */+ Bytes.SIZEOF_INT/* size */) << 3;
-
- /**
- * No.
- */
- final public boolean isKeyCoder() {
-
- return false;
-
- }
-
- /**
- * Yes.
- */
- final public boolean isValueCoder() {
-
- return true;
-
- }
-
- /**
- * Sole constructor (handles de-serialization also).
- */
- public FastRDFValueCoder() {
-
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
-
- // NOP
-
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
-
- // NOP
-
- }
-
- public AbstractFixedByteArrayBuffer encode(final IRaba raba,
- final DataOutputBuffer buf) {
-
- /*
- * Note: This code path has nearly zero overhead when compared to
- * encodeLive().
- */
-
- return encodeLive(raba, buf).data();
-
- }
-
- public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) {
-
- if (raba == null)
- throw new UnsupportedOperationException();
-
- if (buf == null)
- throw new UnsupportedOperationException();
-
- final int n = raba.size();
-
- // This is sufficient capacity to code the data.
- final int initialCapacity = 1 + Bytes.SIZEOF_INT
- + BytesUtil.bitFlagByteLength(3 * n);
-
- buf.ensureCapacity(initialCapacity);
-
- // The byte offset of the start of the coded record in the buffer.
- final int O_origin = buf.pos();
-
- final int size = raba.size();
-
- buf.putByte(VERSION0);
-
- buf.putInt(size);
-
- /*
- * @todo use variant OBS(byte[], off, len) constructor and
- * pre-extend the buffer to have sufficient capacity so the OBS can
- * write directly onto the backing byte[], which will be much
- * faster.
- */
- final OutputBitStream obs = buf.getOutputBitStream();
-// final long O_values;
- try {
-
-// obs.writeInt(VERSION0, 8/* nbits */);
-//
-// obs.writeNibble(size);
-//
-// // Note: the bit offset where we start to code the values.
-// O_values = obs.writtenBits();
-
- for (int i = 0; i < size; i++) {
-
- if (raba.isNull(i)) {
-
- // flag a deleted value (de-serialize to a null).
- obs.writeInt(7, 3/* nbits */);
-
- } else {
-
- final byte[] val = raba.get(i);
-
- obs.writeInt((int) val[0], 3/* nbits */);
-
- }
-
- }
-
- // ALWAYS FLUSH.
- obs.flush();
-
- } catch (IOException ex) {
-
- throw new RuntimeException(ex);
-
- }
-
- // slice on just the coded data record.
- final AbstractFixedByteArrayBuffer slice = buf.slice(O_origin, buf.pos()
- - O_origin);
-
-// // adjusted bit offset to the start of the coded values in the slice.
-// final int O_valuesAdjusted = ((int) O_values) - O_origin << 3;
-//
-// return new CodedRabaImpl(slice, size, O_valuesAdjusted);
-
- return new CodedRabaImpl(slice, size);
-
- }
-
- public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) {
-
- return new CodedRabaImpl(data);
-
- }
-
- /**
- * Decoder.
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- */
- private static class CodedRabaImpl extends AbstractCodedRaba {
-
- private final AbstractFixedByteArrayBuffer data;
-
- /**
- * Cached.
- */
- private final int size;
-
-// /**
-// * Bit offset to the first coded value.
-// */
-// private final int O_values;
-
- final public AbstractFixedByteArrayBuffer data() {
-
- return data;
-
- }
-
- /**
- * No.
- */
- final public boolean isKeys() {
-
- return false;
-
- }
-
- final public int size() {
-
- return size;
-
- }
-
- final public int capacity() {
-
- return size;
-
- }
-
- final public boolean isEmpty() {
-
- return size == 0;
-
- }
-
- /**
- * Always <code>true</code>.
- */
- final public boolean isFull() {
-
- return true;
-
- }
-
- /**
- * Constructor used when encoding a data record.
- *
- * @param data
- * The coded data record.
- * @param size
- * The size of the coded {@link IRaba}.
- */
-// * @param O_values
-// * The bit offset of the start of the coded values.
- public CodedRabaImpl(final AbstractFixedByteArrayBuffer data,
- final int size) { //, final int O_values) {
-
- this.data = data;
-
- this.size = size;
-
-// this.O_values = O_values;
-
- }
-
- /**
- * Constructor used when decoding a data record.
- *
- * @param data
- * The coded data record.
- */
- public CodedRabaImpl(final AbstractFixedByteArrayBuffer data) {
-
- if (data == null)
- throw new IllegalArgumentException();
-
- this.data = data;
-
- final byte version = data.getByte(0/*off*/);
-
- if (version != VERSION0) {
-
- throw new RuntimeException("Unknown version=" + version);
-
- }
-
- size = data.getInt(1/*off*/);//ibs.readNibble();
-
-// final InputBitStream ibs = data.getInputBitStream();
-//
-// try {
-//
-// final byte version = (byte) ibs.readInt(8/* nbits */);
-//
-// if (version != VERSION0) {
-//
-// throw new RuntimeException("Unknown version=" + version);
-//
-// }
-//
-// size = ibs.readNibble();
-//
-// O_values = (int) ibs.readBits();
-//
-// } catch (IOException ex) {
-//
-// throw new RuntimeException(ex);
-//
-//// close not required for IBS backed by byte[] and has high overhead.
-//// } finally {
-////
-//// try {
-////
-//// ibs.close();
-////
-//// } catch (IOException ex) {
-////
-//// log.error(ex);
-////
-//// }
-////
-// }
-
- }
-
- /**
- * Thread-safe extract of the bits coded value for the specified index.
- *
- * @param index
- * The specified index.
- *
- * @return The bit coded value.
- *
- * @throws IndexOutOfBoundsException
- * unless the index is in [0:size-1].
- */
- final protected byte getBits(final int index) {
-
- if (index < 0 || index >= size)
- throw new IndexOutOfBoundsException();
-
- final InputBitStream ibs = data.getInputBitStream();
- try {
-
- ibs.position(O_values + (index * 3L));
-
- final int value = ibs.readInt(3/* nbits */);
-
- return (byte) (0xff & value);
-
- } catch(IOException ex) {
-
- throw new RuntimeException(ex);
-
-// close not required for IBS backed by byte[] and has high overhead.
-// } finally {
-// try {
-// ibs.close();
-// } catch(IOException ex) {
-// log.error(ex);
-// }
- }
-
-// int value = 0;
-//
-// for (int i = 0; i < 3; i++, bitIndex++) {
-//
-// final boolean bit = data.getBit(bitIndex);
-//
-// value |= (bit ? 1 : 0) << i;
-//
-// }
-//
-// return (byte) (value & 0xff);
-
- }
-
- final public int copy(final int index, final OutputStream os) {
-
- final byte bits = getBits(index);
-
- if (bits == 7) {
-
- // A null.
- throw new NullPointerException();
-
- } else {
-
- try {
-
- os.write(bits);
-
- } catch (IOException e) {
-
- throw new RuntimeException(e);
-
- }
-
- }
-
- return 1;
-
- }
-
- final public byte[] get(final int index) {
-
- final byte bits = getBits(index);
-
- if (bits == 7) {
-
- // A null.
- return null;
-
- } else {
-
- return new byte[] { bits };
-
- }
-
- }
-
- final public boolean isNull(final int index) {
-
- return getBits(index) == 7;
-
- }
-
- /**
- * Returns ONE (1) unless the value is a <code>null</code>.
- *
- * {@inheritDoc}
- */
- final public int length(final int index) {
-
- if (isNull(index))
- throw new NullPointerException();
-
- return 1;
-
- }
-
- /**
- * Not supported.
- */
- final public int search(final byte[] searchKey) {
-
- throw new UnsupportedOperationException();
-
- }
-
- }
-
-}
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -88,8 +88,28 @@
}
- public void readExternal(ObjectInput in) throws IOException,
+ /**
+ * The initial version.
+ */
+ private static final transient short VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient short VERSION = VERSION0;
+
+ public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
+
+ final short version = in.readShort();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
final int size = in.readInt();
@@ -103,8 +123,10 @@
}
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ out.writeShort(VERSION);
+
out.writeInt(a.length);
for(IV iv : a) {
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/vocab/BaseVocabulary.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/vocab/BaseVocabulary.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/vocab/BaseVocabulary.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -36,16 +36,17 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+
import org.apache.log4j.Logger;
import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.ValueFactoryImpl;
+
import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.btree.keys.KeyBuilder;
import com.bigdata.io.DataOutputBuffer;
import com.bigdata.rdf.internal.IV;
import com.bigdata.rdf.internal.IVUtility;
-import com.bigdata.rdf.internal.TermId;
import com.bigdata.rdf.model.BigdataValue;
import com.bigdata.rdf.model.BigdataValueFactory;
import com.bigdata.rdf.model.BigdataValueSerializer;
@@ -246,6 +247,16 @@
}
/**
+ * The initial version.
+ */
+ private static final transient short VERSION0 = 0;
+
+ /**
+ * The current version.
+ */
+ private static final transient short VERSION = VERSION0;
+
+ /**
* Note: The de-serialized state contains {@link Value}s but not
* {@link BigdataValue}s since the {@link AbstractTripleStore} reference is
* not available and we can not obtain the appropriate
@@ -258,6 +269,16 @@
if (values != null)
throw new IllegalStateException();
+ final short version = in.readShort();
+
+ switch (version) {
+ case VERSION0:
+ break;
+ default:
+ throw new UnsupportedOperationException("Unknown version: "
+ + version);
+ }
+
final ValueFactory valueFactory = new ValueFactoryImpl();
final BigdataValueSerializer<Value> valueSer = new BigdataValueSerializer<Value>(
@@ -305,6 +326,8 @@
if (values == null)
throw new IllegalStateException();
+
+ out.writeShort(VERSION);
final int nvalues = values.size();
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOValueCoders.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOValueCoders.java 2010-07-26 19:14:39 UTC (rev 3298)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOValueCoders.java 2010-07-26 19:31:59 UTC (rev 3299)
@@ -29,7 +29,9 @@
import java.io.IOException;
import java.util.Random;
+
import junit.framework.TestCase2;
+
import com.bigdata.btree.AbstractBTreeTestCase;
import com.bigdata.btree.ICounter;
import com.bigdata.btree.raba.IRaba;
@@ -40,7 +42,6 @@
import com.bigdata.io.AbstractFixedByteArrayBuffer;
import com.bigdata.io.DataOutputBuffer;
import com.bigdata.io.FixedByteArrayBuffer;
-import com.bigdata.rdf.internal.IV;
import com.bigdata.rdf.internal.TermId;
import com.bigdata.rdf.internal.VTE;
import com.bigdata.rdf.lexicon.ITermIdCodes;
@@ -186,12 +187,12 @@
}
- public void test_FastRDFValueCoder() {
+// public void test_FastRDFValueCoder() {
+//
+// doRoundTripTests(new FastRDFValueCoder(), false/* sids */, true/* inference */);
+//
+// }
- doRoundTripTests(new FastRDFValueCoder(), false/* sids */, true/* inference */);
-
- }
-
/**
* Simple tests for {@link FastRDFValueCoder2}.
* <P>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|