Skip to content

Commit 1337f0b

Browse files
author
chengyitian
committed
AJ-655: fix issue about deserialize decimal for cep;
1 parent 5615670 commit 1337f0b

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/com/xxdb/data/BasicDecimal128.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ public BasicDecimal128(ExtendedDataInput in) throws IOException {
4040
unscaledValue = handleLittleEndianBigEndian(in);
4141
}
4242

43+
public BasicDecimal128(ExtendedDataInput in, int scale) throws IOException {
44+
this.scale = scale;
45+
unscaledValue = handleLittleEndianBigEndian(in);
46+
}
47+
4348
BasicDecimal128(int scale, BigInteger unscaledVal) {
4449
this.unscaledValue = unscaledVal;
4550
this.scale = scale;
4651
}
4752

53+
54+
4855
private static BigInteger handleLittleEndianBigEndian(ExtendedDataInput in) throws IOException {
4956
byte[] buffer = new byte[16];
5057
BigInteger value;

src/com/xxdb/data/BasicDecimal32.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public BasicDecimal32(ExtendedDataInput in) throws IOException{
1717
value_ = in.readInt();
1818
}
1919

20+
public BasicDecimal32(ExtendedDataInput in, int scale) throws IOException {
21+
this.scale_ = scale;
22+
value_ = in.readInt();
23+
}
24+
2025
public BasicDecimal32(int value, int scale){
2126
this(String.valueOf(value), scale);
2227
}

src/com/xxdb/data/BasicDecimal64.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public BasicDecimal64(ExtendedDataInput in) throws IOException{
2222
scale_ = in.readInt();
2323
value_ = in.readLong();
2424
}
25+
public BasicDecimal64(ExtendedDataInput in, int scale) throws IOException{
26+
scale_ = scale;
27+
value_ = in.readLong();
28+
}
2529

2630
public BasicDecimal64(long value, int scale){
2731
this(String.valueOf(value), scale);

src/com/xxdb/streaming/client/cep/EventHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,14 @@ private boolean checkSchema(List<EventScheme> eventSchemes, List<String> expandT
388388

389389
private Entity deserializeScalar(Entity.DATA_TYPE type, int extraParam, ExtendedDataInput input) throws IOException {
390390
BasicEntityFactory factory = new BasicEntityFactory();
391-
return factory.createEntity(Entity.DATA_FORM.DF_SCALAR, type, input, false);
391+
if (type == Entity.DATA_TYPE.DT_DECIMAL32)
392+
return new BasicDecimal32(input, extraParam);
393+
else if (type == Entity.DATA_TYPE.DT_DECIMAL64)
394+
return new BasicDecimal64(input, extraParam);
395+
else if (type == Entity.DATA_TYPE.DT_DECIMAL128)
396+
return new BasicDecimal128(input, extraParam);
397+
else
398+
return factory.createEntity(Entity.DATA_FORM.DF_SCALAR, type, input, false);
392399
}
393400

394401
private Entity deserializeFastArray(Entity.DATA_TYPE type, int extraParam, ExtendedDataInput input) throws IOException {

0 commit comments

Comments
 (0)