-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE-442] Support time window (#443)
* feat: support time window * fix: remove unused var * fix: ut
- Loading branch information
Showing
40 changed files
with
560 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ow/geaflow-core/geaflow-api/src/main/java/com/antgroup/geaflow/api/window/WindowType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.antgroup.geaflow.api.window; | ||
|
||
public enum WindowType { | ||
ALL_WINDOW, // all data | ||
FIXED_TIME_TUMBLING_WINDOW, // window with time unit | ||
SIZE_TUMBLING_WINDOW, // window with size unit | ||
CUSTOM | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...aflow-api/src/main/java/com/antgroup/geaflow/api/window/impl/FixedTimeTumblingWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.antgroup.geaflow.api.window.impl; | ||
|
||
import com.antgroup.geaflow.api.window.ITumblingWindow; | ||
import com.antgroup.geaflow.api.window.WindowType; | ||
|
||
public class FixedTimeTumblingWindow<T> implements ITumblingWindow<T> { | ||
|
||
private final long timeWindowInSecond; | ||
private long windowId; | ||
|
||
public FixedTimeTumblingWindow(long timeWindowInSecond) { | ||
this.timeWindowInSecond = timeWindowInSecond; | ||
} | ||
|
||
public long getTimeWindowSize() { | ||
return timeWindowInSecond; | ||
} | ||
|
||
@Override | ||
public long windowId() { | ||
return windowId; | ||
} | ||
|
||
@Override | ||
public void initWindow(long windowId) { | ||
this.windowId = windowId; | ||
} | ||
|
||
@Override | ||
public long assignWindow(T value) { | ||
return windowId; | ||
} | ||
|
||
@Override | ||
public WindowType getType() { | ||
return WindowType.FIXED_TIME_TUMBLING_WINDOW; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...nnector-api/src/main/java/com/antgroup/geaflow/dsl/connector/api/AbstractTableSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.antgroup.geaflow.dsl.connector.api; | ||
|
||
|
||
import com.antgroup.geaflow.dsl.common.exception.GeaFlowDSLException; | ||
import com.antgroup.geaflow.dsl.connector.api.window.AllFetchWindow; | ||
import com.antgroup.geaflow.dsl.connector.api.window.FetchWindow; | ||
import com.antgroup.geaflow.dsl.connector.api.window.SizeFetchWindow; | ||
import com.antgroup.geaflow.dsl.connector.api.window.TimeFetchWindow; | ||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
public abstract class AbstractTableSource implements TableSource { | ||
|
||
public <T> FetchData<T> fetch(Partition partition, Optional<Offset> startOffset, FetchWindow windowInfo) throws IOException { | ||
switch (windowInfo.getType()) { | ||
case ALL_WINDOW: | ||
return fetch(partition, startOffset, (AllFetchWindow) windowInfo); | ||
case SIZE_TUMBLING_WINDOW: | ||
return fetch(partition, startOffset, (SizeFetchWindow) windowInfo); | ||
case FIXED_TIME_TUMBLING_WINDOW: | ||
return fetch(partition, startOffset, (TimeFetchWindow) windowInfo); | ||
default: | ||
throw new GeaFlowDSLException("Not support window type:{}", windowInfo.getType()); | ||
} | ||
} | ||
|
||
|
||
public <T> FetchData<T> fetch(Partition partition, Optional<Offset> startOffset, AllFetchWindow windowInfo) throws IOException { | ||
throw new GeaFlowDSLException("Not support"); | ||
} | ||
|
||
public <T> FetchData<T> fetch(Partition partition, Optional<Offset> startOffset, SizeFetchWindow windowInfo) throws IOException { | ||
throw new GeaFlowDSLException("Not support"); | ||
} | ||
|
||
public <T> FetchData<T> fetch(Partition partition, Optional<Offset> startOffset, TimeFetchWindow windowInfo) throws IOException { | ||
throw new GeaFlowDSLException("Not support"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...-api/src/main/java/com/antgroup/geaflow/dsl/connector/api/window/AbstractFetchWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.antgroup.geaflow.dsl.connector.api.window; | ||
|
||
public abstract class AbstractFetchWindow implements FetchWindow { | ||
|
||
protected final long windowId; | ||
|
||
public AbstractFetchWindow(long windowId) { | ||
this.windowId = windowId; | ||
} | ||
|
||
@Override | ||
public long windowId() { | ||
return windowId; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ector-api/src/main/java/com/antgroup/geaflow/dsl/connector/api/window/AllFetchWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.antgroup.geaflow.dsl.connector.api.window; | ||
|
||
import com.antgroup.geaflow.api.window.WindowType; | ||
|
||
/** | ||
* Fetch all. | ||
*/ | ||
public class AllFetchWindow extends AbstractFetchWindow { | ||
|
||
public AllFetchWindow(long windowId) { | ||
super(windowId); | ||
} | ||
|
||
@Override | ||
public long windowSize() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public WindowType getType() { | ||
return WindowType.ALL_WINDOW; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...onnector-api/src/main/java/com/antgroup/geaflow/dsl/connector/api/window/FetchWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.antgroup.geaflow.dsl.connector.api.window; | ||
|
||
import com.antgroup.geaflow.api.window.WindowType; | ||
|
||
/** | ||
* Interface for the table source fetch records. | ||
*/ | ||
public interface FetchWindow { | ||
|
||
/** | ||
* Return the window id. | ||
*/ | ||
long windowId(); | ||
|
||
/** | ||
* Return the window size. | ||
*/ | ||
long windowSize(); | ||
|
||
/** | ||
* Return the window type. | ||
*/ | ||
WindowType getType(); | ||
|
||
} |
Oops, something went wrong.