{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/emitter/tumbling-count-window",
  "title" : "Tumbling-count-window Emitter Configuration",
  "description" : "The `tumbling-count-window` creates a-per-worker tumbling count window. In this implementation a window aggregate is stored only in the machine's  memory.\n The aggregate is emitted to configured sink via a emit point.\n\nBased on `VoltAggregateBuilder` each event is transformed into a request.\n Lastly a key can be provided so incoming event is routed to the right local window and aggregated.\n\nNote that the window is a local, per-worker keyed aggregate, not a machine-wide keyed aggregate.\n\nIn case of downstream system error this `tumbling-count-window` will re-process events.\n",
  "type" : "object",
  "properties" : {
    "tumbling-count-window" : {
      "type" : "object",
      "properties" : {
        "maxEventsPerWindow" : {
          "type" : "integer",
          "description" : "Defines how many events this window can accumulate before it gets closed. Must be greater than 0",
          "minimum" : -2147483648,
          "maximum" : 2147483647
        },
        "keyExtractor" : {
          "description" : "The key is optional, if set the window will aggregate only events with the same key value. The key has to conform to Java equal and hashCode contract.",
          "anyOf" : [ {
            "type" : "string",
            "description" : "Java method reference or JavaScript code"
          }, {
            "type" : "object",
            "properties" : {
              "implementation" : {
                "type" : "string",
                "description" : "Java method reference or JavaScript code"
              },
              "type" : {
                "type" : "string",
                "description" : "The return type of the extractor"
              }
            },
            "required" : [ "implementation" ]
          } ]
        },
        "aggregateDefinition" : {
          "type" : "object",
          "description" : "The aggregate is defined by the provided builder",
          "properties" : {
            "builder" : {
              "type" : "array",
              "items" : {
                "type" : "object",
                "properties" : {
                  "type" : {
                    "type" : "string",
                    "description" : "The aggregation operation (e.g., count, sum, min, max, first, last, distinct)"
                  }
                },
                "required" : [ "type" ]
              }
            },
            "from" : {
              "type" : "string",
              "description" : "The fully qualified name of the class that contains the aggregate functions"
            }
          },
          "required" : [ "from", "builder" ]
        },
        "timeConfig" : {
          "type" : "object",
          "description" : "Configuration for processing-time or event-time handling.",
          "properties" : {
            "eventTimeExtractor" : {
              "type" : "string",
              "description" : "If provided, the time is sourced from the event itself. Without it, time comes from the worker's\nwall clock at the moment of processing.\n\nRequired when idleTimeoutClock is EVENT_TIME (event-time idle needs event timestamps).\n"
            },
            "idleTimeout" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Inactivity timeout after which a window (or session) is emitted and closed.\n\nWhile the pipeline is busy, quiet keys are detected as part of normal batch processing\nand emitted once they cross this threshold. While the pipeline is fully silent, idle\ncleanup is driven by the periodic pipeline heartbeat (60s).\n\nIf idleTimeout is not set, idle cleanup is disabled and the window only closes via its\nprimary trigger (count, time span, session gap, ...).\n\nThe clock used to measure silence is controlled by idleTimeoutClock.\n"
            },
            "idleTimeoutClock" : {
              "type" : "string",
              "description" : "Specifies the clock used to measure inactivity for idleTimeout:\n- PROCESSING_TIME - silence measured in real time. Quiet keys flush after idleTimeout of real time,\n  regardless of event-time progression. Suitable for live streams where the idle SLA is real time.\n- EVENT_TIME - silence measured in event time (requires eventTimeExtractor). Quiet keys flush only\n  as the watermark advances by idleTimeout. Suitable for replays / historical processing where\n  results must be deterministic.\n",
              "enum" : [ "processing_time", "event_time", "PROCESSING_TIME", "EVENT_TIME" ]
            }
          },
          "additionalProperties" : false
        },
        "exceptionHandler" : {
          "type" : "string",
          "description" : "Custom exception handler enabling interception of all errors related to this emitter."
        },
        "triggers" : {
          "type" : "array",
          "description" : "List of trigger configurations that create sub-pipelines",
          "items" : {
            "type" : "object",
            "properties" : {
              "trigger" : {
                "type" : "string",
                "enum" : [ "org.voltdb.stream.api.pipeline.emitter.ExceptionTrigger#onError", "org.voltdb.stream.plugin.window.api.WindowTrigger#atWindowEnd", "org.voltdb.stream.plugin.window.api.WindowTrigger#atAggregate" ],
                "description" : "The trigger point that activates this sub-pipeline"
              },
              "processors" : {
                "type" : "array",
                "description" : "Optional list of processors to apply before the sink or emitter",
                "items" : {
                  "$ref" : "#/$defs/processor"
                }
              },
              "sink" : {
                "$ref" : "#/$defs/sink"
              },
              "emitter" : {
                "$ref" : "#/$defs/emitter"
              }
            },
            "oneOf" : [ {
              "required" : [ "trigger", "sink" ]
            }, {
              "required" : [ "trigger", "emitter" ]
            } ]
          }
        }
      },
      "required" : [ "aggregateDefinition", "triggers" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "tumbling-count-window" ],
  "additionalProperties" : false
}
