-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ChannelEnumerator by ListEnumerator.
- Loading branch information
Ralph Gasser
committed
Feb 5, 2024
1 parent
680e086
commit a567a1f
Showing
3 changed files
with
54 additions
and
31 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/enumerate/ChannelEnumerator.kt
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/enumerate/ListEnumerator.kt
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,53 @@ | ||
package org.vitrivr.engine.index.enumerate | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import org.vitrivr.engine.core.context.IndexContext | ||
import org.vitrivr.engine.core.operators.ingest.Enumerator | ||
import org.vitrivr.engine.core.operators.ingest.EnumeratorFactory | ||
import org.vitrivr.engine.core.source.Source | ||
import java.util.LinkedList | ||
|
||
/** | ||
* A [Enumerator] that allows a caller to explicitly prepare a list of [Source]s to enumerate. | ||
* | ||
* @author Ralph Gasser | ||
* @version 1.0.0 | ||
*/ | ||
class ListEnumerator : EnumeratorFactory { | ||
|
||
/** | ||
* Creates a new [Enumerator] instance from this [ListEnumerator]. | ||
* | ||
* @param context The [IndexContext] to use. | ||
* @param parameters Optional set of parameters. | ||
*/ | ||
override fun newOperator(context: IndexContext, parameters: Map<String, String>): Enumerator { | ||
return Instance(context) | ||
} | ||
|
||
/** | ||
* The [Enumerator] returned by this [FileSystemEnumerator]. | ||
*/ | ||
private class Instance(private val context: IndexContext) : Enumerator { | ||
|
||
/** List of [Source]s that should be enumerated. */ | ||
private val list: LinkedList<Source> = LinkedList() | ||
|
||
override fun toFlow(scope: CoroutineScope): Flow<Source> = flow { | ||
for (s in this@Instance.list) { | ||
emit(s) | ||
} | ||
} | ||
|
||
/** | ||
* Enqueues a new [Source]. | ||
* | ||
* @param source [Source] to add. | ||
*/ | ||
fun add(source: Source) { | ||
this.list.add(source) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...in/resources/META-INF/services/org.vitrivr.engine.core.operators.ingest.EnumeratorFactory
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.vitrivr.engine.index.enumerate.FileSystemEnumerator | ||
org.vitrivr.engine.index.enumerate.ApiEnumerator | ||
org.vitrivr.engine.index.enumerate.ChannelEnumerator | ||
org.vitrivr.engine.index.enumerate.ListEnumerator |