-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] Introduce flint-data for model and interface
Signed-off-by: Louis Chu <[email protected]>
- Loading branch information
Showing
10 changed files
with
230 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.8.0 |
39 changes: 39 additions & 0 deletions
39
flint-data/src/main/scala/org/opensearch/flint/data/ContextualData.scala
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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.data | ||
|
||
/** | ||
* Provides a mutable map to store and retrieve contextual data using key-value pairs. | ||
*/ | ||
trait ContextualData { | ||
|
||
/** Holds the contextual data as key-value pairs. */ | ||
var context: Map[String, Any] = Map.empty | ||
|
||
/** | ||
* Adds a key-value pair to the context map. | ||
* | ||
* @param key | ||
* The key under which the value is stored. | ||
* @param value | ||
* The data value to store. | ||
*/ | ||
def addContext(key: String, value: Any): Unit = { | ||
context += (key -> value) | ||
} | ||
|
||
/** | ||
* Retrieves the value associated with a key from the context map. | ||
* | ||
* @param key | ||
* The key whose value needs to be retrieved. | ||
* @return | ||
* An option containing the value if it exists, None otherwise. | ||
*/ | ||
def getContext(key: String): Option[Any] = { | ||
context.get(key) | ||
} | ||
} |
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
Oops, something went wrong.