5
5
import java .util .HashMap ;
6
6
import java .util .Map ;
7
7
import java .util .Objects ;
8
+ import org .slf4j .Logger ;
9
+ import org .slf4j .LoggerFactory ;
8
10
import com .xxdb .io .ExtendedDataInput ;
9
11
import com .xxdb .io .ExtendedDataOutput ;
10
12
import com .fasterxml .jackson .annotation .JsonIgnore ;
@@ -15,17 +17,36 @@ public class BasicIotAnyVector extends AbstractVector {
15
17
private BasicIntVector indexsDataType ;
16
18
private BasicIntVector indexs ;
17
19
18
- public BasicIotAnyVector (Entity [] array ) {
20
+ private static final Logger log = LoggerFactory .getLogger (BasicIotAnyVector .class );
21
+
22
+
23
+ public BasicIotAnyVector (Scalar [] scalars ) {
19
24
super (DATA_FORM .DF_VECTOR );
25
+
26
+ if (Objects .isNull (scalars ) || scalars .length == 0 )
27
+ throw new RuntimeException ("The param 'scalars' cannot be null or empty." );
28
+
20
29
subVector = new HashMap <>();
21
30
indexsDataType = new BasicIntVector (0 );
22
31
indexs = new BasicIntVector (0 );
23
- for (int i = 0 ; i < array .length ; i ++) {
24
- subVector .put (array [i ].getDataType ().getValue (), array [i ]);
25
- for (int j = 0 ; j < array [i ].rows (); j ++ ) {
26
- indexsDataType .add (array [i ].getDataType ().getValue ());
27
- indexs .add (j );
32
+
33
+ try {
34
+ for (Scalar scalar : scalars ) {
35
+ int curDataTypeValue = scalar .getDataType ().getValue ();
36
+
37
+ if (Objects .isNull (subVector .get (curDataTypeValue ))) {
38
+ Vector curVector = BasicEntityFactory .instance ().createVectorWithDefaultValue (scalar .getDataType (), 0 , -1 );
39
+ curVector .Append (scalar );
40
+ subVector .put (curDataTypeValue , curVector );
41
+ } else {
42
+ ((Vector ) subVector .get (curDataTypeValue )).Append (scalar );
43
+ }
44
+
45
+ indexsDataType .add (curDataTypeValue );
46
+ indexs .add (subVector .get (curDataTypeValue ).rows () - 1 );
28
47
}
48
+ } catch (Exception e ) {
49
+ log .error (e .getMessage ());
29
50
}
30
51
}
31
52
0 commit comments