Skip to content

Commit 86a5e1b

Browse files
author
chengyitian
committed
Merge branch 'dev' of dolphindb.net:dolphindb/api-java
2 parents cfc9c95 + bdce5d2 commit 86a5e1b

Some content is hidden

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

56 files changed

+2722
-482
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.dolphindb</groupId>
44
<artifactId>dolphindb-javaapi</artifactId>
5-
<version>3.00.0.1</version>
5+
<version>3.00.0.2</version>
66
<packaging>jar</packaging>
77

88
<properties>
9-
<dolphindb.version>3.00.0.1</dolphindb.version>
9+
<dolphindb.version>3.00.0.2</dolphindb.version>
1010
</properties>
1111
<name>DolphinDB Java API</name>
1212
<description>The messaging and data conversion protocol between Java and DolphinDB server</description>
@@ -31,7 +31,7 @@
3131
<connection>scm:git:git@github.com:dolphindb/api-java.git</connection>
3232
<developerConnection>scm:git:git@github.com:dolphindb/api-java.git</developerConnection>
3333
<url>git@github.com:dolphindb/api-java.git</url>
34-
<tag>api-java-3.00.0.1</tag>
34+
<tag>api-java-3.00.0.2</tag>
3535
</scm>
3636
<dependencies>
3737
<dependency>

src/com/xxdb/data/BasicBooleanVector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,8 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
241241
numElementAndPartial.partial = 0;
242242
return targetNumElement;
243243
}
244+
245+
public byte[] getValues() {
246+
return values;
247+
}
244248
}

src/com/xxdb/data/BasicByteVector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,8 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
261261
numElementAndPartial.partial = 0;
262262
return targetNumElement;
263263
}
264+
265+
public byte[] getValues() {
266+
return values;
267+
}
264268
}

src/com/xxdb/data/BasicComplexVector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,8 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
281281
numElementAndPartial.partial = 0;
282282
return targetNumElement * 16;
283283
}
284+
285+
public Double2[] getValues() {
286+
return values;
287+
}
284288
}

src/com/xxdb/data/BasicDecimal128Vector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,9 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
503503
numElementAndPartial.partial = 0;
504504
return targetNumElement * unitLength;
505505
}
506+
507+
public BigInteger[] getUnscaledValues() {
508+
return unscaledValues;
509+
}
506510
}
507511

src/com/xxdb/data/BasicDecimal32Vector.java

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class BasicDecimal32Vector extends AbstractVector{
1616
private int scale_ = -1;
17-
private int[] values;
17+
private int[] unscaledValues;
1818
private int size;
1919
private int capacity;
2020

@@ -27,18 +27,18 @@ public BasicDecimal32Vector(int size, int scale){
2727
if (scale < 0 || scale > 9)
2828
throw new RuntimeException("Scale " + scale + " is out of bounds, it must be in [0,9].");
2929
this.scale_ = scale;
30-
this.values = new int[size];
30+
this.unscaledValues = new int[size];
3131

32-
this.size = values.length;
33-
capacity = values.length;
32+
this.size = unscaledValues.length;
33+
capacity = unscaledValues.length;
3434
}
3535

3636
BasicDecimal32Vector(DATA_FORM df, int size){
3737
super(df);
38-
values = new int[size];
38+
unscaledValues = new int[size];
3939

40-
this.size = values.length;
41-
capacity = values.length;
40+
this.size = unscaledValues.length;
41+
capacity = unscaledValues.length;
4242
}
4343

4444
public BasicDecimal32Vector(String[] data, int scale) {
@@ -48,12 +48,12 @@ public BasicDecimal32Vector(String[] data, int scale) {
4848
this.scale_ = scale;
4949

5050
int length = data.length;
51-
values = new int[length];
51+
unscaledValues = new int[length];
5252
for (int i = 0; i < length; i++) {
5353
BigDecimal bd = new BigDecimal(data[i]);
5454
BigDecimal multipliedValue = bd.scaleByPowerOfTen(scale).setScale(0, RoundingMode.HALF_UP);
5555
if (multipliedValue.intValue() > Integer.MIN_VALUE && multipliedValue.intValue() < Integer.MAX_VALUE)
56-
values[i] = multipliedValue.intValue();
56+
unscaledValues[i] = multipliedValue.intValue();
5757
}
5858

5959
size = length;
@@ -65,17 +65,17 @@ public BasicDecimal32Vector(String[] data, int scale) {
6565
if (scale < 0 || scale > 9)
6666
throw new RuntimeException("Scale " + scale + " is out of bounds, it must be in [0,9].");
6767
this.scale_ = scale;
68-
this.values = dataValue;
69-
this.size = values.length;
70-
capacity = values.length;
68+
this.unscaledValues = dataValue;
69+
this.size = unscaledValues.length;
70+
capacity = unscaledValues.length;
7171
}
7272

7373
public BasicDecimal32Vector(DATA_FORM df, ExtendedDataInput in, int extra) throws IOException{
7474
super(df);
7575
int rows = in.readInt();
7676
int cols = in.readInt();
7777
int size = rows * cols;
78-
values = new int[size];
78+
unscaledValues = new int[size];
7979
if (extra != -1)
8080
scale_ = extra;
8181
else
@@ -92,13 +92,13 @@ public BasicDecimal32Vector(DATA_FORM df, ExtendedDataInput in, int extra) throw
9292
ByteBuffer byteBuffer = ByteBuffer.wrap(buf, 0, len).order(bo);
9393
for (int i = 0; i < end; i++){
9494
int value = byteBuffer.getInt(i * 4);
95-
values[i + start] = value;
95+
unscaledValues[i + start] = value;
9696
}
9797
off += len;
9898
}
9999

100-
this.size = values.length;
101-
capacity = values.length;
100+
this.size = unscaledValues.length;
101+
capacity = unscaledValues.length;
102102
}
103103

104104
@Deprecated
@@ -116,9 +116,9 @@ public BasicDecimal32Vector(double[] data, int scale){
116116
BigDecimal dbvalue = new BigDecimal(Double.toString(data[i]));
117117
newIntValue[i] = (dbvalue.multiply(pow)).intValue();
118118
}
119-
values = newIntValue;
120-
this.size = values.length;
121-
capacity = values.length;
119+
unscaledValues = newIntValue;
120+
this.size = unscaledValues.length;
121+
capacity = unscaledValues.length;
122122
}
123123

124124
@Override
@@ -132,19 +132,19 @@ public void deserialize(int start, int count, ExtendedDataInput in) throws IOExc
132132
int end = len / 4;
133133
ByteBuffer byteBuffer = ByteBuffer.wrap(buf, 0, len).order(bo);
134134
for (int i = 0; i < end; i++)
135-
values[i + start] = byteBuffer.getInt(i * 4);
135+
unscaledValues[i + start] = byteBuffer.getInt(i * 4);
136136
off += len;
137137
start += end;
138138
}
139139

140-
this.size = values.length;
141-
capacity = values.length;
140+
this.size = unscaledValues.length;
141+
capacity = unscaledValues.length;
142142
}
143143

144144
@Override
145145
protected void writeVectorToOutputStream(ExtendedDataOutput out) throws IOException {
146146
int[] data = new int[size];
147-
System.arraycopy(values, 0, data, 0, size);
147+
System.arraycopy(unscaledValues, 0, data, 0, size);
148148
out.writeInt(scale_);
149149
out.writeIntArray(data);
150150
}
@@ -159,7 +159,7 @@ public Vector getSubVector(int[] indices) {
159159
int length = indices.length;
160160
int[] sub = new int[length];
161161
for(int i=0; i<length; ++i)
162-
sub[i] = values[indices[i]];
162+
sub[i] = unscaledValues[indices[i]];
163163
return new BasicDecimal32Vector(sub, scale_);
164164
}
165165

