diff --git a/pom.xml b/pom.xml
index 5180e84..f87f4ff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,8 +31,6 @@
1.18.14
0.15.0
- 1.13
- 0.9.0
3.11.0
0.5.11
2.10.0
@@ -70,16 +68,6 @@
${lombok.version}
provided
-
- commons-codec
- commons-codec
- ${commons-codec.version}
-
-
- com.hierynomus
- smbj
- ${hierynomus.version}
-
com.google.protobuf
protobuf-java
diff --git a/src/main/java/com/jd/jdbc/common/Hex.java b/src/main/java/com/jd/jdbc/common/Hex.java
new file mode 100644
index 0000000..1f369af
--- /dev/null
+++ b/src/main/java/com/jd/jdbc/common/Hex.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.jd.jdbc.common;
+
+public class Hex {
+
+ /**
+ * Used to build output as Hex
+ */
+ private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
+ 'e', 'f'};
+
+ /**
+ * Used to build output as Hex
+ */
+ private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
+ 'E', 'F'};
+
+ /**
+ * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned
+ * String will be double the length of the passed array, as it takes two characters to represent any given byte.
+ *
+ * @param data a byte[] to convert to Hex characters
+ * @return A String containing lower-case hexadecimal characters
+ * @since 1.4
+ */
+ public static String encodeHexString(final byte[] data) {
+ return new String(encodeHex(data));
+ }
+
+
+ /**
+ * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+ * The returned array will be double the length of the passed array, as it takes two characters to represent any
+ * given byte.
+ *
+ * @param data a byte[] to convert to Hex characters
+ * @return A char[] containing lower-case hexadecimal characters
+ */
+ public static char[] encodeHex(final byte[] data) {
+ return encodeHex(data, true);
+ }
+
+
+ /**
+ * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+ * The returned array will be double the length of the passed array, as it takes two characters to represent any
+ * given byte.
+ *
+ * @param data a byte[] to convert to Hex characters
+ * @param toLowerCase true
converts to lowercase, false
to uppercase
+ * @return A char[] containing hexadecimal characters in the selected case
+ * @since 1.4
+ */
+ public static char[] encodeHex(final byte[] data, final boolean toLowerCase) {
+ return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
+ }
+
+
+ /**
+ * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+ * The returned array will be double the length of the passed array, as it takes two characters to represent any
+ * given byte.
+ *
+ * @param data a byte[] to convert to Hex characters
+ * @param toDigits the output alphabet (must contain at least 16 chars)
+ * @return A char[] containing the appropriate characters from the alphabet For best results, this should be either
+ * upper- or lower-case hex.
+ * @since 1.4
+ */
+ protected static char[] encodeHex(final byte[] data, final char[] toDigits) {
+ final int l = data.length;
+ final char[] out = new char[l << 1];
+ // two characters form the hex value.
+ for (int i = 0, j = 0; i < l; i++) {
+ out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
+ out[j++] = toDigits[0x0F & data[i]];
+ }
+ return out;
+ }
+}
diff --git a/src/main/java/com/jd/jdbc/key/Key.java b/src/main/java/com/jd/jdbc/key/Key.java
index c39e3b8..43aea99 100644
--- a/src/main/java/com/jd/jdbc/key/Key.java
+++ b/src/main/java/com/jd/jdbc/key/Key.java
@@ -18,18 +18,9 @@
package com.jd.jdbc.key;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.TextFormat;
-import com.hierynomus.protocol.commons.buffer.Buffer;
-import com.jd.jdbc.sqlparser.support.logging.Log;
-import com.jd.jdbc.sqlparser.support.logging.LogFactory;
import io.vitess.proto.Topodata.KeyRange;
-import io.vitess.proto.Topodata.KeyspaceIdType;
-import java.math.BigInteger;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
public class Key {
@@ -37,136 +28,6 @@ public class Key {
public static final Map keyRangeEndCache = new ConcurrentHashMap<>(16, 1);
- private final static Log log = LogFactory.getLog(Key.class);
-
- //
- // KeyspaceIdType helper methods
- //
-
- // ParseKeyspaceIDType parses the keyspace id type into the enum
- public static KeyspaceIdType parseKeyspaceIDType(String param) {
- if (param.equals("")) {
- return KeyspaceIdType.UNSET;
- }
- KeyspaceIdType value = KeyspaceIdType.UNSET;
- switch (param.toUpperCase()) {
- case "UINT64":
- value = KeyspaceIdType.UINT64;
- case "BYTES":
- value = KeyspaceIdType.BYTES;
- case "UNSET":
- value = KeyspaceIdType.UNSET;
- }
-
- return value;
- }
- //
- // KeyRange helper methods
- //
-
- // EvenShardsKeyRange returns a key range definition for a shard at index "i",
- // assuming range based sharding with "n" equal-width shards in total.
- // i starts at 0.
- //
- // Example: (1, 2) returns the second out of two shards in total i.e. "80-".
- //
- // This function must not be used in the Vitess code base because Vitess also
- // supports shards with different widths. In that case, the output of this
- // function would be wrong.
- //
- // Note: start and end values have trailing zero bytes omitted.
- // For example, "80-" has only the first byte (0x80) set.
- // We do this to produce the same KeyRange objects as ParseKeyRangeParts() does.
- // Because it's using the Go hex methods, it's omitting trailing zero bytes as
- // well.
-
- public static KeyRange evenShardsKeyRange(long i, long n) {
- if (n <= 0) {
- //return nil, fmt.Errorf("the shard count must be > 0: %v", n)
- return null;
- }
- if (i >= n) {
- return null;
- //return nil, fmt.Errorf("the index of the shard must be less than the total number of shards: %v < %v", i, n)
- }
- if ((n & (n - 1)) != 0) {
- return null;
- //return nil, fmt.Errorf("the shard count must be a power of two: %v", n)
- }
-
- // Determine the number of bytes which are required to represent any
- // KeyRange start or end for the given n.
- // This is required to trim the returned values to the same length e.g.
- // (256, 512) should return 8000-8080 as shard key range.
- int minBytes = 0;
- for (long nn = (n - 1); nn > 0; nn >>= 8) {
- minBytes++;
- }
-
-
- // Note: The byte value is empty if start or end is the min or the max
- // respectively.
- byte[] startBytes = {};
- byte[] endBytes = {};
-
- if (n > 0) {
- BigInteger bi = new BigInteger("18446744073709551615");
- BigInteger val = new BigInteger(String.valueOf(n));
- BigInteger width = bi.divide(val);
- width = width.add(new BigInteger("1"));
- BigInteger start = width.multiply(new BigInteger(String.valueOf(i)));
- BigInteger end = start.add(width);
-
- if (end.compareTo(new BigInteger("18446744073709551616")) == 0
- || end.compareTo(new BigInteger("18446744073709551616")) == 1) {
- end = new BigInteger("0");
- }
- try {
- byte[] sb = Uint64key.bytes(start);
- //byte[] sb=sbuf.readRawBytes();
- if ((sb.length) >= minBytes) {
- startBytes = new byte[minBytes];
- System.arraycopy(sb, 0, startBytes, 0, minBytes);
- } else {
- startBytes = new byte[sb.length];
- System.arraycopy(sb, 0, startBytes, 0, sb.length);
- }
- } catch (Buffer.BufferException e) {
- throw new RuntimeException("Key buffer copy fail", e);
- }
-
- try {
- byte[] eb = Uint64key.bytes(end);
- if ((eb.length) >= minBytes) {
- endBytes = new byte[minBytes];
- System.arraycopy(eb, 0, endBytes, 0, minBytes);
- } else {
- endBytes = new byte[eb.length];
- System.arraycopy(eb, 0, endBytes, 0, eb.length);
- }
- } catch (Buffer.BufferException e) {
- throw new RuntimeException("Key buffer copy fail", e);
- }
- if (start.compareTo(new BigInteger("0")) == 0) {
- byte[] tp = {};
- startBytes = tp;
- }
- if (end.compareTo(new BigInteger("0")) == 0) {
- // Always set the end except for the last shard. In that case, the
- // end value (2^64) flows over and is the same as 0.
- byte[] tp = {};
- endBytes = tp;
- }
- }
-
-
- KeyRange kr = KeyRange.newBuilder()
- .setStart(ByteString.copyFrom(startBytes))
- .setEnd(ByteString.copyFrom(endBytes)).build();
-
- return kr;
- }
-
// KeyRangeContains returns true if the provided id is in the keyrange.
public static boolean keyRangeContains(KeyRange kr, byte[] id) {
if (kr == null) {
@@ -187,220 +48,4 @@ public static boolean keyRangeContains(KeyRange kr, byte[] id) {
return Bytes.compare(startCache, id) <= 0 && ((kr.getEnd()).size() == 0 || Bytes.compare(id, endCache) < 0);
}
-
- // ParseKeyRangeParts parses a start and end hex values and build a proto KeyRange
- public static KeyRange parseKeyRangeParts(String start, String end) {
- byte[] s = {};
- try {
- s = Hex.decodeHex(start.toCharArray());
- } catch (DecoderException e) {
- log.error("Key.parseKeyRangeParts failed", e);
- return null;
- }
-
-
- byte[] e = {};
- try {
- e = Hex.decodeHex(end.toCharArray());
- } catch (DecoderException ex) {
- log.error("Key.parseKeyRangeParts.Hex.decodeHex failed", ex);
- return null;
- }
- KeyRange kr = KeyRange.newBuilder()
- .setStart(ByteString.copyFrom(s))
- .setEnd(ByteString.copyFrom(e)).build();
- return kr;
- }
-
-
- // KeyRangeString prints a topodatapb.KeyRange
- public static String keyRangeString(KeyRange k) {
- if (k == null) {
- return "";
- }
- return Hex.encodeHexString(k.getStart().toByteArray()) + "-" + Hex.encodeHexString(k.getEnd().toByteArray());
- }
-
- // KeyRangeIsPartial returns true if the KeyRange does not cover the entire space.
- public static Boolean KeyRangeIsPartial(KeyRange kr) {
- if (kr == null) {
- return false;
- }
- return !(kr.getStart().size() == 0 && kr.getEnd().size() == 0);
- }
-
- // KeyRangeEqual returns true if both key ranges cover the same area
- public static Boolean keyRangeEqual(KeyRange left, KeyRange right) {
- if (left == null) {
- return right == null || (right.getStart().size() == 0 && right.getEnd().size() == 0);
- }
- if (right == null) {
- return left.getStart().size() == 0 && left.getEnd().size() == 0;
- }
- return Bytes.equal(left.getStart().toByteArray(), right.getStart().toByteArray()) &&
- Bytes.equal(left.getEnd().toByteArray(), right.getEnd().toByteArray());
- }
-
- // KeyRangeStartEqual returns true if both key ranges have the same start
- public static Boolean keyRangeStartEqual(KeyRange left, KeyRange right) {
- if (left == null) {
- return right == null || right.getStart().size() == 0;
- }
- if (right == null) {
- return left.getStart().size() == 0;
- }
- return Bytes.equal(left.getStart().toByteArray(), right.getStart().toByteArray());
- }
-
- // KeyRangeEndEqual returns true if both key ranges have the same end
- public static boolean keyRangeEndEqual(KeyRange left, KeyRange right) {
- if (left == null) {
- return right == null || right.getEnd().size() == 0;
- }
- if (right == null) {
- return (left.getEnd().size()) == 0;
- }
- return Bytes.equal(left.getEnd().toByteArray(), right.getEnd().toByteArray());
- }
-
- // For more info on the following functions, see:
- // See: http://stackoverflow.com/questions/4879315/what-is-a-tidy-algorithm-to-find-overlapping-intervals
- // two segments defined as (a,b) and (c,d) (with a c) && (a < d)
- // overlap = min(b, d) - max(c, a)
-
- // KeyRangesIntersect returns true if some Keyspace values exist in both ranges.
- public static boolean keyRangesIntersect(KeyRange first, KeyRange second) {
- if (first == null || second == null) {
- return true;
- }
- return (first.getEnd().size() == 0 || Bytes.compare(second.getStart().toByteArray(), first.getEnd().toByteArray()) < 0) &&
- (second.getEnd().size() == 0 || Bytes.compare(first.getStart().toByteArray(), second.getEnd().toByteArray()) < 0);
- }
-
-
- // KeyRangesOverlap returns the overlap between two KeyRanges.
- // They need to overlap, otherwise an error is returned.
- public static KeyRange keyRangesOverlap(KeyRange first, KeyRange second) {
- if (!keyRangesIntersect(first, second)) {
- log.info(String.format("KeyRanges %s and %s don't overlap", first, second));
- return null;
- }
- if (first == null) {
- return second;
- }
- if (second == null) {
- return first;
- }
- // compute max(c,a) and min(b,d)
- // start with (a,b)
- KeyRange result = first;
- KeyRange.Builder builder = KeyRange.newBuilder();
- // if c > a, then use c
- if (Bytes.compare(second.getStart().toByteArray(), first.getStart().toByteArray()) > 0) {
- try {
- TextFormat.merge(result.toString(), builder);
- } catch (TextFormat.ParseException e) {
- log.error(e.getMessage(), e);
- }
- result = builder.setStart(second.getStart()).build();
- }
- // if b is maxed out, or
- // (d is not maxed out and d < b)
- // ^ valid test as neither b nor d are max
- // then use d
- if (first.getEnd().size() == 0 || (second.getEnd().size() != 0 && Bytes.compare(second.getEnd().toByteArray(), first.getEnd().toByteArray()) < 0)) {
- try {
- TextFormat.merge(result.toString(), builder);
- } catch (TextFormat.ParseException e) {
- log.error("result.parse failed, result is " + result, e);
- }
- result = builder.setEnd(second.getEnd()).build();
- }
- return result;
- }
-
- // KeyRangeIncludes returns true if the first provided KeyRange, big,
- // contains the second KeyRange, small. If they intersect, but small
- // spills out, this returns false.
- public static boolean keyRangeIncludes(KeyRange big, KeyRange small) {
- if (big == null) {
- // The outside one covers everything, we're good.
- return true;
- }
- if (small == null) {
- // The smaller one covers everything, better have the
- // bigger one also cover everything.
- return big.getStart().size() == 0 && big.getEnd().size() == 0;
- }
- // Now we check small.Start >= big.Start, and small.End <= big.End
- if (big.getStart().size() != 0 && Bytes.compare(small.getStart().toByteArray(), big.getStart().toByteArray()) < 0) {
- return false;
- }
- return big.getEnd().size() == 0 || (small.getEnd().size() != 0 && Bytes.compare(small.getEnd().toByteArray(), big.getEnd().toByteArray()) <= 0);
- }
-
- // ParseShardingSpec parses a string that describes a sharding
- // specification. a-b-c-d will be parsed as a-b, b-c, c-d. The empty
- // string may serve both as the start and end of the keyspace: -a-b-
- // will be parsed as start-a, a-b, b-end.
- public static KeyRange[] parseShardingSpec(String spec) {
- String[] parts = Strings.split(spec, "-");
- if (parts.length == 1) {
- log.info("malformed spec: doesn't define a range: " + spec);
- return null;
- }
- String old = parts[0];
- KeyRange[] ranges = new KeyRange[parts.length - 1];
-
- int i = 0;
- for (int j = 1; j < parts.length; j++) {
- String p = parts[j];
- if (p.equals("") && i != (parts.length - 2)) {
- log.info("malformed spec: MinKey/MaxKey cannot be in the middle of the spec: " + spec);
- return null;
- }
- if (!p.equals("") && p.compareTo(old) == -1) {
- //throw new RuntimeException(System.out.format("malformed spec: shard limits should be in order: %s", spec).toString());
- log.info("malformed spec: shard limits should be in order: " + spec);
- return null;
- }
-
- byte[] s = {};
- try {
- s = Hex.decodeHex(old.toCharArray());
- } catch (DecoderException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- if (s == null) {
- return null;
- }
- if (s.length == 0) {
- s = null;
- }
-
- byte[] e = {};
- try {
- e = Hex.decodeHex(p.toCharArray());
- } catch (DecoderException ex) {
- log.error("Hex.decodeHex(p) fail, p is " + p, ex);
- return null;
- }
- if (e.length == 0) {
- e = null;
- }
- KeyRange.Builder bd = KeyRange.newBuilder();
- if (s != null) {
- bd.setStart(ByteString.copyFrom(s));
- }
- if (e != null) {
- bd.setEnd(ByteString.copyFrom(e));
- }
- ranges[i] = bd.build();
- i++;
- old = p;
- }
- return ranges;
- }
}
diff --git a/src/main/java/com/jd/jdbc/key/Uint64key.java b/src/main/java/com/jd/jdbc/key/Uint64key.java
index d3d3a87..c0ae697 100644
--- a/src/main/java/com/jd/jdbc/key/Uint64key.java
+++ b/src/main/java/com/jd/jdbc/key/Uint64key.java
@@ -19,8 +19,6 @@
package com.jd.jdbc.key;
import com.google.common.primitives.UnsignedLong;
-import com.hierynomus.protocol.commons.buffer.Buffer;
-import com.hierynomus.protocol.commons.buffer.Endian;
import java.math.BigInteger;
/**
@@ -36,7 +34,7 @@ public static String string(long longValue) {
}
// Bytes returns the keyspace id (as bytes) associated with a Uint64Key.
- public static byte[] bytes(BigInteger i) throws Buffer.BufferException {
+ public static byte[] bytes(BigInteger i) {
byte[] aa = new byte[8];
aa[0] = i.shiftRight(56).byteValue();
aa[1] = i.shiftRight(48).byteValue();
@@ -49,15 +47,6 @@ public static byte[] bytes(BigInteger i) throws Buffer.BufferException {
return aa;
}
- public static byte[] bytes(BigInteger i, Endian endiannes) throws Buffer.BufferException {
- byte[] aa = new byte[8];
- Buffer.PlainBuffer plainBuffer = new Buffer.PlainBuffer(8, endiannes);
- plainBuffer.putRawBytes(new byte[] {((byte) i.shiftRight(56).intValue()), ((byte) i.shiftRight(48).intValue()), ((byte) i.shiftRight(40).intValue()), ((byte) i.shiftRight(32).intValue()),
- ((byte) i.shiftRight(24).intValue()), ((byte) i.shiftRight(16).intValue()), ((byte) i.shiftRight(8).intValue()), ((byte) i.intValue())});
- plainBuffer.readRawBytes(aa);
- return aa;
- }
-
public static BigInteger uint64(byte[] b) {
//_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
int b7 = b[7] & 0xff;
diff --git a/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtPutBindVarsVisitor.java b/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtPutBindVarsVisitor.java
index fd5af21..ba591d1 100644
--- a/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtPutBindVarsVisitor.java
+++ b/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtPutBindVarsVisitor.java
@@ -16,8 +16,7 @@
package com.jd.jdbc.sqlparser.dialect.mysql.visitor;
-import com.jd.jdbc.engine.LimitEngine;
-import com.jd.jdbc.engine.sequence.Generate;
+import com.jd.jdbc.common.Hex;
import com.jd.jdbc.sqlparser.ast.SQLExpr;
import com.jd.jdbc.sqlparser.ast.SQLLimit;
import com.jd.jdbc.sqlparser.ast.SQLObject;
@@ -52,14 +51,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.apache.commons.codec.binary.Hex;
public class VtPutBindVarsVisitor extends MySqlASTVisitorAdapter {
private static final Log LOGGER = LogFactory.getLog(VtPutBindVarsVisitor.class);
- private static final Integer DEFAULT_VAR_REFINDEX = -1;
-
private final Map bindVariableMap;
public VtPutBindVarsVisitor(final Map bindVariableMap) {
@@ -282,85 +278,4 @@ private SQLValuableExpr getValueableExpr(final VtValue vtValue) {
}
return valuableExpr;
}
-
- private SQLValuableExpr getValueableExpr(final SQLVariantRefExpr x) {
- BindVariable bindVariable;
- if (LimitEngine.LIMIT_VAR_REFINDEX == x.getIndex() || LimitEngine.LIMIT_VAR_NAME.equals(x.getName())) {
- bindVariable = this.bindVariableMap.get(x.getName().replaceAll(":", ""));
- } else if (Generate.SEQ_VAR_REFINDEX == x.getIndex()) {
- bindVariable = this.bindVariableMap.get(x.getName().replaceAll(":", ""));
- } else if (DEFAULT_VAR_REFINDEX == x.getIndex()) {
- bindVariable = this.bindVariableMap.get(x.getName().replaceAll(":", ""));
- } else {
- bindVariable = this.bindVariableMap.get(String.valueOf(x.getIndex()));
- }
- boolean isSeq = x.getName().startsWith(Generate.SEQ_VAR_NAME);
-
- SQLValuableExpr valuableExpr = null;
- try {
- VtValue bv = VtValue.newVtValue(bindVariable);
- Query.Type vtType = bv.getVtType();
- switch (vtType) {
- case VARBINARY:
- case VARCHAR:
- case TEXT:
- case TIME:
- valuableExpr = new SQLCharExpr(bv.toString());
- break;
- case BIT:
- valuableExpr = new SQLBooleanExpr(bv.toBoolean());
- break;
- case INT8:
- case INT16:
- case INT32:
- try {
- valuableExpr = new SQLIntegerExpr(bv.toInt());
- } catch (SQLException e) {
- LOGGER.error(e.getMessage(), e);
- }
- break;
- case INT64:
- try {
- valuableExpr = new SQLIntegerExpr(bv.toLong());
- } catch (SQLException e) {
- LOGGER.error(e.getMessage(), e);
- }
- break;
- case UINT64:
- valuableExpr = new SQLIntegerExpr(new BigInteger(bv.toString()));
- break;
- case DECIMAL:
- case FLOAT64:
- case FLOAT32:
- valuableExpr = new SQLNumberExpr(bv.toDecimal());
- break;
- case DATE:
- valuableExpr = new SQLDateExpr(bv.toString());
- break;
- case DATETIME:
- case TIMESTAMP:
- valuableExpr = new SQLTimestampExpr(bv.toString());
- break;
- case BLOB:
- case BINARY:
- valuableExpr = new SQLHexExpr(Hex.encodeHexString(bv.getVtValue()));
- break;
- case NULL_TYPE:
- if (isSeq) {
- BindVariable variable = this.bindVariableMap.get(x.getName());
- VtValue value = VtValue.newVtValue(variable);
- valuableExpr = new SQLIntegerExpr(value.toLong());
-
- } else {
- valuableExpr = new SQLNullExpr();
- }
- break;
- default:
- break;
- }
- } catch (SQLException e) {
- LOGGER.error(e.getMessage(), e);
- }
- return valuableExpr;
- }
}
diff --git a/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtRestoreVisitor.java b/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtRestoreVisitor.java
index 36639aa..b05ded6 100644
--- a/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtRestoreVisitor.java
+++ b/src/main/java/com/jd/jdbc/sqlparser/dialect/mysql/visitor/VtRestoreVisitor.java
@@ -16,6 +16,7 @@
package com.jd.jdbc.sqlparser.dialect.mysql.visitor;
+import com.jd.jdbc.common.Hex;
import com.jd.jdbc.sqlparser.SqlParser;
import com.jd.jdbc.sqlparser.ast.SQLExpr;
import com.jd.jdbc.sqlparser.ast.expr.SQLBooleanExpr;
@@ -43,7 +44,6 @@
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.codec.binary.Hex;
public class VtRestoreVisitor extends MySqlOutputVisitor {
diff --git a/src/main/java/com/jd/jdbc/sqltypes/VtValue.java b/src/main/java/com/jd/jdbc/sqltypes/VtValue.java
index 467f11b..77bc9cf 100644
--- a/src/main/java/com/jd/jdbc/sqltypes/VtValue.java
+++ b/src/main/java/com/jd/jdbc/sqltypes/VtValue.java
@@ -43,7 +43,6 @@
import java.util.List;
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.codec.binary.Hex;
@Getter
@Setter
@@ -224,25 +223,6 @@ public static VtValue newVtValue(Query.Type typ, byte[] val) throws SQLException
}
}
- public static String toSqlReadable(Query.Type typ, byte[] val) {
- if (typ == Query.Type.BINARY ||
- typ == Query.Type.VARBINARY ||
- typ == Query.Type.BLOB) {
-
- /* e.g.:
- byte[] buffer = new byte[]{0x4D, 0x79, 0x53, 0x51,0x4C, ...};
- to X'4D7953514C...'
- */
- return "X'" + Hex.encodeHexString(val) + "'";
- } else {
- if (VtType.isQuoted(typ)) {
- return "'" + new String(val) + "'";
- } else {
- return new String(val);
- }
- }
- }
-
public static boolean isQuoted(Query.Type vtType) {
return vtType != null && VtType.isQuoted(vtType);
}
@@ -343,10 +323,6 @@ public String toString() {
return StringUtils.toString(vtValue, charEncoding);
}
- public String toSqlReadable() {
- return toSqlReadable(vtType, vtValue);
- }
-
public boolean toBoolean() {
if (isNull()) {
return false;
diff --git a/src/main/java/com/jd/jdbc/vindexes/cryto/TripleDES.java b/src/main/java/com/jd/jdbc/vindexes/cryto/TripleDES.java
index ad53e60..06d7bd9 100644
--- a/src/main/java/com/jd/jdbc/vindexes/cryto/TripleDES.java
+++ b/src/main/java/com/jd/jdbc/vindexes/cryto/TripleDES.java
@@ -41,8 +41,6 @@ public final class TripleDES {
private static final Log log = LogFactory.getLog(TripleDES.class);
- private static final String UNICODE_FORMAT = "UTF8";
-
private static final TripleDES INSTANCE = new TripleDES();
private static final Cipher DEC_CIPHER;