use of com.bigdata.rdf.internal.impl.literal.XSDIntegerIV in project wikidata-query-rdf by wikimedia.
the class WikibaseGeoUnitTest method testInteger.
@Test
@SuppressWarnings("rawtypes")
public void testInteger() {
LexiconRelation rel = store().getLexiconRelation();
Literal l = pointLiteral("Point(40.4426 -80.0068)");
LiteralExtensionIV iv = (LiteralExtensionIV) rel.getInlineIV(l);
assertEquals(GeoSparql.WKT_LITERAL, iv.getExtensionIV().getValue().toString());
assertEquals(new XSDIntegerIV(new BigInteger("1008819921758573694187894119050371595694851885687493623808")), iv.getDelegate());
}
use of com.bigdata.rdf.internal.impl.literal.XSDIntegerIV in project wikidata-query-rdf by wikimedia.
the class InlineFixedWidthHexIntegerURIHandler method getLocalNameFromDelegate.
@Override
public String getLocalNameFromDelegate(AbstractLiteralIV<BigdataLiteral, ?> delegate) {
final BigInteger bigintVal;
if (delegate instanceof XSDIntegerIV) {
// Getting BigInteger directly from IV
bigintVal = ((XSDIntegerIV<?>) delegate).getInlineValue();
} else {
// Need to recode localName from IV
final String intStr = super.getLocalNameFromDelegate(delegate);
// radix 10 here because localName from delegate is encoded to decimal number by XSDIntegerIV
bigintVal = new BigInteger(intStr, 10);
}
return toFixedWidthHexString(bigintVal);
}
use of com.bigdata.rdf.internal.impl.literal.XSDIntegerIV in project wikidata-query-rdf by wikimedia.
the class WikibaseStyleStatementInlineUriHandler method inlineIvFrom.
/**
* Build the delegate holding the uri from the localname with the prefix
* already resolved into signum.
*/
@SuppressWarnings("rawtypes")
private static AbstractLiteralIV inlineIvFrom(int signum, String localName) {
int firstDash = localName.indexOf('-');
long entity = Long.parseLong(localName.substring(1, firstDash), 10);
try {
UUID u = UUID.fromString(localName.substring(firstDash + 1));
BigInteger i = BigInteger.valueOf(signum * entity);
i = i.shiftLeft(Long.SIZE).or(unsigned(u.getMostSignificantBits()));
i = i.shiftLeft(Long.SIZE).or(unsigned(u.getLeastSignificantBits()));
return new XSDIntegerIV(i);
} catch (IllegalArgumentException e) {
log.warn("tmp", e);
return null;
}
}
Aggregations