Some range index tests fail, possible bug #1201

Closed
olvidalo opened this Issue Dec 14, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@olvidalo
Contributor

olvidalo commented Dec 14, 2016

While preparing #1200 I've noticed that some of the range index tests fail since ce145ce. I've looked into the code and I couldn't really figure out if this is a bug in the test or in the actual code, but I suspect the latter. I haven't found an open issue for this so I wanted to bring it to your attention in case nobody noticed already, just to be sure.

All these failures seem to be related to one particular problem where a query to the index yields duplicate results for elements that only exist once. For example, in the range.xql test suite, for the data:

<address id="rüssel">
            <name>Rudi Rüssel</name>
            <street>Elefantenweg 67</street>
            <city code="65428">Rüsselsheim</city>
</address>
<address id="muh">
            <name>Berta  Muh
            </name>
            <street>Wiesenweg 14</street>
            <city code="65463">Almweide</city>
</address>   

the test

declare
    %test:args("üss")
    %test:assertEquals("Rüsselsheim")
    %test:args("ta M")
    %test:assertEquals("Almweide")
function rt:contains-string($name as xs:string) {
    //address[range:contains(name, $name)]/city/text()
};

Returns RüsselsheimRüsselsheim or AlmweideAlmweideresp., while there is only one element with the text each.

