com.bigdata.rdf.model.BigdataValueFactory Java Examples
The following examples show how to use
com.bigdata.rdf.model.BigdataValueFactory.
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: RDRHistory.java From database with GNU General Public License v2.0 | 6 votes |
/** * Helper method to resolve added and removed terms. */ protected IV<?,?>[] resolveTerms(final URI[] terms) throws Exception { final BigdataValueFactory vf = database.getValueFactory(); final BigdataValue[] values = new BigdataValue[terms.length]; for (int i = 0; i < terms.length; i++) { values[i] = vf.asValue(terms[i]); } database.addTerms(values); final IV<?,?>[] ivs = new IV[terms.length]; for (int i = 0; i < values.length; i++) { ivs[i] = values[i].getIV(); } return ivs; }
Example #2
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 6 votes |
/** * Get simple lat lon schema description, where lat and lon correspong to * long values (rather than 5 precise doubles). */ protected GeoSpatialLiteralExtension<BigdataValue> getSimpleLatLonGSLiteralExtensionWithRange( final BigdataValueFactory vf, final Long min) { final GeoSpatialDatatypeFieldConfiguration field1Config = new GeoSpatialDatatypeFieldConfiguration( ValueType.LONG, min, 1, ServiceMapping.LATITUDE, null); final GeoSpatialDatatypeFieldConfiguration field2Config = new GeoSpatialDatatypeFieldConfiguration( ValueType.LONG, min, 1, ServiceMapping.LONGITUDE, null); final List<GeoSpatialDatatypeFieldConfiguration> fieldConfig = new ArrayList<GeoSpatialDatatypeFieldConfiguration>(); fieldConfig.add(field1Config); fieldConfig.add(field2Config); final GeoSpatialDatatypeConfiguration config = new GeoSpatialDatatypeConfiguration( STR_DATATYPE_LAT_LON_LONG_MIN, new GeoSpatialDefaultLiteralSerializer(), fieldConfig); return getGSLiteralExtension(vf, config); }
Example #3
Source File: GROUP_CONCAT.java From database with GNU General Public License v2.0 | 6 votes |
synchronized public IV done() { if(sep == null) cache(); if (firstCause != null) { throw new RuntimeException(firstCause); } final BigdataValueFactory vf = getValueFactory(); IV ret; if (aggregated == null) { ret = DummyConstantNode.toDummyIV(vf.createLiteral("")); } else { ret = DummyConstantNode.toDummyIV(vf.createLiteral(aggregated .toString())); } // System.err.println("aggregated:=" + aggregated+" : "+ret); return ret; }
Example #4
Source File: AbstractOptimizerTestCaseWithUtilityMethods.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a SPARQL 1.1 {@link ServiceNode} using the specified vars in its * body, with a constant endpoint. */ ServiceNode serviceSparql11WithConstant(final String... varNames) { final JoinGroupNode jgn = joinGroupWithVars(varNames); final BigdataValueFactory f = store.getValueFactory(); final BigdataURI serviceEndpoint = f.createURI("http://custom.endpoint"); final IV serviceEndpointIV = makeIV(serviceEndpoint); final BigdataValue[] values = new BigdataValue[] { serviceEndpoint }; store.getLexiconRelation().addTerms( values, values.length, false/* readOnly */); final ServiceNode serviceNode = (ServiceNode) new Helper(){{ tmp = service(constantNode(serviceEndpointIV),jgn); }}.getTmp(); return serviceNode; }
Example #5
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 6 votes |
/** * Generates the combination of all literals in the given range. E.g., passing * in 0 as from and 2 as to, we get 0#0, 0#1, 0#2, 1#0, 1#1, 1#2, 2#0, 2#1, * and 2#2. * @param vf * the value factory used to generate the literals * @return the list of generated literals */ protected final BigdataLiteral[] getGeospatialLiteralsLatLonInRange( final BigdataValueFactory vf, final int from, final int to, final URI datatype) { final int numComponents = to-from+1; // we'll create a permutation over all values above final BigdataLiteral[] dt = new BigdataLiteral[numComponents*numComponents]; // compute permutations from the base arrays provided above: // 0#0, 0#1, ..., 0#n, 1#0, 1#1, 1#n, ..., n#n int ctr = 0; for (int y = from; y <= to; y++) { for (int x = from; x <= to; x++) { dt[ctr++] = vf.createLiteral(x + "#" + y, datatype); } } return dt; }
Example #6
Source File: GeoSpatialTestWKTLiteralSerializer.java From database with GNU General Public License v2.0 | 6 votes |
@Override public IV<?,?> serializeLocation( final BigdataValueFactory vf, final Object latitude, final Object longitude) { final StringBuffer buf = new StringBuffer(); buf.append("Point("); buf.append(latitude); buf.append(","); buf.append(longitude); buf.append(")"); return DummyConstantNode.toDummyIV( vf.createLiteral( buf.toString(), new URIImpl("http://www.opengis.net/ont/geosparql#wktLiteral"))); }
Example #7
Source File: TestBlobsWriteTask.java From database with GNU General Public License v2.0 | 6 votes |
/** * Thin wrapper for the {@link BlobsWriteTask} as invoked by the * {@link LexiconRelation}. This can be used to unify the {@link IV}s for * the caller's {@link BigdataValue} with those in the TERMS index and * (optionally) to assign new {@link IV}s (when read-only is * <code>false</code>). * * @param vf * @param ndx * @param readOnly * @param toldBNodes * @param values * @return */ private WriteTaskStats addValues(final BigdataValueFactory vf, final IIndex ndx, final boolean readOnly, final boolean toldBNodes, final BigdataValue[] values) { final WriteTaskStats stats = new WriteTaskStats(); final BlobsWriteTask task = new BlobsWriteTask(ndx, vf, readOnly, toldBNodes, values.length, values, stats); try { task.call(); } catch (Exception e) { throw new RuntimeException(e); } if(log.isInfoEnabled()) log.info(stats); return stats; }
Example #8
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 6 votes |
/** * Get a {@link GeoSpatialLiteralExtension} object processing lat+lon * schema literals. */ protected GeoSpatialLiteralExtension<BigdataValue> getLatLonGSLiteralExtension(final BigdataValueFactory vf) { final GeoSpatialDatatypeFieldConfiguration field1Config = new GeoSpatialDatatypeFieldConfiguration( ValueType.DOUBLE, null, 100000, ServiceMapping.LATITUDE, null); final GeoSpatialDatatypeFieldConfiguration field2Config = new GeoSpatialDatatypeFieldConfiguration( ValueType.DOUBLE, null, 100000, ServiceMapping.LONGITUDE, null); final List<GeoSpatialDatatypeFieldConfiguration> fieldConfig = new ArrayList<GeoSpatialDatatypeFieldConfiguration>(); fieldConfig.add(field1Config); fieldConfig.add(field2Config); final GeoSpatialDatatypeConfiguration config = new GeoSpatialDatatypeConfiguration( STR_DATATYPE_LAT_LON_DOUBLE, new GeoSpatialDefaultLiteralSerializer(), fieldConfig); return getGSLiteralExtension(vf, config); }
Example #9
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Test z-order string construction by means of a simple, two dimensional * index with mixed negative and positive integer values. */ public void testZIndexOrderingMixed() { final BigdataValueFactory vf = BigdataValueFactoryImpl.getInstance("test"); // the range in the test we delegate to is -2 .. 1 final GeoSpatialLiteralExtension<BigdataValue> litExt = getSimpleLatLonGSLiteralExtension(vf); zIndexOrderingMixedBase(vf, litExt, URI_DATATYPE_LAT_LON_LONG); }
Example #10
Source File: BlazeEdge.java From tinkerpop3 with GNU General Public License v2.0 | 5 votes |
/** * Construct an instance. */ BlazeEdge(final BlazeGraph graph, final BigdataStatement stmt, final BigdataURI label, final BlazeVertex from, final BlazeVertex to) { super(graph, stmt.getPredicate(), label); final BigdataValueFactory rdfvf = graph.rdfValueFactory(); this.sid = rdfvf.createBNode(stmt); this.vertices = new Vertices(from, to); }
Example #11
Source File: TestBind.java From database with GNU General Public License v2.0 | 5 votes |
/** * A variant on {@link #test_bind05()} where the {@link IV} having the * cached {@link BigdataValue} is in the other source solution (test of * symmetry). */ public void test_bind05b() { final BigdataValueFactory f = BigdataValueFactoryImpl .getInstance(getName()); final BigdataLiteral lit = f.createLiteral(1); final IVariable<?> x = Var.var("x"); final IV iv1 = new XSDNumericIV<BigdataLiteral>(1); final IV iv2 = new XSDNumericIV<BigdataLiteral>(1); final IV iv3 = new XSDNumericIV<BigdataLiteral>(1); final IConstant<?> val1 = new Constant(iv1); final IConstant<?> val2 = new Constant(iv2); final IConstant<?> val3 = new Constant(iv3); iv2.setValue((BigdataValue) lit); iv3.setValue((BigdataValue) lit); final ListBindingSet expected = new ListBindingSet(); expected.set(x, val3); final ListBindingSet left = new ListBindingSet(); left.set(x, val1); final ListBindingSet right = new ListBindingSet(); right.set(x, val2); final IBindingSet actual = BOpContext.bind(left, right, //true/*leftIsPipeline*/, null/*constraints*/, null/*varsToKeep*/); assertEquals(expected, actual); assertEquals(iv3.getValue(), ((IV)actual.get(x).get()).getValue()); }
Example #12
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 23: * {@link Options#INLINE_TEXT_LITERALS} is false * {@link Options#INLINE_XSD_DATATYPE_LITERALS} is true * data loaded from file */ public void test_23() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, false /*inlineTextLiterals*/ , true /*inlineXSDDatatypeLiterals*/ ); loadData(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertFalse(values[0].getIV().isInline()); // http://s assertTrue(values[1].getIV().isInline()); // 1 assertTrue(values[2].getIV().isInline()); // "2"^^xsd:int assertTrue(values[3].getIV().isInline()); // 3.0 assertTrue(values[4].getIV().isInline()); // "4.0"^^xsd:double assertTrue(values[5].getIV().isInline()); // true assertTrue(values[6].getIV().isInline()); // "false"^^xsd:boolean assertFalse(values[7].getIV().isInline()); // "plain string" assertFalse(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertFalse(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #13
Source File: AbstractHashJoinUtilityTestCase.java From database with GNU General Public License v2.0 | 5 votes |
/** * Return a (Mock) IV for a Value. * * @param v * The value. * * @return The Mock IV. */ @SuppressWarnings({ "unchecked", "rawtypes" }) private IV makeIV(final Value v) { final BigdataValueFactory valueFactory = BigdataValueFactoryImpl .getInstance(namespace); final BigdataValue bv = valueFactory.asValue(v); final IV iv = new TermId(VTE.valueOf(v), nextId++); iv.setValue(bv); return iv; }
Example #14
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Get a {@link GeoSpatialLiteralExtension} object processing literals of * the schema specified in the {@link SchemaDescription} object. */ protected GeoSpatialLiteralExtension<BigdataValue> getGSLiteralExtension( final BigdataValueFactory vf, final GeoSpatialDatatypeConfiguration datatypeConfig) { return new GeoSpatialLiteralExtension<BigdataValue>( new IDatatypeURIResolver() { public BigdataURI resolve(URI uri) { final BigdataURI buri = vf.createURI(uri.stringValue()); buri.setIV(newTermId(VTE.URI)); return buri; } },datatypeConfig); }
Example #15
Source File: XsdLongBOp.java From database with GNU General Public License v2.0 | 5 votes |
public IV get(final IBindingSet bs) { final IV iv = getAndCheckBound(0, bs); if (log.isDebugEnabled()) { log.debug(iv); } final Value val = asValue(iv); if (log.isDebugEnabled()) { log.debug(val); } // use to create my simple literals final BigdataValueFactory vf = getValueFactory(); try { if (val instanceof Literal) { final Literal lit = (Literal) val; if (lit.getDatatype() != null && lit.getDatatype().equals(XSD.LONG)) { // if xsd:unsignedLong literal return it return iv; } else { final BigdataLiteral str = vf.createLiteral(Long.valueOf(lit.getLabel())); return super.asIV(str, bs); } } } catch (Exception e) { // exception handling following } throw new SparqlTypeErrorException(); // fallback }
Example #16
Source File: TestIVariableBindingRequirements.java From database with GNU General Public License v2.0 | 5 votes |
/** * Test interface implementation for SPARQL 1.1 SERVICE with constant * specifying service endpoint. */ @SuppressWarnings({ "rawtypes", "serial" }) public void testServiceSparql11Constant() { final BigdataValueFactory f = store.getValueFactory(); final BigdataURI serviceEndpoint = f.createURI("http://custom.endpoint"); final IV serviceEndpointIV = makeIV(serviceEndpoint); final BigdataValue[] values = new BigdataValue[] { serviceEndpoint }; store.getLexiconRelation().addTerms( values, values.length, false/* readOnly */); final ServiceNode serviceNode = (ServiceNode) new Helper(){{ tmp = service( constantNode(serviceEndpointIV), joinGroupNode( statementPatternNode(varNode(x),constantNode(a),varNode(y)))); }}.getTmp(); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); add(Var.var("y")); }}; // dummy sa object final StaticAnalysis sa = new StaticAnalysis(new QueryRoot(QueryType.SELECT), null); assertEquals(requiredBound, serviceNode.getRequiredBound(sa)); assertEquals(desiredBound, serviceNode.getDesiredBound(sa)); }
Example #17
Source File: XSDUnsignedShortIV.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createLiteral(value, true); v.setIV(this); setValue(v); } return v; }
Example #18
Source File: FullyInlineURIIV.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createURI(uri.stringValue()); v.setIV(this); setValue(v); } return v; }
Example #19
Source File: GeoSpatialDefaultLiteralSerializer.java From database with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public IV<?,?> serializeLongitude(final BigdataValueFactory vf, final Object longitude) { if (longitude instanceof Double) { return new XSDNumericIV((Double)longitude); } else if (longitude instanceof Long) { return new XSDNumericIV(((Long)longitude).doubleValue()); } else { throw new GeoSpatialSearchException("Longitude value expected to be either Double or Long"); } }
Example #20
Source File: TestTicket1086.java From database with GNU General Public License v2.0 | 5 votes |
/** * When loading quads into a triple store and the BigdataSail option * REJECT_QUADS_IN_TRIPLE_MODE is set to true, an exception will be thrown. */ public void testQuadStrippingRejected() throws Exception { BigdataSailRepositoryConnection cxn = null; final BigdataSail sail = getSail(getTriplesNoInferenceNoQuadsStripping()); boolean exceptionEncountered = false; try { sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); cxn = (BigdataSailRepositoryConnection) repo.getConnection(); final BigdataValueFactory vf = (BigdataValueFactory) sail .getValueFactory(); final URI s = vf.createURI("http://test/s"); final URI p = vf.createURI("http://test/p"); final URI o = vf.createURI("http://test/o"); final URI c = vf.createURI("http://test/c"); BigdataStatement stmt = vf.createStatement(s, p, o, c); cxn.add(stmt); } catch (RepositoryException e) { exceptionEncountered = true; // expected ! } finally { if (cxn != null) cxn.close(); sail.__tearDownUnitTest(); } assertTrue(exceptionEncountered); }
Example #21
Source File: XSDUnsignedLongIV.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createLiteral(value, true); v.setIV(this); setValue(v); } return v; }
Example #22
Source File: GeoSpatialDummyLiteralSerializer.java From database with GNU General Public License v2.0 | 5 votes |
@Override public IV<?,?> serializeLocationAndTime( final BigdataValueFactory vf, final Object latitude, final Object longitude, final Object time) { return DummyConstantNode.toDummyIV(vf.createLiteral("LocationAndTime(" + concat(latitude, longitude, time) + ")")); }
Example #23
Source File: TestInlineURIs.java From database with GNU General Public License v2.0 | 5 votes |
public void testInlineUUIDs() throws Exception { /* * The bigdata store, backed by a temporary journal file. */ final AbstractTripleStore store = getStore(getProperties()); try { final BigdataValueFactory vf = store.getValueFactory(); final BigdataURI uri1 = vf.createURI("urn:uuid:" + UUID.randomUUID().toString()); final BigdataURI uri2 = vf.createURI("urn:uuid:" + UUID.randomUUID().toString()); final BigdataURI uri3 = vf.createURI("urn:uuid:foo"); final StatementBuffer<BigdataStatement> sb = new StatementBuffer<BigdataStatement>(store, 10/* capacity */); sb.add(uri1, RDF.TYPE, XSD.UUID); sb.add(uri2, RDF.TYPE, XSD.UUID); sb.add(uri3, RDF.TYPE, XSD.UUID); sb.flush(); store.commit(); if (log.isDebugEnabled()) log.debug(store.dumpStore()); assertTrue(uri1.getIV().isInline()); assertTrue(uri2.getIV().isInline()); assertFalse(uri3.getIV().isInline()); } finally { store.__tearDownUnitTest(); } }
Example #24
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test for round-trip of GeoSpatial literals of lat+lon * GeoSpatial literals. */ public void test_encodeDecodeLatLonGeoSpatialLiterals() throws Exception { final BigdataValueFactory vf = BigdataValueFactoryImpl.getInstance("test"); final GeoSpatialLiteralExtension<BigdataValue> ext = getLatLonGSLiteralExtension(vf); encodeDecodeGeoSpatialLiterals( vf, getDummyGeospatialLiteralsLatLon(vf, URI_DATATYPE_LAT_LON_DOUBLE), ext); }
Example #25
Source File: TestEncodeDecodeXSDDateIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test for xsd:date literal encoding. */ public void test_encodeDecodeDateLiterals() throws Exception { final BigdataValueFactory vf = BigdataValueFactoryImpl.getInstance("test"); final DateTimeExtension<BigdataValue> ext = getDateTimeExtensionGMT(vf); final BigdataLiteral[] dt = { vf.createLiteral("-2015-01-01", XSD.DATE), vf.createLiteral("-2015-12-31", XSD.DATE), vf.createLiteral("9999-01-01", XSD.DATE), vf.createLiteral("9999-12-31", XSD.DATE) }; // create associated IVs final IV<?, ?>[] e = new IV[dt.length]; for (int i = 0; i < dt.length; i++) { e[i] = ext.createIV(dt[i]); } for (int i = 0; i < e.length; i++) { @SuppressWarnings("rawtypes") final BigdataValue valRoundTrip = ext.asValue((LiteralExtensionIV) e[i], vf); assertEquals(valRoundTrip, dt[i] /* original value */); } final IV<?, ?>[] a = doEncodeDecodeTest(e); doComparatorTest(e); }
Example #26
Source File: TestEncodeDecodeXSDDateIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test for xsd:dateTime literal encoding. */ public void test_encodeDecodeTime() throws Exception { final BigdataValueFactory vf = BigdataValueFactoryImpl.getInstance("test"); final DateTimeExtension<BigdataValue> ext = getDateTimeExtensionGMT(vf); final BigdataLiteral[] dt = { vf.createLiteral("00:00:00", XSD.TIME), vf.createLiteral("01:02:03", XSD.TIME), vf.createLiteral("10:20:30", XSD.TIME), vf.createLiteral("23:59:59", XSD.TIME) }; // create associated IVs final IV<?, ?>[] e = new IV[dt.length]; for (int i = 0; i < dt.length; i++) { e[i] = ext.createIV(dt[i]); } final String[] expected = { "00:00:00", "01:02:03", "10:20:30", "23:59:59" }; for (int i = 0; i < e.length; i++) { @SuppressWarnings("rawtypes") final BigdataValue valRoundTrip = ext.asValue((LiteralExtensionIV) e[i], vf); assertEquals(valRoundTrip.toString(), "\"" + expected[i] + ".000Z\"^^<http://www.w3.org/2001/XMLSchema#time>" ); } final IV<?, ?>[] a = doEncodeDecodeTest(e); doComparatorTest(e); }
Example #27
Source File: TestEncodeDecodeXSDDateIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Get a {@link DateTimeExtension} object. */ protected DateTimeExtension<BigdataValue> getDateTimeExtensionGMT(final BigdataValueFactory vf) { return new DateTimeExtension<BigdataValue>( new IDatatypeURIResolver() { public BigdataURI resolve(URI uri) { final BigdataURI buri = vf.createURI(uri.stringValue()); buri.setIV(newTermId(VTE.URI)); return buri; } },TimeZone.getTimeZone("GMT")); }
Example #28
Source File: TestEncodeDecodeGeoSpatialLiteralIVs.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test for round-trip of GeoSpatial literals of lat+lon+time * GeoSpatial literals. */ public void test_encodeDecodeLatLonTimeGeoSpatialLiterals() throws Exception { final BigdataValueFactory vf = BigdataValueFactoryImpl.getInstance("test"); final GeoSpatialLiteralExtension<BigdataValue> ext = getLatLonTimeGSLiteralExtension(vf); encodeDecodeGeoSpatialLiterals( vf, getDummyGeospatialLiteralsLatLonTime(vf, URI_DATATYPE_LAT_LON_TIME), ext); }
Example #29
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 19: * {@link Options#INLINE_TEXT_LITERALS} is false * {@link Options#INLINE_XSD_DATATYPE_LITERALS} is false * data loaded from file */ public void test_19() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, false /*inlineTextLiterals*/ , false /*inlineXSDDatatypeLiterals*/); loadData(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertFalse(values[0].getIV().isInline()); // http://s assertFalse(values[1].getIV().isInline()); // 1 assertFalse(values[2].getIV().isInline()); // "2"^^xsd:int assertFalse(values[3].getIV().isInline()); // 3.0 assertFalse(values[4].getIV().isInline()); // "4.0"^^xsd:double assertFalse(values[5].getIV().isInline()); // true assertFalse(values[6].getIV().isInline()); // "false"^^xsd:boolean assertFalse(values[7].getIV().isInline()); // "plain string" assertFalse(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertFalse(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #30
Source File: GeoSpatialDefaultLiteralSerializer.java From database with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public IV<?,?> serializeLatitude(final BigdataValueFactory vf, final Object latitude) { if (latitude instanceof Double) { return new XSDNumericIV((Double)latitude); } else if (latitude instanceof Long) { return new XSDNumericIV(((Long)latitude).doubleValue()); } else { throw new GeoSpatialSearchException("Latitude value expected to be either Double or Long"); } }