Skip to content

Commit c4e46b3

Browse files
fix 300.2.3
1 parent 3bced30 commit c4e46b3

File tree

167 files changed

+55201
-0
lines changed

Some content is hidden

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

167 files changed

+55201
-0
lines changed

src/BasicDBTask.cs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//-------------------------------------------------------------------------------------------
2+
// Copyright © 2021 DolphinDB Inc.
3+
// Date : 2021.01.21
4+
// Author : zhikun.luo
5+
//-------------------------------------------------------------------------------------------
6+
7+
using dolphindb.data;
8+
using System.Collections.Generic;
9+
using System;
10+
using System.Threading;
11+
using dolphindb.io;
12+
13+
namespace dolphindb
14+
{
15+
public class BasicDBTask:IDBTask
16+
{
17+
private IEntity result = null;
18+
private string errMsg = null;
19+
private bool successful = false;
20+
private string script;
21+
private List<IEntity> args;
22+
private bool clearMemory_;
23+
private int priority_;
24+
private int parallelism_;
25+
private DBConnection conn;
26+
private WaitHandle waitHandle = new AutoResetEvent(false);
27+
private Semaphore semaphore = new Semaphore(1,1);
28+
29+
public void waitFor()
30+
{
31+
semaphore.WaitOne();
32+
}
33+
public void finish()
34+
{
35+
semaphore.Release();
36+
}
37+
public BasicDBTask(string script, List<IEntity> args, int priority = 4, int parallelism = 64, bool clearMemory = false)
38+
{
39+
semaphore.WaitOne();
40+
this.script = script;
41+
this.args = args;
42+
this.clearMemory_ = clearMemory;
43+
this.priority_ = priority;
44+
this.parallelism_ = parallelism;
45+
}
46+
public BasicDBTask(string script, int priority = 4, int parallelism = 64, bool clearMemory = false)
47+
{
48+
semaphore.WaitOne();
49+
this.script = script;
50+
this.clearMemory_ = clearMemory;
51+
this.priority_ = priority;
52+
this.parallelism_ = parallelism;
53+
}
54+
public IEntity call()
55+
{
56+
try
57+
{
58+
if (args != null)
59+
result = conn.run(script, args, priority_, parallelism_, 0, clearMemory_);
60+
else
61+
result = conn.run(script, priority_, parallelism_, 0, clearMemory_);
62+
errMsg = null;
63+
successful = true;
64+
return result;
65+
}
66+
catch(Exception t)
67+
{
68+
successful = false;
69+
result = null;
70+
errMsg = t.Message;
71+
return null;
72+
}
73+
}
74+
public void setDBConnection(DBConnection conn)
75+
{
76+
this.conn = conn;
77+
}
78+
public IEntity getResults()
79+
{
80+
return result;
81+
}
82+
public string getErrorMsg()
83+
{
84+
return errMsg;
85+
}
86+
public bool isSuccessful()
87+
{
88+
return successful;
89+
}
90+
91+
public bool isFinished()
92+
{
93+
if(successful || errMsg != null)
94+
{
95+
return true;
96+
}
97+
else
98+
{
99+
return false;
100+
}
101+
}
102+
}
103+
}

src/EntityBlockReader.cs

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
 //-------------------------------------------------------------------------------------------
2+
// Copyright © 2021 DolphinDB Inc.
3+
// Date : 2021.01.15
4+
// Author : zhikun.luo
5+
//-------------------------------------------------------------------------------------------
6+
7+
8+
using System;
9+
using dolphindb.io;
10+
using dolphindb.data;
11+
using System.Data;
12+
13+
namespace dolphindb
14+
{
15+
public class EntityBlockReader:IEntity
16+
{
17+
private IEntity currentValue;
18+
private int size;
19+
private int currentIndex = 0;
20+
private ExtendedDataInput instream;
21+
22+
public EntityBlockReader(ExtendedDataInput input)
23+
{
24+
int rows = input.readInt();
25+
int cols = input.readInt();
26+
size = rows * cols;
27+
currentIndex = 0;
28+
instream = input;
29+
}
30+
31+
public object getObject()
32+
{
33+
BasicEntityFactory factory = new BasicEntityFactory();
34+
if (currentIndex>=size) return null;
35+
36+
short flag = instream.readShort();
37+
int form = flag >> 8;
38+
int type = flag & 0xff;
39+
bool extended = type >= 128;
40+
if (type >= 128)
41+
type -= 128;
42+
currentValue = factory.createEntity((DATA_FORM)form, (DATA_TYPE)type, instream, extended);
43+
currentIndex++;
44+
return currentValue;
45+
}
46+
47+
public void skipAll()
48+
{
49+
BasicEntityFactory factory = new BasicEntityFactory();
50+
for (int i = currentIndex; i < size; i++)
51+
{
52+
short flag = instream.readShort();
53+
int form = flag >> 8;
54+
int type = flag & 0xff;
55+
bool extended = type >= 128;
56+
if (type >= 128)
57+
type -= 128;
58+
currentValue = factory.createEntity((DATA_FORM)form, (DATA_TYPE)type, instream, extended);
59+
currentIndex++;
60+
}
61+
}
62+
63+
public DataTable toDataTable()
64+
{
65+
throw new NotImplementedException();
66+
}
67+
public Boolean hasNext()
68+
{
69+
return currentIndex < size;
70+
}
71+
72+
73+
public DATA_FORM getDataForm()
74+
{
75+
return DATA_FORM.DF_TABLE;
76+
}
77+
78+
79+
public DATA_CATEGORY getDataCategory()
80+
{
81+
return DATA_CATEGORY.MIXED;
82+
}
83+
84+
85+
public DATA_TYPE getDataType()
86+
{
87+
return DATA_TYPE.DT_ANY;
88+
}
89+
90+
91+
public int rows()
92+
{
93+
return 0;
94+
}
95+
96+
97+
public int columns()
98+
{
99+
return 0;
100+
}
101+
102+
103+
public String getString()
104+
{
105+
return null;
106+
}
107+
108+
109+
public void write(ExtendedDataOutput output)
110+
{
111+
112+
}
113+
114+
115+
public bool isScalar()
116+
{
117+
return false;
118+
}
119+
120+
121+
public bool isVector()
122+
{
123+
return false;
124+
}
125+
126+
127+
public bool isPair()
128+
{
129+
return false;
130+
}
131+
132+
133+
public bool isTable()
134+
{
135+
return true;
136+
}
137+
138+
139+
public bool isMatrix()
140+
{
141+
return false;
142+
}
143+
144+
145+
public bool isDictionary()
146+
{
147+
return false;
148+
}
149+
150+
151+
public bool isChart()
152+
{
153+
return false;
154+
}
155+
156+
157+
public bool isChunk()
158+
{
159+
return false;
160+
}
161+
162+
public void writeCompressed(ExtendedDataOutput output)
163+
{
164+
throw new NotImplementedException();
165+
}
166+
}
167+
168+
}

0 commit comments

Comments
 (0)