Previous topic  Top  Next topic  Print this Topic

Handling of NULL Values: fillNULL



A ObjectLogic query is only valid if all of its variables are included. If any variable cannot be bound, the bindings of the other variables do not form a result.





Jerry[hasName->"Jerry Mouse"].                


?- ?X:Person AND ?X[hasName->?Y].                


X             Y

Jerry              "Jerry Mouse"                

For some applications this is not the behaviour the user would expect. From database systems they are used to see:

X             Y

Jerry              "Jerry Mouse"

Tom                null                

To enable OntoBroker to fill out the missing results with such a placeholder the query option "fillnull" can be used. This feature fills up the missing variable bindings with a constant "null".


Query options in ObjectLogic are written as an annotation in front of the query



@{q1, options[fillnull]} ?- ?X:Person AND ?X[hasName->?Y].


X                    Y

Jerry                "Jerry Mouse"

Tom              null                


The query must allow the inferencing algorithm to first of all ground all instances and relations before calling the aggregation.

@{q1, options[fillnull]} ?- ?X[hasName->?Y].

This will result in an error such as the following:

[ERROR]: error on server encountered: com.ontoprise.exception.

LiteralOrderingException: Could not order literals so that

the program is evaluable. This could have the following

reasons: a) a input signature for at least one Built-in could

not be satisfied or b) the program contains unsafe rules

which could not be ordered so that they are top-down evaluable.

Reason: The variable ?X cannot be bound with values, so there is no ordering available that the aggregation can be called (hasName is a hidden aggregation when using fillnull).

Using instead:

@{q1, options[fillnull]} ?- ?X:Person AND ?X[hasName->?Y].

Will deliver the results, as X can be bound with the available "instance of" information. Do not use any built-ins for attribute/relation values:


@{options[fillnull]}?- ?X:C[a->?Y] and _unify(?Y,b).

Built-ins can´t cope with the null-value. Only the _filter(?Y,b) Built-in will work.

Fillnull ignores the assigned values of a variable:

@{options[fillnull]}?- p(?Y)  and ?X:C[a->?Y] .

The assigned value of ?Y is ignored.