public class HierarchyHelper
extends java.lang.Object
Provides convenience methods used internally to manage hierarchical catalogs -related tasks
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MAPRED_KEY_SEPARATOR
Separator used in composite keys generated by
createMapRedOutputKey(String, String) |
Constructor and Description |
---|
HierarchyHelper() |
Modifier and Type | Method and Description |
---|---|
static HierarchyInfo |
createHierarchyInfo(Configuration conf)
Returns an initialized, empty (no content in hierarchy levels) instance of a
HierarchyInfo implementation contained in the configuration. |
static java.lang.String |
createMapRedOutputKey(java.lang.String hlName, java.lang.String id)
Creates a key for the given hierarchy level name, feature id which can be used as an output key by a mapper and then read from a reducer
|
static java.lang.String[] |
getHierarchyLevelsNames(HierarchyInfo hierInfo) |
static int |
getLoadHierarchyFromLevel(HierarchyInfo hierarchyInfo, Configuration conf)
Gets the value of the configuration parameter
ConfigParams.HIERARCHY_LOAD_MIN_LEVEL . |
static int |
getLoadHierarchyToLevel(HierarchyInfo hierarchyInfo, Configuration conf)
Gets the value of the configuration parameter
ConfigParams.HIERARCHY_LOAD_MAX_LEVEL . |
static java.lang.String[] |
getMapRedOutputKeyComponents(java.lang.String key)
Gets the components for a hierarchy level-feature id key created using the method
createMapRedOutputKey(String, String) |
static void |
loadHierarchyLevels(HierarchyInfo hierarchyInfo, Configuration conf)
Loads the content for all the hierarchy levels defined in the current job configuration using an initialized HierarchyInfo instance.
|
static void |
loadHierarchyLevels(HierarchyInfo hierarchyInfo, int fromLevel, int toLevel, Configuration conf)
Loads the content for the hierarchy levels from fromLevel to toLevel using an initialized HierarchyInfo instance.
|
static void |
setupHierarchyDataIndex(Path[] hierarchyDataPaths, Path hieararchicalIndexPath, HierarchyInfo hierarchyInfo, Configuration conf)
If the given hierarchy index exists and is valid it is loaded to the distributed cache, otherwise the hierarchy index is created for the given hierarchy data paths
|
public static final java.lang.String MAPRED_KEY_SEPARATOR
createMapRedOutputKey(String, String)
public static HierarchyInfo createHierarchyInfo(Configuration conf) throws java.lang.Exception
HierarchyInfo
implementation contained in the configuration.conf
- the job configurationjava.lang.Exception
public static java.lang.String createMapRedOutputKey(java.lang.String hlName, java.lang.String id)
hlName
- a hierarchy level nameid
- a hierarchy level's feature idpublic static java.lang.String[] getHierarchyLevelsNames(HierarchyInfo hierInfo)
public static int getLoadHierarchyFromLevel(HierarchyInfo hierarchyInfo, Configuration conf)
ConfigParams.HIERARCHY_LOAD_MIN_LEVEL
.hierarchyInfo
- the current job's HierarchyInfo instanceconf
- the job configurationpublic static int getLoadHierarchyToLevel(HierarchyInfo hierarchyInfo, Configuration conf)
ConfigParams.HIERARCHY_LOAD_MAX_LEVEL
.hierarchyInfo
- the current job's HierarchyInfo instanceconf
- the job configurationHierarchyInfo.getNumberOfLevels()
public static java.lang.String[] getMapRedOutputKeyComponents(java.lang.String key)
createMapRedOutputKey(String, String)
key
- the composite keypublic static void loadHierarchyLevels(HierarchyInfo hierarchyInfo, Configuration conf) throws java.io.IOException
hierarchyInfo
- an initialized HierarchyInfo. To get an initialized HierarchyInfo call createHierarchyInfo(Configuration)
conf
- the job configurationjava.io.IOException
public static void loadHierarchyLevels(HierarchyInfo hierarchyInfo, int fromLevel, int toLevel, Configuration conf) throws java.io.IOException
hierarchyInfo
- an initialized HierarchyInfo. To get an initialized HierarchyInfo call createHierarchyInfo(Configuration)
fromLevel
- the minimum leveltoLevel
- the maximum levelconf
- the job configurationjava.io.IOException
public static void setupHierarchyDataIndex(Path[] hierarchyDataPaths, Path hieararchicalIndexPath, HierarchyInfo hierarchyInfo, Configuration conf) throws java.lang.Exception
hierarchyDataPaths
- the paths of the hierarchy data to be indexed. If the hierarchy index already exists it will be ignored.hieararchicalIndexPath
- the path of the resulting hierarchy index.hierarchyInfo
- the instance describing the current hierarchyconf
- the job configurationjava.io.IOException
java.lang.Exception
Copyright © 2017 Oracle and/or its affiliates. All Rights Reserved.