Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-292] improve rewrite performance
  • Loading branch information
rusher committed May 5, 2016
1 parent fa6fd29 commit 07c2ebe
Show file tree
Hide file tree
Showing 25 changed files with 432 additions and 19 deletions.
4 changes: 4 additions & 0 deletions documentation/Changelog.md
@@ -1,4 +1,5 @@
# Changelog
* [1.5.0](#1.5.0) Snapshot available, not released
* [1.4.5](#1.4.5) Snapshot available, not released
* [1.4.4](#1.4.4) Released on 04 mai 2016
* [1.4.3](#1.4.3) Released on 22 april 2016
Expand All @@ -7,6 +8,9 @@
* [1.4.0](#1.4.0) Released on 31 march 2016

---
## 1.5.0
* [CONJ-291] Globally performance improvement

## 1.4.5
* [CONJ-289] PrepareStatement on master reconnection after a failover
* [CONJ-288] using SHOW VARIABLES to replace SELECT on connection to permit connection on a galera non primary node
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -6,7 +6,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>1.4.5-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand Down
Expand Up @@ -66,6 +66,10 @@ public void writeTo(final OutputStream os) throws IOException {
ParameterWriter.write(os, bigDecimal);
}

public void writeUnsafeTo(final PacketOutputStream os) throws IOException {
os.writeUnsafe(bigDecimal.toPlainString().getBytes());
}

public long getApproximateTextProtocolLength() {
return bigDecimal.toPlainString().getBytes().length;
}
Expand Down
Expand Up @@ -69,6 +69,9 @@ public void writeTo(OutputStream os) throws IOException {
ParameterWriter.write(os, bytes, noBackslashEscapes);
}

public void writeUnsafeTo(final PacketOutputStream os) throws IOException {
ParameterWriter.writeUnsafe(os, bytes, noBackslashEscapes);
}

public long getApproximateTextProtocolLength() {
return bytes.length * 2;
Expand Down
Expand Up @@ -68,6 +68,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(String.valueOf(value).getBytes());
}

public void writeUnsafeTo(final PacketOutputStream os) throws IOException {
os.writeUnsafe(String.valueOf(value).getBytes());
}

public long getApproximateTextProtocolLength() {
return String.valueOf(value).getBytes().length * 2;
}
Expand Down
Expand Up @@ -84,11 +84,24 @@ public DateParameter(Date date, Calendar cal, Options options) {
* @param os output buffer
*/
public void writeTo(OutputStream os) throws IOException {
ParameterWriter.writeDate(os, calendar());
}

/**
* Write to server OutputStream in text protocol without checking buffer size.
*
* @param os output buffer
*/
public void writeUnsafeTo(PacketOutputStream os) throws IOException {
ParameterWriter.writeDateUnsafe(os, calendar());
}

private Calendar calendar() {
if (options.useLegacyDatetimeCode || options.maximizeMysqlCompatibility) {
calendar = Calendar.getInstance();
}
calendar.setTimeInMillis(date.getTime());
ParameterWriter.writeDate(os, calendar);
return calendar;
}

public long getApproximateTextProtocolLength() {
Expand Down
Expand Up @@ -68,6 +68,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(String.valueOf(value).getBytes());
}

public void writeUnsafeTo(PacketOutputStream os) throws IOException {
os.writeUnsafe(String.valueOf(value).getBytes());
}

public long getApproximateTextProtocolLength() {
return String.valueOf(value).getBytes().length;
}
Expand Down
Expand Up @@ -68,6 +68,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(String.valueOf(value).getBytes());
}

public void writeUnsafeTo(PacketOutputStream os) throws IOException {
os.writeUnsafe(String.valueOf(value).getBytes());
}

public long getApproximateTextProtocolLength() {
return String.valueOf(value).getBytes().length;
}
Expand Down
Expand Up @@ -67,6 +67,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(String.valueOf(value).getBytes());
}

public void writeUnsafeTo(PacketOutputStream os) throws IOException {
os.writeUnsafe(String.valueOf(value).getBytes());
}

public long getApproximateTextProtocolLength() {
return String.valueOf(value).getBytes().length;
}
Expand Down
Expand Up @@ -67,6 +67,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(String.valueOf(value).getBytes());
}

public void writeUnsafeTo(PacketOutputStream os) throws IOException {
os.writeUnsafe(String.valueOf(value).getBytes());
}

public long getApproximateTextProtocolLength() {
return String.valueOf(value).getBytes().length;
}
Expand Down
Expand Up @@ -50,6 +50,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
package org.mariadb.jdbc.internal.packet.dao.parameters;

import org.mariadb.jdbc.internal.MariaDbType;
import org.mariadb.jdbc.internal.stream.PacketOutputStream;

import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -71,6 +72,10 @@ public void writeTo(final OutputStream os) throws IOException {
os.write(NULL);
}

public void writeUnsafeTo(PacketOutputStream os) throws IOException {
os.writeUnsafe(NULL);
}

public long getApproximateTextProtocolLength() {
return 4;
}
Expand Down
Expand Up @@ -67,6 +67,8 @@ public abstract class ParameterHolder implements Cloneable {
*/
public abstract void writeTo(OutputStream os) throws IOException;

public abstract void writeUnsafeTo(PacketOutputStream os) throws IOException;

public abstract long getApproximateTextProtocolLength() throws IOException;

/**
Expand Down

0 comments on commit 07c2ebe

Please sign in to comment.