Maybe somebody knowledgable about the range index code could have a quick look into it. I've pasted the complete range index test results below, and all failures seem to indicate the same problem. Running it with a clean data directory produces the same results.

    [junit] XQuery Test suite: http://exist-db.org/xquery/range/test
    [junit] 	FAILED: contains-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	FAILED: contains-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Almweide' Actual: 'AlmweideAlmweide'
    [junit] 	FAILED: ends-with-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	FAILED: ends-with-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Almweide' Actual: 'AlmweideAlmweide'
    [junit] 	PASSED: equality-field-integer
    [junit] 	FAILED: equality-field-nested. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Hofthiergarten' Actual: 'HofthiergartenHofthiergarten'
    [junit] 	FAILED: equality-field-nested. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Hofthiergarten' Actual: 'HofthiergartenHofthiergarten'
    [junit] 	FAILED: equality-field-nested. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Dorfprozelten' Actual: 'DorfprozeltenDorfprozelten'
    [junit] 	PASSED: equality-fields
    [junit] 	PASSED: equality-fields
    [junit] 	PASSED: equality-fields-multi
    [junit] 	PASSED: equality-fields-multi
    [junit] 	PASSED: equality-fields-with-context
    [junit] 	PASSED: equality-fields-with-context
    [junit] 	FAILED: equality-int-attribute. assertEquals failed: wrong number of items returned by function. Expected: 2. Got: 4. Expected: 'Rüsselsheim Rüsselsheim' Actual: 'RüsselsheimRüsselsheimRüsselsheimRüsselsheim'
    [junit] 	ERROR: equality-qname-string-attribute. exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2. [at line 132, column 44, source: /Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] In function:
    [junit] 	rt:equality-qname-string-attribute(xs:string) [8:12:/Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] 	test:apply(function, item()*) [334:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:apply(function, element(), item()*) [241:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:call-test(function, element(), element()*) [142:32:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]. XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2..
    [junit] 	FAILED: equality-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	FAILED: equality-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Almweide' Actual: 'AlmweideAlmweide'
    [junit] 	PASSED: equality-string-collation
    [junit] 	PASSED: equality-string-collation
    [junit] 	ERROR: equality-string-self. exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2. [at line 117, column 33, source: /Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] In function:
    [junit] 	rt:equality-string-self(xs:string) [8:12:/Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] 	test:apply(function, item()*) [334:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:apply(function, element(), item()*) [241:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:call-test(function, element(), element()*) [142:32:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]. XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2..
    [junit] 	ERROR: equality-string-self. exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2. [at line 117, column 33, source: /Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] In function:
    [junit] 	rt:equality-string-self(xs:string) [8:12:/Users/mts/Dev/exist/extensions/indexes/range/test/src/xquery/range.xql]
    [junit] 	test:apply(function, item()*) [334:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:apply(function, element(), item()*) [241:9:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]
    [junit] 	test:call-test(function, element(), element()*) [142:32:jar:file:/Users/mts/Dev/exist/exist.jar!/org/exist/xquery/lib/xqsuite/xqsuite.xql]. XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: normalize-space($arg as xs:string?) xs:string. Expected cardinality: zero or one, got 2..
    [junit] 	FAILED: field-contains-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	PASSED: field-contains-string
    [junit] 	PASSED: field-ends-with-string
    [junit] 	PASSED: field-ends-with-string
    [junit] 	FAILED: field-matches-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	PASSED: field-matches-string
    [junit] 	PASSED: field-starts-with-string
    [junit] 	PASSED: field-starts-with-string
    [junit] 	FAILED: ge-integer. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: ge-integer. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	FAILED: ge-integer. assertEquals failed.. Expected: '3' Actual: '6'
    [junit] 	FAILED: ge-string. assertEquals failed.. Expected: '3' Actual: '6'
    [junit] 	FAILED: ge-string. assertEquals failed.. Expected: '4' Actual: '8'
    [junit] 	FAILED: ge-string. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: gt-integer. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	PASSED: gt-integer
    [junit] 	FAILED: gt-integer. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: gt-string. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: gt-string. assertEquals failed.. Expected: '3' Actual: '6'
    [junit] 	FAILED: gt-string. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	FAILED: le-integer. assertEquals failed.. Expected: '3' Actual: '6'
    [junit] 	FAILED: le-integer. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: le-string. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: le-string. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	FAILED: le-string. assertEquals failed.. Expected: '3' Actual: '6'
    [junit] 	FAILED: lt-integer. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: lt-integer. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	FAILED: lt-string. assertEquals failed.. Expected: '1' Actual: '2'
    [junit] 	PASSED: lt-string
    [junit] 	FAILED: lt-string. assertEquals failed.. Expected: '2' Actual: '4'
    [junit] 	FAILED: matches-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	PASSED: remove-document
    [junit] 	FAILED: starts-with-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Rüsselsheim' Actual: 'RüsselsheimRüsselsheim'
    [junit] 	FAILED: starts-with-string. assertEquals failed: wrong number of items returned by function. Expected: 1. Got: 2. Expected: 'Almweide' Actual: 'AlmweideAlmweide'
    [junit] 	PASSED: update-delete
    [junit] 	FAILED: update-insert. assertEquals failed: wrong number of items returned by function. Expected: 2. Got: 1. Expected: 'Uferweg 67 Bach' Actual: 'Bach'
    [junit] 	FAILED: update-replace. assertEquals failed.. Expected: 'Am Staudamm 3 Bach' Actual: 'Am Staudamm 3Am Staudamm 3'
    [junit] 	FAILED: update-value. assertEquals failed: wrong number of items returned by function. Expected: 2. Got: 3. Expected: 'Am Waldrand 4 Wiesental' Actual: 'Am Waldrand 4Am Waldrand 4'
    [junit] 8543 [WARN] BrokerPool: Could not clear ThreadLocals for thread: Signal Dispatcher
    [junit] 8543 [WARN] BrokerPool: Could not clear ThreadLocals for thread: Reference Handler
    [junit] 8543 [WARN] BrokerPool: Could not clear ThreadLocals for thread: Finalizer
    [junit] 8543 [WARN] BrokerPool: Could not clear ThreadLocals for thread: Thread-3
    [junit] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 8.194 sec
    [junit] Test xquery.range.RunTests FAILED
@adamretter

This comment has been minimized.

Show comment
Hide comment
@adamretter

adamretter Dec 14, 2016

Member

@wolfgangmm This is from the Range Index changes that you made. Any thoughts?

Member

adamretter commented Dec 14, 2016

@wolfgangmm This is from the Range Index changes that you made. Any thoughts?

wolfgangmm added a commit to wolfgangmm/exist that referenced this issue Jan 8, 2017

@dizzzz dizzzz closed this in #1213 Jan 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment