public class Hierarchies extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Hierarchies.HierarchicalElement
A JavaBean to represent an element in a hierarchical system from which transitive ancestors
can be computed.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ANCESTORS_TABLE
Default table name where expanded ancestor information is stored.
|
static String |
HIERARCHIES_DATABASE
Default database name where the ancestor information is stored.
|
static String |
HIERARCHY_URI_PREFIX
A URI prefix for hierarchical systems.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.spark.sql.Dataset<Ancestor> |
getAncestors()
Returns a dataset of all ancestors in this collection.
|
static Hierarchies |
getDefault(org.apache.spark.sql.SparkSession spark)
Returns the collection of ancestors from the default database and table.
|
static Hierarchies |
getEmpty(org.apache.spark.sql.SparkSession spark)
Returns an empty Hierarchies instance.
|
static Hierarchies |
getFromDatabase(org.apache.spark.sql.SparkSession spark,
String database)
Returns the collection of ancestors from the table in the given database.
|
static org.apache.spark.sql.Encoder<Hierarchies.HierarchicalElement> |
getHierarchicalElementEncoder()
Returns the encoder for hierarchical elements.
|
Map<String,String> |
getLatestVersions()
Returns the latest version of all hierarchies.
|
Map<String,String> |
getLatestVersions(Set<String> uris)
Returns latest versions of the given hierarchies.
|
org.apache.spark.sql.Dataset<UrlAndVersion> |
getMembers()
Returns a dataset of UrlAndVersion members of this collection.
|
static org.apache.spark.sql.Encoder<UrlAndVersion> |
getUriAndVersionEncoder()
Returns the encoder for UrlAndVersion tuples.
|
Hierarchies |
withHierarchies(Hierarchies hierarchies)
Returns a new hierarchies instance with the given hierarchies.
|
Hierarchies |
withHierarchyElements(String hierarchyUri,
String hierarchyVersion,
org.apache.spark.sql.Dataset<Hierarchies.HierarchicalElement> elements)
Returns a new hierarchies instance with the transitive ancestors computed from the given
dataset of
Hierarchies.HierarchicalElement. |
void |
writeToDatabase()
Writes the ancestors to the default database "ontologies" using the default table "ancestors".
|
void |
writeToDatabase(String database)
Writes the ancestors to the given database using the default table name "ancestors".
|
void |
writeToTables(String ancestorsTable)
Writes the ancestors to the given table.
|
public static final String HIERARCHIES_DATABASE
public static final String ANCESTORS_TABLE
public static final String HIERARCHY_URI_PREFIX
public static org.apache.spark.sql.Encoder<UrlAndVersion> getUriAndVersionEncoder()
public static org.apache.spark.sql.Encoder<Hierarchies.HierarchicalElement> getHierarchicalElementEncoder()
public static Hierarchies getDefault(org.apache.spark.sql.SparkSession spark)
spark - the spark sessionpublic static Hierarchies getFromDatabase(org.apache.spark.sql.SparkSession spark, String database)
spark - the spark sessiondatabase - name of the database containing the ancestors tablepublic static Hierarchies getEmpty(org.apache.spark.sql.SparkSession spark)
spark - the spark sessionpublic org.apache.spark.sql.Dataset<Ancestor> getAncestors()
public org.apache.spark.sql.Dataset<UrlAndVersion> getMembers()
public Map<String,String> getLatestVersions()
public Map<String,String> getLatestVersions(Set<String> uris)
uris - a set of URIs for which to retrieve the latest versions, or null to load them allpublic Hierarchies withHierarchyElements(String hierarchyUri, String hierarchyVersion, org.apache.spark.sql.Dataset<Hierarchies.HierarchicalElement> elements)
Hierarchies.HierarchicalElement.hierarchyUri - the URI of the hierarchical system to addhierarchyVersion - the version of the hierarchical system to addelements - the elements from which to calculate the ancestorspublic Hierarchies withHierarchies(Hierarchies hierarchies)
hierarchies - the hierarchies to add to this instancepublic void writeToDatabase()
public void writeToDatabase(String database)
database - the name of the database to which the ancestors are savedpublic void writeToTables(String ancestorsTable)
Warning: these updates are likely not atomic due to the lack of transactional semantics in the underlying data store. Concurrent users may see previous items removed before new ones are added, or items appear separately than others. This is intended for use in a user-specific sandbox or staging environment.
ancestorsTable - the name of the table to which the ancestors are savedCopyright © 2020. All rights reserved.