You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@marmotta.apache.org by FRANCISCO XAVIER SUMBA TORAL <xa...@ucuenca.ec> on 2015/06/01 08:26:16 UTC
[jira] [Commented] (MARMOTTA-584) Add GeoSPARQL support to KiWi triple store
I am trying to register a function ( SfIntersectsFunction) , such as fulltextquery function, using nativefunction interface , but it no register.
IN SfIntersectsFunction.java
public class SfIntersectsFunction implements NativeFunction {
// auto-register for SPARQL environment
static {
if(!FunctionRegistry.getInstance().has(FN_GEOSPARQL .SF_INTERSECTS.toString())) {
FunctionRegistry.getInstance().add(new SfIntersectsFunction());
}
}
@Override
public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException {
throw new UnsupportedOperationException("cannot evaluate in-memory, needs to be supported by the database");
}
@Override
public String getURI() {
return FN_GEOSPARQL .SF_INTERSECTS.toString();
}
/**
* Return true if this function has available native support for the given dialect
*
* @param dialect
* @return
*/
@Override
public boolean isSupported(KiWiDialect dialect) {
return dialect instanceof PostgreSQLDialect;
}
/**
* Return a string representing how this function is translated into SQL in the given dialect
*
* @param dialect
* @param args
* @return
*/
@Override
public String getNative(KiWiDialect dialect, String... args) {
if(dialect instanceof PostgreSQLDialect) {
if(args.length == 2) {
return String.format("(to_tsvector('simple' :: regconfig,%1$s) @@ plainto_tsquery('simple' :: regconfig,%2$s))", args[0], args[1]);
} else if(args.length == 3) {
return String.format("(to_tsvector(kiwi_ft_lang(%3$s) :: regconfig, %1$s) @@ plainto_tsquery(kiwi_ft_lang(%3$s) :: regconfig, %2$s))", args[0], args[1], args[2]);
}
}
throw new UnsupportedOperationException("fulltext search not supported by dialect "+dialect);
}
/**
* Get the return type of the function. This is needed for SQL type casting inside KiWi.
*
* @return
*/
@Override
public ValueType getReturnType() {
return ValueType.BOOL;
}
/**
* Get the argument type of the function for the arg'th argument (starting to count at 0).
* This is needed for SQL type casting inside KiWi.
*
* @param arg
* @return
*/
@Override
public ValueType getArgumentType(int arg) {
return ValueType.STRING;
}
/**
* Return the minimum number of arguments this function requires.
*
* @return
*/
@Override
public int getMinArgs() {
return 2;
}
/**
* Return the maximum number of arguments this function can take
*
* @return
*/
@Override
public int getMaxArgs() {
return 3;
}
}
IN FN_GEOSPARQL.java
public class FN_GEOSPARQL {
public static final String NAMESPACE = "http://www.opengis.net/def/function/geosparql/ <http://www.opengis.net/def/function/geosparql/>";
public static final String PREFIX = "geof";
public static final Namespace NS = new NamespaceImpl(PREFIX, NAMESPACE);
//BOOLEAN FUNCTIONS
public static final URI SF_INTERSECTS;
static {
ValueFactory f = new ValueFactoryImpl();
SF_INTERSECTS = f.createURI(NAMESPACE,"sfIntersects");
}
do I need some aditional step for registering the function?
My first intention is to register the function to avoid the error
org.openrdf.query.QueryEvaluationException: Unknown function 'http://www.opengis <http://www.opengis/>
.net/def/function/geosparql/sfIntersects'
with this query
PREFIX geof: <http://www.opengis.net/def/function/geosparql/ <http://www.opengis.net/def/function/geosparql/>>
SELECT ?subject ?property WHERE {
?subject a ?object.
?subject ?property ?object.
FILTER( geof:sfIntersects("valor1", "valor2") )
}
is right what I am trying to do?
Thanks
Re: [jira] [Commented] (MARMOTTA-584) Add GeoSPARQL support to KiWi triple store
Posted by FRANCISCO XAVIER SUMBA TORAL <xa...@ucuenca.ec>.
Que mas, ya respondió Sergio y esta feísimo como ha hecho Sebastian. Ahora si estoy perdido a nivel de base de datos esta cagado.
> El 3/6/2015, a las 3:40, Sergio Fernández <wi...@apache.org> escribió:
>
> Hi Francisco,
>
> KiWi extensions are registered using Java ServiceLoader [1]. I'd recommend
> you to check the original email where Sebastian reported the new feature
> [2].
>
> Hope that helps.
>
> Cheers,
>
> [1] https://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html <https://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html>
> [2] http://markmail.org/message/dnshapfwr37nyfc5 <http://markmail.org/message/dnshapfwr37nyfc5>
>
>
>
> On Mon, Jun 1, 2015 at 8:26 AM, FRANCISCO XAVIER SUMBA TORAL <
> xavier.sumba93@ucuenca.ec <ma...@ucuenca.ec>> wrote:
>
>> I am trying to register a function ( SfIntersectsFunction) , such as
>> fulltextquery function, using nativefunction interface , but it no
>> register.
>>
>>
>> IN SfIntersectsFunction.java
>>
>> public class SfIntersectsFunction implements NativeFunction {
>>
>> // auto-register for SPARQL environment
>> static {
>> if(!FunctionRegistry.getInstance().has(FN_GEOSPARQL
>> .SF_INTERSECTS.toString())) {
>> FunctionRegistry.getInstance().add(new SfIntersectsFunction());
>> }
>> }
>>
>> @Override
>> public Value evaluate(ValueFactory valueFactory, Value... args) throws
>> ValueExprEvaluationException {
>> throw new UnsupportedOperationException("cannot evaluate
>> in-memory, needs to be supported by the database");
>> }
>>
>> @Override
>> public String getURI() {
>> return FN_GEOSPARQL .SF_INTERSECTS.toString();
>> }
>>
>>
>> /**
>> * Return true if this function has available native support for the
>> given dialect
>> *
>> * @param dialect
>> * @return
>> */
>> @Override
>> public boolean isSupported(KiWiDialect dialect) {
>> return dialect instanceof PostgreSQLDialect;
>> }
>>
>> /**
>> * Return a string representing how this function is translated into
>> SQL in the given dialect
>> *
>> * @param dialect
>> * @param args
>> * @return
>> */
>> @Override
>> public String getNative(KiWiDialect dialect, String... args) {
>> if(dialect instanceof PostgreSQLDialect) {
>> if(args.length == 2) {
>> return String.format("(to_tsvector('simple' ::
>> regconfig,%1$s) @@ plainto_tsquery('simple' :: regconfig,%2$s))", args[0],
>> args[1]);
>> } else if(args.length == 3) {
>> return String.format("(to_tsvector(kiwi_ft_lang(%3$s) ::
>> regconfig, %1$s) @@ plainto_tsquery(kiwi_ft_lang(%3$s) :: regconfig,
>> %2$s))", args[0], args[1], args[2]);
>> }
>>
>> }
>> throw new UnsupportedOperationException("fulltext search not
>> supported by dialect "+dialect);
>> }
>>
>> /**
>> * Get the return type of the function. This is needed for SQL type
>> casting inside KiWi.
>> *
>> * @return
>> */
>> @Override
>> public ValueType getReturnType() {
>> return ValueType.BOOL;
>> }
>>
>> /**
>> * Get the argument type of the function for the arg'th argument
>> (starting to count at 0).
>> * This is needed for SQL type casting inside KiWi.
>> *
>> * @param arg
>> * @return
>> */
>> @Override
>> public ValueType getArgumentType(int arg) {
>> return ValueType.STRING;
>> }
>>
>> /**
>> * Return the minimum number of arguments this function requires.
>> *
>> * @return
>> */
>> @Override
>> public int getMinArgs() {
>> return 2;
>> }
>>
>> /**
>> * Return the maximum number of arguments this function can take
>> *
>> * @return
>> */
>> @Override
>> public int getMaxArgs() {
>> return 3;
>> }
>> }
>>
>>
>>
>>
>>
>>
>> IN FN_GEOSPARQL.java
>>
>>
>> public class FN_GEOSPARQL {
>>
>> public static final String NAMESPACE = "
>> http://www.opengis.net/def/function/geosparql/ <
>> http://www.opengis.net/def/function/geosparql/ <http://www.opengis.net/def/function/geosparql/>>";
>>
>>
>> public static final String PREFIX = "geof";
>>
>>
>> public static final Namespace NS = new NamespaceImpl(PREFIX,
>> NAMESPACE);
>>
>> //BOOLEAN FUNCTIONS
>> public static final URI SF_INTERSECTS;
>>
>>
>> static {
>> ValueFactory f = new ValueFactoryImpl();
>>
>> SF_INTERSECTS = f.createURI(NAMESPACE,"sfIntersects");
>>
>> }
>>
>>
>>
>> do I need some aditional step for registering the function?
>>
>> My first intention is to register the function to avoid the error
>>
>> org.openrdf.query.QueryEvaluationException: Unknown function '
>> http://www.opengis <http://www.opengis/> <http://www.opengis/ <http://www.opengis/>>
>> .net/def/function/geosparql/sfIntersects'
>>
>>
>> with this query
>>
>> PREFIX geof: <http://www.opengis.net/def/function/geosparql/ <http://www.opengis.net/def/function/geosparql/> <
>> http://www.opengis.net/def/function/geosparql/ <http://www.opengis.net/def/function/geosparql/>>>
>> SELECT ?subject ?property WHERE {
>> ?subject a ?object.
>> ?subject ?property ?object.
>> FILTER( geof:sfIntersects("valor1", "valor2") )
>> }
>>
>> is right what I am trying to do?
>>
>>
>>
>> Thanks
>
>
>
>
> --
> Sergio Fernández
> Partner Technology Manager
> Redlink GmbH
> m: +43 6602747925
> e: sergio.fernandez@redlink.co <ma...@redlink.co>
> w: http://redlink.co <http://redlink.co/>
Re: [jira] [Commented] (MARMOTTA-584) Add GeoSPARQL support to KiWi triple store
Posted by Sergio Fernández <wi...@apache.org>.
Hi Francisco,
KiWi extensions are registered using Java ServiceLoader [1]. I'd recommend
you to check the original email where Sebastian reported the new feature
[2].
Hope that helps.
Cheers,
[1] https://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html
[2] http://markmail.org/message/dnshapfwr37nyfc5
On Mon, Jun 1, 2015 at 8:26 AM, FRANCISCO XAVIER SUMBA TORAL <
xavier.sumba93@ucuenca.ec> wrote:
> I am trying to register a function ( SfIntersectsFunction) , such as
> fulltextquery function, using nativefunction interface , but it no
> register.
>
>
> IN SfIntersectsFunction.java
>
> public class SfIntersectsFunction implements NativeFunction {
>
> // auto-register for SPARQL environment
> static {
> if(!FunctionRegistry.getInstance().has(FN_GEOSPARQL
> .SF_INTERSECTS.toString())) {
> FunctionRegistry.getInstance().add(new SfIntersectsFunction());
> }
> }
>
> @Override
> public Value evaluate(ValueFactory valueFactory, Value... args) throws
> ValueExprEvaluationException {
> throw new UnsupportedOperationException("cannot evaluate
> in-memory, needs to be supported by the database");
> }
>
> @Override
> public String getURI() {
> return FN_GEOSPARQL .SF_INTERSECTS.toString();
> }
>
>
> /**
> * Return true if this function has available native support for the
> given dialect
> *
> * @param dialect
> * @return
> */
> @Override
> public boolean isSupported(KiWiDialect dialect) {
> return dialect instanceof PostgreSQLDialect;
> }
>
> /**
> * Return a string representing how this function is translated into
> SQL in the given dialect
> *
> * @param dialect
> * @param args
> * @return
> */
> @Override
> public String getNative(KiWiDialect dialect, String... args) {
> if(dialect instanceof PostgreSQLDialect) {
> if(args.length == 2) {
> return String.format("(to_tsvector('simple' ::
> regconfig,%1$s) @@ plainto_tsquery('simple' :: regconfig,%2$s))", args[0],
> args[1]);
> } else if(args.length == 3) {
> return String.format("(to_tsvector(kiwi_ft_lang(%3$s) ::
> regconfig, %1$s) @@ plainto_tsquery(kiwi_ft_lang(%3$s) :: regconfig,
> %2$s))", args[0], args[1], args[2]);
> }
>
> }
> throw new UnsupportedOperationException("fulltext search not
> supported by dialect "+dialect);
> }
>
> /**
> * Get the return type of the function. This is needed for SQL type
> casting inside KiWi.
> *
> * @return
> */
> @Override
> public ValueType getReturnType() {
> return ValueType.BOOL;
> }
>
> /**
> * Get the argument type of the function for the arg'th argument
> (starting to count at 0).
> * This is needed for SQL type casting inside KiWi.
> *
> * @param arg
> * @return
> */
> @Override
> public ValueType getArgumentType(int arg) {
> return ValueType.STRING;
> }
>
> /**
> * Return the minimum number of arguments this function requires.
> *
> * @return
> */
> @Override
> public int getMinArgs() {
> return 2;
> }
>
> /**
> * Return the maximum number of arguments this function can take
> *
> * @return
> */
> @Override
> public int getMaxArgs() {
> return 3;
> }
> }
>
>
>
>
>
>
> IN FN_GEOSPARQL.java
>
>
> public class FN_GEOSPARQL {
>
> public static final String NAMESPACE = "
> http://www.opengis.net/def/function/geosparql/ <
> http://www.opengis.net/def/function/geosparql/>";
>
>
> public static final String PREFIX = "geof";
>
>
> public static final Namespace NS = new NamespaceImpl(PREFIX,
> NAMESPACE);
>
> //BOOLEAN FUNCTIONS
> public static final URI SF_INTERSECTS;
>
>
> static {
> ValueFactory f = new ValueFactoryImpl();
>
> SF_INTERSECTS = f.createURI(NAMESPACE,"sfIntersects");
>
> }
>
>
>
> do I need some aditional step for registering the function?
>
> My first intention is to register the function to avoid the error
>
> org.openrdf.query.QueryEvaluationException: Unknown function '
> http://www.opengis <http://www.opengis/>
> .net/def/function/geosparql/sfIntersects'
>
>
> with this query
>
> PREFIX geof: <http://www.opengis.net/def/function/geosparql/ <
> http://www.opengis.net/def/function/geosparql/>>
> SELECT ?subject ?property WHERE {
> ?subject a ?object.
> ?subject ?property ?object.
> FILTER( geof:sfIntersects("valor1", "valor2") )
> }
>
> is right what I am trying to do?
>
>
>
> Thanks
--
Sergio Fernández
Partner Technology Manager
Redlink GmbH
m: +43 6602747925
e: sergio.fernandez@redlink.co
w: http://redlink.co