@@ -153,6 +153,10 @@ public boolean serializeEvent(String eventType, List<Entity> attributes, List<En
153
153
154
154
for (int i = 0 ; i < attributes .size (); ++i ) {
155
155
if (info .getEventScheme ().getScheme ().getAttrTypes ().get (i ) != attributes .get (i ).getDataType ()) {
156
+ // An exception: when the type in schema is symbol, you can pass a string attribute
157
+ if (info .getEventScheme ().getScheme ().getAttrTypes ().get (i ) == Entity .DATA_TYPE .DT_SYMBOL && attributes .get (i ).getDataType () == Entity .DATA_TYPE .DT_STRING )
158
+ continue ;
159
+
156
160
errMsg .append ("the type of " ).append (i + 1 ).append ("th attribute of " ).append (eventType )
157
161
.append (" should be " ).append (info .getEventScheme ().getScheme ().getAttrTypes ().get (i ).toString ())
158
162
.append (" but now it is " ).append (attributes .get (i ).getDataType ().toString ());
@@ -330,10 +334,13 @@ private boolean checkSchema(List<EventScheme> eventSchemes, List<String> expandT
330
334
Entity .DATA_TYPE type = scheme .getAttrTypes ().get (j );
331
335
Entity .DATA_FORM form = scheme .getAttrForms ().get (j );
332
336
333
- // todo 因为目前server代码不能正确序列化symbol vector,所以API暂时先不支持
334
- // if (type < 0 || type > Entity.DATA_TYPE.DT_OBJECT_ARRAY || type == Entity.DATA_TYPE.DT_SYMBOL) {
335
- if (type == Entity .DATA_TYPE .DT_SYMBOL ) {
336
- errMsg .append ("not support DT_SYMBOL type." );
337
+ if (Objects .isNull (type )) {
338
+ errMsg .append ("attrType must be non-null." );
339
+ return false ;
340
+ }
341
+
342
+ if (type .getValue () < Entity .DATA_TYPE .DT_VOID .getValue () || type .getValue () > Entity .DATA_TYPE .DT_DECIMAL128_ARRAY .getValue ()) {
343
+ errMsg .append ("Invalid data type for the field " + scheme .getAttrKeys ().get (j ) + " of event " + scheme .getEventType ());
337
344
return false ;
338
345
}
339
346
@@ -347,9 +354,13 @@ private boolean checkSchema(List<EventScheme> eventSchemes, List<String> expandT
347
354
continue ;
348
355
}
349
356
350
- // BLOB STRING
351
357
// todo unitlen 如何获取,以及后续是否有用,这里先写 1
352
358
int unitLen = AbstractVector .getUnitLength (type );
359
+ if (type == Entity .DATA_TYPE .DT_SYMBOL ){
360
+ // the size of symbol is 4, but it need to be serialized as a string
361
+ unitLen = -1 ;
362
+ }
363
+
353
364
if (unitLen > 0 ) {
354
365
if (form == Entity .DATA_FORM .DF_SCALAR ) {
355
366
serls .add (new ScalarAttributeSerializer (unitLen ));
0 commit comments