|
From: <tho...@us...> - 2014-06-11 13:13:24
|
Revision: 8466
http://sourceforge.net/p/bigdata/code/8466
Author: thompsonbry
Date: 2014-06-11 13:13:13 +0000 (Wed, 11 Jun 2014)
Log Message:
-----------
Fix for Name2Addr prefix scan and improved correctness for LexiconRelation.prefixScan().
Key changes are to:
- IKeyBuilderFactory - defines getPrimaryKeyBuilder()
- LexiconRelation - uses the getPrimaryKeyBuilder() method.
- Name2Addr - uses the getPrimaryKeyBuilder() method.
Javadoc updates to PrefixFilter.
Added @Override and final attributes to several classes that were touched by this fix.
I have run through the TestLocalTripleStore and TestRWJournal test suites and everything is good. I am currently running TestBigdataSailWithQuads but do not anticipate any issues.
I have verified that the existing tests for Name2Addr and the LexiconRelation prefix scans fail if the code uses the default collation strength rather than PRIMARY so we know that we have regression tests in place for those behaviors.
See #974 (Name2Addr.indexNameScan(prefix) uses scan + filter)
Modified Paths:
--------------
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/DefaultTupleSerializer.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/filter/PrefixFilter.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ASCIIKeyBuilderFactory.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/DefaultKeyBuilderFactory.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilderFactory.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ThreadLocalKeyBuilderFactory.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java
branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestCompletionScan.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTCK.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/DefaultTupleSerializer.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/DefaultTupleSerializer.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/DefaultTupleSerializer.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -102,12 +102,14 @@
private IRabaCoder leafKeysCoder;
private IRabaCoder leafValsCoder;
+ @Override
final public IRabaCoder getLeafKeysCoder() {
return leafKeysCoder;
}
+ @Override
final public IRabaCoder getLeafValuesCoder() {
return leafValsCoder;
@@ -213,6 +215,7 @@
}
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
@@ -237,6 +240,7 @@
* that the specific configuration values are persisted, even when the
* {@link DefaultTupleSerializer} is de-serialized on a different host.
*/
+ @Override
final public IKeyBuilder getKeyBuilder() {
if(threadLocalKeyBuilderFactory == null) {
@@ -259,6 +263,30 @@
}
+ @Override
+ final public IKeyBuilder getPrimaryKeyBuilder() {
+
+ if(threadLocalKeyBuilderFactory == null) {
+
+ /*
+ * This can happen if you use the de-serialization ctor by mistake.
+ */
+
+ throw new IllegalStateException();
+
+ }
+
+ /*
+ * TODO This should probably to a reset() before returning the object.
+ * However, we need to verify that no callers are assuming that it does
+ * NOT do a reset and implicitly relying on passing the intermediate key
+ * via the return value (which would be very bad style).
+ */
+ return threadLocalKeyBuilderFactory.getPrimaryKeyBuilder();
+
+ }
+
+ @Override
public byte[] serializeKey(final Object obj) {
if (obj == null)
@@ -277,6 +305,7 @@
* @return The serialized representation of the object as a byte[] -or-
* <code>null</code> if the reference is <code>null</code>.
*/
+ @Override
public byte[] serializeVal(final V obj) {
return SerializerUtil.serialize(obj);
@@ -287,6 +316,7 @@
* De-serializes an object from the {@link ITuple#getValue() value} stored
* in the tuple (ignores the key stored in the tuple).
*/
+ @Override
public V deserialize(ITuple tuple) {
if (tuple == null)
@@ -308,6 +338,7 @@
* @throws UnsupportedOperationException
* always.
*/
+ @Override
public K deserializeKey(ITuple tuple) {
throw new UnsupportedOperationException();
@@ -327,6 +358,7 @@
*/
private final static transient byte VERSION = VERSION0;
+ @Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
@@ -346,6 +378,7 @@
}
+ @Override
public void writeExternal(final ObjectOutput out) throws IOException {
out.writeByte(VERSION);
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -2910,11 +2910,19 @@
* specified for <i>this</i> index.
* </p>
*/
+ @Override
public IKeyBuilder getKeyBuilder() {
return getTupleSerializer().getKeyBuilder();
}
+
+ @Override
+ public IKeyBuilder getPrimaryKeyBuilder() {
+
+ return getTupleSerializer().getPrimaryKeyBuilder();
+
+ }
/**
* @see Configuration#getProperty(IIndexManager, Properties, String, String,
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/filter/PrefixFilter.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/filter/PrefixFilter.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/filter/PrefixFilter.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -26,7 +26,7 @@
* </p>
* <h4>WARNING</h4>
* <p>
- * <strong>The prefix keys MUST be formed with {@link StrengthEnum#Identical}.
+ * <strong>The prefix keys MUST be formed with {@link StrengthEnum#Primary}.
* This is necessary in order to match all keys in the index since it causes the
* secondary characteristics to NOT be included in the prefix key even if they
* are present in the keys in the index.</strong> Using other
@@ -55,20 +55,21 @@
* <p>
* at IDENTICAL strength. The additional bytes for the IDENTICAL strength
* reflect the Locale specific Unicode sort key encoding of secondary
- * characteristics such as case. The successor of the PRIMARY strength byte[] is
+ * characteristics such as case. The successor of the IDENTICAL strength byte[]
+ * is
* </p>
*
* <pre>
- * [43, 75, 89, 41, 68]
+ * [43, 75, 89, 41, 67, 1, 9, 1, 143, 9]
* </pre>
*
* <p>
* (one was added to the last byte) which spans all keys of interest. However
- * the successor of the IDENTICAL strength byte[] would
+ * the successor of the PRIMARY strength byte[] would
* </p>
*
* <pre>
- * [43, 75, 89, 41, 67, 1, 9, 1, 143, 9]
+ * [43, 75, 89, 41, 68]
* </pre>
*
* <p>
@@ -81,8 +82,8 @@
* <pre>
* Properties properties = new Properties();
*
- * properties.setProperty(KeyBuilder.Options.STRENGTH, StrengthEnum.Primary
- * .toString());
+ * properties.setProperty(KeyBuilder.Options.STRENGTH,
+ * StrengthEnum.Primary.toString());
*
* prefixKeyBuilder = KeyBuilder.newUnicodeInstance(properties);
* </pre>
@@ -104,7 +105,9 @@
* partition....
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
+ *
+ * @see <a href="http://trac.bigdata.com/ticket/974" >
+ * Name2Addr.indexNameScan(prefix) uses scan + filter </a>
*/
public class PrefixFilter<E> extends FilterBase implements ITupleFilter<E> {
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ASCIIKeyBuilderFactory.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ASCIIKeyBuilderFactory.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ASCIIKeyBuilderFactory.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -39,7 +39,6 @@
* Factory for instances that do NOT support Unicode.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class ASCIIKeyBuilderFactory implements IKeyBuilderFactory, Externalizable {
@@ -59,6 +58,7 @@
/**
* Representation includes all aspects of the {@link Serializable} state.
*/
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getName());
@@ -87,19 +87,35 @@
}
+ @Override
public IKeyBuilder getKeyBuilder() {
return KeyBuilder.newInstance(initialCapacity);
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Note: The PRIMARY is identical to the as-configured {@link IKeyBuilder}
+ * for ASCII.
+ */
+ @Override
+ public IKeyBuilder getPrimaryKeyBuilder() {
+ return getKeyBuilder();
+
+ }
+
+ @Override
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+
initialCapacity = in.readInt();
}
- public void writeExternal(ObjectOutput out) throws IOException {
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeInt(initialCapacity);
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/DefaultKeyBuilderFactory.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/DefaultKeyBuilderFactory.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/DefaultKeyBuilderFactory.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -409,6 +409,7 @@
}
+ @Override
public IKeyBuilder getKeyBuilder() {
if(log.isDebugEnabled()) {
@@ -422,6 +423,20 @@
}
+ @Override
+ public IKeyBuilder getPrimaryKeyBuilder() {
+
+ if(log.isDebugEnabled()) {
+
+ log.debug(toString());
+
+ }
+
+ return KeyBuilder.newInstance(initialCapacity, collator, locale,
+ StrengthEnum.Primary, decompositionMode);
+
+ }
+
/**
* Text of the exception thrown when the ICU library is required but is not
* available.
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilderFactory.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilderFactory.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilderFactory.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -32,7 +32,6 @@
* A factory for pre-configured {@link IKeyBuilder} instances.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public interface IKeyBuilderFactory {
@@ -41,4 +40,15 @@
*/
public IKeyBuilder getKeyBuilder();
+ /**
+ * Return an instance of the configured {@link IKeyBuilder} that has been
+ * overridden to have {@link StrengthEnum#Primary} collation strength. This
+ * may be used to form successors for Unicode prefix scans without having
+ * the secondary sort ordering characteristics mucking things up.
+ *
+ * @see <a href="http://trac.bigdata.com/ticket/974" >
+ * Name2Addr.indexNameScan(prefix) uses scan + filter </a>
+ */
+ public IKeyBuilder getPrimaryKeyBuilder();
+
}
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ThreadLocalKeyBuilderFactory.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ThreadLocalKeyBuilderFactory.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/keys/ThreadLocalKeyBuilderFactory.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -31,8 +31,9 @@
import com.bigdata.btree.IIndex;
/**
+ * A thread-local implementation.
+ *
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class ThreadLocalKeyBuilderFactory implements IKeyBuilderFactory {
@@ -58,6 +59,7 @@
*/
private ThreadLocal<IKeyBuilder> threadLocalKeyBuilder = new ThreadLocal<IKeyBuilder>() {
+ @Override
protected synchronized IKeyBuilder initialValue() {
return delegate.getKeyBuilder();
@@ -67,13 +69,41 @@
};
/**
+ * {@inheritDoc}
+ * <p>
* Return a {@link ThreadLocal} {@link IKeyBuilder} instance configured
* using the {@link IKeyBuilderFactory} specified to the ctor.
*/
+ @Override
public IKeyBuilder getKeyBuilder() {
return threadLocalKeyBuilder.get();
}
+ private ThreadLocal<IKeyBuilder> threadLocalPrimaryKeyBuilder = new ThreadLocal<IKeyBuilder>() {
+
+ @Override
+ protected synchronized IKeyBuilder initialValue() {
+
+ return delegate.getPrimaryKeyBuilder();
+
+ }
+
+ };
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Return a {@link ThreadLocal} {@link IKeyBuilder} instance configured
+ * using the {@link IKeyBuilderFactory} specified to the ctor but with the
+ * {@link StrengthEnum} overriden as {@link StrengthEnum#Primary}.
+ */
+ @Override
+ public IKeyBuilder getPrimaryKeyBuilder() {
+
+ return threadLocalPrimaryKeyBuilder.get();
+
+ }
+
}
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -62,7 +62,6 @@
import com.bigdata.btree.ITuple;
import com.bigdata.btree.ITupleIterator;
import com.bigdata.btree.IndexMetadata;
-import com.bigdata.btree.keys.CollatorEnum;
import com.bigdata.btree.keys.DefaultKeyBuilderFactory;
import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.btree.keys.IKeyBuilderFactory;
@@ -82,9 +81,7 @@
import com.bigdata.resources.IndexManager;
import com.bigdata.resources.ResourceManager;
import com.bigdata.util.concurrent.ExecutionExceptions;
-import com.ibm.icu.text.Collator;
-import cutthecrap.utils.striterators.Filter;
import cutthecrap.utils.striterators.IStriterator;
import cutthecrap.utils.striterators.Resolver;
import cutthecrap.utils.striterators.Striterator;
@@ -185,7 +182,6 @@
* reference to the index and we need both on hand to do the commit.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
private class DirtyListener implements IDirtyListener, Comparable<DirtyListener> {
@@ -194,6 +190,7 @@
boolean needsCheckpoint;
long checkpointAddr = 0L;
+ @Override
public String toString() {
return "DirtyListener{name="
@@ -204,7 +201,8 @@
}
- private DirtyListener(String name, ICheckpointProtocol btree, boolean needsCheckpoint) {
+ private DirtyListener(final String name,
+ final ICheckpointProtocol btree, final boolean needsCheckpoint) {
assert name!=null;
@@ -253,6 +251,7 @@
*
* @param btree
*/
+ @Override
public void dirtyEvent(final ICheckpointProtocol btree) {
assert btree == this.btree;
@@ -549,6 +548,7 @@
/**
* @return <i>self</i>
*/
+ @Override
public CommitIndexTask call() throws Exception {
if (log.isInfoEnabled())
@@ -666,6 +666,7 @@
* >Flush indices in parallel during checkpoint to reduce IO
* latency</a>
*/
+ @Override
synchronized
public long handleCommit(final long commitTime) {
@@ -1394,6 +1395,7 @@
}
+ @Override
public String toString() {
return "Entry{name=" + name + ",checkpointAddr=" + checkpointAddr
@@ -1558,6 +1560,7 @@
*/
private final static transient byte VERSION = VERSION0;
+ @Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
@@ -1575,6 +1578,7 @@
}
+ @Override
public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
@@ -1596,34 +1600,11 @@
*
* @return The names of the indices spanned by that prefix in that index.
*
- * FIXME There is a problem with the prefix scan. It appears that we
- * are not able to generate the key for a prefix correctly. This
- * problem is being worked around by scanning the entire
- * {@link Name2Addr} index and then filter for those entries that
- * start with the specified prefix. This is not very scalable.
- * <p>
- * If you change {@link Name2Addr} to use {@link CollatorEnum#ASCII}
- * then the prefix scan works correctly without that filter. The
- * problem is related to how the {@link Collator} is encoding the
- * keys. Neither the ICU nor the JDK collators work for this right
- * now. At least the ICU collator winds up with some additional
- * bytes after the "end" of the prefix that do not appear when you
- * encode the entire index name. For example, compare "kb" and
- * "kb.red". See TestName2Addr for more about this issue.
- * <p>
- * Fixing this problem MIGHT require a data migration. Or we might
- * be able to handle this entirely by using an appropriate
- * {@link Name2Addr#getKey(String)} and
- * {@link Name2AddrTupleSerializer#serializeKey(Object)}
- * implementation (depending on how the keys are being encoded).
- * <p>
- * Update: See <a
- * href="https://sourceforge.net/apps/trac/bigdata/ticket/743">
- * AbstractTripleStore.destroy() does not filter for correct prefix
- * </a> as well. Maybe the problem is just that we need to have the
- * "." appended to the namespace. This could be something that is
- * done automatically if the caller does not take care of it
- * themselves.
+ * @see <a href="http://trac.bigdata.com/ticket/974" >
+ * Name2Addr.indexNameScan(prefix) uses scan + filter </a>
+ * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/743">
+ * AbstractTripleStore.destroy() does not filter for correct prefix
+ * </a>
*/
public static final Iterator<String> indexNameScan(final String prefix,
final IIndex n2a) {
@@ -1631,27 +1612,37 @@
final byte[] fromKey;
final byte[] toKey;
final boolean hasPrefix = prefix != null && prefix.length() > 0;
- final boolean restrictScan = false;
+// final boolean restrictScan = true;
- if (hasPrefix && restrictScan) {
+ if (hasPrefix ) //&& restrictScan)
+ {
/*
* When the namespace prefix was given, generate the toKey as the
* fixed length successor of the fromKey.
+ *
+ * Note: We MUST use StrengthEnum:=PRIMARY for the prefix scan in
+ * order to avoid the secondary collation ordering effects.
*/
- log.error("prefix=" + prefix);
+// final IKeyBuilder keyBuilder = n2a.getIndexMetadata()
+// .getTupleSerializer().getKeyBuilder();
+// final Properties properties = new Properties();
+//
+// properties.setProperty(KeyBuilder.Options.STRENGTH,
+// StrengthEnum.Primary.toString());
+//
+// final IKeyBuilder keyBuilder = new DefaultKeyBuilderFactory(
+// properties).getKeyBuilder();
final IKeyBuilder keyBuilder = n2a.getIndexMetadata()
- .getTupleSerializer().getKeyBuilder();
-
+ .getPrimaryKeyBuilder();
+
fromKey = keyBuilder.reset().append(prefix).getKey();
- // toKey =
- // keyBuilder.reset().append(prefix).appendNul().getKey();
toKey = SuccessorUtil.successor(fromKey.clone());
- if (true || log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.error("fromKey=" + BytesUtil.toString(fromKey));
@@ -1670,6 +1661,9 @@
@SuppressWarnings("unchecked")
final ITupleIterator<Entry> itr = n2a.rangeIterator(fromKey, toKey);
+ /*
+ * Add resolver from the tuple to the name of the index.
+ */
IStriterator sitr = new Striterator(itr);
sitr = sitr.addFilter(new Resolver() {
@@ -1686,38 +1680,63 @@
});
- if (hasPrefix && !restrictScan) {
+// if (hasPrefix && !restrictScan) {
+//
+// /*
+// * Only report the names that match the prefix.
+// *
+// * Note: For the moment, the filter is hacked by examining the
+// * de-serialized Entry objects and only reporting those that start
+// * with the [prefix].
+// */
+//
+// sitr = sitr.addFilter(new Filter() {
+//
+// private static final long serialVersionUID = 1L;
+//
+// @Override
+// public boolean isValid(final Object obj) {
+//
+// final String name = (String) obj;
+//
+// if (name.startsWith(prefix)) {
+//
+// // acceptable.
+// return true;
+// }
+// return false;
+// }
+// });
+//
+// }
- /*
- * Only report the names that match the prefix.
- *
- * Note: For the moment, the filter is hacked by examining the
- * de-serialized Entry objects and only reporting those that start
- * with the [prefix].
- */
-
- sitr = sitr.addFilter(new Filter() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean isValid(final Object obj) {
-
- final String name = (String) obj;
-
- if (name.startsWith(prefix)) {
-
- // acceptable.
- return true;
- }
- return false;
- }
- });
-
- }
-
return sitr;
}
+// /**
+// * The SuccessorUtil does not work with CollatedKeys since it bumps the "meta/control" data
+// * at the end of the key, rather than the "value" data of the key.
+// *
+// * It has been observed that the key data is delimited with a 01 byte, followed by meta/control
+// * data with the key itself delimited by a 00 byte.
+// *
+// * Note that this has only been analyzed for the ICU collator, the standard Java collator does include
+// * 00 bytes in the key. However, it too appears to delimit the value key with a 01 byte so the
+// * same method should work.
+// *
+// * @param src - original key
+// * @return the next key
+// */
+// private static byte[] successor(final byte[] src) {
+// final byte[] nxt = src.clone();
+// for (int i = 1; i < nxt.length; i++) {
+// if (nxt[i] == 01) { // end of data
+// nxt[i-1]++;
+// break;
+// }
+// }
+//
+// return nxt;
+// }
}
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -82,7 +82,6 @@
* Test suite for {@link BufferMode#DiskRW} journals.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class TestRWJournal extends AbstractJournalTestCase {
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -71,11 +71,8 @@
import com.bigdata.btree.IndexTypeEnum;
import com.bigdata.btree.filter.PrefixFilter;
import com.bigdata.btree.filter.TupleFilter;
-import com.bigdata.btree.keys.DefaultKeyBuilderFactory;
import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.btree.keys.KVO;
-import com.bigdata.btree.keys.KeyBuilder;
-import com.bigdata.btree.keys.StrengthEnum;
import com.bigdata.cache.ConcurrentWeakValueCacheWithBatchedUpdates;
import com.bigdata.journal.IIndexManager;
import com.bigdata.journal.IResourceLock;
@@ -105,7 +102,6 @@
import com.bigdata.rdf.model.BigdataValueSerializer;
import com.bigdata.rdf.rio.StatementBuffer;
import com.bigdata.rdf.spo.ISPO;
-import com.bigdata.rdf.spo.SPO;
import com.bigdata.rdf.store.AbstractTripleStore;
import com.bigdata.rdf.vocab.NoVocabulary;
import com.bigdata.rdf.vocab.Vocabulary;
@@ -1421,27 +1417,32 @@
}
- /*
+ /**
* The KeyBuilder used to form the prefix keys.
*
- * Note: The prefix keys are formed with IDENTICAL strength. This is
+ * Note: The prefix keys are formed with PRIMARY strength. This is
* necessary in order to match all keys in the index since it causes the
* secondary characteristics to NOT be included in the prefix key even
* if they are present in the keys in the index.
+ *
+ * @see <a href="http://trac.bigdata.com/ticket/974" >
+ * Name2Addr.indexNameScan(prefix) uses scan + filter </a>
*/
- final LexiconKeyBuilder keyBuilder;
- {
+ final LexiconKeyBuilder keyBuilder = ((Term2IdTupleSerializer) getTerm2IdIndex()
+ .getIndexMetadata().getTupleSerializer())
+ .getLexiconPrimaryKeyBuilder();
+// {
+//
+// final Properties properties = new Properties();
+//
+// properties.setProperty(KeyBuilder.Options.STRENGTH,
+// StrengthEnum.Primary.toString());
+//
+// keyBuilder = new Term2IdTupleSerializer(
+// new DefaultKeyBuilderFactory(properties)).getLexiconKeyBuilder();
+//
+// }
- final Properties properties = new Properties();
-
- properties.setProperty(KeyBuilder.Options.STRENGTH,
- StrengthEnum.Primary.toString());
-
- keyBuilder = new Term2IdTupleSerializer(
- new DefaultKeyBuilderFactory(properties)).getLexiconKeyBuilder();
-
- }
-
/*
* Formulate the keys[].
*
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/Term2IdTupleSerializer.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -118,12 +118,30 @@
}
/**
+ * Return a {@link LexiconKeyBuilder} that is setup with collation strength
+ * PRIMARY.
+ *
+ * @see <a href="http://trac.bigdata.com/ticket/974" >
+ * Name2Addr.indexNameScan(prefix) uses scan + filter </a>
+ */
+ public LexiconKeyBuilder getLexiconPrimaryKeyBuilder() {
+
+ /*
+ * FIXME We should save off a reference to this to reduce heap churn
+ * and then use that reference in this class.
+ */
+ return new LexiconKeyBuilder(getPrimaryKeyBuilder());
+
+ }
+
+ /**
* You can not decode the term:id keys since they include Unicode sort keys
* and that is a lossy transform.
*
* @throws UnsupportedOperationException
* always
*/
+ @Override
public Object deserializeKey(ITuple tuple) {
throw new UnsupportedOperationException();
@@ -136,6 +154,7 @@
* @param obj
* The RDF {@link Value}.
*/
+ @Override
public byte[] serializeKey(Object obj) {
return getLexiconKeyBuilder().value2Key((Value)obj);
@@ -149,6 +168,7 @@
* @param obj
* A term identifier expressed as a {@link TermId}.
*/
+ @Override
public byte[] serializeVal(final Object obj) {
final IV<?,?> iv = (IV<?,?>) obj;
@@ -169,6 +189,7 @@
* De-serializes the {@link ITuple} as a {@link IV} whose value is the
* term identifier associated with the key. The key itself is not decodable.
*/
+ @Override
public IV deserialize(final ITuple tuple) {
final ByteArrayBuffer b = tuple.getValueBuffer();
@@ -187,6 +208,7 @@
*/
private final static transient byte VERSION = VERSION0;
+ @Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
@@ -204,6 +226,7 @@
}
+ @Override
public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestCompletionScan.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestCompletionScan.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestCompletionScan.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -63,7 +63,6 @@
* {@link LexiconRelation#prefixScan(org.openrdf.model.Literal[])}.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class TestCompletionScan extends AbstractTripleStoreTestCase {
@@ -85,7 +84,7 @@
*/
public void test_completionScan() {
- AbstractTripleStore store = getStore();
+ final AbstractTripleStore store = getStore();
try {
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTCK.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTCK.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTCK.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -38,7 +38,6 @@
* Test driver for debugging Sesame or DAWG manifest tests.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class TestTCK extends AbstractDataDrivenSPARQLTestCase {
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -42,7 +42,6 @@
* various indices are NOT isolatable.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class TestLocalTripleStore extends AbstractTestCase {
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2014-06-11 09:34:45 UTC (rev 8465)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2014-06-11 13:13:13 UTC (rev 8466)
@@ -46,7 +46,6 @@
* the pipeline join algorithm.
*
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
*/
public class TestBigdataSailWithQuads extends AbstractBigdataSailTestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|