Skip to content

Commit a204d5a

Browse files
release 300.2.2
1 parent bf0b6f8 commit a204d5a

Some content is hidden

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

42 files changed

+5315
-430
lines changed

src/DBConnection.cs

+35-18
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,6 @@ bool connect()
256256
}
257257
isConnected_ = true;
258258

259-
if (!asynTask_)
260-
{
261-
if (!((BasicBoolean)run("iif(getNodeType() == 0 or getNodeType() == 3 or getNodeType() == 4, isDataNodeInitialized(), bool(1))")).getValue())
262-
{
263-
System.Console.WriteLine("data node is not initialized. ");
264-
socket_.Close();
265-
isConnected_ = false;
266-
return false;
267-
}
268-
}
269-
270259
if (userId_ != null && userId_.Length > 0 && password_.Length > 0)
271260
{
272261
if (asynTask_)
@@ -279,6 +268,17 @@ bool connect()
279268
}
280269
}
281270

271+
//if (!asynTask_)
272+
//{
273+
// if (!((BasicBoolean)run("iif(getNodeType() == 0 or getNodeType() == 3 or getNodeType() == 4, isDataNodeInitialized(), bool(1))")).getValue())
274+
// {
275+
// System.Console.WriteLine("data node is not initialized. ");
276+
// socket_.Close();
277+
// isConnected_ = false;
278+
// return false;
279+
// }
280+
//}
281+
282282
if (startup_ != null && startup_ != "")
283283
run(startup_);
284284

@@ -297,7 +297,7 @@ public void login()
297297
List<IEntity> args = new List<IEntity>();
298298
if (encrypted_)
299299
{
300-
BasicString keyCode = (BasicString)run("getDynamicPublicKey()");
300+
BasicString keyCode = (BasicString)run("getDynamicPublicKey", args);
301301

302302
string key = RSAUtils.GetKey(keyCode.getString());
303303
string usr = RSAUtils.RSA(userId_, key);
@@ -313,7 +313,7 @@ public void login()
313313
{
314314
args.Add(new BasicString(userId_));
315315
args.Add(new BasicString(password_));
316-
run("login('" + userId_ + "','" + password_ + "')"); //no encrypted temporary
316+
run("login", args); //no encrypted temporary
317317

318318
}
319319
}
@@ -406,7 +406,7 @@ private IEntity runInternal(string script, string scriptType, ProgressListener l
406406
{
407407
throw new IOException("Invalid form value: " + form);
408408
}
409-
if (type < 0 || type > (int)DATA_TYPE.DT_DECIMAL128_ARRAY || type > (int)DATA_TYPE.DT_DECIMAL128 && type < (int)(int)DATA_TYPE.DT_BOOL_ARRAY)
409+
if (type < 0 || type > (int)DATA_TYPE.DT_DECIMAL128_ARRAY || type > (int)DATA_TYPE.DT_IOTANY && type < (int)(int)DATA_TYPE.DT_BOOL_ARRAY)
410410
{
411411
throw new IOException("Invalid type value: " + type);
412412
}
@@ -1046,8 +1046,10 @@ bool connected()
10461046
{
10471047
try
10481048
{
1049-
BasicInt ret = (BasicInt)conn_.run("1+1");
1050-
return ret.getInt() == 2;
1049+
1050+
List<IEntity> args = new List<IEntity>();
1051+
conn_.run("version", args);
1052+
return true;
10511053
}
10521054
catch (IOException)
10531055
{
@@ -1084,7 +1086,21 @@ bool connectMinNode()
10841086
}
10851087
try
10861088
{
1087-
table = (BasicTable)conn_.run("rpc(getControllerAlias(), getClusterPerf)");
1089+
List<IEntity> args = new List<IEntity>();
1090+
string version = run("version", args).getString();
1091+
dolphindb.route.DBVersion dbVersion = new dolphindb.route.DBVersion(version);
1092+
int v0 = dbVersion.getSubV(0);
1093+
int v1 = dbVersion.getSubV(1);
1094+
int v2 = dbVersion.getSubV(2);
1095+
1096+
if ((v0 == 2 && v1 == 0 && v2 >= 15))
1097+
{
1098+
table = (BasicTable)conn_.run("getClusterPerf", args);
1099+
}
1100+
else
1101+
{
1102+
table = (BasicTable)conn_.run("rpc(getControllerAlias(),getClusterPerf)");
1103+
}
10881104
break;
10891105
}
10901106
catch (Exception e)
@@ -1190,7 +1206,8 @@ bool connectNode(string hostName, int port)
11901206
else if (type == ExceptionType.ET_NOINITIALIZED)
11911207
return false;
11921208
else //UNKNOW
1193-
throw new IOException(e.Message);
1209+
//throw new IOException(e.Message);
1210+
return false;
11941211
}
11951212
}
11961213
else

