/** * Create the execution context for running Stellar. */ public static Context getContext(Map<String, String> globals) { Context context = new Context.Builder() .with(Context.Capabilities.GLOBAL_CONFIG, () -> globals) .with(Context.Capabilities.STELLAR_CONFIG, () -> globals) .build(); StellarFunctions.initialize(context); return context; } }
@Stellar(name="IS_DOMAIN" ,description = "Tests if a string refers to a valid domain name. Domain names are evaluated according" + " to the standards RFC1034 section 3, and RFC1123 section 2.1." ,params = { "address - The string to test" } , returns = "True if the string refers to a valid domain name and false if otherwise") public static class IS_DOMAIN extends Predicate2StellarFunction { public IS_DOMAIN() { super(new DomainValidation()); } }
public DefaultStellarStatefulExecutor() { this(StellarFunctions.FUNCTION_RESOLVER(), Context.EMPTY_CONTEXT()); }
public StellarTransformationTest(Cache<CachingStellarProcessor.Key, Object> cache) { if(cache == null) { context = Context.EMPTY_CONTEXT(); } else { context = new Context.Builder().with(Context.Capabilities.CACHE, () -> cache).build(); } }
@Stellar( name="TO_LOWER" , description = "Transforms the first argument to a lowercase string" , params = { "input - String" } , returns = "Lowercase string" ) public static class ToLower extends BaseStellarFunction { @Override public Object apply(List<Object> strings) { return strings.get(0)==null?null:strings.get(0).toString().toLowerCase(); } }
@Stellar(name="TO_STRING" , description = "Transforms the first argument to a string" , params = { "input - Object" } , returns = "String" ) public static class ToString extends BaseStellarFunction { @Override public Object apply(List<Object> strings) { return strings.get(0)==null?null:strings.get(0).toString(); } }
@Stellar(name="LOG2" ,description="Returns the log (base 2) of a number." ,params = { "number - The number to take the log (base 2) value of" } , returns="The log (base 2) of the number passed in." ) public static class Log2 extends StellarMathFunction { public Log2() { super(MathOperations.LOG2); } }
@Stellar(name="TAN" ,description="Returns the tangent of a number." ,params = { "number - The number to take the tangent of" } , returns="The tangent of the number passed in." ) public static class Tan extends StellarMathFunction { public Tan() { super(MathOperations.TAN); } }
@Stellar(name="ROUND" ,description="Rounds a number to the nearest integer. This is half-up rounding." ,params = { "number - The number to round" } , returns="The nearest integer (based on half-up rounding)." ) public static class Round extends StellarMathFunction { public Round() { super(MathOperations.ROUND); } }
@Stellar(namespace="LOCAL" ,name="LS" ,description="Lists the contents of a directory" ,params = { "path - The path of the file." } ,returns = "The contents of the directory in tabular form sorted by last modification date." ) public static class FileLs extends FileSystemLs { public FileLs() { super(FS_TYPE.LOCAL); } }
@Stellar(namespace="HDFS" ,name="READ" ,description="Retrieves the contents as a string of a file in HDFS." ,params = { "path - The path in HDFS of the file."} ,returns = "The contents of the file in the path from HDFS and null otherwise." ) public static class HDFSGet extends FileSystemGet { public HDFSGet() { super(FS_TYPE.HDFS); } }
@Stellar(name="TO_LONG" , description="Transforms the first argument to a long integer" , params = { "input - Object of string or numeric type"} , returns = "Long version of the first argument" ) public static class TO_LONG extends Cast<Long> { public TO_LONG() { super(Long.class); } }
@Stellar(name="TO_FLOAT" , description="Transforms the first argument to a float" , params = { "input - Object of string or numeric type"} , returns = "Float version of the first argument" ) public static class TO_FLOAT extends Cast<Float> { public TO_FLOAT() { super(Float.class); } } }
@Stellar(name="LOG10" ,description="Returns the log (base 10) of a number." ,params = { "number - The number to take the log (base 10) value of" } , returns="The log (base 10) of the number passed in." ) public static class Log10 extends StellarMathFunction { public Log10() { super(MathOperations.LOG10); } }
@Stellar(name="TRIM" , description = "Trims whitespace from both sides of a string." , params = { "input - String" } , returns = "String" ) public static class Trim extends BaseStellarFunction { @Override public Object apply(List<Object> strings) { return strings.get(0)==null?null:strings.get(0).toString().trim(); } }
@Stellar(name="IS_URL" ,description = "Tests if a string is a valid URL" ,params = { "url - The string to test" } , returns = "True if the string is a valid URL and false if otherwise." ) public static class IS_URL extends Predicate2StellarFunction { public IS_URL() { super(new URLValidation()); } }
@Stellar(name="ABS" ,description="Returns the absolute value of a number." ,params = { "number - The number to take the absolute value of" } , returns="The absolute value of the number passed in." ) public static class Abs extends StellarMathFunction{ public Abs() { super(MathOperations.ABS); } }
@Stellar(namespace="LOCAL" ,name="READ" ,description="Retrieves the contents as a string of a file on the local filesystem." ,params = { "path - The path of the file."} ,returns = "The contents of the file or null otherwise." ) public static class FileGet extends FileSystemGet { public FileGet() { super(FS_TYPE.LOCAL); } }
@Stellar(namespace="HDFS" ,name="READ_LINES" ,description="Retrieves the contents of a HDFS file as a list of strings." ,params = { "path - The path in HDFS of the file."} ,returns = "A list of lines" ) public static class HDFSGetList extends FileSystemGetList { public HDFSGetList() { super(FS_TYPE.HDFS); } }
/** * I am the real deal. I am a Stellar function. */ @Stellar(namespace="namespace", name="function", description="description", returns="returns", params={"param1"}) private static class IAmAFunction extends BaseStellarFunction { public IAmAFunction() { } @Override public Object apply(List<Object> args) { return null; } }