Skip to content

Commit b6f23f3

Browse files
committed
docs: synced via GitHub Actions
1 parent 1c57935 commit b6f23f3

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 事件队列
2+
3+
## 数据库事件表
4+
5+
### 广播
6+
7+
1. topic以 `bro-`为前缀
8+
2. 启动时查询 `eventTime > currentTime - eventTimeOffset` 的事件,并依次处理
9+
10+
```sql
11+
select o
12+
from event o
13+
where o.topic = 'test'
14+
and o.eventTime > ${startTime}
15+
and o.eventID > lastProcessEventID
16+
order by o.eventID asc
17+
```
18+
19+
### 集群分工
20+
21+
1. topic以 `cluster-`为前缀
22+
2. 查询所有 `processTime < currentTime`的记录,修改processTime为`currentTime + maxProcessSpan`,这样其他节点就不会处理同样的事件
23+
3. 成功处理完毕后将事件状态设置为processed,或者删除事件

src/dev-guide/orm/logical-delete.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ deleteVersionProp用于避免逻辑删除时唯一键依然存在导致与正常
1515
缺省情况下EQL查询和关联集合查询都会考虑到逻辑删除条件,只查询`delFlag=0`的记录。
1616

1717
QueryBean和SQL对象都支持disableLogicalDelete设置,从而禁用逻辑删除的过滤条件。
18+
19+
IOrmEntity上也具有`orm_disableLogicalDelete()`方法,则可以真正执行物理删除,否则`session.delete(entity)`实际只会设置entity的deleteFlag属性。
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 乐观锁
2+
3+
## 启用乐观锁
4+
5+
在Excel模型中,为字段指定【数据域】为version,则会设置实体的versionProp配置,它的类型应该是INTEGER或者BIGINT。
6+
7+
更新数据库时会自动加入version条件,并自动对version+1。
8+
9+
如果更新了多条记录,则EntityPersisterImpl中将会抛出`nop.err.orm.update-entity-multiple-rows`异常.
10+
如果更新失败,更新条目数为0,则会抛出`nop.err.orm.update-entity-not-found`异常。
11+
12+
## 禁用乐观锁
13+
14+
`entity.orm_disableVersionCheckError(true)`可以禁用指定实体的乐观锁更新检查,按照versionProp更新失败时不会抛出异常,但是会导致实体被设置为readonly。

src/dev-guide/stream/windowing.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# 窗口函数
2+
3+
## WindowOperator
4+
5+
1. 先为元素分配一组窗口
6+
2. 针对每个窗口,检查trigger是否触发,并修改timer状态
7+
3. timer触发时,同样是检查trigger是否触发
8+
9+
```javascript
10+
void processElement(StreamRecord<IN> element){
11+
const elementWindows = windowAssigner.assignWindows(
12+
element.getValue(), element.getTimestamp(), windowAssignerContext);
13+
for (const window of elementWindows) {
14+
TriggerResult triggerResult = triggerContext.onElement(element);
15+
16+
if (triggerResult.isFire()) {
17+
ACC contents = windowState.get();
18+
if (contents != null) {
19+
emitWindowContents(actualWindow, contents);
20+
}
21+
}
22+
23+
if (triggerResult.isPurge()) {
24+
windowState.clear();
25+
}
26+
registerCleanupTimer(actualWindow);
27+
}
28+
}
29+
30+
void onEventTime(InternalTimer<K, W> timer) {
31+
triggerContext.key = timer.getKey();
32+
triggerContext.window = timer.getNamespace();
33+
34+
MergingWindowSet<W> mergingWindows;
35+
36+
if (windowAssigner instanceof MergingWindowAssigner) {
37+
mergingWindows = getMergingWindowSet();
38+
W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
39+
if (stateWindow == null) {
40+
// Timer firing for non-existent window, this can only happen if a
41+
// trigger did not clean up timers. We have already cleared the merging
42+
// window and therefore the Trigger state, however, so nothing to do.
43+
return;
44+
} else {
45+
windowState.setCurrentNamespace(stateWindow);
46+
}
47+
} else {
48+
windowState.setCurrentNamespace(triggerContext.window);
49+
mergingWindows = null;
50+
}
51+
52+
TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp());
53+
54+
if (triggerResult.isFire()) {
55+
ACC contents = windowState.get();
56+
if (contents != null) {
57+
emitWindowContents(triggerContext.window, contents);
58+
}
59+
}
60+
61+
if (triggerResult.isPurge()) {
62+
windowState.clear();
63+
}
64+
65+
if (windowAssigner.isEventTime()
66+
&& isCleanupTime(triggerContext.window, timer.getTimestamp())) {
67+
clearAllState(triggerContext.window, windowState, mergingWindows);
68+
}
69+
70+
if (mergingWindows != null) {
71+
// need to make sure to update the merging state in state
72+
mergingWindows.persist();
73+
}
74+
}
75+
```
76+
77+
EvictorWindowOperator和WindowOperator的区别仅在于emit的时候是否调用evictor来删除窗口。

0 commit comments

Comments
 (0)