CompiledNode.java

1
/*******************************************************************************
2
 * Copyright (C) 2026, Leo Galambos
3
 * All rights reserved.
4
 * 
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 * 
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 
11
 * 2. Redistributions in binary form must reproduce the above copyright notice,
12
 *    this list of conditions and the following disclaimer in the documentation
13
 *    and/or other materials provided with the distribution.
14
 * 
15
 * 3. All advertising materials mentioning features or use of this software must
16
 *    display the following acknowledgement:
17
 *    This product includes software developed by the Egothor project.
18
 * 
19
 * 4. Neither the name of the copyright holder nor the names of its contributors
20
 *    may be used to endorse or promote products derived from this software
21
 *    without specific prior written permission.
22
 * 
23
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
 * POSSIBILITY OF SUCH DAMAGE.
34
 ******************************************************************************/
35
package org.egothor.stemmer.trie;
36
37
import java.util.Arrays;
38
39
/**
40
 * Immutable compiled trie node optimized for read access.
41
 *
42
 * <p>
43
 * The returned arrays are the internal backing storage of the compiled node.
44
 * They are exposed for efficient access by closely related trie infrastructure
45
 * and therefore must never be modified by callers.
46
 *
47
 * @param <V>           value type
48
 * @param edgeLabels    internal edge label array
49
 * @param children      internal child array
50
 * @param orderedValues internal ordered values array
51
 * @param orderedCounts internal ordered counts array
52
 */
53
public record CompiledNode<V>(char[] edgeLabels, CompiledNode<V>[] children, V[] orderedValues, int... orderedCounts) {
54
55
    /**
56
     * Finds a child for the supplied edge character.
57
     *
58
     * @param edge edge character
59
     * @return child node, or {@code null} if absent
60
     */
61
    public CompiledNode<V> findChild(final char edge) {
62
        final int index = Arrays.binarySearch(this.edgeLabels, edge);
63 2 1. findChild : negated conditional → KILLED
2. findChild : changed conditional boundary → KILLED
        if (index < 0) {
64
            return null;
65
        }
66 1 1. findChild : replaced return value with null for org/egothor/stemmer/trie/CompiledNode::findChild → KILLED
        return this.children[index];
67
    }
68
}

Mutations

63

1.1
Location : findChild
Killed by : org.egothor.stemmer.FrequencyTrieTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.FrequencyTrieTest]/[method:emptyTrieReturnsNullEmptyArrayAndEmptyEntries()]
negated conditional → KILLED

2.2
Location : findChild
Killed by : org.egothor.stemmer.FrequencyTrieTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.FrequencyTrieTest]/[method:rankedReductionKeepsNodesSeparateWhenOrderingDiffers()]
changed conditional boundary → KILLED

66

1.1
Location : findChild
Killed by : org.egothor.stemmer.FrequencyTrieTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.FrequencyTrieTest]/[method:rankedReductionKeepsNodesSeparateWhenOrderingDiffers()]
replaced return value with null for org/egothor/stemmer/trie/CompiledNode::findChild → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1