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+ }
0 commit comments