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. Neither the name of the copyright holder nor the names of its contributors
16
 *    may be used to endorse or promote products derived from this software
17
 *    without specific prior written permission.
18
 * 
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 ******************************************************************************/
31
package org.egothor.stemmer.trie;
32
33
import java.util.Arrays;
34
35
/**
36
 * Immutable compiled trie node optimized for read access.
37
 *
38
 * <p>
39
 * The returned arrays are the internal backing storage of the compiled node.
40
 * They are exposed for efficient access by closely related trie infrastructure
41
 * and therefore must never be modified by callers.
42
 *
43
 * @param <V>           value type
44
 * @param edgeLabels    internal edge label array
45
 * @param children      internal child array
46
 * @param orderedValues internal ordered values array
47
 * @param orderedCounts internal ordered counts array
48
 */
49
public record CompiledNode<V>(char[] edgeLabels, CompiledNode<V>[] children, V[] orderedValues, int... orderedCounts) {
50
51
    /**
52
     * Finds a child for the supplied edge character.
53
     *
54
     * @param edge edge character
55
     * @return child node, or {@code null} if absent
56
     */
57
    public CompiledNode<V> findChild(final char edge) {
58
        final int index = Arrays.binarySearch(this.edgeLabels, edge);
59 2 1. findChild : negated conditional → KILLED
2. findChild : changed conditional boundary → KILLED
        if (index < 0) {
60
            return null;
61
        }
62 1 1. findChild : replaced return value with null for org/egothor/stemmer/trie/CompiledNode::findChild → KILLED
        return this.children[index];
63
    }
64
}

Mutations

59

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

62

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