summaryrefslogtreecommitdiffstats
path: root/predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java
diff options
context:
space:
mode:
Diffstat (limited to 'predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java')
-rw-r--r--predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java b/predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java
new file mode 100644
index 00000000000..b51f648dcb6
--- /dev/null
+++ b/predicate-search/src/main/java/com/yahoo/search/predicate/index/conjunction/ConjunctionId.java
@@ -0,0 +1,28 @@
+// Copyright 2016 Yahoo Inc. 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;
+ }
+}