Class EvaluationThread
- All Implemented Interfaces:
Runnable
GeneratedQuery
instances in parallel using a
StatementComparator
.
Submits one task per query to a fixed thread pool (poolSize
). Each task retries up to
repCountIfFailure
times until the comparator returns a numeric score (non-NaN). Progress
is signaled via startedProgress
/finishedProgress
. If the comparator is an
LLMComparator
, a rate-limit reporter is registered.
On full success, signalDone
is invoked.
Threading: results are stored in a synchronized map; interruption is honored and cancels work.
Read results via getResult()
only after successful completion.
- Since:
- 1.0
- Author:
- Felix Seggebäing
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class de.seggebaeing.sqlanalyzer.logic.util.thread.WorkerThread
poolSize, signalDone
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionEvaluationThread
(int poolSize, int repCountIfFailure, Set<GeneratedQuery> gqs, StatementComparator comparator, Runnable signalDone, Runnable startedProgress, Runnable finishedProgress, Consumer<Instant> reportRetryIn) Constructs an evaluation worker thread. -
Method Summary
Modifier and TypeMethodDescriptionReturns the computed similarity scores perGeneratedQuery
.void
run()
Executes evaluation by dispatching one task perGeneratedQuery
to a fixed thread pool.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
EvaluationThread
public EvaluationThread(int poolSize, int repCountIfFailure, Set<GeneratedQuery> gqs, StatementComparator comparator, Runnable signalDone, Runnable startedProgress, Runnable finishedProgress, Consumer<Instant> reportRetryIn) Constructs an evaluation worker thread.- Parameters:
poolSize
- number of parallel subworkers to userepCountIfFailure
- maximum attempts per query until a non-NaN score is returnedgqs
- set of generated queries to evaluatecomparator
- comparator used to compute similarity scoressignalDone
- callback invoked on successful completion (may benull
)startedProgress
- callback invoked when a task startsfinishedProgress
- callback invoked when a task finishesreportRetryIn
- optional consumer for retry instants when using anLLMComparator
- Implementation Note:
- Thread is named
"Evaluation-Worker-<n>"
using an atomic counter.
-
-
Method Details
-
run
public void run()Executes evaluation by dispatching one task perGeneratedQuery
to a fixed thread pool.If the comparator is an
LLMComparator
, registers the rate-limit reporter. Initializes a synchronized score map, submits all tasks, then shuts down the pool and awaits completion (practically unbounded). On full success, invokessignalDone
if non-null. On interruption, cancels subworkers, logs, and re-interrupts the thread; on timeout, logs an error.- Specified by:
run
in interfaceRunnable
- Specified by:
run
in classWorkerThread
-
getResult
Returns the computed similarity scores perGeneratedQuery
.Behavior is undefined if called before the worker has completed successfully.
- Specified by:
getResult
in classWorkerThread
- Returns:
- a synchronized map of queries to their scores
- Implementation Note:
- The returned map is a
Collections.synchronizedMap
; synchronize on it when iterating.
-