Skip to content

Commit 36db3a8

Browse files
author
chengyitian
committed
AJ-649: add check for attrKey and attrForm;
1 parent 5e63718 commit 36db3a8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,25 @@ public EventHandler(List<EventScheme> eventSchemes, List<String> eventTimeKeys,
3434
if (Utils.isEmpty(event.getEventType()))
3535
throw new IllegalArgumentException("eventType must be non-empty.");
3636

37-
// check if has duplicate key in attrKeys
37+
// check scheme attrKey
3838
Set<String> set = new HashSet<>();
3939
for (String attrKey : event.getAttrKeys()) {
40+
if (Utils.isEmpty(attrKey))
41+
throw new IllegalArgumentException("attrKey must be non-null and non-empty.");
42+
43+
// check if has duplicate key in attrKeys
4044
if (!set.add(attrKey))
4145
throw new IllegalArgumentException("EventScheme cannot has duplicated attrKey in attrKeys.");
4246
}
4347

48+
// check scheme attrForm
49+
for (Entity.DATA_FORM attrForm : event.getAttrForms()) {
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.");
54+
}
55+
4456
int length = event.getAttrKeys().size();
4557
if (event.getAttrExtraParams().isEmpty()) {
4658
event.setAttrExtraParams(Collections.nCopies(length, 0));

0 commit comments

Comments
 (0)