Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Lichtenberger committed Jul 14, 2023
2 parents d0282fd + 1e51ae5 commit 036e664
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 51 deletions.
100 changes: 100 additions & 0 deletions Uncommitted_changes_before_rebase_[Changes].patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Subject: [PATCH] Uncommitted changes before rebase [Changes]
---
Index: bundles/sirix-core/src/main/java/org/sirix/utils/IntToObjectMap.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/sirix-core/src/main/java/org/sirix/utils/IntToObjectMap.java b/bundles/sirix-core/src/main/java/org/sirix/utils/IntToObjectMap.java
--- a/bundles/sirix-core/src/main/java/org/sirix/utils/IntToObjectMap.java
+++ b/bundles/sirix-core/src/main/java/org/sirix/utils/IntToObjectMap.java
@@ -1,7 +1,11 @@
package org.sirix.utils;

+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Arrays;
import java.util.Iterator;
+import java.util.NoSuchElementException;

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -137,9 +141,13 @@

@SuppressWarnings("unchecked")
public T next() {
+ if (!iterator.hasNext()) {
+ throw new NoSuchElementException();
+ }
return (T) values[iterator.next()];
}

+ @Override
public void remove() {
iterator.remove();
}
@@ -151,7 +159,7 @@
private static int defaultCapacity = 16;

/**
- * Holds the base hash entries. if the capacity is 2^N, than the base hash
+ * Holds the base hash entries. if the capacity is 2^N, thn the base hash
* holds 2^(N+1). It can hold
*/
int[] baseHash;
@@ -301,7 +309,7 @@
// And setting all the <code>next[i]</code> to point at
// <code>i+1</code>.
for (int i = 1; i < this.capacity; ) {
- next[i] = ++i;
+ next[i] = i + 1;
}