src/Properties/AssemblyInfo.cs

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

src/data/AbstractVector.cs

+11-15
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ public virtual void write(ExtendedDataOutput @out)
9191
if (this is BasicSymbolVector && rows() != 0)
9292
flag += 128;
9393
@out.writeShort(flag);
94-
@out.writeInt(rows());
94+
if(getDataType() == DATA_TYPE.DT_IOTANY)
95+
{
96+
@out.writeInt(((BasicIotAnyVector)this).serializeAnyVectorRows());
97+
}
98+
else
99+
{
100+
@out.writeInt(rows());
101+
}
95102
@out.writeInt(columns());
96103
writeVectorToOutputStream(@out);
97104
}
@@ -122,21 +129,10 @@ public virtual object getList()
122129
public abstract void add(object value);
123130
public abstract void addRange(object list);
124131

125-
public virtual int hashBucket(int index, int buckets)
126-
{
127-
return -1;
128-
}
129-
130-
public virtual IVector getSubVector(int[] indices)
131-
{
132-
IVector iv = new BasicIntVector(1);
133-
return iv;
134-
}
132+
public abstract int hashBucket(int index, int buckets);
133+
public abstract IVector getSubVector(int[] indices);
135134

136-
public virtual int asof(IScalar value)
137-
{
138-
return -1;
139-
}
135+
public abstract int asof(IScalar value);
140136

