Java Code Examples for com.bigdata.rdf.store.AbstractTripleStore#getLexiconRelation()

The following examples show how to use com.bigdata.rdf.store.AbstractTripleStore#getLexiconRelation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestIVCache.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Unit test for {@link IV#getValue()} and friends.
 */
   public void test_getValue() {
   	
   	final AbstractTripleStore store = getStore(getProperties());

   	try {
   		
   		final LexiconRelation lex = store.getLexiconRelation();

   		final BigdataValueFactory f = lex.getValueFactory();
   		
   		final BigdataURI uri = f.createURI("http://www.bigdata.com");
   		final BigdataBNode bnd = f.createBNode();//"12");
   		final BigdataLiteral lit = f.createLiteral("bigdata");
   		
   		final BigdataValue[] a = new BigdataValue[] {
   			uri, bnd, lit
   		};
   		
   		// insert some terms.
   		lex.addTerms(a, a.length, false/*readOnly*/);

   		doTest(lex,uri.getIV(), uri);
   		doTest(lex,bnd.getIV(), bnd);
   		doTest(lex,lit.getIV(), lit);
   		
		doTest(lex, new XSDBooleanIV<BigdataLiteral>(true));
		doTest(lex, new XSDNumericIV<BigdataLiteral>((byte)1));
		doTest(lex, new XSDNumericIV<BigdataLiteral>((short)1));
		doTest(lex, new XSDNumericIV<BigdataLiteral>(1));
		doTest(lex, new XSDNumericIV<BigdataLiteral>(1L));
		doTest(lex, new XSDNumericIV<BigdataLiteral>(1f));
		doTest(lex, new XSDNumericIV<BigdataLiteral>(1d));
		doTest(lex, new XSDIntegerIV<BigdataLiteral>(BigInteger.valueOf(1L)));
		doTest(lex, new XSDDecimalIV<BigdataLiteral>(BigDecimal.valueOf(1d)));
		
		doTest(lex, new UUIDBNodeIV<BigdataBNode>(UUID.randomUUID()));
		doTest(lex, new NumericBNodeIV<BigdataBNode>(1));
		
		doTest(lex, new UUIDLiteralIV<BigdataLiteral>(UUID.randomUUID()));
		
   	} finally {
   		
   		store.__tearDownUnitTest();
   		
   	}
   	
}
 
Example 2
Source File: GASService.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * @param outVars
 *            The declared output variables (the ones that the
 *            caller wants to extract). Any position that will not
 *            be extracted is a <code>null</code>.
 */
public BindingSetReducer(//
        final IVariable<?>[] outVars,
        final AbstractTripleStore store,
        final IGASProgram<VS, ES, ST> gasProgram,
        final IGASContext<VS, ES, ST> ctx) {

    this.outVars = outVars;

    this.store = store;

    this.lex = store.getLexiconRelation();
    
    this.vf = store.getValueFactory();
    
    this.binderList = gasProgram.getBinderList();

}
 
Example 3
Source File: TestAccessPaths.java    From database with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Test the access path.
 * 
 * @param expected
 *            The {@link BigdataValue} with its {@link IV}.
 * @param expectedKeyOrder
 *            The keyorder to be used.
 * @param store
 *            The store.
 */
private void doAccessPathTest(final BigdataValue expected,
		final IKeyOrder<BigdataValue> expectedKeyOrder,
		final AbstractTripleStore store) {

	assertNotNull(expected.getIV());

	final LexiconRelation r = store.getLexiconRelation();

	@SuppressWarnings("unchecked")
       final IVariable<BigdataValue> termvar = Var.var("termvar");
	
	final IPredicate<BigdataValue> predicate = LexPredicate
			.reverseInstance(r.getNamespace(), ITx.UNISOLATED, termvar,
					new Constant<IV>(expected.getIV()));

	final IKeyOrder<BigdataValue> keyOrder = r.getKeyOrder(predicate);

	assertEquals(expectedKeyOrder, keyOrder);

	final IAccessPath<BigdataValue> ap = r.newAccessPath(
			store.getIndexManager(), predicate, keyOrder);

	assertEquals(1, ap.rangeCount(false/* exact */));
	assertEquals(1, ap.rangeCount(true/* exact */));

	final Iterator<BigdataValue> itr = ap.iterator();
	assertTrue(itr.hasNext());
	final BigdataValue actual = itr.next();
	assertFalse(itr.hasNext());

	assertEquals(expected, actual);

	assertEquals(expected.getIV(), actual.getIV());

}