Last active
August 29, 2015 14:03
-
-
Save ixixi/c16f9d9af0d1b3d282c6 to your computer and use it in GitHub Desktop.
ScalaUDFExample
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
package in.ixixi.norikra.udf | |
import com.espertech.esper.epl.agg.aggregator.AggregationMethod | |
class ExampleScalaUDF extends AggregationMethod{ | |
var counter = 0L | |
def getValueType: Class[_] = classOf[Long] | |
def enter(value: AnyRef) { counter += value.toString.length } | |
def leave(value: AnyRef) { counter -= value.toString.length } | |
def getValue: AnyRef = (counter:java.lang.Long):AnyRef | |
def clear { counter = 0L } | |
} |
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
package in.ixixi.norikra.udf | |
import com.espertech.esper.client.hook.AggregationFunctionFactory | |
import com.espertech.esper.epl.agg.aggregator.AggregationMethod | |
import com.espertech.esper.epl.agg.service.AggregationValidationContext | |
class ExampleScalaUDFFactory extends AggregationFunctionFactory{ | |
def setFunctionName(functionName: String) | |
def validate(validationContext: AggregationValidationContext) | |
def getValueType: Class[_] = classOf[Long] | |
def newAggregator: AggregationMethod = new ExampleScalaUDF | |
} |
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
require 'java' | |
require 'norikra/udf' | |
module Norikra | |
module UDF | |
class ScalaUDFExample < Norikra::UDF::AggregationSingle | |
def self.init | |
require 'norikra-udf-scala-example.jar' | |
end | |
def definition | |
["strlength", "in.ixixi.norikra.udf.ExampleScalaUDFFactory"] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment