Skip to content

Commit 430d036

Browse files
committed
Merge branch 'dev' of https://dolphindb.net/dolphindb/api-java into dev
2 parents 6148e0b + 8c24b03 commit 430d036

File tree

10 files changed

+1467
-1002
lines changed

10 files changed

+1467
-1002
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class EventClient extends AbstractClient {
2828

2929
private static final Logger log = LoggerFactory.getLogger(DBConnection.class);
3030

31-
public EventClient(List<EventScheme> eventSchemes, List<String> eventTimeKeys, List<String> commonKeys) throws SocketException {
31+
public EventClient(List<EventSchema> eventSchemas, List<String> eventTimeKeys, List<String> commonKeys) throws SocketException {
3232
super(0);
33-
eventHandler = new EventHandler(eventSchemes, eventTimeKeys, commonKeys);
33+
eventHandler = new EventHandler(eventSchemas, eventTimeKeys, commonKeys);
3434
}
3535

3636
public void subscribe(String host, int port, String tableName, String actionName, MessageHandler handler, long offset, boolean reconnect, String userName, String password) throws IOException {

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

Lines changed: 67 additions & 66 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
public class EventInfo {
66

77
private List<AttributeSerializer> attributeSerializers;
8-
private EventSchemeEx eventScheme;
8+
private EventSchemaEx eventSchema;
99

10-
public EventInfo(List<AttributeSerializer> attributeSerializers, EventSchemeEx eventScheme) {
10+
public EventInfo(List<AttributeSerializer> attributeSerializers, EventSchemaEx eventSchema) {
1111
this.attributeSerializers = attributeSerializers;
12-
this.eventScheme = eventScheme;
12+
this.eventSchema = eventSchema;
1313
}
1414

1515
public List<AttributeSerializer> getAttributeSerializers() {
1616
return this.attributeSerializers;
1717
}
1818

19-
public EventSchemeEx getEventScheme() {
20-
return this.eventScheme;
19+
public EventSchemaEx getEventSchema() {
20+
return this.eventSchema;
2121
}
2222
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.xxdb.streaming.client.cep;
2+
3+
import com.xxdb.data.Entity;
4+
import java.util.ArrayList;
5+
import java.util.List;
6+
7+
public class EventSchema {
8+
9+
private String eventType;
10+
private List<String> fieldNames;
11+
private List<Entity.DATA_TYPE> fieldTypes;
12+
private List<Entity.DATA_FORM> fieldForms;
13+
private List<Integer> fieldExtraParams;
14+
15+
public EventSchema() {
16+
this.fieldNames = new ArrayList<>();
17+
this.fieldTypes = new ArrayList<>();
18+
this.fieldForms = new ArrayList<>();
19+
this.fieldExtraParams = new ArrayList<>();
20+
}
21+
22+
public List<String> getFieldNames() {
23+
return fieldNames;
24+
}
25+
26+
public String getEventType() {
27+
return this.eventType;
28+
}
29+
30+
public List<Entity.DATA_TYPE> getFieldTypes() {
31+
return this.fieldTypes;
32+
}
33+
34+
public List<Entity.DATA_FORM> getFieldForms() {
35+
return this.fieldForms;
36+
}
37+
38+
public List<Integer> getFieldExtraParams() {
39+
return this.fieldExtraParams;
40+
}
41+
42+
public void setFieldExtraParams(List<Integer> fieldExtraParams) {
43+
this.fieldExtraParams = fieldExtraParams;
44+
}
45+
46+
public void setEventType(String eventType) {
47+
this.eventType = eventType;
48+
}
49+
50+
public void setFieldNames(List<String> fieldNames) {
51+
this.fieldNames = fieldNames;
52+
}
53+
54+
public void setFieldTypes(List<Entity.DATA_TYPE> fieldTypes) {
55+
this.fieldTypes = fieldTypes;
56+
}
57+
58+
public void setFieldForms(List<Entity.DATA_FORM> fieldForms) {
59+
this.fieldForms = fieldForms;
60+
}
61+
}

src/com/xxdb/streaming/client/cep/EventSchemeEx.java renamed to src/com/xxdb/streaming/client/cep/EventSchemaEx.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
public class EventSchemeEx {
6+
public class EventSchemaEx {
77

8-
private EventScheme scheme;
8+
private EventSchema schema;
99
private int timeIndex;
1010
private List<Integer> commonKeyIndex;
1111

12-
public EventSchemeEx() {
13-
this.scheme = new EventScheme();
12+
public EventSchemaEx() {
13+
this.schema = new EventSchema();
1414
this.commonKeyIndex = new ArrayList<>();
1515
}
1616

17-
public EventScheme getScheme() {
18-
return this.scheme;
17+
public EventSchema getSchema() {
18+
return this.schema;
1919
}
2020

21-
public void setScheme(EventScheme scheme) {
22-
this.scheme = scheme;
21+
public void setSchema(EventSchema schema) {
22+
this.schema = schema;
2323
}
2424

2525
public int getTimeIndex() {

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

Lines changed: 0 additions & 61 deletions
This file was deleted.

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,9 @@ public class EventSender {
1212
private String insertScript;
1313
private EventHandler eventHandler;
1414
private DBConnection conn;
15-
private boolean isConnected;
16-
17-
public EventSender(List<EventScheme> eventSchemes, List<String> eventTimeKeys, List<String> commonKeys) {
18-
this.eventHandler = new EventHandler(eventSchemes, eventTimeKeys, commonKeys);
19-
this.isConnected = false;
20-
}
21-
22-
public void connect(DBConnection conn, String tableName) throws IOException {
23-
if (this.isConnected)
24-
throw new RuntimeException("The eventSender has already been called.");
25-
26-
if (!conn.isConnected())
27-
throw new RuntimeException("The connection to dolphindb has not been established.");
2815

16+
public EventSender(DBConnection conn, String tableName, List<EventSchema> eventSchemas, List<String> eventTimeKeys, List<String> commonKeys) throws IOException {
17+
this.eventHandler = new EventHandler(eventSchemas, eventTimeKeys, commonKeys);
2918
this.conn = conn;
3019

3120
String sql = "select top 0 * from " + tableName;
@@ -35,13 +24,9 @@ public void connect(DBConnection conn, String tableName) throws IOException {
3524
throw new RuntimeException(errMsg.toString());
3625

3726
this.insertScript = "tableInsert{" + tableName + "}";
38-
this.isConnected = true;
3927
}
4028

4129
public void sendEvent(String eventType, List<Entity> attributes) {
42-
if (!isConnected)
43-
throw new RuntimeException("This eventSender has not connected to the dolphindb");
44-
4530
List<Entity> args = new ArrayList<>();
4631
StringBuilder errMsg = new StringBuilder();
4732

@@ -55,8 +40,4 @@ public void sendEvent(String eventType, List<Entity> attributes) {
5540
}
5641
}
5742

58-
public static EventSender createEventSender(List<EventScheme> eventSchemes, List<String> eventTimeKeys, List<String> commonKeys) {
59-
return new EventSender(eventSchemes, eventTimeKeys, commonKeys);
60-
}
61-
6243
}

0 commit comments

Comments
 (0)