Skip to content

Commit

Permalink
revise code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasmine-ge committed Jul 31, 2024
1 parent 8127ada commit 4d5379c
Show file tree
Hide file tree
Showing 43 changed files with 55 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ public ColumnWriterBuffer getColumnWriterBuffer() {
}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException {
SerializeBulkPrefix(serializer);
SerializeBulk(serializer, now);
SerializeBulkSuffix(serializer);
public void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException {

}

@Override
public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {

}

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) throws IOException, SQLException {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public static Block readFrom(BinaryDeserializer deserializer,
String type = deserializer.readUTF8StringBinary();

IDataType dataType = DataTypeFactory.get(type, serverContext);
Object[] arr = dataType.deserializeBinaryFromStream(rowCnt, deserializer);
dataType.deserializeBinaryPrefix(rowCnt, deserializer);
Object[] arr = dataType.deserializeBinaryBulk(rowCnt, deserializer);
dataType.deserializeBinarySuffix(rowCnt, deserializer);
columns[i] = ColumnFactory.createColumn(name, dataType, arr);
}

Expand Down Expand Up @@ -126,7 +128,9 @@ public void writeTo(BinarySerializer serializer) throws IOException, SQLExceptio
for (IColumn column : columns) {
serializer.writeUTF8StringBinary(column.name());
serializer.writeUTF8StringBinary(column.type().name());
column.flushToSerializer(serializer, true);
column.SerializeBulkPrefix(serializer);
column.SerializeBulk(serializer, true);
column.SerializeBulkSuffix(serializer);
}
}

Expand Down
13 changes: 1 addition & 12 deletions timeplus-native-jdbc/src/main/java/com/timeplus/data/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,7 @@ public void write(Object object) throws IOException, SQLException {
}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException {
super.flushToSerializer(serializer, now);
}

@Override
public void SerializeBulkPrefix(BinarySerializer serializer) { }

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) { }

@Override
public void SerializeBulk(BinarySerializer serializer, boolean now) throws IOException, SQLException {
public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {
if (now) {
buffer.writeTo(serializer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ public void write(Object object) throws IOException, SQLException {
}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {
super.flushToSerializer(serializer, immediate);
}

@Override
public void SerializeBulk(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {

public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {
flushOffsets(serializer);
data.SerializeBulk(serializer, false);

if (immediate) {
if (now) {
buffer.writeTo(serializer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public void write(Object object) throws IOException, SQLException {
}

@Override
public void SerializeBulk(BinarySerializer serializer, boolean immediate) throws IOException, SQLException {
/// The data layout: [version][index_type][dictionary][indexes]
// serializer.writeLong(version);
public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {
/// The data layout: [index_type][dictionary][indexes]
serializer.writeLong(IndexType.UInt64.getValue() | IndexType.HasAdditionalKeysBit.getValue());
serializer.writeLong(dict.size());
for (int i = 0; i < dict.size(); i++) {
Expand All @@ -99,18 +98,7 @@ public void clear() {

@Override
public void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException {
/// The data layout: [version][index_type][dictionary][indexes]
serializer.writeLong(version);
}

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) {
}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {
super.flushToSerializer(serializer, immediate);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void write(Object object) throws IOException, SQLException {
}

@Override
public void SerializeBulk(BinarySerializer serializer, boolean now) throws IOException, SQLException {
public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {

flushOffsets(serializer);

Expand Down Expand Up @@ -100,12 +100,5 @@ public void SerializeBulkPrefix(BinarySerializer serializer) throws SQLException
}
}

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) {
}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {
super.flushToSerializer(serializer, immediate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void write(@Nullable Object object) throws IOException, SQLException {
}

@Override
public void SerializeBulk(BinarySerializer serializer, boolean immediate) throws IOException {
public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {
for (byte sign : nullableSign) {
serializer.writeByte(sign);
}

if (immediate)
if (now)
buffer.writeTo(serializer);
}

Expand All @@ -62,18 +62,4 @@ public void setColumnWriterBuffer(ColumnWriterBuffer buffer) {
data.setColumnWriterBuffer(buffer);
}

@Override
public void SerializeBulkPrefix(BinarySerializer serializer) {

}

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) {

}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {
super.flushToSerializer(serializer, immediate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ public void write(Object object) throws IOException, SQLException {
}

@Override
public void SerializeBulk(BinarySerializer serializer, boolean now) throws SQLException, IOException {
// if (isExported()) {
// serializer.writeUTF8StringBinary(name);
// serializer.writeUTF8StringBinary(type.name());
// }

public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException {
// we should to flush all the nested data to serializer
// because they are using separate buffers.
for (IColumn data : columnDataArray) {
Expand Down Expand Up @@ -82,13 +77,4 @@ public void SerializeBulkPrefix(BinarySerializer serializer) throws SQLException
}
}

@Override
public void SerializeBulkSuffix(BinarySerializer serializer) {

}

@Override
public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException {
super.flushToSerializer(serializer, immediate);
}
}
17 changes: 7 additions & 10 deletions timeplus-native-jdbc/src/main/java/com/timeplus/data/IColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,23 @@ public interface IColumn {

void write(Object object) throws IOException, SQLException;

void clear();

void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException;
void setColumnWriterBuffer(ColumnWriterBuffer buffer);

ColumnWriterBuffer getColumnWriterBuffer();
/**
* Flush to socket output stream
*
* @param serializer is serializer wrapper of tcp socket
* @param now means we should flush all the buffer to serializer now
*/
void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException;

void SerializeBulkSuffix(BinarySerializer serializer) throws IOException, SQLException;

void SerializeBulk(BinarySerializer serializer, boolean now) throws IOException, SQLException;

void clear();
void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException;

void setColumnWriterBuffer(ColumnWriterBuffer buffer);
void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException;

ColumnWriterBuffer getColumnWriterBuffer();
void SerializeBulkSuffix(BinarySerializer serializer) throws IOException, SQLException;
}



Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ default Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer
return data;
}

void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException;
default void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException {

void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException;

default Object[] deserializeBinaryFromStream(int rows, BinaryDeserializer deserializer) throws SQLException, IOException {
deserializeBinaryPrefix(rows, deserializer);
Object[] arr = deserializeBinaryBulk(rows, deserializer);
deserializeBinarySuffix(rows, deserializer);
return arr;
}

default void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,4 @@ public LocalDate deserializeText(SQLLexer lexer) throws SQLException {
return LocalDate.of(year, month, day);
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,4 @@ public LocalDate deserializeText(SQLLexer lexer) throws SQLException {
return LocalDate.of(year, month, day);
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,4 @@ public Long deserializeText(SQLLexer lexer) throws SQLException {
return lexer.numberLiteral().longValue() & 0xffffffffL;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,4 @@ private static String convertIPv6ToHexadecimalString(String ipv6) {
return ipv6.replace(":", "");
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,5 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException {
return new BigInteger(Integer128, 10);
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,4 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException {
return new BigInteger(Integer256, 10);
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ public boolean isSigned() {
return true;
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,4 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException {
return new BigInteger(Uinteger128, 10);
}

@Override
public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException {

}

@Override
public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException {

}
}
Loading

0 comments on commit 4d5379c

Please sign in to comment.