Implements an n-cube. This is a hyper (n-dimensional) cube of cells, made up of 'n' number of axes. Each Axis is composed of Columns that denote discrete nodes along an axis. Use NCubeManager to manage a list of NCubes. Documentation on Github. Useful for pricing, rating, and configuration modeling.
Modifiers | Name | Description |
---|---|---|
static class |
NCube.NCubeReader |
Permanently add Custom Reader / Writer to json-io so that n-cube will use its native JSON format when written or read with json-io. |
static class |
NCube.NCubeWriter |
Custom writer for NCube when used with json-io |
private static class |
NCube.StackEntry |
This is a "Pointer" (or Key) to a cell in an NCube. |
Modifiers | Name | Description |
---|---|---|
private static byte[] |
ARRAY_BYTES |
|
private static byte[] |
A_BYTES |
|
private static byte[] |
COL_BYTES |
|
private static byte[] |
C_BYTES |
|
static java.lang.String |
DEFAULT_CELL_VALUE |
|
static java.lang.String |
DEFAULT_CELL_VALUE_CACHE |
|
static java.lang.String |
DEFAULT_CELL_VALUE_TYPE |
|
static java.lang.String |
DEFAULT_CELL_VALUE_URL |
|
protected static byte[] |
FALSE_BYTES |
|
private static org.slf4j.Logger |
LOG |
|
private static byte[] |
MAP_BYTES |
|
private static byte[] |
NULL_BYTES |
|
private static byte[] |
O_BYTES |
|
static java.lang.String |
RULE_EXEC_INFO |
|
protected static byte[] |
TRUE_BYTES |
|
private java.util.Map<java.lang.String, Advice> |
advices |
|
private ApplicationID |
appId |
|
private java.util.Map<java.lang.String, Axis> |
axisList |
|
protected java.util.Map<LongHashSet, T> |
cells |
|
private T |
defaultCellValue |
|
private static java.lang.ThreadLocal<java.util.Deque<StackEntry>> |
executionStack |
|
private java.util.Map<java.lang.Long, Axis> |
idToAxis |
|
private java.util.Map |
metaProps |
|
private java.lang.String |
name |
|
private java.lang.String |
sha1 |
|
static java.lang.String |
validCubeNameChars |
Constructor and description |
---|
NCube
(java.lang.String name) Creata a new NCube instance with the passed in name |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addAdvice(Advice advice, java.lang.String method) Add advice to this n-cube that will be called before / after any Controller Method or URL-based Expression, for the given method |
|
void |
addAxis(Axis axis) Add an Axis to this NCube. |
|
Column |
addColumn(java.lang.String axisName, java.lang.Comparable value, java.lang.String colName = null, java.lang.Long suggestedId = null) Add a column to the n-cube |
|
void |
addMetaProperties(java.util.Map<java.lang.String, java.lang.Object> allAtOnce) Add a Map of meta properties all at once. |
|
private static void |
assertAtLeast1Rule(java.util.Collection<Column> columns, java.lang.String errorMessage) |
|
T |
at(java.util.Map coordinate, java.util.Map output = [:], java.lang.Object defaultValue = null) Fetch the contents of the cell at the location specified by the coordinate argument. |
|
void |
breakAxisReference(java.lang.String axisName) Convert a reference axis to a non-reference axis. |
|
protected void |
clearAdvices() For testing, advices need to be removed after test completes. |
|
void |
clearCells() Clear all cell values. |
|
void |
clearMetaProperties() Remove all meta properties associated to this n-cube. |
|
void |
clearSha1() |
|
private java.lang.String |
columnIdsToString(java.util.Set<java.lang.Long> columns) |
|
boolean |
containsCell(java.util.Map coordinate, boolean useDefault = false) Test to see if a value is mapped at the given coordinate. |
|
boolean |
containsCellById(java.util.Collection<java.lang.Long> coordinate)
|
<T> |
static NCube<T> |
createCubeFromBytes(byte[] bytes) Create a cube from a byte[] of JSON bytes, or a gzip byte[] of JSON bytes, both are JSON content representing an n-cube. |
<T> |
static NCube<T> |
createCubeFromStream(java.io.InputStream stream) Create an n-cube from a stream of bytes. |
|
NCube |
createStubCube() |
|
private static void |
deepSha1(java.security.MessageDigest md, java.lang.Object value, byte sep) |
|
boolean |
deleteAxis(java.lang.String axisName) Remove an axis from an NCube. |
|
boolean |
deleteColumn(java.lang.String axisName, java.lang.Comparable value) Delete a column from the named axis. |
|
protected void |
dropOrphans(java.util.Set<java.lang.Long> columnIds, long axisId) Walk cell map and ensure all coordinates are fully resolvable |
|
NCube |
duplicate(java.lang.String newName) Create an equivalent n-cube as 'this'. |
|
private void |
ensureAllRuleAxesBound(java.util.Map coordinate, java.util.Map<java.lang.String, java.lang.Integer> conditionsFiredCountPerAxis) Verify that at least one rule on each rule axis fired. |
|
protected LongHashSet |
ensureFullCoordinate(java.util.Collection<java.lang.Long> coordinate) Make sure the returned Set |
|
boolean |
equals(java.lang.Object other) |
|
private T |
executeAssociatedStatement(java.util.Map input, java.util.Map output, RuleInfo ruleInfo, Binding binding) |
|
private java.lang.Object |
executeExpression(java.util.Map ctx, CommandCell cmd) |
|
java.lang.Object |
extractMetaPropertyValue(java.lang.Object value, java.util.Map input = [:], java.util.Map output = [:]) If a meta property value is fetched from an Axis or a Column, the value should be extracted using this API, so as to allow executable values to be retrieved. |
|
Column |
findColumn(java.lang.String axisName, java.lang.Comparable value) Convenience method to locate column when you have the axis name as a String and the value to find. |
<T> |
static NCube<T> |
fromSimpleJson(java.lang.String json) Use this API to create NCubes from a simple JSON format. |
<T> |
static NCube<T> |
fromSimpleJson(java.io.InputStream stream) Use this API to create NCubes from a simple JSON format. |
|
static groovy.util.MapEntry |
generateRuleName(java.util.Set<java.lang.String> names, int count) |
|
Axis |
get(java.lang.String axisName) This API allows Groovy code to do this: ncube.axisName or ncube['axisName'] to fetch an axis. |
|
java.util.List<Advice> |
getAdvices(java.lang.String method) @return List |
|
ApplicationID |
getApplicationID()
|
|
java.util.List<Axis> |
getAxes() @return List |
|
Axis |
getAxis(java.lang.String axisName) Retrieve an axis (by name) from this NCube. |
|
Axis |
getAxisFromColumnId(long id, boolean columnMustExist = true) Given the passed in Column ID, return the axis that contains the column. |
|
java.util.Set<java.lang.String> |
getAxisNames() @return Set |
|
protected static java.lang.Boolean |
getBoolean(java.util.Map obj, java.lang.String key) |
|
T |
getCell(java.util.Map coordinate, java.util.Map output = [:], java.lang.Object defaultValue = null) Fetch the contents of the cell at the location specified by the coordinate argument. |
|
protected T |
getCellById(java.util.Set<java.lang.Long> colIds, java.util.Map coordinate, java.util.Map output, java.lang.Object defaultValue = null) The lowest level cell fetch. |
|
java.lang.Object |
getCellByIdNoExecute(java.util.Set<java.lang.Long> coordinate) Mainly useful for displaying an ncube within an editor. |
|
java.util.Map<LongHashSet, T> |
getCellMap() @return read-only copy of the n-cube cells. |
|
java.lang.Object |
getCellNoExecute(java.util.Map coordinate) Fetch the actual 'formula' at the given cell. |
|
java.lang.Object |
getColumnDefault(java.util.Set<java.lang.Long> colIds) Given the passed in column IDs, return the column level default value if one exists or null otherwise. |
|
java.util.Map |
getCoordinateFromIds(java.util.Set<java.lang.Long> idCoord) Turn a Set of column IDs into a 'normal' coordinate that has values that will bind to axes the 'normal' way. |
|
LongHashSet |
getCoordinateKey(java.util.Map coordinate, java.util.Map output = new CaseInsensitiveMap()
|
|
private static java.util.Map<java.lang.String, java.lang.Integer> |
getCountersPerAxis(java.lang.String[] axisNames) |
|
byte[] |
getCubeAsGzipJsonBytes() @return byte[] containing the bytes of this N-Cube when converted to JSON format and then gzipped. |
|
protected java.util.Set<java.lang.String> |
getDeclaredScope(java.util.Map input, java.util.Map output) Get the declared required scope keys for this n-cube. |
|
T |
getDefaultCellValue()
|
|
java.util.Map<java.lang.String, java.lang.Object> |
getDisplayCoordinateFromIds(java.util.Set<java.lang.Long> idCoord) Fetch a 'display' coordinate from the passed in Set of IDs. |
|
protected static java.lang.Long |
getLong(java.util.Map obj, java.lang.String key) |
|
java.util.Map<java.lang.Object, T> |
getMap(java.util.Map coordinate, java.util.Map output = [:], java.lang.Object defaultValue = null) Get a Map of column values and corresponding cell values where all axes but one are held to a fixed (single) column, and one axis allows more than one value to match against it. |
|
long |
getMaxAxisId() Determine highest ID used by the axes. |
|
java.util.Map |
getMetaProperties() Fetch n-cube meta properties (SHA1, HEAD_SHA1, and CHANGE_TYPE are not meta-properties. |
|
java.lang.Object |
getMetaProperty(java.lang.String key) Fetch the value associated to the passed in Key from the MetaProperties (if any exist). |
|
java.lang.String |
getName() @return String name of the NCube |
|
int |
getNumCells() @return int total number of cells that are uniquely set (non default) within this NCube. |
|
int |
getNumDimensions() @return int the number of axis (dimensions) for this n-cube. |
|
long |
getNumPotentialCells() @return long number of potential cells this n-cube potentially has |
|
java.util.Set<java.lang.String> |
getOptionalScope(java.util.Map input, java.util.Map output) Get the optional scope keys. |
|
java.util.List<java.util.Map<java.lang.String, T>> |
getPopulatedCellCoordinates()
|
|
java.util.Map<java.util.Map, java.util.Set<java.lang.String>> |
getReferencedCubeNames()
|
|
private static java.util.Map<java.util.Map, java.util.Set<java.lang.String>> |
getReferences(java.util.Map<java.util.Map, java.util.Set<java.lang.String>> refs, java.util.Map coord, CommandCell cmdCell) |
|
protected java.util.Set<java.lang.String> |
getRequiredAxes()
|
|
java.util.Set<java.lang.String> |
getRequiredScope(java.util.Map input, java.util.Map output) Determine the required 'scope' needed to access all cells within this NCube. |
|
static RuleInfo |
getRuleInfo(java.util.Map output) Get / Create the RuleInfo Map stored at output[NCube.RULE_EXEC_INFO] |
|
java.lang.String |
getStatus() @return ReleaseStatus of this n-cube as it was loaded. |
|
protected static java.lang.String |
getString(java.util.Map obj, java.lang.String key) |
|
java.lang.String |
getVersion() @return String version of this n-cube as it was loaded. |
|
private Axis |
getWildcardAxis(java.util.Map<java.lang.String, java.lang.Object> coordinate) @param coordinate passed in coordinate for accessing this n-cube |
|
private java.util.List<Column> |
getWildcardColumns(Axis wildcardAxis, java.util.Map coordinate)
|
|
boolean |
hasRuleAxis() @return boolean true if there is at least one rule axis, false if there are no rule axes. |
|
int |
hashCode() |
|
static void |
healUnamedRules(AxisType type, java.lang.Object[] columns) |
<T> |
private static NCube<T> |
hydrateCube(java.util.Map jsonNCube) Load an n-cube from JSON format, which was read in by json-io as a Map of Maps. |
|
private static boolean |
incrementVariableRadixCount(java.util.Map<java.lang.String, java.lang.Integer> counters, java.util.Map<java.lang.String, java.util.List<Column>> bindings, java.lang.String[] axisNames) Increment the variable radix number passed in. |
|
boolean |
isComparableCube(NCube<T> other) Test if another n-cube is 'comparable' with this n-cube. |
|
static boolean |
isTrue(java.lang.Object ruleValue) Follow the exact same treatment of TRUTH as Groovy |
|
private static boolean |
isZero(java.lang.Integer count) |
|
void |
mergeDeltas(java.util.List<Delta> deltas) Merge the passed in List of Delta's into this n-cube. |
|
private static void |
moveAxisMetaPropsToDefaultColumn(Axis axis) Snag all meta-properties on Axis that start with Axis.DEFAULT_COLUMN_PREFIX, as this is where the default column's meta properties are stored, and copy them to the default column (if one exists) |
|
static java.util.Map |
objectToMap(java.lang.Object o) Convert an Object to a Map. |
|
protected java.util.Map |
prepareExecutionContext(java.util.Map coord, java.util.Map output) Prepare the execution context by providing it with references to important items like the input coordinate, output map, stack, and this (ncube). |
|
protected static java.io.InputStream |
rawStreamToInputStream(java.io.InputStream stream) |
|
void |
removeAxisReferenceTransform(java.lang.String axisName) Remove transform from a reference axis. |
|
T |
removeCell(java.util.Map coordinate) Clear (remove) the cell at the given coordinate. |
|
T |
removeCellById(java.util.Set<java.lang.Long> coordinate) Clear a cell directly from the cell sparse-matrix specified by the passed in Column IDs. |
|
java.lang.Object |
removeMetaProperty(java.lang.String key) Remove a meta-property entry |
|
void |
renameAxis(java.lang.String oldName, java.lang.String newName) Rename an axis |
|
private java.util.Map<java.lang.String, java.util.List<Column>> |
selectColumns(java.util.Map<java.lang.String, java.lang.Object> input, java.util.Map output) Bind the input coordinate to each axis. |
|
void |
setApplicationID(ApplicationID appId) |
|
T |
setCell(T value, java.util.Map coordinate) Store a value in the cell at the passed in coordinate. |
|
T |
setCellById(T value, java.util.Set<java.lang.Long> coordinate) Set a cell directly into the cell sparse-matrix specified by the passed in Column IDs. |
|
void |
setDefaultCellValue(T defaultCellValue) Set the default cell value for this n-cube. |
|
java.lang.Object |
setMetaProperty(java.lang.String key, java.lang.Object value) Set (add / overwrite) a Meta Property associated to this n-cube. |
|
void |
setName(java.lang.String name) Set the name of this n-cube |
|
protected void |
setSha1(java.lang.String sha1) This should only be called from NCubeManager when loading the cube from a database It is mainly to prevent an unnecessary sha1 calculation after being loaded from a db that already knows the sha1. |
|
java.lang.String |
sha1()
|
|
private static java.lang.String |
stackToString() |
|
private static void |
stripFoistedAppId(NCube ncube) |
|
java.lang.String |
toFormattedJson(java.util.Map options = null) Format this n-cube into JSON using the passed in 'options' Map to control the desired output. |
|
java.lang.String |
toHtml(java.lang.String... headers) Use this API to generate an HTML view of this NCube. |
|
protected static java.lang.String |
toJson(java.lang.Object o) |
|
java.lang.String |
toString() |
|
private static void |
trackInputKeysUsed(java.util.Map input, java.util.Map output) |
|
private static void |
trackUnboundAxis(java.util.Map output, java.lang.String cubeName, java.lang.String axisName, java.lang.Object value) |
|
protected static void |
transformMetaProperties(java.util.Map props) Convert the values on the value side of the Map from JsonObject to an appropriate CellInfo. |
|
void |
updateColumn(long id, java.lang.Comparable value, java.lang.String name = null, int order = -1i) Change the value of a Column along an axis. |
|
java.util.Set<java.lang.Long> |
updateColumns(java.lang.String axisName, java.util.Collection<Column> newCols, boolean allowPositiveColumnIds = false) Update all of the columns along an axis at once. |
|
private java.util.Map |
validateCoordinate(java.util.Map coordinate, java.util.Map output) Ensure that the Map coordinate dimensionality satisfies this nCube. |
|
static void |
validateCubeName(java.lang.String cubeName) Ensure that the passed in name is a valid n-cube name, |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Creata a new NCube instance with the passed in name
name
- String name to use for the NCube.Add advice to this n-cube that will be called before / after any Controller Method or URL-based Expression, for the given method
Add an Axis to this NCube. If the axis has a default column, all cells will be added to the default column. Otherwise, all cells will be cleared.
axis
- Axis to addAdd a column to the n-cube
axisName
- String name of the Axis to which the column will be added.value
- Comparable that will be the value for the given column. Cannot be null.colName
- The optional name of the column, useful for RULE axis columns. Optional.suggestedId
- Long id. If id is not valid for the column (unique id, and axis portion matches axis on which
it is added), then the ID will be generated. Optional.Add a Map of meta properties all at once.
allAtOnce
- Map of meta properties to addFetch the contents of the cell at the location specified by the coordinate argument. Be aware that if you have any rule cubes in the execution path, they can execute more than one cell. The cell value returned is the value of the last cell executed. Typically, in a rule cube, you are writing to specific keys within the rule cube, and the calling code then accesses the 'output' Map to fetch the values at these specific keys.
coordinate
- Map of String keys to values meant to bind to each axis of the n-cube.output
- Map that can be written to by the code within the the n-cubes (for example,
GroovyExpressions.defaultValue
- Object placed here will be returned if there is no cell at the location
pinpointed by the input coordinate. Normally, the defaulValue of the
n-cube is returned, but if this parameter is passed a non-null value,
then it will be returned.Convert a reference axis to a non-reference axis. 'Break the Reference.'
axisName
- String name of reference axis to convert.For testing, advices need to be removed after test completes.
Clear all cell values. All axes and columns remain.
Remove all meta properties associated to this n-cube.
Test to see if a value is mapped at the given coordinate. The 2nd argument allows you to take into account the n-cube level Default Cell value or not. Set to true to have the default value considered, false otherwise.
coordinate
- Map (coordinate) of a celluseDefault
- (optional, defaults to false. Set to true, then if a non-default
value for the n-cube is set, this method will return true).
Create a cube from a byte[] of JSON bytes, or a gzip byte[] of JSON bytes, both are JSON content representing an n-cube. Calling ncube.toFormattedJson() is the source of the JSON format used.
Create an n-cube from a stream of bytes. The stream can be either a JSON stream of an n-cube or a g-zip JSON stream.
Remove an axis from an NCube. All cells will be cleared when an axis is deleted.
axisName
- String name of axis to removeDelete a column from the named axis. All cells that reference this column will be deleted.
axisName
- String name of Axis contains column to be removed.value
- Comparable value used to identify column (Long if identifying a RULE column)Walk cell map and ensure all coordinates are fully resolvable
Create an equivalent n-cube as 'this'.
Verify that at least one rule on each rule axis fired. If not, then you have a CoordinateNotFoundException.
coordinate
- Input (Map) coordinate for getCell()conditionsFiredCountPerAxis
- Map that tracks AxisName to number of fired-columns bound to axis Make sure the returned Set
If a meta property value is fetched from an Axis or a Column, the value should be extracted using this API, so as to allow executable values to be retrieved.
value
- Object value to be extracted.Convenience method to locate column when you have the axis name as a String and the value to find. If the named axis is a rule axis, then it is expected that value is either a String name of the rule or the long ID of the rule column.
axisName
- String name of axis. Case does not matter when locating by name.value
- Comparable value used to find the column.Use this API to create NCubes from a simple JSON format.
json
- Simple JSON formatUse this API to create NCubes from a simple JSON format.
stream
- Simple JSON formatThis API allows Groovy code to do this: ncube.axisName or ncube['axisName'] to fetch an axis.
axisName
- String name of axis to get (case ignored)
Retrieve an axis (by name) from this NCube.
axisName
- String name of Axis to fetch.Given the passed in Column ID, return the axis that contains the column.
id
- Long id of a Column on one of the Axes within this n-cube.columnMustExist
- boolean, defaults to true. The axis will only be
returned if the column id passed in is that of a column on the axis. For
example, a deleted column ID, while it may contain the correct axis id,
it is no longer on the axis. If this is false, then the axis will still
be returned even if the column id represents a column no longer on the
axis. If true, both the axis and column must exist.
Fetch the contents of the cell at the location specified by the coordinate argument. Note that if you have any rule axes, they can execute more than one time. The value returned by this method is the value of the last cell executed. Typically, in a rule cube, you are writing to specific keys within the output Map, and the calling code then accesses the 'output' Map to fetch the values at these specific keys. A rule axis name can have a String, Collection, Map, or nothing associated to it. - If the value is a String, then it is the name of the rule to begin execution (skips past rules ahead of it). - If the value associated to a rule axis name is a Collection, then it is considered a Collection of rule names to run (orchestration). In that case, only the named rules will be executed (their conditions evaluated, and if true, the associated statements). - If the associated value is a Map, then the keys will be the names of meta-property keys associated to the rule condition column meta-property keys, and the values must match the value associated to the meta-property. The special value NCUBE.DONT_CARE can be associated to the key, in which case only the key name of the meta-property must match the key name in the passed in map in order for the rule to be selected. If there is more than one entry in the passed in Map, then the rules must match on all entries. This is a conjunction (or AND) - the rules match all keys are selected. - If nothing is associated to the rule axis name (or null), then all rules are selected. Once the rules are selected, all rule conditions are executed. If the condition is true, then the associated statement is executed. Note: More than one rule axis can be added to an n-cube. In this case, each rule axis name can have its own orchestration (rule list) to select the rules on the given axis.
coordinate
- Map of String keys to values meant to bind to each axis of the n-cube.output
- Map that can be written to by the code within the the n-cubes (for example,
GroovyExpressions.defaultValue
- Object placed here will be returned if there is no cell at the location
pinpointed by the input coordinate. Normally, the defaulValue of the
n-cube is returned, but if this parameter is passed a non-null value,
then it will be returned. The lowest level cell fetch. This method uses the Set
Mainly useful for displaying an ncube within an editor. This will get the actual stored cell, not execute it. The caller will get CommandCell instances for example, as opposed to the return value of the executed CommandCell.
Fetch the actual 'formula' at the given cell. In the case of primitives, the primitive will be returned. However, in the case of an Expression, the Expression will be returned, not executed.
Given the passed in column IDs, return the column level default value if one exists or null otherwise. In the case of intersection, then null is returned, meaning that the n-cube level default cell value will be returned at intersections.
Turn a Set of column IDs into a 'normal' coordinate that has values that will bind to axes the 'normal' way. For RULE axes, the key will be the rule axis name and the value will be the rule name. If there is no rule name, then the value will be the long ID of the column on the rule axis.
idCoord
- Set
coordinate
- Map containing Axis names as keys, and Comparable's as
values. The coordinate key matches an axis name, and then the column on the
axis is found that best matches the input coordinate value. Use this when
the input is expected to only match one value on an axis. For example, for a
RULE axis, the key name is the RULE axis name, and the value is the rule name
to match.
Get the declared required scope keys for this n-cube. These keys are required to 'talk' to this cube and any of it's subordinate cubes. Note that the keys can be a list of Strings of an expression (which could join another n-cube).
input
- Map containing inputoutput
- Map for writing output.
Fetch a 'display' coordinate from the passed in Set of IDs. The returned coordinate will have the String 'default column' for column ids that represent default columns. If any of the columns have a name (like columns on a rule axis), the name will be included in the String associated to the axis name entry.
idCoord
- SetGet a Map of column values and corresponding cell values where all axes but one are held to a fixed (single) column, and one axis allows more than one value to match against it.
coordinate
- Map - A coordinate where the keys are axis names, and the
values are intended to match a column on each axis, with one exception. One
of the axis values in the coordinate input map must be an instanceof a Set.
If the set is empty, all columns and cell values for the given axis will be
returned in a Map. If the Set has values in it, then only the columns
on the 'wildcard' axis that match the values in the set will be returned (along
with the corresponding cell values).output
- Map that can be written to by the code within the the n-cubes (for example,
GroovyExpressions. Optional.defaultValue
- Object placed here will be returned if there is no cell at the location
pinpointed by the input coordinate. Normally, the defaulValue of the
n-cube is returned, but if this parameter is passed a non-null value,
then it will be returned. Optional.Determine highest ID used by the axes. When adding an additional axis, it is recommended to use this value plus 1 for adding another axis.
Fetch n-cube meta properties (SHA1, HEAD_SHA1, and CHANGE_TYPE are not meta-properties. Use their respective accessor functions to obtain those).
Fetch the value associated to the passed in Key from the MetaProperties (if any exist). If none exist, null is returned.
Get the optional scope keys. These are keys that if supplied, might change the returned value, but if not supplied a value is still returned. For example, an axis that has a Default column is an optional scope. If no value is supplied for that axis, the Default column is chosen. However, supplying a value for it *may* change the column selected. Similarly, a cube may reference another cube, and the 'sub-cube' may use different scope keys than the calling cube. These additional keys are located and added as optional scope.
Determine the required 'scope' needed to access all cells within this NCube. Effectively, you are determining how many axis names (keys in a Map coordinate) are required to be able to access any cell within this NCube. Keep in mind, that CommandCells allow this NCube to reference other NCubes and therefore the referenced NCubes must be checked as well. This code will not get stuck in an infinite loop if one cube has cells that reference another cube, and it has cells that reference back (it has cycle detection).
Get / Create the RuleInfo Map stored at output[NCube.RULE_EXEC_INFO]
coordinate
- passed in coordinate for accessing this n-cube
coordinate
- Map containing Axis names as keys, and Comparable's as
values. The coordinate key matches an axis name, and then the column on the
axis is found that best matches the input coordinate value. The input coordinate
must contain one Set as a value for one of the axes of the NCube. If empty,
then the Set is treated as '*' (star). If it has 1 or more elements in
it, then for each entry in the Set, a column position value is returned.
Load an n-cube from JSON format, which was read in by json-io as a Map of Maps. This is the 'regular' JSON format that is output from the JsonFormatter with no special settings. For example, the JSON format created when indexFormat=true is not loadable by this method.
jsonNCube
- Map is the regular JSON format read and returned by json-io in Map of Map format.Increment the variable radix number passed in. The number is represented by a Map, where the keys are the digit names (axis names), and the values are the associated values for the number.
Test if another n-cube is 'comparable' with this n-cube. This means that they have the same number of dimensions (axes) and each axis has the same name. This test will allow many operations to be performed on two cubes once it is known they are 'compatible' such as union, intersection, even matrix operations like multiply, etc.
other
- NCube to compare to this ncube.Follow the exact same treatment of TRUTH as Groovy
Merge the passed in List of Delta's into this n-cube.
deltas
- List of Delta instances.Snag all meta-properties on Axis that start with Axis.DEFAULT_COLUMN_PREFIX, as this is where the default column's meta properties are stored, and copy them to the default column (if one exists)
Convert an Object to a Map. This allows an object to then be passed into n-cube as a coordinate. Of course the returned map can have additional key/value pairs added to it after calling this method, but before calling getCell().
o
- Object any Java object to bind to an NCube.Prepare the execution context by providing it with references to important items like the input coordinate, output map, stack, and this (ncube).
Remove transform from a reference axis.
axisName
- String name of reference axis.Clear (remove) the cell at the given coordinate. The cell is dropped from the internal sparse storage. After this call, containsCell(coord) for the same cell will return false.
coordinate
- Map coordinate of Cell to remove.Clear a cell directly from the cell sparse-matrix specified by the passed in Column IDs. After this call, containsCell(coord) for the same coordinate would return false.
Remove a meta-property entry
Rename an axis
oldName
- String old namenewName
- String new name Bind the input coordinate to each axis. The reason the column is a List of columns that the coordinate
binds to on the axis, is to support RULE axes. On a regular axis, the coordinate binds
to a column (with a binary search or hashMap lookup), however, on a RULE axis, the act
of binding to an axis results in a Listinput
- The passed in input coordinate to bind (or multi-bind) to each axis.
Store a value in the cell at the passed in coordinate.
value
- A value to store in the NCube cell.coordinate
- Map coordinate used to identify what cell to update.
The Map contains keys that are axis names, and values that will
locate to the nearest column on the axis.Set a cell directly into the cell sparse-matrix specified by the passed in Column IDs.
Set the default cell value for this n-cube. This is a space-saving technique, as the most common cell value can be set as the defaultCellValue, and then the cells that would have had this value can be left empty.
defaultCellValue
- T the default value that will be returned when a coordinate
specifies a cell that has no entry associated to it.Set (add / overwrite) a Meta Property associated to this n-cube.
key
- String key name of meta propertyvalue
- Object value to associate to keySet the name of this n-cube
name
- String nameThis should only be called from NCubeManager when loading the cube from a database It is mainly to prevent an unnecessary sha1 calculation after being loaded from a db that already knows the sha1.
sha1
- String SHA-1 value to set into this n-cube. Should only be called internally
from code constructing this n-cube from a persistent store.
Format this n-cube into JSON using the passed in 'options' Map to control the desired output. See the JsonFormatter's format() API for available options.
Use this API to generate an HTML view of this NCube.
headers
- String list of axis names to place at top. If more than one is listed, the first axis encountered that
matches one of the passed in headers, will be the axis chosen to be displayed at the top.Convert the values on the value side of the Map from JsonObject to an appropriate CellInfo. If the value is not a JsonObject, it is left alone (primitives).
props
- Map of String meta-property keys to valuesChange the value of a Column along an axis.
id
- long indicates the column to changevalue
- Comparable new value to set into the columnorder
- int (optional) new display order for columnUpdate all of the columns along an axis at once. Any cell referencing a column that is deleted, will also be deleted from the internal sparse matrix (Map) of cells.
axisName
- String axis name to updatenewCols
- ListEnsure that the Map coordinate dimensionality satisfies this nCube. This method verifies that all axes are listed by name in the input coordinate.
coordinate
- Map input coordinateEnsure that the passed in name is a valid n-cube name,
cubeName
- String cube name to test.