Skip to content

Commit 6b37910

Browse files
release300.1.0
1 parent 5bbf73d commit 6b37910

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+7495
-4797
lines changed

src/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.00.0.0")]
36-
[assembly: AssemblyFileVersion("3.00.0.0")]
35+
[assembly: AssemblyVersion("3.00.1.0")]
36+
[assembly: AssemblyFileVersion("3.00.1.0")]

src/data/AbstractMatrix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public virtual void setColumnLabels(IVector vector)
150150
public virtual string getString()
151151
{
152152
int rows = Math.Min(Utils.DISPLAY_ROWS, this.rows());
153-
int limitColMaxWidth = 25;
153+
int limitColMaxWidth = Utils.DISPLAY_WIDTH;
154154
int length = 0;
155155
int curCol = 0;
156156
int maxColWidth;

src/data/BasicDecimal128.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public BasicDecimal128(decimal data, int scale){
3737
this.scale_ = scale;
3838
}
3939

40-
public BasicDecimal128(ExtendedDataInput @input)
40+
internal BasicDecimal128(ExtendedDataInput @input, int scale = -1)
4141
{
42-
scale_ = @input.readInt();
42+
scale_ = scale == -1 ? @input.readInt() : scale;
4343
byte[] data = new byte[16];
4444
@input.readFully(data);
4545
reserveBytes(data, !@input.isLittleEndian());

src/data/BasicDecimal128Matrix.cs

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
using dolphindb.io;
2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace dolphindb.data
6+
{
7+
8+
public class BasicDecimal128Matrix : AbstractMatrix
9+
{
10+
private BasicDecimal128Vector value;
11+
12+
public BasicDecimal128Matrix(int rows, int columns, int scale) : base(rows, columns)
13+
{
14+
this.value = new BasicDecimal128Vector(rows * columns, scale);
15+
}
16+
17+
public BasicDecimal128Matrix(int rows, int columns, IList<decimal[]> list, int scale) : base(rows, columns)
18+
{
19+
List<decimal> tmp = new List<decimal>();
20+
foreach (decimal[] data in list)
21+
{
22+
tmp.AddRange(data);
23+
}
24+
if (tmp.Count != rows * columns)
25+
{
26+
throw new Exception("the total size of list must be equal to rows * columns");
27+
}
28+
value = new BasicDecimal128Vector(tmp, scale);
29+
}
30+
31+
public BasicDecimal128Matrix(int rows, int columns, IList<string[]> list, int scale) : base(rows, columns)
32+
{
33+
List<string> tmp = new List<string>();
34+
foreach (string[] data in list)
35+
{
36+
tmp.AddRange(data);
37+
}
38+
if (tmp.Count != rows * columns)
39+
{
40+
throw new Exception("the total size of list must be equal to rows * columns");
41+
}
42+
value = new BasicDecimal128Vector(tmp, scale);
43+
}
44+
45+
public BasicDecimal128Matrix(ExtendedDataInput @in) : base(@in)
46+
{
47+
}
48+
49+
public virtual void setDecimal(int row, int column, decimal value)
50+
{
51+
this.value.setDecimal(getIndex(row, column), value);
52+
}
53+
54+
public virtual decimal getDecimal(int row, int column)
55+
{
56+
return value.getDecimal(getIndex(row, column));
57+
}
58+
59+
public void setString(int row, int column, string value)
60+
{
61+
this.value.set(getIndex(row, column), value);
62+
}
63+
64+
public override bool isNull(int row, int column)
65+
{
66+
return value.isNull(getIndex(row, column));
67+
}
68+
69+
public override void setNull(int row, int column)
70+
{
71+
value.setNull(getIndex(row, column));
72+
}
73+
74+
public override IScalar get(int row, int column)
75+
{
76+
return this.value.get(getIndex(row, column));
77+
}
78+
79+
public void set(int row, int column, IScalar value)
80+
{
81+
this.value.set(getIndex(row, column), value);
82+
}
83+
84+
public override DATA_CATEGORY getDataCategory()
85+
{
86+
return DATA_CATEGORY.DENARY;
87+
}
88+
89+
public override DATA_TYPE getDataType()
90+
{
91+
return DATA_TYPE.DT_DECIMAL128;
92+
}
93+
94+
public override Type getElementClass()
95+
{
96+
return typeof(BasicDecimal128);
97+
}
98+
99+
protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in)
100+
{
101+
int scale = @in.readInt();
102+
this.value = new BasicDecimal128Vector(rows * columns, scale);
103+
value.deserialize(0, rows * columns, @in);
104+
}
105+
106+
protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out)
107+
{
108+
this.value.writeVectorToOutputStream(@out);
109+
}
110+
111+
public int getScale()
112+
{
113+
return value.getScale();
114+
}
115+
}
116+
117+
}

src/data/BasicDecimal128Vector.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,13 @@ public override void set(int index, IScalar value)
279279
{
280280
int originScale = value.getScale();
281281
BigInteger convertData;
282-
if (originScale > scale_)
282+
if (originScale == scale_)
283283
{
284-
convertData = ((BasicDecimal128)value).getRawData() / BasicDecimal128.pow10(originScale - scale_);
284+
convertData = ((BasicDecimal128)value).getRawData();
285+
}
286+
else if (originScale > scale_)
287+
{
288+
convertData = new BasicDecimal128(value.getString(), scale_).getRawData();
285289
}
286290
else
287291
{
@@ -336,5 +340,10 @@ public decimal getDecimal(int index)
336340
{
337341
return ((BasicDecimal128)get(index)).getDecimalValue();
338342
}
343+
344+
public void setDecimal(int index, decimal value)
345+
{
346+
set(index, new BasicDecimal128(value, scale_));
347+
}
339348
}
340349
}