@@ -170,17 +170,17 @@ public int asof(Scalar value) {
170170

171171
@Override
172172
public boolean isNull(int index) {
173-
return values[index] == Integer.MIN_VALUE;
173+
return unscaledValues[index] == Integer.MIN_VALUE;
174174
}
175175

176176
@Override
177177
public void setNull(int index) {
178-
values[index] = Integer.MIN_VALUE;
178+
unscaledValues[index] = Integer.MIN_VALUE;
179179
}
180180

181181
@Override
182182
public Entity get(int index) {
183-
return new BasicDecimal32(new int[]{scale_, values[index]});
183+
return new BasicDecimal32(new int[]{scale_, unscaledValues[index]});
184184
}
185185

186186
@Override
@@ -193,7 +193,7 @@ public void set(int index, Entity value) throws Exception {
193193
DATA_TYPE type = value.getDataType();
194194
if(scale_ < 0) scale_ = newScale;
195195
if(((Scalar)value).isNull())
196-
values[index] = Integer.MIN_VALUE;
196+
unscaledValues[index] = Integer.MIN_VALUE;
197197
else{
198198
if(scale_ != newScale) {
199199
BigInteger newValue = BigInteger.valueOf(((BasicDecimal32) (value)).getInt());
@@ -205,9 +205,9 @@ public void set(int index, Entity value) throws Exception {
205205
pow = pow.pow(scale_ - newScale);
206206
newValue = newValue.multiply(pow);
207207
}
208-
values[index] = newValue.intValue();
208+
unscaledValues[index] = newValue.intValue();
209209
}else{
210-
values[index] = ((BasicDecimal32) value).getInt();
210+
unscaledValues[index] = ((BasicDecimal32) value).getInt();
211211
}
212212
}
213213
}
@@ -220,7 +220,7 @@ public Class<?> getElementClass() {
220220
@Override
221221
public void serialize(int start, int count, ExtendedDataOutput out) throws IOException {
222222
for (int i = 0; i < count; i++){
223-
out.writeInt(values[start + i]);
223+
out.writeInt(unscaledValues[start + i]);
224224
}
225225
}
226226

@@ -230,52 +230,52 @@ public int getUnitLength() {
230230
}
231231

232232
public void add(String value) {
233-
if (size + 1 > capacity && values.length > 0) {
234-
values = Arrays.copyOf(values, values.length * 2);
235-
} else if (values.length <= 0){
236-
values = new int[1];
233+
if (size + 1 > capacity && unscaledValues.length > 0) {
234+
unscaledValues = Arrays.copyOf(unscaledValues, unscaledValues.length * 2);
235+
} else if (unscaledValues.length <= 0){
236+
unscaledValues = new int[1];
237237
}
238238

239-
capacity = values.length;
239+
capacity = unscaledValues.length;
240240
if (value.equals("0.0"))
241-
values[size] = 0;
241+
unscaledValues[size] = 0;
242242
else if(value.equals(""))
243-
values[size] = Integer.MIN_VALUE;
243+
unscaledValues[size] = Integer.MIN_VALUE;
244244
else {
245245
BigDecimal pow = BigDecimal.TEN.pow(scale_);
246246
BigDecimal bd = new BigDecimal(value);
247247
if (checkDecimal32Range(bd.multiply(pow).intValue()))
248-
values[size] = bd.multiply(pow).intValue();
248+
unscaledValues[size] = bd.multiply(pow).intValue();
249249
}
250250
size++;
251251
}
252252

253253
@Deprecated
254254
public void add(double value) {
255-
if (size + 1 > capacity && values.length > 0){
256-
values = Arrays.copyOf(values, values.length * 2);
257-
}else if (values.length <= 0){
258-
values = Arrays.copyOf(values, values.length + 1);
255+
if (size + 1 > capacity && unscaledValues.length > 0){
256+
unscaledValues = Arrays.copyOf(unscaledValues, unscaledValues.length * 2);
257+
}else if (unscaledValues.length <= 0){
258+
unscaledValues = Arrays.copyOf(unscaledValues, unscaledValues.length + 1);
259259
}
260-
capacity = values.length;
260+
capacity = unscaledValues.length;
261261
if (value == 0.0)
262-
values[size] = 0;
262+
unscaledValues[size] = 0;
263263
else {
264264
BigDecimal pow = new BigDecimal(1);
265265
for (long i = 0; i < scale_; i++) {
266266
pow = pow.multiply(new BigDecimal(10));
267267
}
268268
BigDecimal dbvalue = new BigDecimal(Double.toString(value));
269-
values[size] = (dbvalue.multiply(pow)).intValue();
269+
unscaledValues[size] = (dbvalue.multiply(pow)).intValue();
270270
}
271271
size++;
272272
}
273273

274274
void addRange(int[] valueList) {
275-
values = Arrays.copyOf(values, valueList.length + values.length);
276-
System.arraycopy(valueList, 0, values, size, valueList.length);
275+
unscaledValues = Arrays.copyOf(unscaledValues, valueList.length + unscaledValues.length);
276+
System.arraycopy(valueList, 0, unscaledValues, size, valueList.length);
277277
size += valueList.length;
278-
capacity = values.length;
278+
capacity = unscaledValues.length;
279279
}
280280

281281
public void addRange(String[] valueList) {
@@ -287,10 +287,10 @@ public void addRange(String[] valueList) {
287287
newIntValue[i] = bd.multiply(pow).intValue();
288288

289289
}
290-
values = Arrays.copyOf(values, newIntValue.length + values.length);
291-
System.arraycopy(newIntValue, 0, values, size, newIntValue.length);
290+
unscaledValues = Arrays.copyOf(unscaledValues, newIntValue.length + unscaledValues.length);
291+
System.arraycopy(newIntValue, 0, unscaledValues, size, newIntValue.length);
292292
size += newIntValue.length;
293-
capacity = values.length;
293+
capacity = unscaledValues.length;
294294
}
295295

296296
@Deprecated
@@ -304,10 +304,10 @@ public void addRange(double[] valueList) {
304304
BigDecimal dbvalue = new BigDecimal(Double.toString(valueList[i]));
305305
newIntValue[i] = (dbvalue.multiply(pow)).intValue();
306306
}
307-
values = Arrays.copyOf(values, newIntValue.length + values.length);
308-
System.arraycopy(newIntValue, 0, values, size, newIntValue.length);
307+
unscaledValues = Arrays.copyOf(unscaledValues, newIntValue.length + unscaledValues.length);
308+
System.arraycopy(newIntValue, 0, unscaledValues, size, newIntValue.length);
309309
size += newIntValue.length;
310-
capacity = values.length;
310+
capacity = unscaledValues.length;
311311
}
312312

313313
@Override
@@ -337,7 +337,7 @@ public int getScale(){
337337
@JsonIgnore
338338
public int[] getdataArray(){
339339
int[] data = new int[size];
340-
System.arraycopy(values, 0, data, 0, size);
340+
System.arraycopy(unscaledValues, 0, data, 0, size);
341341
return data;
342342
}
343343

@@ -371,7 +371,7 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
371371
targetNumElement = Math.min((out.remaining() / getUnitLength()), targetNumElement);
372372
for (int i = 0; i < targetNumElement; ++i)
373373
{
374-
out.putInt(values[indexStart + i]);
374+
out.putInt(unscaledValues[indexStart + i]);
375375
}
376376
numElementAndPartial.numElement = targetNumElement;
377377
numElementAndPartial.partial = 0;
@@ -381,4 +381,8 @@ public int serialize(int indexStart, int offect, int targetNumElement, NumElemen
381381
private boolean checkDecimal32Range(int value) {
382382
return value > Integer.MIN_VALUE && value < Integer.MAX_VALUE;
383383
}
384+
385+
public int[] getUnscaledValues() {
386+
return unscaledValues;
387+
}
384388
}

0 commit comments

Comments
 (0)