@@ -153,6 +153,10 @@ public boolean serializeEvent(String eventType, List<Entity> attributes, List<En
153153
154154 for (int i = 0 ; i < attributes .size (); ++i ) {
155155 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+
156160 errMsg .append ("the type of " ).append (i + 1 ).append ("th attribute of " ).append (eventType )
157161 .append (" should be " ).append (info .getEventScheme ().getScheme ().getAttrTypes ().get (i ).toString ())
158162 .append (" but now it is " ).append (attributes .get (i ).getDataType ().toString ());
@@ -330,10 +334,13 @@ private boolean checkSchema(List<EventScheme> eventSchemes, List<String> expandT
330334 Entity .DATA_TYPE type = scheme .getAttrTypes ().get (j );
331335 Entity .DATA_FORM form = scheme .getAttrForms ().get (j );
332336
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 ());
337344 return false ;
338345 }
339346
@@ -347,9 +354,13 @@ private boolean checkSchema(List<EventScheme> eventSchemes, List<String> expandT
347354 continue ;
348355 }
349356
350- // BLOB STRING
351357 // todo unitlen 如何获取,以及后续是否有用,这里先写 1
352358 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+
353364 if (unitLen > 0 ) {
354365 if (form == Entity .DATA_FORM .DF_SCALAR ) {
355366 serls .add (new ScalarAttributeSerializer (unitLen ));
0 commit comments