Search in sources :

Example 1 with XSDIntegerIV

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());
}
Also used : GeoUtils.pointLiteral(org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointLiteral) Literal(org.openrdf.model.Literal) XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) BigInteger(java.math.BigInteger) LiteralExtensionIV(com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV) LexiconRelation(com.bigdata.rdf.lexicon.LexiconRelation) Test(org.junit.Test)

Example 2 with XSDIntegerIV

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);
}
Also used : XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) BigInteger(java.math.BigInteger)

Example 3 with XSDIntegerIV

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;
    }
}
Also used : XSDIntegerIV(com.bigdata.rdf.internal.impl.literal.XSDIntegerIV) BigInteger(java.math.BigInteger) UUID(java.util.UUID)

Aggregations

XSDIntegerIV (com.bigdata.rdf.internal.impl.literal.XSDIntegerIV)3 BigInteger (java.math.BigInteger)3 LiteralExtensionIV (com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV)1 LexiconRelation (com.bigdata.rdf.lexicon.LexiconRelation)1 UUID (java.util.UUID)1 Test (org.junit.Test)1 Literal (org.openrdf.model.Literal)1 GeoUtils.pointLiteral (org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointLiteral)1