aboutsummaryrefslogtreecommitdiffstats
path: root/predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java
blob: c330a5b414583c982c674d6092aa7df0b9c72b45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.predicate.index.conjunction;

/**
 * Conjunction id format:
 *   bit 31-1:  id/hash
 *   bit 0:     0: negated, 1: not negated
 *
 * @author bjorncs
 */
public class ConjunctionId {

    public static int compare(int c1, int c2) {
        return Integer.compare(c1 | 1, c2 | 1);
    }

    public static boolean equals(int c1, int c2) {
        return (c1 | 1) == (c2 | 1);
    }

    public static boolean isPositive(int c) {
        return (c & 1) == 1;
    }

    public static int nextId(int c) {
        return (c | 1) + 1;
    }

}