|
From: <tho...@us...> - 2010-07-20 19:50:29
|
Revision: 3252
http://bigdata.svn.sourceforge.net/bigdata/?rev=3252&view=rev
Author: thompsonbry
Date: 2010-07-20 19:50:22 +0000 (Tue, 20 Jul 2010)
Log Message:
-----------
Added test suite for the non-inline mode.
Made BufferMode#Disk a synonym for DiskWORM.
Deprecated DiskOnlyStrategy. It has been replaced by WORMStrategy.
Removed some dead code in LexiconKeyBuilder.
Modified Paths:
--------------
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestTerm2IdTupleSerializer.java
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestAll.java
Added Paths:
-----------
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java
Removed Paths:
-------------
branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWORM.java
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -421,7 +421,7 @@
*
* @return The extent.
*/
- static long assertNonDiskExtent(long extent) {
+ static long assertNonDiskExtent(final long extent) {
if( extent > Integer.MAX_VALUE ) {
@@ -432,8 +432,9 @@
* disk-based strategy.
*/
- throw new RuntimeException("The extent requires the "
- + BufferMode.Disk + " mode: extent=" + extent);
+ throw new RuntimeException(
+ "The extent requires a disk-backed buffer mode: extent="
+ + extent);
}
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -1027,32 +1027,33 @@
}
- case Disk: {
+// case Disk: {
+//
+// /*
+// * Setup the buffer strategy.
+// */
+//
+// fileMetadata = new FileMetadata(file, BufferMode.Disk,
+// useDirectBuffers, initialExtent, maximumExtent, create,
+// isEmptyFile, deleteOnExit, readOnly, forceWrites,
+// offsetBits, //readCacheCapacity, readCacheMaxRecordSize,
+// //readOnly ? null : writeCache,
+// writeCacheEnabled,
+// validateChecksum,
+// createTime, checker, alternateRootBlock);
+//
+// _bufferStrategy = new DiskOnlyStrategy(
+// 0L/* soft limit for maximumExtent */,
+//// minimumExtension,
+// fileMetadata);
+//
+// this._rootBlock = fileMetadata.rootBlock;
+//
+// break;
+//
+// }
- /*
- * Setup the buffer strategy.
- */
-
- fileMetadata = new FileMetadata(file, BufferMode.Disk,
- useDirectBuffers, initialExtent, maximumExtent, create,
- isEmptyFile, deleteOnExit, readOnly, forceWrites,
- offsetBits, //readCacheCapacity, readCacheMaxRecordSize,
- //readOnly ? null : writeCache,
- writeCacheEnabled,
- validateChecksum,
- createTime, checker, alternateRootBlock);
-
- _bufferStrategy = new DiskOnlyStrategy(
- 0L/* soft limit for maximumExtent */,
-// minimumExtension,
- fileMetadata);
-
- this._rootBlock = fileMetadata.rootBlock;
-
- break;
-
- }
-
+ case Disk:
case DiskWORM: {
/*
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -100,13 +100,10 @@
/**
* <p>
- * The journal is managed on disk. This option may be used with files of
- * more than {@link Integer#MAX_VALUE} bytes in extent. Journal performance
- * for large files should be fair on write, but performance will degrade as
- * the journal is NOT optimized for random reads (poor locality).
+ * This is a synonym for {@link #DiskWORM}.
* </p>
*
- * @see DiskOnlyStrategy
+ * @see WORMStrategy
*/
Disk(true/* stable */, false/* fullyBuffered */),
@@ -119,12 +116,6 @@
* </p>
*
* @see WORMStrategy
- *
- * @deprecated This mode exists to test a new version of the
- * {@link DiskOnlyStrategy} which does not require
- * synchronization for disk read/write operations except when
- * the file size is being changed. Once this is working properly
- * it will replace the {@link DiskOnlyStrategy}.
*/
DiskWORM(true/* stable */, false/* fullyBuffered */),
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -155,6 +155,8 @@
*
* @see BufferMode#Disk
* @see BufferMode#Temporary
+ *
+ * @deprecated This has been replaced by {@link WORMStrategy}.
*/
public class DiskOnlyStrategy extends AbstractBufferStrategy implements
IDiskBasedStrategy {
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -582,8 +582,8 @@
break;
}
case Disk:
- buffer = null;
- break;
+// buffer = null;
+// break;
case DiskWORM:
buffer = null;
break;
@@ -757,8 +757,8 @@
buffer = null;
break;
case Disk:
- buffer = null;
- break;
+// buffer = null;
+// break;
case DiskWORM:
buffer = null;
break;
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -495,7 +495,7 @@
/**
* The default for the {@link #BUFFER_MODE}.
*/
- String DEFAULT_BUFFER_MODE = BufferMode.Disk.toString();
+ String DEFAULT_BUFFER_MODE = BufferMode.DiskWORM.toString();
/**
* The default for {@link #USE_DIRECT_BUFFERS}.
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -123,6 +123,8 @@
* relation.
*
* @return An immutable set of the index names for the relation.
+ *
+ * @todo replace with getKeyOrders()?
*/
Set<String> getIndexNames();
@@ -157,6 +159,8 @@
//
// /**
// * Return the primary index for the relation.
+// *
+// * @todo how about getIndex(IKeyOrder) instead?
// */
// IIndex getPrimaryIndex();
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -171,6 +171,8 @@
/**
* An optional constraint on the visitable elements.
+ *
+ * @todo rename as get(Element)Filter().
*/
public IElementFilter<E> getConstraint();
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -29,6 +29,18 @@
import java.io.Serializable;
+/**
+ * An object which describes which kinds of RDF Values are inlined into the
+ * statement indices and how other RDF Values are coded into the lexicon.
+ *
+ * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
+ * @version $Id$
+ *
+ * FIXME Version information in serialization format.
+ *
+ * @todo large literal size boundary.
+ * @todo other configuration options.
+ */
public class LexiconConfiguration implements Serializable,
ILexiconConfiguration {
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java 2010-07-20 19:42:57 UTC (rev 3251)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java 2010-07-20 19:50:22 UTC (rev 3252)
@@ -1,18 +1,13 @@
package com.bigdata.rdf.lexicon;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openrdf.model.BNode;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
-import org.openrdf.model.vocabulary.RDF;
import org.openrdf.model.vocabulary.XMLSchema;
import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.btree.keys.IKeyBuilderFactory;
-import com.bigdata.btree.keys.KeyBuilder;
import com.bigdata.btree.keys.StrengthEnum;
/**
@@ -78,257 +73,577 @@
public final IKeyBuilder keyBuilder;
- /**
- * Interface for classes encapsulating the logic to encode (and where
- * possible, decode) datatype literals.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static interface IDatatypeKeyCoder {
-
- /**
- * Interpret the text as some specific data type and encode a
- * representation of that data type value suitable for an index whose
- * keys are unsigned byte[]s.
- *
- * @param keyBuilder
- * The object used to build up the key.
- * @param text
- * A lexical representation of the value.
- */
- void encode(IKeyBuilder keyBuilder, String text);
-
- /**
- * Decode a slice of a byte[] containing a key formed by
- * {@link #encode(IKeyBuilder, String)}.
- *
- * @param key
- * The byte[].
- * @param off
- * The first byte in the slice.
- * @param len
- * The length of the slice.
- *
- * @return A lexical representation of the decoded value.
- *
- * @throws UnsupportedOperationException
- * If the keys for the datatype encoded by this interface
- * can not be decoded without loss. For example, this is
- * true of {@link XMLSchema#STRING} when compressed Unicode
- * sort keys are used.
- *
- * @todo the [len] parameter is probably not necessary for most things,
- * but there are some cool key types that are both variable length
- * and totally ordered. E.g., eXist XML node identifiers.
- */
- String decode(byte[] key, int off, int len);
-
- /**
- * Return <code>true</code> if the implementation of this interface
- * encodes keys which can be decoded without loss. "Loss" means that it
- * is not possible to decode a value which correspond to the same point
- * in the value space of the datatype. For example, <code>.5</code> and
- * <code>0.5</code> both represent the same point in the
- * {@link XMLSchema#FLOAT} value space. These values are therefore
- * decodable without loss, even though the decoded value might not have
- * the same lexical representation.
- */
- boolean isDecodable();
-
- /**
- * Return the unique code designated for the primitive data type handled
- * by this coder. Coders which self-report values for this method which
- * are in conflict will be reported by a runtime exception. The
- * appropriate code values are declared by this interface. The primitive
- * datatypes include:
- *
- * <pre>
- * 3.2.1 string
- * 3.2.2 boolean
- * 3.2.3 decimal
- * 3.2.4 float
- * 3.2.5 double
- * 3.2.6 duration
- * 3.2.7 dateTime
- * 3.2.8 time
- * 3.2.9 date
- * 3.2.10 gYearMonth
- * 3.2.11 gYear
- * 3.2.12 gMonthDay
- * 3.2.13 gDay
- * 3.2.14 gMonth
- * 3.2.15 hexBinary
- * 3.2.16 base64Binary
- * 3.2.17 anyURI
- * 3.2.18 QName
- * 3.2.19 NOTATION
- * </pre>
- *
- * @see http://www.w3.org/TR/swbp-xsch-datatypes/
- * @see <a ref="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-primitive-datatypes>primitiv
- * e data types.</a>
- */
- int code();
-
- /**
- * Code used for unrecognized or otherwise unhandled data types.
- */
- int CODE_OTHER = 0;
-
- int CODE_XSD_STRING = 1;
-
- int CODE_XSD_BOOLEAN = 2;
-
- /**
- * Arbitrary magnitude decimal values with arbitrary digits after the
- * decimal.
- */
- int CODE_XSD_DECIMAL = 3;
-
- int CODE_XSD_FLOAT = 4;
-
- int CODE_XSD_DOUBLE = 5;
-
- /** @deprecated until good semantics have been developed. */
- int CODE_XSD_DURATION = 6;
-
- int CODE_XSD_DATETIME = 7;
-
- int CODE_XSD_TIME = 8;
-
- int CODE_XSD_DATE = 9;
-
- int CODE_XSD_GYEARMONTH = 10;
-
- int CODE_XSD_GYEAR = 11;
-
- int CODE_XSD_GMONTHDAY = 12;
-
- int CODE_XSD_HEXBINARY = 13;
-
- int CODE_XSD_BASE64BINARY = 14;
-
- int CODE_XSD_ANYURI = 15;
-
- int CODE_XSD_QNAME = 16;
-
- int CODE_XSD_NOTATION = 17;
-
- /*
- * Arbitrary magnitude integers.
- */
- int CODE_XSD_INTEGER = 18;
-
- /*
- * Various signed fixed width integer types.
- */
- int CODE_XSD_LONG = 32;
-
- int CODE_XSD_INT = 33;
-
- int CODE_XSD_SHORT = 34;
-
- int CODE_XSD_BYTE = 35;
-
- /*
- * Various unsigned fixed with integer types.
- */
- int CODE_XSD_ULONG = 36;
-
- int CODE_XSD_UINT = 37;
-
- int CODE_XSD_USHORT = 38;
-
- int CODE_XSD_UBYTE = 39;
-
- /**
- * An {@link RDF#XMLLITERAL}.
- */
- int CODE_XML_LITERAL = 40;
-
- }
-
- /**
- * Handles anything derived from the primitive data type
- * {@link XMLSchema#BOOLEAN}. All such values are coded in a single byte.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDBooleanCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDBooleanCoder();
-
- public int code() {
-
- return CODE_XSD_BOOLEAN;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return KeyBuilder.decodeByte(buf[off]) == 1 ? "true" : "false";
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- text = text.trim();
-
- final boolean t;
-
- if ("true".equalsIgnoreCase(text) || "1".equals(text)) {
-
- t = true;
-
- } else if ("false".equalsIgnoreCase(text) || "0".equals(text)) {
-
- t = false;
-
- } else {
-
- throw new RuntimeException("Does not match xsd:boolean : "
- + text);
-
- }
-
- keyBuilder.append((byte) (t ? 1 : 0));
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
// /**
+// * Interface for classes encapsulating the logic to encode (and where
+// * possible, decode) datatype literals.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static interface IDatatypeKeyCoder {
+//
+// /**
+// * Interpret the text as some specific data type and encode a
+// * representation of that data type value suitable for an index whose
+// * keys are unsigned byte[]s.
+// *
+// * @param keyBuilder
+// * The object used to build up the key.
+// * @param text
+// * A lexical representation of the value.
+// */
+// void encode(IKeyBuilder keyBuilder, String text);
+//
+// /**
+// * Decode a slice of a byte[] containing a key formed by
+// * {@link #encode(IKeyBuilder, String)}.
+// *
+// * @param key
+// * The byte[].
+// * @param off
+// * The first byte in the slice.
+// * @param len
+// * The length of the slice.
+// *
+// * @return A lexical representation of the decoded value.
+// *
+// * @throws UnsupportedOperationException
+// * If the keys for the datatype encoded by this interface
+// * can not be decoded without loss. For example, this is
+// * true of {@link XMLSchema#STRING} when compressed Unicode
+// * sort keys are used.
+// *
+// * @todo the [len] parameter is probably not necessary for most things,
+// * but there are some cool key types that are both variable length
+// * and totally ordered. E.g., eXist XML node identifiers.
+// */
+// String decode(byte[] key, int off, int len);
+//
+// /**
+// * Return <code>true</code> if the implementation of this interface
+// * encodes keys which can be decoded without loss. "Loss" means that it
+// * is not possible to decode a value which correspond to the same point
+// * in the value space of the datatype. For example, <code>.5</code> and
+// * <code>0.5</code> both represent the same point in the
+// * {@link XMLSchema#FLOAT} value space. These values are therefore
+// * decodable without loss, even though the decoded value might not have
+// * the same lexical representation.
+// */
+// boolean isDecodable();
+//
+// /**
+// * Return the unique code designated for the primitive data type handled
+// * by this coder. Coders which self-report values for this method which
+// * are in conflict will be reported by a runtime exception. The
+// * appropriate code values are declared by this interface. The primitive
+// * datatypes include:
+// *
+// * <pre>
+// * 3.2.1 string
+// * 3.2.2 boolean
+// * 3.2.3 decimal
+// * 3.2.4 float
+// * 3.2.5 double
+// * 3.2.6 duration
+// * 3.2.7 dateTime
+// * 3.2.8 time
+// * 3.2.9 date
+// * 3.2.10 gYearMonth
+// * 3.2.11 gYear
+// * 3.2.12 gMonthDay
+// * 3.2.13 gDay
+// * 3.2.14 gMonth
+// * 3.2.15 hexBinary
+// * 3.2.16 base64Binary
+// * 3.2.17 anyURI
+// * 3.2.18 QName
+// * 3.2.19 NOTATION
+// * </pre>
+// *
+// * @see http://www.w3.org/TR/swbp-xsch-datatypes/
+// * @see <a ref="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-primitive-datatypes>primitiv
+// * e data types.</a>
+// */
+// int code();
+//
+// /**
+// * Code used for unrecognized or otherwise unhandled data types.
+// */
+// int CODE_OTHER = 0;
+//
+// int CODE_XSD_STRING = 1;
+//
+// int CODE_XSD_BOOLEAN = 2;
+//
+// /**
+// * Arbitrary magnitude decimal values with arbitrary digits after the
+// * decimal.
+// */
+// int CODE_XSD_DECIMAL = 3;
+//
+// int CODE_XSD_FLOAT = 4;
+//
+// int CODE_XSD_DOUBLE = 5;
+//
+// /** @deprecated until good semantics have been developed. */
+// int CODE_XSD_DURATION = 6;
+//
+// int CODE_XSD_DATETIME = 7;
+//
+// int CODE_XSD_TIME = 8;
+//
+// int CODE_XSD_DATE = 9;
+//
+// int CODE_XSD_GYEARMONTH = 10;
+//
+// int CODE_XSD_GYEAR = 11;
+//
+// int CODE_XSD_GMONTHDAY = 12;
+//
+// int CODE_XSD_HEXBINARY = 13;
+//
+// int CODE_XSD_BASE64BINARY = 14;
+//
+// int CODE_XSD_ANYURI = 15;
+//
+// int CODE_XSD_QNAME = 16;
+//
+// int CODE_XSD_NOTATION = 17;
+//
+// /*
+// * Arbitrary magnitude integers.
+// */
+// int CODE_XSD_INTEGER = 18;
+//
+// /*
+// * Various signed fixed width integer types.
+// */
+// int CODE_XSD_LONG = 32;
+//
+// int CODE_XSD_INT = 33;
+//
+// int CODE_XSD_SHORT = 34;
+//
+// int CODE_XSD_BYTE = 35;
+//
+// /*
+// * Various unsigned fixed with integer types.
+// */
+// int CODE_XSD_ULONG = 36;
+//
+// int CODE_XSD_UINT = 37;
+//
+// int CODE_XSD_USHORT = 38;
+//
+// int CODE_XSD_UBYTE = 39;
+//
+// /**
+// * An {@link RDF#XMLLITERAL}.
+// */
+// int CODE_XML_LITERAL = 40;
+//
+// }
+//
+// /**
// * Handles anything derived from the primitive data type
-// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and ARE
-// * NOT decodable.
+// * {@link XMLSchema#BOOLEAN}. All such values are coded in a single byte.
// *
// * @author <a href="mailto:tho...@us...">Bryan
// * Thompson</a>
// * @version $Id$
// */
-// public static class XSDStringCoder implements IDatatypeKeyCoder {
+// public static class XSDBooleanCoder implements IDatatypeKeyCoder {
//
-// public static transient final IDatatypeKeyCoder INSTANCE = new XSDStringCoder();
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDBooleanCoder();
//
// public int code() {
//
-// return CODE_XSD_STRING;
+// return CODE_XSD_BOOLEAN;
//
// }
//
// public String decode(byte[] buf, int off, int len) {
//
+// return KeyBuilder.decodeByte(buf[off]) == 1 ? "true" : "false";
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// text = text.trim();
+//
+// final boolean t;
+//
+// if ("true".equalsIgnoreCase(text) || "1".equals(text)) {
+//
+// t = true;
+//
+// } else if ("false".equalsIgnoreCase(text) || "0".equals(text)) {
+//
+// t = false;
+//
+// } else {
+//
+// throw new RuntimeException("Does not match xsd:boolean : "
+// + text);
+//
+// }
+//
+// keyBuilder.append((byte) (t ? 1 : 0));
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+//// /**
+//// * Handles anything derived from the primitive data type
+//// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and ARE
+//// * NOT decodable.
+//// *
+//// * @author <a href="mailto:tho...@us...">Bryan
+//// * Thompson</a>
+//// * @version $Id$
+//// */
+//// public static class XSDStringCoder implements IDatatypeKeyCoder {
+////
+//// public static transient final IDatatypeKeyCoder INSTANCE = new XSDStringCoder();
+////
+//// public int code() {
+////
+//// return CODE_XSD_STRING;
+////
+//// }
+////
+//// public String decode(byte[] buf, int off, int len) {
+////
+//// throw new UnsupportedOperationException();
+////
+//// }
+////
+//// public void encode(IKeyBuilder keyBuilder, String text) {
+////
+//// keyBuilder.append(text);
+////
+//// }
+////
+//// /** No - this class uses Unicode sort keys, which are not decodable. */
+//// public boolean isDecodable() {
+////
+//// return false;
+////
+//// }
+////
+//// }
+//
+// /**
+// * Handles {@link XMLSchema#LONG}. All such values are coded as 64-bit
+// * integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDLongCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDLongCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_LONG;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Long.toString(KeyBuilder.decodeLong(buf, off));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Long.valueOf(text).longValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+// /**
+// * Handles {@link XMLSchema#INT}. All such values are coded as 32-bit
+// * integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDIntCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDIntCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_INT;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Integer.toString(KeyBuilder.decodeInt(buf, off));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Integer.valueOf(text).intValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+// /**
+// * Handles {@link XMLSchema#SHORT}. All such values are coded as 16-bit
+// * integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDShortCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDShortCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_SHORT;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Short.toString(KeyBuilder.decodeShort(buf, off));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Short.valueOf(text).shortValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+// /**
+// * Handles {@link XMLSchema#BYTE}. All such values are coded as 8-bit
+// * integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDByteCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDByteCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_BYTE;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Byte.toString(KeyBuilder.decodeByte(buf[off]));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Byte.valueOf(text).byteValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+// /**
+// * Handles anything derived from the primitive data type
+// * {@link XMLSchema#FLOAT}. All such values are coded as 32-bit integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDFloatCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDFloatCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_FLOAT;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Float.toString(KeyBuilder.decodeFloat(buf, off));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Float.valueOf(text).floatValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+// /**
+// * Handles anything derived from the primitive data type
+// * {@link XMLSchema#DOUBLE}. All such values are coded as 64-bit integers.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDDoubleCoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDoubleCoder();
+//
+// public int code() {
+//
+// return CODE_XSD_DOUBLE;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
+// return Double.toString(KeyBuilder.decodeDouble(buf, off));
+//
+// }
+//
+// public void encode(IKeyBuilder keyBuilder, String text) {
+//
+// keyBuilder.append(Double.valueOf(text).doubleValue());
+//
+// }
+//
+// /** Yes. */
+// public boolean isDecodable() {
+//
+// return true;
+//
+// }
+//
+// }
+//
+//// /**
+//// * Handles anything derived from the primitive data type
+//// * {@link XMLSchema#DATETIME}.
+//// *
+//// * @author <a href="mailto:tho...@us...">Bryan
+//// * Thompson</a>
+//// * @version $Id$
+//// */
+//// public static class XSDDateTimeCoder implements IDatatypeKeyCoder {
+////
+//// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDateTimeCoder();
+////
+//// public int code() {
+////
+//// return CODE_XSD_DATETIME;
+////
+//// }
+////
+//// public String decode(byte[] buf, int off, int len) {
+////
+//// throw new UnsupportedOperationException();
+////// return Double.toString(KeyBuilder.decodeDouble(buf, off));
+////
+//// }
+////
+//// public void encode(IKeyBuilder keyBuilder, String text) {
+////
+//// final XMLGregorianCalendar cal = XMLDatatypeUtil.parseCalendar(text);
+////
+//// // FIXME normalize to UTC and encode as int64 seconds since epoch or what?
+////
+////// keyBuilder.append(.doubleValue());
+////
+//// throw new UnsupportedOperationException();
+////
+//// }
+////
+//// /** No. */
+//// public boolean isDecodable() {
+////
+//// return false;
+////
+//// }
+////
+//// }
+//
+// /**
+// * Handles anything derived from the primitive data type
+// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and
+// * ARE NOT decodable.
+// *
+// * @author <a href="mailto:tho...@us...">Bryan
+// * Thompson</a>
+// * @version $Id$
+// */
+// public static class XSDAnyURICoder implements IDatatypeKeyCoder {
+//
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDAnyURICoder();
+//
+// public int code() {
+//
+// return CODE_XSD_ANYURI;
+//
+// }
+//
+// public String decode(byte[] buf, int off, int len) {
+//
// throw new UnsupportedOperationException();
//
// }
@@ -347,529 +662,209 @@
// }
//
// }
-
- /**
- * Handles {@link XMLSchema#LONG}. All such values are coded as 64-bit
- * integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDLongCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDLongCoder();
-
- public int code() {
-
- return CODE_XSD_LONG;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Long.toString(KeyBuilder.decodeLong(buf, off));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Long.valueOf(text).longValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
- /**
- * Handles {@link XMLSchema#INT}. All such values are coded as 32-bit
- * integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDIntCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDIntCoder();
-
- public int code() {
-
- return CODE_XSD_INT;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Integer.toString(KeyBuilder.decodeInt(buf, off));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Integer.valueOf(text).intValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
- /**
- * Handles {@link XMLSchema#SHORT}. All such values are coded as 16-bit
- * integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDShortCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDShortCoder();
-
- public int code() {
-
- return CODE_XSD_SHORT;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Short.toString(KeyBuilder.decodeShort(buf, off));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Short.valueOf(text).shortValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
- /**
- * Handles {@link XMLSchema#BYTE}. All such values are coded as 8-bit
- * integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDByteCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDByteCoder();
-
- public int code() {
-
- return CODE_XSD_BYTE;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Byte.toString(KeyBuilder.decodeByte(buf[off]));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Byte.valueOf(text).byteValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
- /**
- * Handles anything derived from the primitive data type
- * {@link XMLSchema#FLOAT}. All such values are coded as 32-bit integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDFloatCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDFloatCoder();
-
- public int code() {
-
- return CODE_XSD_FLOAT;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Float.toString(KeyBuilder.decodeFloat(buf, off));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Float.valueOf(text).floatValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
- /**
- * Handles anything derived from the primitive data type
- * {@link XMLSchema#DOUBLE}. All such values are coded as 64-bit integers.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDDoubleCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDDoubleCoder();
-
- public int code() {
-
- return CODE_XSD_DOUBLE;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- return Double.toString(KeyBuilder.decodeDouble(buf, off));
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(Double.valueOf(text).doubleValue());
-
- }
-
- /** Yes. */
- public boolean isDecodable() {
-
- return true;
-
- }
-
- }
-
+//
// /**
// * Handles anything derived from the primitive data type
-// * {@link XMLSchema#DATETIME}.
+// * {@link RDF#XMLLITERAL}. Values are coded as Unicode sort keys and ARE NOT
+// * decodable.
// *
// * @author <a href="mailto:tho...@us...">Bryan
// * Thompson</a>
// * @version $Id$
// */
-// public static class XSDDateTimeCoder implements IDatatypeKeyCoder {
+// public static class XSDXmlLiteralCoder implements IDatatypeKeyCoder {
//
-// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDateTimeCoder();
+// public static transient final IDatatypeKeyCoder INSTANCE = new XSDXmlLiteralCoder();
//
// public int code() {
//
-// return CODE_XSD_DATETIME;
+// return CODE_XML_LITERAL;
//
// }
//
// public String decode(byte[] buf, int off, int len) {
//
// throw new UnsupportedOperationException();
-//// return Double.toString(KeyBuilder.decodeDouble(buf, off));
//
// }
//
// public void encode(IKeyBuilder keyBuilder, String text) {
//
-// final XMLGregorianCalendar cal = XMLDatatypeUtil.parseCalendar(text);
+// keyBuilder.append(text);
//
-// // FIXME normalize to UTC and encode as int64 seconds since epoch or what?
-//
-//// keyBuilder.append(.doubleValue());
+// }
//
+// /** No - this class uses Unicode sort keys, which are not decodable. */
+// public boolean isDecodable() {
+//
+// return false;
+//
+// }
+//
+// }
+//
+// /**
+// * Map from the specific datatype URI to the coder instance for that
+// * datatype.
+// */
+// private static final Map<URI/* datatype */, IDatatypeKeyCoder> coders;
+//
+// private static final Map<Integer, IDatatypeKeyCoder> codes;
+//
+// synchronized static private void registerCoder(final URI datatype,
+// IDatatypeKeyCoder newCoder) {
+//
+// if (coders == null)
// throw new UnsupportedOperationException();
+//
+// if (newCoder == null)
+// throw new IllegalArgumentException();
//
+// final int code = newCoder.code();
+//
+// if (codes.containsKey(code)) {
+//
+// throw new IllegalStateException(
+// "Coder already registered for code: code=" + code
+// + ", val=" + codes.get(code) + ", new=" + newCoder);
+//
// }
//
-// /** No. */
-// public boolean isDecodable() {
+// if (coders.containsKey(code)) {
//
-// return false;
+// throw new IllegalStateException(
+// "Coder already registered for datatype: datatype="
+// + datatype + ", val=" + codes.get(code) + ", new="
+// + newCoder);
//
// }
//
+// coders.put(datatype, newCoder);
+//
+// codes.put(code, newCoder);
+//
// }
+//
+// static {
+//
+// if(true) {
+//
+// /*
+// * Disable coders.
+// *
+// * FIXME configuration option for coders? Per triple store instance?
+// * Or are the coders just not compatible with the SPARQL
+// * specification?
+// */
+//
+// coders = null;
+//
+// codes = null;
+//
+// } else {
+//
+// // datatype URI to coder map.
+// coders = new HashMap<URI, IDatatypeKeyCoder>();
+//
+// // code to coder map.
+// codes = new HashMap<Integer, IDatatypeKeyCoder>();
+//
+// // 3.2.1 string and derived types.
+// // Note: string is mapped onto plainLiteral by RDF Semantics.
+//// registerCoder(XMLSchema.STRING, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.NORMALIZEDSTRING, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.TOKEN, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.LANGUAGE, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.NAME, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.NCNAME, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.ID, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.IDREF, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.IDREFS, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.ENTITY, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.ENTITIES, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.NMTOKEN, XSDStringCoder.INSTANCE);
+//// registerCoder(XMLSchema.NMTOKENS, XSDStringCoder.INSTANCE);
+//
+// // 3.2.2 boolean
+// registerCoder(XMLSchema.BOOLEAN, XSDBooleanCoder.INSTANCE);
+//
+// // 3.2.3 decimal and derived types.
+//
+// /*
+// * @todo decimal really needs to be a BigDecimal representation if such
+// * a thing can be mapped onto a totally ordered unsigned byte[] key.
+// * Failing that, it needs to be projected to a maximum magnitude fixed
+// * byte length representation. Failing that, all comparison of order
+// * must be done by the SPARQL engine.
+// */
+//// registerCoder(XMLSchema.DECIMAL, XSDDecimalCoder.INSTANCE);
+//
+// /*
+// * @todo integer really needs to be a BigInteger representation if such
+// * a thing can be mapped onto a totally ordered unsigned byte[] key
+// * (negative integers always appear to be larger than positive integers
+// * with naive encoding). Failing that, it needs to be projected to a
+// * maximum magnitude fixed byte length representation. Failing that, all
+// * comparison of order must be done by the SPARQL engine.
+// */
+//// registerCoder(XMLSchema.INTEGER, XSDDecimalCoder.INSTANCE);
+//// registerCoder(XMLSchema.POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE);
+//// registerCoder(XMLSchema.NON_POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE);
+//// registerCoder(XMLSchema.NON_NEGATIVE_INTEGER, XSDDecimalCoder.INSTANCE);
+//
+// /*
+// * These are all fixed width signed datatypes. Each has its own code and
+// * its own disjoint value space.
+// */
+// registerCoder(XMLSchema.LONG, XSDLongCoder.INSTANCE); // 64-bits
+// registerCoder(XMLSchema.INT, XSDIntCoder.INSTANCE); // 32-bits
+// registerCoder(XMLSchema.SHORT, XSDShortCoder.INSTANCE); // 16-bits
+// registerCoder(XMLSchema.BYTE, XSDByteCoder.INSTANCE); // 8 bits.
+// /*
+// * These are all fixed width unsigned datatypes. Each has its own code
+// * and its own disjoint value space.
+// *
+// * @todo unsigned long
+// * @todo unsigned int
+// * @todo unsigned short
+// * @todo unsigned byte
+// */
+//// registerCoder(XMLSchema.UNSIGNED_LONG, XSDULongCoder.INSTANCE); // 64-bits
+//// registerCoder(XMLSchema.UNSIGNED_INT, XSDUIntCoder.INSTANCE);// 32-bits
+//// registerCoder(XMLSchema.UNSIGNED_SHORT, XSDUShortecimalCoder.INSTANCE); // 16-bits
+//// registerCoder(XMLSchema.UNSIGNED_BYTE, XSDUByteCoder.INSTANCE); // 8-bits
+//
+// // 3.2.4 float
+// registerCoder(XMLSchema.FLOAT, XSDFloatCoder.INSTANCE);
+//
+// // 3.2.5 double
+// registerCoder(XMLSchema.DOUBLE, XSDDoubleCoder.INSTANCE);
+//
+// // 3.2.6 duration Note: not implemented yet per W3C Note.
+//
+// // @todo 3.2.7 dateTime
+//// registerCoder(XMLSchema.DATETIME, XSDDateTimeCoder.INSTANCE);
+// // @todo 3.2.8 time
+// // @todo 3.2.9 date
+// // @todo 3.2.10 gYearMonth
+// // @todo 3.2.11 gYear
+// // @todo 3.2.12 gMonthDay
+// // @todo 3.2.13 gDay
+// // @todo 3.2.14 gMonth
+// // @todo 3.2.15 hexBinary
+// // @todo 3.2.16 base64Binary
+// // 3.2.17 anyURI
+// registerCoder(XMLSchema.ANYURI, XSDAnyURICoder.INSTANCE);
+// // @todo 3.2.18 QName
+// // @todo 3.2.19 NOTATION
+//
+// registerCoder(RDF.XMLLITERAL, XSDXmlLiteralCoder.INSTANCE);
+//
+// }
+//
+// }
/**
- * Handles anything derived from the primitive data type
- * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and
- * ARE NOT decodable.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDAnyURICoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDAnyURICoder();
-
- public int code() {
-
- return CODE_XSD_ANYURI;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- throw new UnsupportedOperationException();
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(text);
-
- }
-
- /** No - this class uses Unicode sort keys, which are not decodable. */
- public boolean isDecodable() {
-
- return false;
-
- }
-
- }
-
- /**
- * Handles anything derived from the primitive data type
- * {@link RDF#XMLLITERAL}. Values are coded as Unicode sort keys and ARE NOT
- * decodable.
- *
- * @author <a href="mailto:tho...@us...">Bryan
- * Thompson</a>
- * @version $Id$
- */
- public static class XSDXmlLiteralCoder implements IDatatypeKeyCoder {
-
- public static transient final IDatatypeKeyCoder INSTANCE = new XSDXmlLiteralCoder();
-
- public int code() {
-
- return CODE_XML_LITERAL;
-
- }
-
- public String decode(byte[] buf, int off, int len) {
-
- throw new UnsupportedOperationException();
-
- }
-
- public void encode(IKeyBuilder keyBuilder, String text) {
-
- keyBuilder.append(text);
-
- }
-
- /** No - this class uses Unicode sort keys, which are not decodable. */
- public boolean isDecodable() {
-
- return false;
-
- }
-
- }
-
- /**
- * Map from the specific datatype URI to the coder instance for that
- * datatype.
- */
- private static final Map<URI/* datatype */, IDatatypeKeyCoder> coders;
-
- private static final Map<Integer, IDatatypeKeyCoder> codes;
-
- synchronized static private void registerCoder(final URI datatype,
- IDatatypeKeyCoder newCoder) {
-
- if (coders == null)
- throw new UnsupportedOperationException();
-
- if (newCoder == null)
- throw new IllegalArgumentException();
-
- final int code = newCoder.code();
-
- if (codes.containsKey(code)) {
-
- throw new IllegalStateException(
- "Coder already registered for code: code=" + code
- + ", val=" + codes.get(code) + ", new=" + newCoder);
-
- }
-
- if (coders.containsKey(code)) {
-
- throw new IllegalStateException(
- "Coder already registered for datatype: datatype="
- + datatype + ", val=" + codes.get(code) + ", new="
- + newCoder);
-
- }
-
- coders.put(datatype, newCoder);
-
- codes.put(code, newCoder);
-
- }
-
- static {
-
- if(true) {
-
- /*
- * Disable coders.
- *
- * FIXME configuration option for coders? Per triple store instance?
- * Or are the coders just not compatible with the SPARQL
- * specification?
- */
-
- coders = null;
-
- codes = null;
-
- } else {
-
- // datatype URI to coder map.
- coders = new HashMap<URI, IDatatypeKeyCoder>();
-
- // code to coder map.
- codes = new HashMap<Integer, IDatatypeKeyCoder>();
-
- // 3.2.1 string and derived types.
- // Note: string is mapped onto plainLiteral by RDF Semantics.
-// registerCoder(XMLSchema.STRING, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.NORMALIZEDSTRING, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.TOKEN, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.LANGUAGE, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.NAME, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.NCNAME, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.ID, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.IDREF, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.IDREFS, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.ENTITY, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.ENTITIES, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.NMTOKEN, XSDStringCoder.INSTANCE);
-// registerCoder(XMLSchema.NMTOKENS, XSDStringCoder.INSTANCE);
-
- // 3.2.2 boolean
- registerCoder(XMLSchema.BOOLEAN, XSDBooleanCoder.INSTANCE);
-
- // 3.2.3 decimal and derived types.
-
- /*
- * @todo decimal really needs to be a BigDecimal representation if such
- * a thing can be mapped onto a totally ordered unsigned byte[] key.
- * Failing that, it needs to be projected to a maximum magnitude fixed
- * byte length representation. Failing that, all comparison of order
- * must be done by the SPARQL engine.
- */
-// registerCoder(XMLSchema.DECIMAL, XSDDecimalCoder.INSTANCE);
-
- /*
- * @todo integer really needs to be a BigInteger representation if such
- * a thing can be mapped onto a totally ordered unsigned byte[] key
- * (negative integers always appear to be larger than positive integers
- * with naive encoding). Failing that, it needs to be projected to a
- * maximum magnitude fixed byte length representation. Failing that, all
- * comparison of order must be done by the SPARQL engine.
- */
-// registerCoder(XMLSchema.INTEGER, XSDDecimalCoder.INSTANCE);
-// registerCoder(XMLSchema.POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE);
-// registerCoder(XMLSchema.NON_POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE);
-// registerCoder(XMLSchema.NON_NEGATIVE_INTEGER, XSDDecimalCoder.INSTANCE);
-
- /*
- * These are all fixed width signed datatypes. Each has its own code and
- * its own disjoint value space.
- */
- registerCoder(XMLSchema.LONG, XSDLongCoder.INSTANCE); // 64-bits
- registerCoder(XMLSchema.INT, XSDIntCoder.INSTANCE); // 32-bits
- registerCoder(XMLSchema.SHORT, XSDShortCoder.INSTANCE); // 16-bits
- registerCoder(XMLSchema.BYTE, XSDByteCoder.INSTANCE); // 8 bits.
- /*
- * These are all fixed width unsigned datatypes. Each has its own code
- * and its own disjoint value space.
- *
- * @todo unsigned long
- * @todo unsigned int
- * @todo unsigned short
- * @todo unsigned byte
- */
-// registerCoder(XMLSchema.UNSIGNED_LONG, XSDULongCoder.INSTANCE); // 64-bits
-// registerCoder(XMLSchema.UNSIGNED_INT, XSDUIntCoder.INSTANCE);// 32-bits
-// registerCoder(XMLSchema.UNSIGNED_SHORT, XSDUShortecimalCoder.INSTANCE); // 16-bits
-// registerCoder(XMLSchema.UNSIGNED_BYTE, XSDUByteCoder.INSTANCE); // 8-bits
-
- // 3.2.4 float
- registerCoder(XMLSchema.FLOAT, XSDFloatCoder.INSTANCE);
-
- // 3.2.5 double
- registerCoder(XMLSchema.DOUBLE, XSDDoubleCoder.INSTANCE);
-
- // 3.2.6 duration Note: not implemented yet per W3C Note.
-
- // @todo 3.2.7 dateTime
-// registerCoder(XMLSchema.DATETIME, XSDDateTimeCoder.INSTANCE);
- // @todo 3.2.8 time
- // @todo 3.2.9 date
- // @todo 3.2.10 gYearMonth
- // @todo 3.2.11 gYear
- // @todo 3.2.12 gMonthDay
- // @todo 3.2.13 gDay
- // @todo 3.2.14 gMonth
- // @todo 3.2.15 hexBinary
- // @todo 3.2.16 base64Binary
- // 3.2.17 anyURI
- registerCoder(XMLSchema.ANYURI, XSDAnyURICoder.INSTANCE);
- // @todo 3.2.18 QName
- // @todo 3.2.19 NOTATION
-
- registerCoder(RDF.XMLLITERAL, XSDXmlLiteralCoder.INSTANCE);
-
- }
-
- }
-
- /**
* Normally invoked by {@link Term2IdTupleSerializer#getLexiconKeyBuilder()}
*
* @param keyBuilder
@@ -972,7 +967,7 @@
}
- if (coders == null) {
+// if (coders == null) {
/*
* Note: This is the original DTL code space. The full lexical form
@@ -995,52 +990,52 @@
return keyBuilder.getKey();
- } else {
+// } else {
+//
+// // clear out any existing key and add prefix for the DTL space.
+// keyBuilder.reset().append(TERM_CODE_DTL2);
+//
+// final IDatatypeKeyCoder coder = coders.get(datatype);
+//
+// if (coder == null) {
+//
+// /*
+// * Unknown datatypes are placed into a disjoint space first, for
+// * all unknown data types, and second, for the specific data
+// * type using its URI encoded as a sort key. Finally, the
+// * unknown data type value is encoded on the key.
+// */
+//
+// // disjoint value space for all unknown data type URIs.
+// keyBuilder.append(IDatatypeKeyCoder.CODE_OTHER);
+//
+// // encode the datatype URI as Unicode sort key to make all
+// ...
[truncated message content] |