Skip to content

Commit c7020bc

Browse files
author
Haotian Xu
committed
AJ-520: add scale for decimal in heterogeneous stream table subscription
1 parent 9ce3ff9 commit c7020bc

15 files changed

+206
-174
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private Entity run(String script, String scriptType, ProgressListener listener,
508508
return new EntityBlockReader(in_);
509509
}
510510
EntityFactory factory = BasicEntityFactory.instance();
511-
return factory.createEntity(df, dt, in_, extended);
511+
return factory.createEntity(df, dt, in_, extended, -1);
512512
}catch (IOException ex){
513513
isConnected_ = false;
514514
socket_ = null;

src/com/xxdb/compression/VectorDecompressor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Vector decompress(EntityFactory factory, ExtendedDataInput in, boolean ex
3535
else if (dt == DATA_TYPE.DT_DECIMAL64)
3636
return new BasicDecimal64Vector(DATA_FORM.DF_VECTOR, decompressedIn, tmp);
3737
else
38-
return (Vector)factory.createEntity(DATA_FORM.DF_VECTOR, dt, decompressedIn, extended);
38+
return (Vector)factory.createEntity(DATA_FORM.DF_VECTOR, dt, decompressedIn, extended, -1); // Haotian - TODO: this function `decompress` may need to be updated
3939
}
4040

4141
}

src/com/xxdb/data/AbstractMatrix.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected AbstractMatrix(ExtendedDataInput in) throws IOException{
3535
type -= 128;
3636
if(form != DATA_FORM.DF_VECTOR.ordinal())
3737
throw new IOException("The form of matrix row labels must be vector");
38-
rowLabels = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, DATA_TYPE.valueOf(type), in, extended);
38+
rowLabels = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, DATA_TYPE.valueOf(type), in, extended, -1);
3939
}
4040

4141
if((hasLabels & 2) == 2){
@@ -50,7 +50,7 @@ protected AbstractMatrix(ExtendedDataInput in) throws IOException{
5050
throw new IOException("The form of matrix columns labels must be vector");
5151
if(type <0 || type >= DATA_TYPE.DT_OBJECT.getValue())
5252
throw new IOException("Invalid data type for matrix column labels: " + type);
53-
columnLabels = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, DATA_TYPE.valueOf(type), in, extended);
53+
columnLabels = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, DATA_TYPE.valueOf(type), in, extended, -1);
5454
}
5555

5656
short flag = in.readShort();

src/com/xxdb/data/BasicAnyVector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected BasicAnyVector(ExtendedDataInput in) throws IOException{
4242
boolean extended = type >= 128;
4343
if(type >= 128)
4444
type -= 128;
45-
Entity obj = BasicEntityFactory.instance().createEntity(DATA_FORM.values()[form], DATA_TYPE.valueOf(type), in, extended);
45+
Entity obj = BasicEntityFactory.instance().createEntity(DATA_FORM.values()[form], DATA_TYPE.valueOf(type), in, extended, -1);
4646
values[i] = obj;
4747
}
4848
}

src/com/xxdb/data/BasicDecimal128.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ public BasicDecimal128(BigInteger unscaledVal, int scale) {
4444
this.scale = scale;
4545
}
4646

47-
public BasicDecimal128(ExtendedDataInput in) throws IOException {
48-
scale = in.readInt();
47+
public BasicDecimal128(ExtendedDataInput in, int extra) throws IOException {
48+
if (extra != -1)
49+
scale = extra;
50+
else
51+
scale = in.readInt();
52+
4953
unscaledValue = handleLittleEndianBigEndian(in);
5054
}
5155

src/com/xxdb/data/BasicDecimal32.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ public class BasicDecimal32 extends AbstractScalar implements Comparable<BasicDe
1111
private int scale_=0;
1212
private int value_;
1313

14-
public BasicDecimal32(ExtendedDataInput in) throws IOException{
15-
scale_ = in.readInt();
14+
public BasicDecimal32(ExtendedDataInput in, int extra) throws IOException{
15+
if (extra != -1)
16+
scale_ = extra;
17+
else
18+
scale_ = in.readInt();
19+
1620
value_ = in.readInt();
1721
}
1822

src/com/xxdb/data/BasicDecimal64.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ public class BasicDecimal64 extends AbstractScalar implements Comparable<BasicDe
1717
private static final BigDecimal DECIMAL64_MIN_VALUE = new BigDecimal("-9223372036854775808");
1818
private static final BigDecimal DECIMAL64_MAX_VALUE = new BigDecimal("9223372036854775807");
1919

20-
public BasicDecimal64(ExtendedDataInput in) throws IOException{
21-
scale_ = in.readInt();
22-
value_ = in.readLong();
20+
public BasicDecimal64(ExtendedDataInput in, int extra) throws IOException{
21+
if (extra != -1)
22+
scale_ = extra;
23+
else
24+
scale_ = in.readInt();
25+
26+
value_ = in.readInt();
2327
}
2428

2529
public BasicDecimal64(long value, int scale){

src/com/xxdb/data/BasicDictionary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public BasicDictionary(DATA_TYPE valueType, ExtendedDataInput in) throws IOExcep
3434
if(form != DATA_FORM.DF_VECTOR.ordinal())
3535
throw new IOException("The form of dictionary keys must be vector");
3636
keyType = DATA_TYPE.valueOf(type);
37-
Vector keys = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, keyType, in, extended);
37+
Vector keys = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, keyType, in, extended, -1);
3838

3939
//read value vector
4040
flag = in.readShort();
@@ -46,7 +46,7 @@ public BasicDictionary(DATA_TYPE valueType, ExtendedDataInput in) throws IOExcep
4646
if(form != DATA_FORM.DF_VECTOR.ordinal())
4747
throw new IOException("The form of dictionary values must be vector");
4848
valueType = DATA_TYPE.valueOf(type);
49-
Vector values = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, valueType, in, extended);
49+
Vector values = (Vector)BasicEntityFactory.instance().createEntity(DATA_FORM.DF_VECTOR, valueType, in, extended, -1);
5050

5151
if(keys.rows() != values.rows()){
5252
throw new IOException("The key size doesn't equate to value size.");

0 commit comments

Comments
 (0)