forked from apache/inlong
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INLONG-10684][SDK] Inlong transform supports context
- Loading branch information
Showing
41 changed files
with
270 additions
and
129 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
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
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
75 changes: 75 additions & 0 deletions
75
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/Context.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,75 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.inlong.sdk.transform.process; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class Context { | ||
|
||
private final Map<String, Object> configuration; | ||
private final Map<String, Object> extParams; | ||
private final Map<String, Object> runtimeParams; | ||
|
||
public Context(Map<String, Object> configuration, Map<String, Object> extParams) { | ||
this.configuration = configuration; | ||
this.extParams = extParams; | ||
this.runtimeParams = new ConcurrentHashMap<>(); | ||
} | ||
|
||
public Object put(String key, Object value) { | ||
return runtimeParams.put(key, value); | ||
} | ||
|
||
public Object get(String key) { | ||
Object obj = runtimeParams.get(key); | ||
if (obj != null) { | ||
return obj; | ||
} | ||
obj = extParams.get(key); | ||
if (obj != null) { | ||
return obj; | ||
} | ||
return configuration.get(key); | ||
} | ||
|
||
public String getString(String key) { | ||
Object obj = this.get(key); | ||
if (obj != null) { | ||
return obj.toString(); | ||
} | ||
return null; | ||
} | ||
|
||
public Integer getInteger(String key) { | ||
Object obj = this.get(key); | ||
if (obj != null) { | ||
return Integer.getInteger(obj.toString()); | ||
} | ||
return null; | ||
} | ||
|
||
public Long getLong(String key) { | ||
Object obj = this.get(key); | ||
if (obj != null) { | ||
return Long.getLong(obj.toString()); | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.