Skip to content

Commit e6c0b77

Browse files
author
chengyitian
committed
AJ-699: modify some 'names' for EventHandler;
1 parent 2f096b2 commit e6c0b77

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/com/xxdb/streaming/client/cep/EventHandler.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ public EventHandler(List<EventSchema> eventSchemas, List<String> eventTimeKeys,
3636

3737
// check schema fieldNames
3838
Set<String> set = new HashSet<>();
39-
for (String attrKey : event.getFieldNames()) {
40-
if (Utils.isEmpty(attrKey))
41-
throw new IllegalArgumentException("attrKey must be non-null and non-empty.");
39+
for (String fieldName : event.getFieldNames()) {
40+
if (Utils.isEmpty(fieldName))
41+
throw new IllegalArgumentException("fieldName must be non-null and non-empty.");
4242

43-
// check if has duplicate key in attrKeys
44-
if (!set.add(attrKey))
45-
throw new IllegalArgumentException("EventSchema cannot has duplicated attrKey in attrKeys.");
43+
// check if has duplicate key in fieldName
44+
if (!set.add(fieldName))
45+
throw new IllegalArgumentException("EventSchema cannot has duplicated fieldName in fieldNames.");
4646
}
4747

4848
// check schema fieldForms
49-
for (Entity.DATA_FORM attrForm : event.getFieldForms()) {
50-
if (Objects.isNull(attrForm))
51-
throw new IllegalArgumentException("attrForm must be non-null.");
52-
if (attrForm != Entity.DATA_FORM.DF_SCALAR && attrForm != Entity.DATA_FORM.DF_VECTOR)
53-
throw new IllegalArgumentException("attrForm only can be DF_SCALAR or DF_VECTOR.");
49+
for (Entity.DATA_FORM fieldForm : event.getFieldForms()) {
50+
if (Objects.isNull(fieldForm))
51+
throw new IllegalArgumentException("fieldForm must be non-null.");
52+
if (fieldForm != Entity.DATA_FORM.DF_SCALAR && fieldForm != Entity.DATA_FORM.DF_VECTOR)
53+
throw new IllegalArgumentException("fieldForm only can be DF_SCALAR or DF_VECTOR.");
5454
}
5555

5656
int length = event.getFieldNames().size();
@@ -67,14 +67,14 @@ public EventHandler(List<EventSchema> eventSchemas, List<String> eventTimeKeys,
6767
// check if fieldExtraParams valid
6868
if (Objects.nonNull(event.getFieldExtraParams()) && !event.getFieldExtraParams().isEmpty()) {
6969
for (int i = 0; i < event.getFieldTypes().size(); i++) {
70-
Entity.DATA_TYPE attrType = event.getFieldTypes().get(i);
70+
Entity.DATA_TYPE fieldType = event.getFieldTypes().get(i);
7171
Integer scale = event.getFieldExtraParams().get(i);
72-
if (attrType == Entity.DATA_TYPE.DT_DECIMAL32 && (scale < 0 || scale > 9))
73-
throw new IllegalArgumentException(attrType + " scale " + scale + " is out of bounds, it must be in [0,9].");
74-
else if (attrType == Entity.DATA_TYPE.DT_DECIMAL64 && (scale < 0 || scale > 18))
75-
throw new IllegalArgumentException(attrType + " scale " + scale + " is out of bounds, it must be in [0,18].");
76-
else if (attrType == Entity.DATA_TYPE.DT_DECIMAL128 && (scale < 0 || scale > 38))
77-
throw new IllegalArgumentException(attrType + " scale " + scale + " is out of bounds, it must be in [0,38].");
72+
if (fieldType == Entity.DATA_TYPE.DT_DECIMAL32 && (scale < 0 || scale > 9))
73+
throw new IllegalArgumentException(fieldType + " scale " + scale + " is out of bounds, it must be in [0,9].");
74+
else if (fieldType == Entity.DATA_TYPE.DT_DECIMAL64 && (scale < 0 || scale > 18))
75+
throw new IllegalArgumentException(fieldType + " scale " + scale + " is out of bounds, it must be in [0,18].");
76+
else if (fieldType == Entity.DATA_TYPE.DT_DECIMAL128 && (scale < 0 || scale > 38))
77+
throw new IllegalArgumentException(fieldType + " scale " + scale + " is out of bounds, it must be in [0,38].");
7878
}
7979
}
8080
}
@@ -169,23 +169,23 @@ public boolean serializeEvent(String eventType, List<Entity> attributes, List<En
169169
return false;
170170
}
171171

172-
// check schema attrExtraParams with decimal attribute.
172+
// check schema fieldExtraParams with decimal attribute.
173173
EventInfo eventInfo = this.eventInfos.get(eventType);
174174
EventSchemaEx eventSchema = eventInfo.getEventSchema();
175175
EventSchema schema = eventSchema.getSchema();
176-
List<Integer> attrExtraParams = schema.getFieldExtraParams();
177-
if (!attrExtraParams.isEmpty()) {
176+
List<Integer> fieldExtraParams = schema.getFieldExtraParams();
177+
if (!fieldExtraParams.isEmpty()) {
178178
Entity attribute = attributes.get(i);
179179
if (attribute.isScalar()) {
180-
if ((attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL32 && ((BasicDecimal32) attribute).getScale() != attrExtraParams.get(i))
181-
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL64 && ((BasicDecimal64) attribute).getScale() != attrExtraParams.get(i))
182-
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL128 && ((BasicDecimal128) attribute).getScale() != attrExtraParams.get(i)))
183-
throw new IllegalArgumentException("The decimal attribute' scale doesn't match to schema attrExtraParams scale.");
180+
if ((attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL32 && ((BasicDecimal32) attribute).getScale() != fieldExtraParams.get(i))
181+
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL64 && ((BasicDecimal64) attribute).getScale() != fieldExtraParams.get(i))
182+
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL128 && ((BasicDecimal128) attribute).getScale() != fieldExtraParams.get(i)))
183+
throw new IllegalArgumentException("The decimal attribute' scale doesn't match to schema fieldExtraParams scale.");
184184
} else if (attribute.isVector()) {
185-
if ((attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL32 && ((BasicDecimal32Vector) attribute).getScale() != attrExtraParams.get(i))
186-
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL64 && ((BasicDecimal64Vector) attribute).getScale() != attrExtraParams.get(i))
187-
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL128 && ((BasicDecimal128Vector) attribute).getScale() != attrExtraParams.get(i)))
188-
throw new IllegalArgumentException("The decimal attribute' scale doesn't match to schema attrExtraParams scale.");
185+
if ((attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL32 && ((BasicDecimal32Vector) attribute).getScale() != fieldExtraParams.get(i))
186+
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL64 && ((BasicDecimal64Vector) attribute).getScale() != fieldExtraParams.get(i))
187+
|| (attribute.getDataType() == Entity.DATA_TYPE.DT_DECIMAL128 && ((BasicDecimal128Vector) attribute).getScale() != fieldExtraParams.get(i)))
188+
throw new IllegalArgumentException("The decimal attribute' scale doesn't match to schema fieldExtraParams scale.");
189189
}
190190
}
191191
}
@@ -336,7 +336,7 @@ private boolean checkSchema(List<EventSchema> eventSchemas, List<String> expandT
336336
Entity.DATA_FORM form = schema.getFieldForms().get(j);
337337

338338
if (Objects.isNull(type)) {
339-
errMsg.append("attrType must be non-null.");
339+
errMsg.append("fieldType must be non-null.");
340340
return false;
341341
}
342342

0 commit comments

Comments
 (0)