Class SchemaMapperImpl
java.lang.Object
org.aksw.jenax.arq.schema_mapping.SchemaMapperImpl
SchemaMapper for mapping RDF tables ("result sets") to SQL tables.
The schema mapper is independent of any instance data an operates only based on
a given set of source variables (column names) together with statistic providers.
As a consequence it is possible to create schema mappings for concrete SPARQL result sets
as well as from schemas of virtual result sets such as obtained by rewriting a SPARQL query
w.r.t. a set of R2RML mappings.
Example for using this class in conjunction with
BindingAnalytics on a concrete SPARQL result set:
List<Binding> bindings = rs...;
Set<Var> resultVars = rs...;
Map<Var, Entry<Multiset<String>, Long>> usedDatatypesAndNulls = bindings.stream()
.collect(ResultSetAnalytics.usedDatatypesAndNullCounts(resultVars).asCollector());
SchemaMapperImpl.newInstance()
.setSourceVars(resultVars)
.setSourceVarToDatatypes(v -> usedDatatypesAndNulls.get(v).getKey().elementSet())
.setSourceVarToNulls(v -> usedDatatypesAndNulls.get(v).getValue())
.setTypePromotionStrategy(TypePromoterImpl.create())
.createSchemaMapping();
- Author:
- Claus Stadler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<org.apache.jena.sparql.core.Var>protected BiFunction<String,String, ? extends ExprRewrite> protected org.aksw.jenax.arq.schema_mapping.TypePromoter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateColumnName(String varName, String datatypeIri) static org.apache.jena.sparql.expr.ExprcreateDatatypeCheck(org.apache.jena.sparql.expr.Expr expr, String datatypeIri) static ExprRewritedefaultTypeConversionSupplier(String srcDatatypeIri, String tgtDatatypeIri) static StringderiveSuffix(String datatype) Set<org.apache.jena.sparql.core.Var>BiFunction<String,String, ? extends ExprRewrite> static SchemaMapperImplsetSourceVars(Set<org.apache.jena.sparql.core.Var> sourceVars) Set the set of columns of the source schema (represented as variables) which participate in the schema mapping.setSourceVarToDatatypes(Function<? super org.apache.jena.sparql.core.Var, ? extends Set<String>> sourceVarToDatatypes) setSourceVarToNulls(Function<? super org.apache.jena.sparql.core.Var, ? extends Number> sourceVarToNulls) setTypeConversionSupplier(BiFunction<String, String, ? extends ExprRewrite> typeConversionSupplier) setTypePromotionStrategy(org.aksw.jenax.arq.schema_mapping.TypePromoter typePromotionStrategy) The type promotion strategy.setTypeRemap(Function<String, String> typeRemap) setVarToFallbackDatatype(String datatype) Sets (and overrides) the fallback for any variable to the given argument.setVarToFallbackDatatype(Function<? super org.apache.jena.sparql.core.Var, String> varToFallbackDatatype) Convenience method to set (and override) the fallback datatype to xsd:string.
-
Field Details
-
sourceVars
-
sourceVarToDatatypes
-
sourceVarToNulls
-
typeRemap
-
typeConversionSupplier
-
varToFallbackDatatype
-
typePromotionStrategy
protected org.aksw.jenax.arq.schema_mapping.TypePromoter typePromotionStrategy
-
-
Constructor Details
-
SchemaMapperImpl
public SchemaMapperImpl()
-
-
Method Details
-
setSourceVars
Set the set of columns of the source schema (represented as variables) which participate in the schema mapping. -
getSourceVars
-
setSourceVarToDatatypes
public SchemaMapperImpl setSourceVarToDatatypes(Function<? super org.apache.jena.sparql.core.Var, ? extends Set<String>> sourceVarToDatatypes) -
setSourceVarToNulls
public SchemaMapperImpl setSourceVarToNulls(Function<? super org.apache.jena.sparql.core.Var, ? extends Number> sourceVarToNulls) -
setVarToFallbackDatatype
public SchemaMapperImpl setVarToFallbackDatatype(Function<? super org.apache.jena.sparql.core.Var, String> varToFallbackDatatype) -
setVarToFallbackDatatype
Sets (and overrides) the fallback for any variable to the given argument. CallssetVarToFallbackDatatype(Function). -
setVarToFallbackDatatypeToString
Convenience method to set (and override) the fallback datatype to xsd:string. CallssetVarToFallbackDatatype(Function). -
getTypeRemap
-
setTypeRemap
-
getTypeConversionSupplier
-
setTypeConversionSupplier
public SchemaMapperImpl setTypeConversionSupplier(BiFunction<String, String, ? extends ExprRewrite> typeConversionSupplier) -
setTypePromotionStrategy
public SchemaMapperImpl setTypePromotionStrategy(org.aksw.jenax.arq.schema_mapping.TypePromoter typePromotionStrategy) The type promotion strategy. This can be used to reduce the number of columns in the target schema by combining weaker types with mightier ones, such as by promoting short to int. The strategy may even promote integer types to floating point ones.- Parameters:
typePromotionStrategy-- Returns:
-
deriveSuffix
-
createSchemaMapping
-
defaultTypeConversionSupplier
public static ExprRewrite defaultTypeConversionSupplier(String srcDatatypeIri, String tgtDatatypeIri) -
createDatatypeCheck
public static org.apache.jena.sparql.expr.Expr createDatatypeCheck(org.apache.jena.sparql.expr.Expr expr, String datatypeIri) -
createColumnName
-
newInstance
-