Skip to content

Commit f3b5ca9

Browse files
author
chengyitian
committed
AJ-634: check if has duplicate key in attrKeys;
1 parent 2b8d264 commit f3b5ca9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.io.ByteArrayOutputStream;
1010
import java.io.IOException;
1111
import java.util.*;
12+
import java.util.Set;
1213

1314
public class EventHandler {
1415

@@ -33,6 +34,13 @@ public EventHandler(List<EventScheme> eventSchemes, List<String> eventTimeKeys,
3334
if (Utils.isEmpty(event.getEventType()))
3435
throw new IllegalArgumentException(funcName + " the eventType cannot be empty");
3536

37+
// check if has duplicate key in attrKeys
38+
Set<String> set = new HashSet<>();
39+
for (String attrKey : event.getAttrKeys()) {
40+
if (!set.add(attrKey))
41+
throw new IllegalArgumentException("EventScheme cannot has duplicated attrKey in attrKeys.");
42+
}
43+
3644
int length = event.getAttrKeys().size();
3745
if (event.getAttrExtraParams().isEmpty()) {
3846
event.setAttrExtraParams(Collections.nCopies(length, 0));

0 commit comments

Comments
 (0)