| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap; |
| 2 | |
| 3 | import java.util.*; |
| 4 | import java.io.IOException; |
| 5 | |
| 6 | import com.fasterxml.jackson.annotation.*; |
| 7 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 8 | import com.fasterxml.jackson.databind.JsonNode; |
| 9 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 10 | |
| 11 | import de.ids_mannheim.korap.response.Notifications; |
| 12 | |
| 13 | import java.nio.ByteBuffer; |
| 14 | |
| 15 | import org.slf4j.Logger; |
| 16 | import org.slf4j.LoggerFactory; |
| 17 | |
| 18 | /** |
| 19 | * Create a Statistics object. |
| 20 | * |
| 21 | * This is early work and highliy experimental! |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 22 | * |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 23 | * <blockquote><pre> |
| 24 | * KrillStats ks = new KrillStats(json); |
| 25 | * </pre></blockquote> |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 26 | * |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 27 | * Should serialize to something like |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 28 | * |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 29 | * "stats" : { |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 30 | * "@type" : "koral:stats", |
| 31 | * "collection" : [ |
| 32 | * { |
| 33 | * "@type" : "stats:collection", |
| 34 | * "foundry" : "base", |
| 35 | * "layer" : "s", |
| 36 | * "key" : "s", |
| 37 | * "value" : 450 |
| 38 | * }, |
| 39 | * { |
| 40 | * "@type" : "stats:collection", |
| 41 | * "key" : "texts", |
| 42 | * "value" : 2 |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 43 | * } |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 44 | * ] |
| 45 | * } |
| 46 | * |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 47 | * |
| 48 | * @author diewald |
| 49 | */ |
| 50 | /* |
| 51 | * TODO: THIS IS CURRENTLY HIGHLY EXPERIMENTAL |
| Akron | 417eaa9 | 2017-01-13 18:00:15 +0100 | [diff] [blame] | 52 | * TODO: Stats may use Column Stride fields (or DocValues) |
| 53 | * (or similiar concepts) https://issues.apache.org/jira/browse/LUCENE-1231 |
| 54 | * https://issues.apache.org/jira/browse/LUCENE-3108 |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 55 | */ |
| 56 | public final class KrillStats extends Notifications { |
| 57 | |
| 58 | // Logger |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 59 | private final static Logger log = LoggerFactory.getLogger(KrillStats.class); |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 60 | |
| 61 | // This advices the java compiler to ignore all loggings |
| 62 | public static final boolean DEBUG = false; |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * Construct a new KrillStats. |
| 67 | * |
| 68 | */ |
| 69 | public KrillStats () {}; |
| 70 | |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 71 | |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 72 | @Override |
| 73 | public JsonNode toJsonNode () { |
| 74 | ObjectMapper mapper = new ObjectMapper(); |
| 75 | ObjectNode json = mapper.createObjectNode(); |
| 76 | |
| 77 | json.put("@type", "koral:stats"); |
| 78 | |
| 79 | return (JsonNode) json; |
| Akron | 08f4ceb | 2016-08-03 23:53:32 +0200 | [diff] [blame] | 80 | } |
| Akron | d7d7b1f | 2016-06-25 00:31:16 +0200 | [diff] [blame] | 81 | }; |