src/data/BasicDecimal32.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public BasicDecimal32(decimal data, int scale)
4141
}
4242
}
4343

44-
public BasicDecimal32(ExtendedDataInput @input)
44+
internal BasicDecimal32(ExtendedDataInput @input, int scale = -1)
4545
{
46-
scale_ = @input.readInt();
46+
scale_ = scale == -1 ? @input.readInt() : scale;
4747
value_ = @input.readInt();
4848
}
4949

src/data/BasicDecimal32Matrix.cs

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using dolphindb.io;
2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace dolphindb.data
6+
{
7+
8+
9+
public class BasicDecimal32Matrix : AbstractMatrix
10+
{
11+
private BasicDecimal32Vector value;
12+
13+
public BasicDecimal32Matrix(int rows, int columns, int scale) : base(rows, columns)
14+
{
15+
this.value = new BasicDecimal32Vector(rows * columns, scale);
16+
}
17+
18+
public BasicDecimal32Matrix(int rows, int columns, IList<decimal[]> list, int scale) : base(rows, columns)
19+
{
20+
List<decimal> tmp = new List<decimal>();
21+
foreach (decimal[] data in list)
22+
{
23+
tmp.AddRange(data);
24+
}
25+
if (tmp.Count != rows * columns)
26+
{
27+
throw new Exception("the total size of list must be equal to rows * columns");
28+
}
29+
value = new BasicDecimal32Vector(tmp, scale);
30+
}
31+
32+
public BasicDecimal32Matrix(int rows, int columns, IList<string[]> list, int scale) : base(rows, columns)
33+
{
34+
List<string> tmp = new List<string>();
35+
foreach (string[] data in list)
36+
{
37+
tmp.AddRange(data);
38+
}
39+
if(tmp.Count != rows * columns)
40+
{
41+
throw new Exception("the total size of list must be equal to rows * columns");
42+
}
43+
value = new BasicDecimal32Vector(tmp, scale);
44+
}
45+
46+
public BasicDecimal32Matrix(ExtendedDataInput @in) : base(@in)
47+
{
48+
}
49+
50+
public virtual void setDecimal(int row, int column, decimal value)
51+
{
52+
this.value.setDecimal(getIndex(row, column), value);
53+
}
54+
55+
public virtual decimal getDecimal(int row, int column)
56+
{
57+
return value.getDecimal(getIndex(row, column));
58+
}
59+
60+
public void setString(int row, int column, string value)
61+
{
62+
this.value.set(getIndex(row, column), value);
63+
}
64+
65+
public override bool isNull(int row, int column)
66+
{
67+
return value.isNull(getIndex(row, column));
68+
}
69+
70+
public override void setNull(int row, int column)
71+
{
72+
value.setNull(getIndex(row, column));
73+
}
74+
75+
public override IScalar get(int row, int column)
76+
{
77+
return this.value.get(getIndex(row, column));
78+
}
79+
80+
public void set(int row, int column, IScalar value)
81+
{
82+
this.value.set(getIndex(row, column), value);
83+
}
84+
85+
public override DATA_CATEGORY getDataCategory()
86+
{
87+
return DATA_CATEGORY.DENARY;
88+
}
89+
90+
public override DATA_TYPE getDataType()
91+
{
92+
return DATA_TYPE.DT_DECIMAL32;
93+
}
94+
95+
public override Type getElementClass()
96+
{
97+
return typeof(BasicDecimal32);
98+
}
99+
100+
protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in)
101+
{
102+
int scale = @in.readInt();
103+
this.value = new BasicDecimal32Vector(rows * columns, scale);
104+
value.deserialize(0, rows * columns, @in);
105+
}
106+
107+
protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out)
108+
{
109+
this.value.writeVectorToOutputStream(@out);
110+
}
111+
112+
public int getScale()
113+
{
114+
return value.getScale();
115+
}
116+
}
117+
118+
}

src/data/BasicDecimal32Vector.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,13 @@ public override void set(int index, IScalar value)
256256
else
257257
{
258258
int originScale = value.getScale();
259-
if (originScale > scale_)
259+
if(originScale == scale_)
260260
{
261-
values_[index] = ((BasicDecimal32)value).getRawData() / BasicDecimal32.pow10(originScale - scale_);
261+
values_[index] = ((BasicDecimal32)value).getRawData();
262+
}
263+
else if (originScale > scale_)
264+
{
265+
values_[index] = new BasicDecimal32(value.getString(), scale_).getRawData();
262266
}
263267
else
264268
{
@@ -309,5 +313,10 @@ public decimal getDecimal(int index)
309313
{
310314
return Utils.createBasicDecimal32(values_[index], scale_).getDecimalValue();
311315
}
316+
317+
public void setDecimal(int index, decimal value)
318+
{
319+
set(index, new BasicDecimal32(value, scale_));
320+
}
312321
}
313322
}

src/data/BasicDecimal64.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public class BasicDecimal64 : AbstractScalar
1313
private int scale_ = 0;//Decimal precision
1414
private long value_; //covert decimal to int for saving
1515

16-
public BasicDecimal64(ExtendedDataInput @input)
16+
internal BasicDecimal64(ExtendedDataInput @input, int scale = -1)
1717
{
18-
scale_ = @input.readInt();
18+
scale_ = scale == -1 ? @input.readInt() : scale;
1919
value_ = @input.readLong();
2020
}
2121

0 commit comments

Comments
 (0)