-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional extra logging for native scripts (#268)
* Add optional extra logging for native scripts * Added Extra Logging section to docs
- Loading branch information
1 parent
337f92b
commit 0078300
Showing
12 changed files
with
424 additions
and
15 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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/o19s/es/ltr/feature/store/ExtraLoggingSupplier.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,26 @@ | ||
package com.o19s.es.ltr.feature.store; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
|
||
public class ExtraLoggingSupplier implements Supplier<Map<String,Object>> { | ||
protected Supplier<Map<String,Object>> supplier; | ||
|
||
public void setSupplier(Supplier<Map<String,Object>> supplier) { | ||
this.supplier = supplier; | ||
} | ||
|
||
/** | ||
* Return a Map to add additional information to be returned when logging feature values. | ||
* | ||
* This Map will only be non-null during the LoggingFetchSubPhase. | ||
*/ | ||
@Override | ||
public Map<String, Object> get() { | ||
if (supplier != null) { | ||
return supplier.get(); | ||
} | ||
return null; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
package com.o19s.es.ltr.query; | ||
|
||
import com.o19s.es.ltr.ranker.LtrRanker; | ||
import org.apache.lucene.search.Query; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Supplier; | ||
|
||
public interface LtrRewritableQuery { | ||
/** | ||
* Rewrite the query so that it holds the vectorSupplier | ||
* Rewrite the query so that it holds the vectorSupplier and provide extra logging support | ||
*/ | ||
Query ltrRewrite(Supplier<LtrRanker.FeatureVector> vectorSuppler) throws IOException; | ||
Query ltrRewrite(LtrRewriteContext context) throws IOException; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/o19s/es/ltr/query/LtrRewriteContext.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,35 @@ | ||
package com.o19s.es.ltr.query; | ||
|
||
import com.o19s.es.ltr.ranker.LogLtrRanker; | ||
import com.o19s.es.ltr.ranker.LtrRanker; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Contains context needed to rewrite queries to holds the vectorSupplier and provide extra logging support | ||
*/ | ||
public class LtrRewriteContext { | ||
private final Supplier<LtrRanker.FeatureVector> vectorSupplier; | ||
private final LtrRanker ranker; | ||
|
||
public LtrRewriteContext(LtrRanker ranker, Supplier<LtrRanker.FeatureVector> vectorSupplier) { | ||
this.ranker = ranker; | ||
this.vectorSupplier = vectorSupplier; | ||
} | ||
|
||
public Supplier<LtrRanker.FeatureVector> getFeatureVectorSupplier() { | ||
return vectorSupplier; | ||
} | ||
|
||
/** | ||
* Get LogConsumer used during the LoggingFetchSubPhase | ||
* | ||
* The returned consumer will only be non-null during the logging fetch phase | ||
*/ | ||
public LogLtrRanker.LogConsumer getLogConsumer() { | ||
if (ranker instanceof LogLtrRanker) { | ||
return ((LogLtrRanker)ranker).getLogConsumer(); | ||
} | ||
return null; | ||
} | ||
} |
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
Oops, something went wrong.