public void test_uri() { final String uri1 = "http://www.cognitiveweb.org"; final String uri2 = "http://www.cognitiveweb.org/a"; final String uri3 = "http://www.cognitiveweb.com/a"; final byte[] k1 = fixture.uri2key(uri1); final byte[] k2 = fixture.uri2key(uri2); final byte[] k3 = fixture.uri2key(uri3); if (log.isInfoEnabled()) { log.info("k1(" + uri1 + ") = " + BytesUtil.toString(k1)); log.info("k2(" + uri2 + ") = " + BytesUtil.toString(k2)); log.info("k3(" + uri3 + ") = " + BytesUtil.toString(k3)); } // subdirectory sorts after root directory. assertTrue(BytesUtil.compareBytes(k1, k2) < 0); // .com extension sorts before .org assertTrue(BytesUtil.compareBytes(k2, k3) > 0); }
/** * Test verifies the ordering among URIs, Literals, and BNodes. This ordering is important when * batching terms of these different types into the term index since you want to insert the type * types according to this order for the best performance. */ public void test_termTypeOrder() { /* * one key of each type. the specific values for the types do not matter * since we are only interested in the relative order between those * types in this test. */ final byte[] k1 = fixture.uri2key("http://www.cognitiveweb.org"); final byte[] k2 = fixture.plainLiteral2key("hello world!"); final byte[] k3 = fixture.blankNode2Key("a12"); assertTrue(BytesUtil.compareBytes(k1, k2) < 0); assertTrue(BytesUtil.compareBytes(k2, k3) < 0); }