141137
public static void checkCompressedMethod(DATA_TYPE type, int method){
142138
if ((int)type > ARRAY_VECTOR_BASE)

src/data/BasicAnyVector.cs

+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
using dolphindb.io;
2+
using System;
3+
using System.Text;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
7+
namespace dolphindb.data
8+
{
9+
public class BasicAnyVector : AbstractVector
10+
{
11+
private List<IEntity> values;
12+
13+
14+
public BasicAnyVector(int size) : base(DATA_FORM.DF_VECTOR)
15+
{
16+
values = new List<IEntity>(size);
17+
for(int i = 0; i < size; ++i)
18+
{
19+
values.Add(null);
20+
}
21+
}
22+
23+
protected internal BasicAnyVector(IEntity[] array): base(DATA_FORM.DF_VECTOR)
24+
{
25+
values = new List<IEntity>(array.Length);
26+
for(int i = 0; i < array.Length ; ++i)
27+
{
28+
values.Add((IEntity)array[i]);
29+
}
30+
}
31+
32+
protected internal BasicAnyVector(ExtendedDataInput @in) : base(DATA_FORM.DF_VECTOR)
33+
{
34+
int rows = @in.readInt();
35+
int cols = @in.readInt();
36+
int size = rows * cols;
37+
values = new List<IEntity>();
38+
39+
BasicEntityFactory factory = new BasicEntityFactory();
40+
for (int i = 0; i < size; ++i)
41+
{
42+
short flag = @in.readShort();
43+
int form = flag >> 8;
44+
int type = flag & 0xff;
45+
bool extended = type >= 128;
46+
if (type >= 128)
47+
type -= 128;
48+
//if (form != 1)
49+
//assert (form == 1);
50+
//if (type != 4)
51+
//assert(type == 4);
52+
IEntity obj = factory.createEntity((DATA_FORM)form, (DATA_TYPE)type, @in, extended);
53+
values.Add(obj);
54+
}
55+
56+
}
57+
58+
public override IScalar get(int index)
59+
{
60+
if (values[index].isScalar())
61+
{
62+
return (IScalar)values[index];
63+
}
64+
else
65+
{
66+
throw new Exception("The element of the vector is not a scalar object.");
67+
}
68+
}
69+
70+
public override void set(int index, IScalar value)
71+
{
72+
values[index] = value;
73+
}
74+
75+
public virtual void setEntity(int index, IEntity value)
76+
{
77+
values[index] = value;
78+
}
79+
80+
public override bool isNull(int index)
81+
{
82+
return values[index] == null || (values[index].isScalar() && ((IScalar)values[index]).isNull());
83+
}
84+
85+
public override void setNull(int index)
86+
{
87+
values[index] = new Void();
88+
}
89+
90+
public override DATA_CATEGORY getDataCategory()
91+
{
92+
return DATA_CATEGORY.MIXED;
93+
}
94+
95+
public override DATA_TYPE getDataType()
96+
{
97+
return DATA_TYPE.DT_ANY;
98+
}
99+
100+
public override int rows()
101+
{
102+
return values.Count;
103+
}
104+
105+
public override string getString()
106+
{
107+
StringBuilder sb = new StringBuilder("(");
108+
int size = Math.Min(10, rows());
109+
if (size > 0)
110+
{
111+
sb.Append(getEntity(0).getString());
112+
}
113+
for (int i = 1; i < size; ++i)
114+
{
115+
sb.Append(',');
116+
sb.Append(getEntity(i).getString());
117+
}
118+
if (size < rows())
119+
{
120+
sb.Append(",...");
121+
}
122+
sb.Append(")");
123+
return sb.ToString();
124+
}
125+
126+
public override Type getElementClass()
127+
{
128+
return typeof(IEntity);
129+
}
130+
131+
protected internal override void writeVectorToOutputStream(ExtendedDataOutput @out)
132+
{
133+
foreach (IEntity value in values)
134+
{
135+
value.write(@out);
136+
}
137+
}
138+
139+
public override void set(int index, string value)
140+
{
141+
values[index] = new BasicString(value);
142+
}
143+
144+
public override object getList()
145+
{
146+
return values.ToList();
147+
}
148+
149+
public override void add(object value)
150+
{
151+
throw new NotImplementedException();
152+
}
153+
154+
public override void addRange(object list)
155+
{
156+
throw new NotImplementedException();
157+
}
158+
159+
public override IVector getSubVector(int[] indices)
160+
{
161+
int length = indices.Length;
162+
IEntity[] sub = new IEntity[length];
163+
for (int i = 0; i < length; ++i)
164+
sub[i] = values[indices[i]];
165+
return new BasicAnyVector(sub);
166+
}
167+
168+
public override int asof(IScalar value)
169+
{
170+
throw new Exception("BasicAnyVector.asof not supported.");
171+
}
172+
173+
public override void deserialize(int start, int count, ExtendedDataInput @in)
174+
{
175+
throw new NotImplementedException();
176+
}
177+
178+
public override void serialize(int start, int count, ExtendedDataOutput @out)
179+
{
180+
throw new NotImplementedException();
181+
}
182+
183+
public override int getUnitLength()
184+
{
185+
throw new NotImplementedException();
186+
}
187+
188+
public override int serialize(int start, int count, int offect, out int numElement, out int parition, ByteBuffer @out)
189+
{
190+
throw new NotImplementedException();
191+
}
192+
193+
public override void append(IScalar value)
194+
{
195+
values.Add(value);
196+
}
197+
198+
public override void append(IVector value)
199+
{
200+
values.Add(value);
201+
}
202+
203+
public void append(IEntity value)
204+
{
205+
values.Add(value);
206+
}
207+
208+
public override IEntity getEntity(int index)
209+
{
210+
return values[index];
211+
}
212+
213+
public override int getExtraParamForType()
214+
{
215+
throw new NotImplementedException();
216+
}
217+
218+
public override int hashBucket(int index, int buckets)
219+
{
220+
throw new NotImplementedException();
221+
}
222+
}
223+
224+
}

src/data/BasicArrayVector.cs

+10
Original file line numberDiff line numberDiff line change
@@ -451,5 +451,15 @@ public override IVector getSubVector(int[] indices)
451451
}
452452
return arrayVector;
453453
}
454+
455+
public override int hashBucket(int index, int buckets)
456+
{
457+
throw new NotImplementedException();
458+
}
459+
460+
public override int asof(IScalar value)
461+
{
462+
throw new NotImplementedException();
463+
}
454464
}
455465
}

0 commit comments

Comments
 (0)