/** * Return the unsigned byte[] key for an RDF {@link Value}. * * @param obj * The RDF {@link Value}. */ @Override public byte[] serializeKey(Object obj) { return getLexiconKeyBuilder().value2Key((Value)obj); }
/** * Return the unsigned byte[] key for an RDF {@link Value}. * * @param obj * The RDF {@link Value}. */ @Override public byte[] serializeKey(Object obj) { return getLexiconKeyBuilder().value2Key((Value)obj); }
/** * Generate the sort keys for the terms. * * @param keyBuilder * The object used to generate the sort keys. * @param terms * The terms whose sort keys will be generated. * @param numTerms * The #of terms in that array. * * @return An array of correlated key-value-object tuples. * <p> * Note that {@link KVO#val} is <code>null</code> until we know * that we need to write it on the reverse index. * * @see LexiconKeyBuilder */ @SuppressWarnings("unchecked") final private KVO<BigdataValue>[] generateSortKeys( final LexiconKeyBuilder keyBuilder, final BigdataValue[] terms, final int numTerms) { final KVO<BigdataValue>[] a = new KVO[numTerms]; for (int i = 0; i < numTerms; i++) { final BigdataValue term = terms[i]; a[i] = new KVO<BigdataValue>(keyBuilder.value2Key(term), null/* val */, term); } return a; }
/** * Generate the sort keys for the terms. * * @param keyBuilder * The object used to generate the sort keys. * @param terms * The terms whose sort keys will be generated. * @param numTerms * The #of terms in that array. * * @return An array of correlated key-value-object tuples. * <p> * Note that {@link KVO#val} is <code>null</code> until we know * that we need to write it on the reverse index. * * @see LexiconKeyBuilder */ @SuppressWarnings("unchecked") final private KVO<BigdataValue>[] generateSortKeys( final LexiconKeyBuilder keyBuilder, final BigdataValue[] terms, final int numTerms) { final KVO<BigdataValue>[] a = new KVO[numTerms]; for (int i = 0; i < numTerms; i++) { final BigdataValue term = terms[i]; a[i] = new KVO<BigdataValue>(keyBuilder.value2Key(term), null/* val */, term); } return a; }
/** * Tests the gross ordering over the different kinds of {@link Value}s but * deliberately does not pay attention to the sort key ordering for string * data. * * @see ITermIndexCodes */ public void test_keyOrder() { final byte[] uri = fixture.value2Key(RDF.TYPE); final byte[] bnd = fixture.value2Key(new BNodeImpl("foo")); final byte[] lit = fixture.value2Key(new LiteralImpl("abc")); final byte[] lcl = fixture.value2Key(new LiteralImpl("abc", "en")); final byte[] dtl = fixture.value2Key(new LiteralImpl("abc", XSD.BOOLEAN)); // URIs before plain literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(uri, lit) < 0); // plain literals before language code literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lit, lcl) < 0); // language code literals before datatype literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lcl, dtl) < 0); // datatype literals before blank nodes. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(dtl, bnd) < 0); }
/** * Tests the gross ordering over the different kinds of {@link Value}s but * deliberately does not pay attention to the sort key ordering for string * data. * * @see ITermIndexCodes */ public void test_keyOrder() { final byte[] uri = fixture.value2Key(RDF.TYPE); final byte[] bnd = fixture.value2Key(new BNodeImpl("foo")); final byte[] lit = fixture.value2Key(new LiteralImpl("abc")); final byte[] lcl = fixture.value2Key(new LiteralImpl("abc", "en")); final byte[] dtl = fixture.value2Key(new LiteralImpl("abc", XSD.BOOLEAN)); // URIs before plain literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(uri, lit) < 0); // plain literals before language code literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lit, lcl) < 0); // language code literals before datatype literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lcl, dtl) < 0); // datatype literals before blank nodes. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(dtl, bnd) < 0); }
/** * Tests encode of a key and the decode of its "code" byte. * * @see ITermIndexCodes */ public void test_encodeDecodeCodeByte() { assertEquals(ITermIndexCodes.TERM_CODE_URI, fixture .value2Key(RDF.TYPE)[0]); assertEquals(ITermIndexCodes.TERM_CODE_BND, fixture .value2Key(new BNodeImpl("foo"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LIT, fixture .value2Key(new LiteralImpl("abc"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LCL, fixture .value2Key(new LiteralImpl("abc","en"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_DTL, fixture .value2Key(new LiteralImpl("abc",XSD.BOOLEAN))[0]); }
/** * Tests encode of a key and the decode of its "code" byte. * * @see ITermIndexCodes */ public void test_encodeDecodeCodeByte() { assertEquals(ITermIndexCodes.TERM_CODE_URI, fixture .value2Key(RDF.TYPE)[0]); assertEquals(ITermIndexCodes.TERM_CODE_BND, fixture .value2Key(new BNodeImpl("foo"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LIT, fixture .value2Key(new LiteralImpl("abc"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LCL, fixture .value2Key(new LiteralImpl("abc","en"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_DTL, fixture .value2Key(new LiteralImpl("abc",XSD.BOOLEAN))[0]); }
/** * Tests the gross ordering over the different kinds of {@link Value}s but * deliberately does not pay attention to the sort key ordering for string * data. * * @see ITermIndexCodes */ public void test_keyOrder() { final byte[] uri = fixture.value2Key(RDF.TYPE); final byte[] bnd = fixture.value2Key(new BNodeImpl("foo")); final byte[] lit = fixture.value2Key(new LiteralImpl("abc")); final byte[] lcl = fixture.value2Key(new LiteralImpl("abc", "en")); final byte[] dtl = fixture.value2Key(new LiteralImpl("abc", XSD.BOOLEAN)); // URIs before plain literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(uri, lit) < 0); // plain literals before language code literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lit, lcl) < 0); // language code literals before datatype literals. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(lcl, dtl) < 0); // datatype literals before blank nodes. assertTrue(UnsignedByteArrayComparator.INSTANCE.compare(dtl, bnd) < 0); }
/** * Tests encode of a key and the decode of its "code" byte. * * @see ITermIndexCodes */ public void test_encodeDecodeCodeByte() { assertEquals(ITermIndexCodes.TERM_CODE_URI, fixture .value2Key(RDF.TYPE)[0]); assertEquals(ITermIndexCodes.TERM_CODE_BND, fixture .value2Key(new BNodeImpl("foo"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LIT, fixture .value2Key(new LiteralImpl("abc"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_LCL, fixture .value2Key(new LiteralImpl("abc","en"))[0]); assertEquals(ITermIndexCodes.TERM_CODE_DTL, fixture .value2Key(new LiteralImpl("abc",XSD.BOOLEAN))[0]); }
.value2Key(v), null/* val */, v, latch));
.value2Key(v), null/* val */, v, latch));
throw new IllegalArgumentException(); keys[i] = keyBuilder.value2Key(lit);
throw new IllegalArgumentException(); keys[i] = keyBuilder.value2Key(lit);
key = tupleSer.getLexiconKeyBuilder().value2Key(value);
key = tupleSer.getLexiconKeyBuilder().value2Key(value);