Package org.qdl_lang.evaluate
Class StemEvaluator
- java.lang.Object
-
- org.qdl_lang.evaluate.AbstractEvaluator
-
- org.qdl_lang.evaluate.StemEvaluator
-
- All Implemented Interfaces:
Serializable
,EvaluatorInterface
public class StemEvaluator extends AbstractEvaluator
Created by Jeff Gaynor
on 1/16/20 at 9:19 AM- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StemEvaluator.AxisAction
static class
StemEvaluator.CyclicArgList
This makes an infinite arg list for creating new stems.-
Nested classes/interfaces inherited from class org.qdl_lang.evaluate.AbstractEvaluator
AbstractEvaluator.CommonKeyIterator, AbstractEvaluator.fPointer, AbstractEvaluator.fpResult
-
-
Field Summary
-
Fields inherited from class org.qdl_lang.evaluate.AbstractEvaluator
bigArgList, bigArgList0, FILE_OP_AUTO, FILE_OP_BINARY, FILE_OP_INPUT_STREAM, FILE_OP_TEXT_INI, FILE_OP_TEXT_STEM, FILE_OP_TEXT_STRING, FILE_OP_TEXT_WITHOUT_LIST_INI, fNames, MAX_ARG_COUNT
-
Fields inherited from interface org.qdl_lang.evaluate.EvaluatorInterface
UNKNOWN_VALUE
-
-
Constructor Summary
Constructors Constructor Description StemEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
dispatch(Polyad polyad, State state)
Does the actual evaluation of thePolyad
.protected void
doCommonKeys(Polyad polyad, State state)
common_keys(stem1., stem2.)
Return a list of keys common to both stems.protected void
doExcludeKeys(Polyad polyad, State state)
exclude_keys(stem., var | list.)
remove all the keys in list.protected void
doForEach(Polyad polyad, State state)
Apply n-ary function to outer product of stems.protected void
doFromJSON(Polyad polyad, State state)
protected void
doHasKey(Polyad polyad, State state)
has_keys(key | keysList., arg.) returns left conformable result if the key or keylist.protected void
doHasKeys(Polyad polyad, State state)
Deprecated.protected void
doIncludeKeys(Polyad polyad, State state)
include_keys(stem., var | list.);
include keys on the right in the resulting stemprotected void
doIndices(Polyad polyad, State state)
protected void
doIsList(Polyad polyad, State state)
protected void
doIsMemberOf(Polyad polyad, State state)
Compute if the left argument is a member of the right argument.protected void
doJoin(Polyad polyad, State state)
protected void
doJPathQuery(Polyad polyad, State state)
protected void
doKeys(Polyad polyad, State state)
Return a stem of nothing key the keys, possibly filtering, so the final stem is of the formprotected void
doListKeys(Polyad polyad, State state)
Returns the keys in a stem as a list, filtering if wanted.protected void
doMakeIndex(Polyad polyad, State state)
protected void
doMask(Polyad polyad, State state)
protected void
doRemove(Polyad polyad, State state)
Remove the entire variable from the symbol table.protected void
doRenameKeys(Polyad polyad, State state)
rename_keys(arg., indices.);
list.protected void
doSetDefault(Polyad polyad, State state)
Sets the default value for a stem.protected void
doShuffle(Polyad polyad, State state)
Permute the elements in a stem.protected void
doSize(Polyad polyad, State state)
protected void
doToJSON(Polyad polyad, State state)
protected void
doTransform(Polyad polyad, State state)
protected void
doValues(Polyad polyad, State state)
protected Object
forEachEval(ExpressionImpl f, State state, List args)
protected void
forEachRecursion(QDLStem output, ExpressionImpl f, State state, Object[] args, IndexList indexList, ArrayList values, int currentIndex)
String[]
getFunctionNames()
A list of the names that this Evaluator knows about.String
getNamespace()
int
getType(String name)
protected void
indexRecursion(QDLStem out, int[] lengths, int index, StemEvaluator.CyclicArgList cyclicArgList)
Fills in the elements for the n(x,y,z,...) function.adv74008protected void
putLongOrStringKey(QDLStem out, Object key)
Needed by list_keys and keys so that returned indices that are longs are indeed longs.protected QDLStem
reverseKeysAndValues(QDLStem inStem)
protected String
rFormatStem(QDLStem stem, List<String> keySubset, boolean sortKeys, boolean multilineMode, int indent, int width)
protected QDLStem
stemPathConverter(String indexList)
Convert output of a JSON query to a stem of lists.-
Methods inherited from class org.qdl_lang.evaluate.AbstractEvaluator
areAllBigDecimals, areAllBoolean, areAllLongs, areAllNumbers, areAllSets, areAllStems, areAllStrings, areAnyBigDecimals, areNoneStems, bdEquals, checkNull, checkNull, convertArgsToStem, evaluate, evaluate, finishExpr, getBigArgList, getBigArgList0, getCommonKeys, getFQFunctionNames, getFunctionReferenceNode, getFunctionReferenceNode, getOperator, getOrCreateStem, isBigDecimal, isBoolean, isBuiltInFunction, isFunctionRef, isLong, isNumber, isScalar, isSet, isStem, isStemList, isString, listFunctions, process1, process2, process2, process3, processSet1, processSet2, processSet2, processStem1, processStem2, processStem3, resolveResourceToFile, tempFname, toBD, toConstants, toStem
-
-
-
-
Field Detail
-
STEM_NAMESPACE
public static final String STEM_NAMESPACE
- See Also:
- Constant Field Values
-
STEM_FUNCTION_BASE_VALUE
public static final int STEM_FUNCTION_BASE_VALUE
- See Also:
- Constant Field Values
-
SIZE
public static final String SIZE
- See Also:
- Constant Field Values
-
SIZE_TYPE
public static final int SIZE_TYPE
- See Also:
- Constant Field Values
-
SHORT_MAKE_INDICES
public static final String SHORT_MAKE_INDICES
- See Also:
- Constant Field Values
-
MAKE_INDICES_TYPE
public static final int MAKE_INDICES_TYPE
- See Also:
- Constant Field Values
-
REMOVE
public static final String REMOVE
- See Also:
- Constant Field Values
-
REMOVE_TYPE
public static final int REMOVE_TYPE
- See Also:
- Constant Field Values
-
SET_DEFAULT
public static final String SET_DEFAULT
- See Also:
- Constant Field Values
-
SET_DEFAULT_TYPE
public static final int SET_DEFAULT_TYPE
- See Also:
- Constant Field Values
-
BOX
public static final String BOX
- See Also:
- Constant Field Values
-
BOX_TYPE
public static final int BOX_TYPE
- See Also:
- Constant Field Values
-
UNBOX
public static final String UNBOX
- See Also:
- Constant Field Values
-
UNBOX_TYPE
public static final int UNBOX_TYPE
- See Also:
- Constant Field Values
-
UNION
public static final String UNION
- See Also:
- Constant Field Values
-
UNION_TYPE
public static final int UNION_TYPE
- See Also:
- Constant Field Values
-
HAS_VALUE
public static final String HAS_VALUE
- See Also:
- Constant Field Values
-
HAS_VALUE_TYPE
public static final int HAS_VALUE_TYPE
- See Also:
- Constant Field Values
-
DIMENSION
public static final String DIMENSION
- See Also:
- Constant Field Values
-
DIMENSION_TYPE
public static final int DIMENSION_TYPE
- See Also:
- Constant Field Values
-
RANK
public static final String RANK
- See Also:
- Constant Field Values
-
RANK_TYPE
public static final int RANK_TYPE
- See Also:
- Constant Field Values
-
FOR_EACH
public static final String FOR_EACH
- See Also:
- Constant Field Values
-
FOR_EACH_TYPE
public static final int FOR_EACH_TYPE
- See Also:
- Constant Field Values
-
COMMON_KEYS
public static final String COMMON_KEYS
- See Also:
- Constant Field Values
-
COMMON_KEYS_TYPE
public static final int COMMON_KEYS_TYPE
- See Also:
- Constant Field Values
-
EXCLUDE_KEYS
public static final String EXCLUDE_KEYS
- See Also:
- Constant Field Values
-
EXCLUDE_KEYS_TYPE
public static final int EXCLUDE_KEYS_TYPE
- See Also:
- Constant Field Values
-
LIST_KEYS
public static final String LIST_KEYS
- See Also:
- Constant Field Values
-
LIST_KEYS_TYPE
public static final int LIST_KEYS_TYPE
- See Also:
- Constant Field Values
-
HAS_KEY
public static final String HAS_KEY
- See Also:
- Constant Field Values
-
HAS_KEY_TYPE
public static final int HAS_KEY_TYPE
- See Also:
- Constant Field Values
-
INCLUDE_KEYS
public static final String INCLUDE_KEYS
- See Also:
- Constant Field Values
-
INCLUDE_KEYS_TYPE
public static final int INCLUDE_KEYS_TYPE
- See Also:
- Constant Field Values
-
RENAME_KEYS
public static final String RENAME_KEYS
- See Also:
- Constant Field Values
-
RENAME_KEYS_TYPE
public static final int RENAME_KEYS_TYPE
- See Also:
- Constant Field Values
-
MASK
public static final String MASK
- See Also:
- Constant Field Values
-
MASK_TYPE
public static final int MASK_TYPE
- See Also:
- Constant Field Values
-
KEYS
public static final String KEYS
- See Also:
- Constant Field Values
-
KEYS_TYPE
public static final int KEYS_TYPE
- See Also:
- Constant Field Values
-
SHUFFLE
public static final String SHUFFLE
- See Also:
- Constant Field Values
-
SHUFFLE_TYPE
public static final int SHUFFLE_TYPE
- See Also:
- Constant Field Values
-
UNIQUE_VALUES
public static final String UNIQUE_VALUES
- See Also:
- Constant Field Values
-
UNIQUE_VALUES_TYPE
public static final int UNIQUE_VALUES_TYPE
- See Also:
- Constant Field Values
-
JOIN
public static final String JOIN
- See Also:
- Constant Field Values
-
JOIN_TYPE
public static final int JOIN_TYPE
- See Also:
- Constant Field Values
-
ALL_KEYS
public static final String ALL_KEYS
- See Also:
- Constant Field Values
-
ALL_KEYS_TYPE
public static final int ALL_KEYS_TYPE
- See Also:
- Constant Field Values
-
TRANSPOSE
public static final String TRANSPOSE
- See Also:
- Constant Field Values
-
TRANSPOSE_TYPE
public static final int TRANSPOSE_TYPE
- See Also:
- Constant Field Values
-
REMAP
public static final String REMAP
- See Also:
- Constant Field Values
-
REMAP_TYPE
public static final int REMAP_TYPE
- See Also:
- Constant Field Values
-
HAS_KEYS
public static final String HAS_KEYS
- See Also:
- Constant Field Values
-
HAS_KEYS_TYPE
public static final int HAS_KEYS_TYPE
- See Also:
- Constant Field Values
-
EXCISE
public static final String EXCISE
- See Also:
- Constant Field Values
-
EXCISE_TYPE
public static final int EXCISE_TYPE
- See Also:
- Constant Field Values
-
IS_LIST
public static final String IS_LIST
- See Also:
- Constant Field Values
-
IS_LIST_TYPE
public static final int IS_LIST_TYPE
- See Also:
- Constant Field Values
-
VALUES
public static final String VALUES
- See Also:
- Constant Field Values
-
VALUES_TYPE
public static final int VALUES_TYPE
- See Also:
- Constant Field Values
-
STAR
public static final String STAR
- See Also:
- Constant Field Values
-
STAR_TYPE
public static final int STAR_TYPE
- See Also:
- Constant Field Values
-
DIFF
public static final String DIFF
- See Also:
- Constant Field Values
-
DIFF_TYPE
public static final int DIFF_TYPE
- See Also:
- Constant Field Values
-
TO_JSON
public static final String TO_JSON
- See Also:
- Constant Field Values
-
TO_JSON_TYPE
public static final int TO_JSON_TYPE
- See Also:
- Constant Field Values
-
FROM_JSON
public static final String FROM_JSON
- See Also:
- Constant Field Values
-
FROM_JSON_TYPE
public static final int FROM_JSON_TYPE
- See Also:
- Constant Field Values
-
JSON_PATH_QUERY
public static final String JSON_PATH_QUERY
- See Also:
- Constant Field Values
-
JSON_PATH_QUERY_TYPE
public static final int JSON_PATH_QUERY_TYPE
- See Also:
- Constant Field Values
-
DISPLAY
public static final String DISPLAY
- See Also:
- Constant Field Values
-
DISPLAY_TYPE
public static final int DISPLAY_TYPE
- See Also:
- Constant Field Values
-
DISPLAY_WIDTH
public static String DISPLAY_WIDTH
-
DISPLAY_WIDTH_DEFAULT
public static int DISPLAY_WIDTH_DEFAULT
-
DISPLAY_KEYS
public static String DISPLAY_KEYS
-
DISPLAY_SORT
public static String DISPLAY_SORT
-
DISPLAY_SORT_DEFAULT
public static boolean DISPLAY_SORT_DEFAULT
-
DISPLAY_SHORT_FORM
public static String DISPLAY_SHORT_FORM
-
DISPLAY_SHORT_FORM_DEFAULT
public static boolean DISPLAY_SHORT_FORM_DEFAULT
-
DISPLAY_STRING_OUTPUT
public static String DISPLAY_STRING_OUTPUT
-
DISPLAY_STRING_OUTPUT_DEFAULT
public static boolean DISPLAY_STRING_OUTPUT_DEFAULT
-
DISPLAY_INDENT
public static String DISPLAY_INDENT
-
DISPLAY_INDENT_DEFAULT
public static int DISPLAY_INDENT_DEFAULT
-
-
Method Detail
-
getNamespace
public String getNamespace()
-
getFunctionNames
public String[] getFunctionNames()
A list of the names that this Evaluator knows about. NOTE that this must be kept in sync by the developer since it is used to determine if a function is built in or a user-defined function.- Specified by:
getFunctionNames
in classAbstractEvaluator
-
getType
public int getType(String name)
-
dispatch
public boolean dispatch(Polyad polyad, State state)
Description copied from class:AbstractEvaluator
Does the actual evaluation of thePolyad
.- Specified by:
dispatch
in classAbstractEvaluator
- Returns:
-
rFormatStem
protected String rFormatStem(QDLStem stem, List<String> keySubset, boolean sortKeys, boolean multilineMode, int indent, int width)
-
doForEach
protected void doForEach(Polyad polyad, State state)
Apply n-ary function to outer product of stems. There n stems passed in. The function is applied to each of them as an outer product. So every element of every argument is evaluated.- Parameters:
polyad
-state
-
-
forEachRecursion
protected void forEachRecursion(QDLStem output, ExpressionImpl f, State state, Object[] args, IndexList indexList, ArrayList values, int currentIndex)
-
forEachEval
protected Object forEachEval(ExpressionImpl f, State state, List args)
-
stemPathConverter
protected QDLStem stemPathConverter(String indexList)
Convert output of a JSON query to a stem of lists. Each list is an index entry.- Parameters:
indexList
-- Returns:
-
doIsMemberOf
protected void doIsMemberOf(Polyad polyad, State state)
Compute if the left argument is a member of the right argument. result is always conformable to the left argument.- Parameters:
polyad
-state
-
-
doListKeys
protected void doListKeys(Polyad polyad, State state)
Returns the keys in a stem as a list, filtering if wanted.- Parameters:
polyad
-state
-
-
doKeys
protected void doKeys(Polyad polyad, State state)
Return a stem of nothing key the keys, possibly filtering, so the final stem is of the form{key0=key0,key1=key1,...}
This is useful in conjunction with the rename keys call, so you can get the keys and do some operations on them then rename the keys in the original stem.- Parameters:
polyad
-state
-
-
putLongOrStringKey
protected void putLongOrStringKey(QDLStem out, Object key)
Needed by list_keys and keys so that returned indices that are longs are indeed longs. Otherwise everything returned would be a string (e.g., '0' not 0) which makes subsequent algebraic operations on them fail.- Parameters:
out
-key
-
-
doHasKeys
protected void doHasKeys(Polyad polyad, State state)
Deprecated.This is not left conformable and any uses should be removed in favor ofdoHasKey(Polyad, State)
- Parameters:
polyad
-state
-
-
doHasKey
protected void doHasKey(Polyad polyad, State state)
has_keys(key | keysList., arg.) returns left conformable result if the key or keylist. are keys in the arg.- Parameters:
polyad
-state
-
-
indexRecursion
protected void indexRecursion(QDLStem out, int[] lengths, int index, StemEvaluator.CyclicArgList cyclicArgList)
Fills in the elements for the n(x,y,z,...) function.adv74008- Parameters:
out
-lengths
-index
-cyclicArgList
-
-
doRemove
protected void doRemove(Polyad polyad, State state)
Remove the entire variable from the symbol table.- Parameters:
polyad
-state
-
-
doIncludeKeys
protected void doIncludeKeys(Polyad polyad, State state)
include_keys(stem., var | list.);
include keys on the right in the resulting stem- Parameters:
polyad
-state
-
-
doExcludeKeys
protected void doExcludeKeys(Polyad polyad, State state)
exclude_keys(stem., var | list.)
remove all the keys in list. from the stem.- Parameters:
polyad
-state
-
-
doShuffle
protected void doShuffle(Polyad polyad, State state)
Permute the elements in a stem. The right argument must contain every key in the left argument or an exception is raised. This is really just using cycle notation from abstract algebra... E.g.,10+3*indices(5) [10,13,16,19,22] rename_keys(10+3*indices(5), [4,2,3,1,0]) [22,19,13,16,10]
read that in [4,2,3,1,0]: old → new, so 0 → 4, 1 → 2, 2→3, 3→1, 4→0
-
doRenameKeys
protected void doRenameKeys(Polyad polyad, State state)
rename_keys(arg., indices.);
list. contains entries of the formindices.old = new
Note that this is different fromdoRemap(Polyad, State)
. The result is that each key in arg. is renamed, but the values are not changed. If a key is in indices. and does not correspond to one on the left, it is skipped, by subsetting rule. If a key is indices and the old and new value are the same, it is skipped.
Limitations are that it applies to the zeroth axis, modifies arg. and the indices. are different than remap.- Parameters:
polyad
-state
-
-
doCommonKeys
protected void doCommonKeys(Polyad polyad, State state)
common_keys(stem1., stem2.)
Return a list of keys common to both stems.- Parameters:
polyad
-state
-
-
doSetDefault
protected void doSetDefault(Polyad polyad, State state)
Sets the default value for a stem. returns the default value set.- Parameters:
polyad
-state
-
-
-