Skip to content

Commit

Permalink
release300.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dolphindb-jffu committed Jun 28, 2024
1 parent 5bbf73d commit 6b37910
Show file tree
Hide file tree
Showing 44 changed files with 7,495 additions and 4,797 deletions.
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.00.0.0")]
[assembly: AssemblyFileVersion("3.00.0.0")]
[assembly: AssemblyVersion("3.00.1.0")]
[assembly: AssemblyFileVersion("3.00.1.0")]
2 changes: 1 addition & 1 deletion src/data/AbstractMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public virtual void setColumnLabels(IVector vector)
public virtual string getString()
{
int rows = Math.Min(Utils.DISPLAY_ROWS, this.rows());
int limitColMaxWidth = 25;
int limitColMaxWidth = Utils.DISPLAY_WIDTH;
int length = 0;
int curCol = 0;
int maxColWidth;
Expand Down
4 changes: 2 additions & 2 deletions src/data/BasicDecimal128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public BasicDecimal128(decimal data, int scale){
this.scale_ = scale;
}

public BasicDecimal128(ExtendedDataInput @input)
internal BasicDecimal128(ExtendedDataInput @input, int scale = -1)
{
scale_ = @input.readInt();
scale_ = scale == -1 ? @input.readInt() : scale;
byte[] data = new byte[16];
@input.readFully(data);
reserveBytes(data, !@input.isLittleEndian());
Expand Down
117 changes: 117 additions & 0 deletions src/data/BasicDecimal128Matrix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using dolphindb.io;
using System;
using System.Collections.Generic;

namespace dolphindb.data
{

public class BasicDecimal128Matrix : AbstractMatrix
{
private BasicDecimal128Vector value;

public BasicDecimal128Matrix(int rows, int columns, int scale) : base(rows, columns)
{
this.value = new BasicDecimal128Vector(rows * columns, scale);
}

public BasicDecimal128Matrix(int rows, int columns, IList<decimal[]> list, int scale) : base(rows, columns)
{
List<decimal> tmp = new List<decimal>();
foreach (decimal[] data in list)
{
tmp.AddRange(data);
}
if (tmp.Count != rows * columns)
{
throw new Exception("the total size of list must be equal to rows * columns");
}
value = new BasicDecimal128Vector(tmp, scale);
}

public BasicDecimal128Matrix(int rows, int columns, IList<string[]> list, int scale) : base(rows, columns)
{
List<string> tmp = new List<string>();
foreach (string[] data in list)
{
tmp.AddRange(data);
}
if (tmp.Count != rows * columns)
{
throw new Exception("the total size of list must be equal to rows * columns");
}
value = new BasicDecimal128Vector(tmp, scale);
}

public BasicDecimal128Matrix(ExtendedDataInput @in) : base(@in)
{
}

public virtual void setDecimal(int row, int column, decimal value)
{
this.value.setDecimal(getIndex(row, column), value);
}

public virtual decimal getDecimal(int row, int column)
{
return value.getDecimal(getIndex(row, column));
}

public void setString(int row, int column, string value)
{
this.value.set(getIndex(row, column), value);
}

public override bool isNull(int row, int column)
{
return value.isNull(getIndex(row, column));
}

public override void setNull(int row, int column)
{
value.setNull(getIndex(row, column));
}

public override IScalar get(int row, int column)
{
return this.value.get(getIndex(row, column));
}

public void set(int row, int column, IScalar value)
{
this.value.set(getIndex(row, column), value);
}

public override DATA_CATEGORY getDataCategory()
{
return DATA_CATEGORY.DENARY;
}

public override DATA_TYPE getDataType()
{
return DATA_TYPE.DT_DECIMAL128;
}

public override Type getElementClass()
{
return typeof(BasicDecimal128);
}

protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in)
{
int scale = @in.readInt();
this.value = new BasicDecimal128Vector(rows * columns, scale);
value.deserialize(0, rows * columns, @in);
}

protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out)
{
this.value.writeVectorToOutputStream(@out);
}

public int getScale()
{
return value.getScale();
}
}

}
13 changes: 11 additions & 2 deletions src/data/BasicDecimal128Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,13 @@ public override void set(int index, IScalar value)
{
int originScale = value.getScale();
BigInteger convertData;
if (originScale > scale_)
if (originScale == scale_)
{
convertData = ((BasicDecimal128)value).getRawData() / BasicDecimal128.pow10(originScale - scale_);
convertData = ((BasicDecimal128)value).getRawData();
}
else if (originScale > scale_)
{
convertData = new BasicDecimal128(value.getString(), scale_).getRawData();
}
else
{
Expand Down Expand Up @@ -336,5 +340,10 @@ public decimal getDecimal(int index)
{
return ((BasicDecimal128)get(index)).getDecimalValue();
}

public void setDecimal(int index, decimal value)
{
set(index, new BasicDecimal128(value, scale_));
}
}
}
4 changes: 2 additions & 2 deletions src/data/BasicDecimal32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public BasicDecimal32(decimal data, int scale)
}
}

public BasicDecimal32(ExtendedDataInput @input)
internal BasicDecimal32(ExtendedDataInput @input, int scale = -1)
{
scale_ = @input.readInt();
scale_ = scale == -1 ? @input.readInt() : scale;
value_ = @input.readInt();
}

Expand Down
118 changes: 118 additions & 0 deletions src/data/BasicDecimal32Matrix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using dolphindb.io;
using System;
using System.Collections.Generic;

namespace dolphindb.data
{


public class BasicDecimal32Matrix : AbstractMatrix
{
private BasicDecimal32Vector value;

public BasicDecimal32Matrix(int rows, int columns, int scale) : base(rows, columns)
{
this.value = new BasicDecimal32Vector(rows * columns, scale);
}

public BasicDecimal32Matrix(int rows, int columns, IList<decimal[]> list, int scale) : base(rows, columns)
{
List<decimal> tmp = new List<decimal>();
foreach (decimal[] data in list)
{
tmp.AddRange(data);
}
if (tmp.Count != rows * columns)
{
throw new Exception("the total size of list must be equal to rows * columns");
}
value = new BasicDecimal32Vector(tmp, scale);
}

public BasicDecimal32Matrix(int rows, int columns, IList<string[]> list, int scale) : base(rows, columns)
{
List<string> tmp = new List<string>();
foreach (string[] data in list)
{
tmp.AddRange(data);
}
if(tmp.Count != rows * columns)
{
throw new Exception("the total size of list must be equal to rows * columns");
}
value = new BasicDecimal32Vector(tmp, scale);
}

public BasicDecimal32Matrix(ExtendedDataInput @in) : base(@in)
{
}

public virtual void setDecimal(int row, int column, decimal value)
{
this.value.setDecimal(getIndex(row, column), value);
}

public virtual decimal getDecimal(int row, int column)
{
return value.getDecimal(getIndex(row, column));
}

public void setString(int row, int column, string value)
{
this.value.set(getIndex(row, column), value);
}

public override bool isNull(int row, int column)
{
return value.isNull(getIndex(row, column));
}

public override void setNull(int row, int column)
{
value.setNull(getIndex(row, column));
}

public override IScalar get(int row, int column)
{
return this.value.get(getIndex(row, column));
}

public void set(int row, int column, IScalar value)
{
this.value.set(getIndex(row, column), value);
}

public override DATA_CATEGORY getDataCategory()
{
return DATA_CATEGORY.DENARY;
}

public override DATA_TYPE getDataType()
{
return DATA_TYPE.DT_DECIMAL32;
}

public override Type getElementClass()
{
return typeof(BasicDecimal32);
}

protected internal override void readMatrixFromInputStream(int rows, int columns, ExtendedDataInput @in)
{
int scale = @in.readInt();
this.value = new BasicDecimal32Vector(rows * columns, scale);
value.deserialize(0, rows * columns, @in);
}

protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out)
{
this.value.writeVectorToOutputStream(@out);
}

public int getScale()
{
return value.getScale();
}
}

}
13 changes: 11 additions & 2 deletions src/data/BasicDecimal32Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ public override void set(int index, IScalar value)
else
{
int originScale = value.getScale();
if (originScale > scale_)
if(originScale == scale_)
{
values_[index] = ((BasicDecimal32)value).getRawData() / BasicDecimal32.pow10(originScale - scale_);
values_[index] = ((BasicDecimal32)value).getRawData();
}
else if (originScale > scale_)
{
values_[index] = new BasicDecimal32(value.getString(), scale_).getRawData();
}
else
{
Expand Down Expand Up @@ -309,5 +313,10 @@ public decimal getDecimal(int index)
{
return Utils.createBasicDecimal32(values_[index], scale_).getDecimalValue();
}

public void setDecimal(int index, decimal value)
{
set(index, new BasicDecimal32(value, scale_));
}
}
}
4 changes: 2 additions & 2 deletions src/data/BasicDecimal64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class BasicDecimal64 : AbstractScalar
private int scale_ = 0;//Decimal precision
private long value_; //covert decimal to int for saving

public BasicDecimal64(ExtendedDataInput @input)
internal BasicDecimal64(ExtendedDataInput @input, int scale = -1)
{
scale_ = @input.readInt();
scale_ = scale == -1 ? @input.readInt() : scale;
value_ = @input.readLong();
}

Expand Down
Loading

0 comments on commit 6b37910

Please sign in to comment.