Remove unused classes

Original commit: elastic/x-pack-elasticsearch@f7aee26821
This commit is contained in:
Costin Leau 2018-02-02 17:14:54 +02:00
parent d51a7192af
commit 817c4759c6
2 changed files with 0 additions and 155 deletions

View File

@ -1,94 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.jdbc.util;
import org.elasticsearch.xpack.sql.jdbc.JdbcSQLException;
import java.sql.SQLException;
// taken from org.apache.lucene.util
abstract class ArrayUtils {
static byte[] grow(byte[] array, int minSize) throws SQLException {
assert minSize >= 0 : "size must be positive (got " + minSize + "): likely integer overflow?";
if (array.length < minSize) {
byte[] newArray = new byte[oversize(minSize, 1)];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
}
else return array;
}
static int oversize(int minTargetSize, int bytesPerElement) throws SQLException {
if (minTargetSize < 0) {
// catch usage that accidentally overflows int
throw new JdbcSQLException("invalid array size [" + minTargetSize + "]");
}
if (minTargetSize == 0) {
// wait until at least one element is requested
return 0;
}
// asymptotic exponential growth by 1/8th, favors
// spending a bit more CPU to not tie up too much wasted
// RAM:
int extra = minTargetSize >> 3;
if (extra < 3) {
// for very small arrays, where constant overhead of
// realloc is presumably relatively high, we grow
// faster
extra = 3;
}
int newSize = minTargetSize + extra;
// add 7 to allow for worst case byte alignment addition below:
if (newSize + 7 < 0) {
// int overflowed -- return max allowed array size
return Integer.MAX_VALUE;
}
if (Constants.JRE_IS_64BIT) {
// round up to 8 byte alignment in 64bit env
switch (bytesPerElement) {
case 4:
// round up to multiple of 2
return (newSize + 1) & 0x7ffffffe;
case 2:
// round up to multiple of 4
return (newSize + 3) & 0x7ffffffc;
case 1:
// round up to multiple of 8
return (newSize + 7) & 0x7ffffff8;
case 8:
// no rounding
default:
// odd (invalid?) size
return newSize;
}
}
else {
// round up to 4 byte alignment in 64bit env
switch (bytesPerElement) {
case 2:
// round up to multiple of 2
return (newSize + 1) & 0x7ffffffe;
case 1:
// round up to multiple of 4
return (newSize + 3) & 0x7ffffffc;
case 4:
case 8:
// no rounding
default:
// odd (invalid?) size
return newSize;
}
}
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.jdbc.util;
import java.util.StringTokenizer;
//taken from Apache Lucene
public abstract class Constants {
/** JVM vendor info. */
public static final String JVM_VENDOR = System.getProperty("java.vm.vendor");
public static final String JVM_VERSION = System.getProperty("java.vm.version");
public static final String JVM_NAME = System.getProperty("java.vm.name");
public static final String JVM_SPEC_VERSION = System.getProperty("java.specification.version");
/** The value of <tt>System.getProperty("java.version")</tt>. **/
public static final String JAVA_VERSION = System.getProperty("java.version");
public static final String OS_ARCH = System.getProperty("os.arch");
public static final String OS_VERSION = System.getProperty("os.version");
public static final String JAVA_VENDOR = System.getProperty("java.vendor");
private static final int JVM_MAJOR_VERSION;
private static final int JVM_MINOR_VERSION;
/** True iff running on a 64bit JVM */
public static final boolean JRE_IS_64BIT;
static {
final StringTokenizer st = new StringTokenizer(JVM_SPEC_VERSION, ".");
JVM_MAJOR_VERSION = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens()) {
JVM_MINOR_VERSION = Integer.parseInt(st.nextToken());
}
else {
JVM_MINOR_VERSION = 0;
}
boolean is64Bit = false;
final String x = System.getProperty("sun.arch.data.model");
if (x != null) {
is64Bit = x.contains("64");
}
else {
if (OS_ARCH != null && OS_ARCH.contains("64")) {
is64Bit = true;
}
else {
is64Bit = false;
}
}
JRE_IS_64BIT = is64Bit;
}
public static final boolean JRE_IS_MINIMUM_JAVA7 = JVM_MAJOR_VERSION > 1 || (JVM_MAJOR_VERSION == 1 && JVM_MINOR_VERSION >= 7);
public static final boolean JRE_IS_MINIMUM_JAVA8 = JVM_MAJOR_VERSION > 1 || (JVM_MAJOR_VERSION == 1 && JVM_MINOR_VERSION >= 8);
public static final boolean JRE_IS_MINIMUM_JAVA9 = JVM_MAJOR_VERSION > 1 || (JVM_MAJOR_VERSION == 1 && JVM_MINOR_VERSION >= 9);
}