// Surly, the last one should point to the 'Ground'.
@@ -329,8 +337,7 @@
* false otherwise.
*/
public boolean containsValue(Object o) {
- for (Iterator<T> iterator = iterator(); iterator.hasNext(); ) {
- T object = iterator.next();
+ for (T object : this) {
if (object.equals(o)) {
return true;
}
@@ -353,7 +360,7 @@

// while the index does not point to the 'Ground'
while (localIndex != 0) {
- // returns the index found in case of of a matching key.
+ // returns the index found in case of a matching key.
if (keys[localIndex] == key) {
return localIndex;
}
@@ -384,7 +391,7 @@

// while the index does not point to the 'Ground'
while (index != 0) {
- // returns the index found in case of of a matching key.
+ // returns the index found in case of a matching key.
if (keys[index] == key) {
return index;
}
@@ -465,7 +472,7 @@
@SuppressWarnings("unused")
private void printBaseHash() {
for (int i = 0; i < this.baseHash.length; i++) {
- System.out.println(i + ".\t" + baseHash[i]);
+ LOGGER.info("{}.\t{}", i, baseHash[i]);
}
}

@@ -491,7 +498,7 @@

// Is there enough room for a new pair?
if (size == capacity) {
- // No? Than grow up!
+ // No? Then grow up!
grow();
}

Empty file.
83 changes: 49 additions & 34 deletions bundles/sirix-core/src/main/java/org/sirix/utils/Calc.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

/**
Expand All @@ -13,9 +14,11 @@
*
*/
public final class Calc {
private Calc() {}

private static final Charset UTF8 = Charset.forName("UTF-8");
private static final int NONENULL = Integer.MAX_VALUE;
private static final String ERROR_MSG = "Input byte array cannot be null";
private static final Charset UTF8 = StandardCharsets.UTF_8;
private static final int MAX_INT = Integer.MAX_VALUE;
public static byte[] fromBigDecimal(BigDecimal i) {
BigInteger bi = i.unscaledValue();
byte[] tmp = bi.toByteArray();
Expand All @@ -38,6 +41,9 @@ public static byte[] fromBigDecimal(BigDecimal i) {
}

public static BigDecimal toBigDecimal(byte[] b) {
if (b == null) {
throw new IllegalArgumentException(ERROR_MSG);
}
if ((b[0] & 0x80) == 0) {
// bit 0 not set: 6 bits are sufficient
// to encode scale unsigned
Expand Down Expand Up @@ -103,6 +109,9 @@ public static void fromString(String s, byte[] b, int off) {
}

public static int toUIntVar(byte[] b) {
if (b == null) {
throw new IllegalArgumentException(ERROR_MSG);
}
int len = b.length;
if (len == 1) {
return b[0] & 0xFF;
Expand Down Expand Up @@ -152,6 +161,9 @@ public static int toInt(byte[] b) {
}

public static int toInt(byte[] b, int off) {
if (b == null) {
throw new IllegalArgumentException(ERROR_MSG);
}
return ((b[off++] & 0xFF) << 24) | ((b[off++] & 0xFF) << 16) | ((b[off++] & 0xFF) << 8)
| (b[off++] & 0xFF);
}
Expand All @@ -175,6 +187,9 @@ public static long toLong(byte[] b) {
}

public static long toLong(byte[] b, int off) {
if (b == null) {
throw new IllegalArgumentException(ERROR_MSG);
}
return ((((long) b[off++] & 0xFF) << 56) | (((long) b[off++] & 0xFF) << 48)
| (((long) b[off++] & 0xFF) << 40) | (((long) b[off++] & 0xFF) << 32)
| (((long) b[off++] & 0xFF) << 24) | (((long) b[off++] & 0xFF) << 16)
Expand Down Expand Up @@ -232,8 +247,8 @@ public static void fromDouble(float i, byte[] b, int off) {

public static int compare(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);

int len1 = v1.length;
int len2 = v2.length;
Expand All @@ -252,8 +267,8 @@ public static int compare(byte[] v1, byte[] v2) {

public static int compare(byte[] v1, int off1, int len1, byte[] v2, int off2, int len2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
int len = Math.min(len1, len2);
int pos = -1;
while (++pos < len) {
Expand All @@ -274,21 +289,21 @@ public static int compare(byte[] v1, int off1, int len1, byte[] v2, int off2, in
* @param v2 the second value to be tested.
* @return -1, if v2 is null but not v1, 1 for vice versa, 0 for both being null, and int max for when neither is null.
*/
private final static int comparsionOfNull(byte[] v1, byte[] v2){
private static int comparisonOfNull(byte[] v1, byte[] v2){
if(v1 == null && v2 == null)
return 0;
else if(v1 != null && v2 == null)
return -1;
else if(v1 == null && v2 != null)
else if(v1 == null)
return 1;
else
return NONENULL;
return MAX_INT;
}

public final static int compareAsPrefix(byte[] v1, byte[] v2) {
public static int compareAsPrefix(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);

int len1 = v1.length;
int len2 = v2.length;
Expand All @@ -309,8 +324,8 @@ public static int compareU(byte[] v1, byte[] v2) {

public static int compareU(byte[] v1, int off1, int len1, byte[] v2, int off2, int len2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
int len = Math.min(len1, len2);
int pos = -1;
while (++pos < len) {
Expand All @@ -323,10 +338,10 @@ public static int compareU(byte[] v1, int off1, int len1, byte[] v2, int off2, i
return len1 - len2;
}

public final static int compareUAsPrefix(byte[] v1, byte[] v2) {
public static int compareUAsPrefix(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != Integer.MAX_VALUE)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != Integer.MAX_VALUE)
return comparisonOfNull(v1, v2);
int len1 = v1.length;
int len2 = v2.length;
int len = Math.min(len1, len2);
Expand All @@ -343,11 +358,11 @@ public final static int compareUAsPrefix(byte[] v1, byte[] v2) {

public static int compareUIntVar(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
int i1 = toUIntVar(v1);
int i2 = toUIntVar(v2);
return (i1 < i2) ? -1 : (i1 == i2) ? 0 : 1;
return Integer.compare(i1, i2);
}

public static int compareInt(byte[] v1, byte[] v2) {
Expand All @@ -357,11 +372,11 @@ public static int compareInt(byte[] v1, byte[] v2) {

public static int compareInt(byte[] v1, int off1, byte[] v2, int off2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
int i1 = toInt(v1, off1);
int i2 = toInt(v2, off2);
return (i1 < i2) ? -1 : (i1 == i2) ? 0 : 1;
return Integer.compare(i1, i2);
}

public static int compareLong(byte[] v1, byte[] v2) {
Expand All @@ -371,44 +386,44 @@ public static int compareLong(byte[] v1, byte[] v2) {

public static int compareLong(byte[] v1, int off1, byte[] v2, int off2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
long i1 = toLong(v1, off1);
long i2 = toLong(v2, off2);
return (i1 < i2) ? -1 : (i1 == i2) ? 0 : 1;
return Long.compare(i1, i2);
}

public static int compareDouble(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
double d1 = toDouble(v1);
double d2 = toDouble(v2);
return Double.compare(d1, d2);
}

public static int compareFloat(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
float f1 = toFloat(v1);
float f2 = toFloat(v2);
return Float.compare(f1, f2);
}

public static int compareBigInteger(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if(comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if(comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
BigInteger i1 = toBigInteger(v1);
BigInteger i2 = toBigInteger(v2);
return i1.compareTo(i2);
}

public static int compareBigDecimal(byte[] v1, byte[] v2) {
// a null value is interpreted as EOF (= highest possible value)
if (comparsionOfNull(v1, v2) != NONENULL)
return comparsionOfNull(v1, v2);
if (comparisonOfNull(v1, v2) != MAX_INT)
return comparisonOfNull(v1, v2);
BigDecimal i1 = toBigDecimal(v1);
BigDecimal i2 = toBigDecimal(v2);
return i1.compareTo(i2);
Expand Down
Loading

0 comments on commit 036e664

Please sign in to comment.