public class SparseDataExporterImpl extends Object implements SparseDataExporter
SparseDataExporter.ScopeEnum
Modifier and Type | Field and Description |
---|---|
protected org.springframework.jdbc.core.JdbcTemplate |
jdbcTemplate |
protected KernelUtil |
kernelUtil |
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate |
namedJdbcTemplate |
protected Map<String,SparseDataFormatterFactory> |
nameToFormatterMap |
protected org.springframework.jdbc.core.simple.SimpleJdbcTemplate |
simpleJdbcTemplate |
protected org.springframework.transaction.support.TransactionTemplate |
txTemplateNew |
Constructor and Description |
---|
SparseDataExporterImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addNominalWordToInstance(SparseData sparseData,
long instanceId,
String word,
String wordValue) |
protected void |
addNumericWordToInstance(SparseData sparseData,
long instanceId,
String word,
double wordValue) |
void |
exportData(InstanceData instanceLabel,
SparseDataFormatter formatter,
Properties properties,
BagOfWordsDecorator bDecorator) |
void |
exportData(Properties props,
SparseDataFormatter formatter,
BagOfWordsDecorator bDecorator) |
void |
exportData(String propertiesFile,
String format) |
DataSource |
getDataSource(DataSource ds) |
KernelUtil |
getKernelUtil() |
Map<String,SparseDataFormatterFactory> |
getNameToFormatterMap() |
protected void |
getNominalInstanceWords(String sql,
String prepareScript,
String prepareScriptDelimiter,
SparseData sparseData,
Map<String,Object> params) |
protected void |
getNumericInstanceWords(String sql,
String prepareScript,
String prepareScriptDelimiter,
SparseData sparseData,
Map<String,Object> params) |
org.springframework.transaction.support.TransactionTemplate |
getTxTemplateNew() |
protected SparseData |
loadData(InstanceData instanceLabel,
String instanceNumericWordQuery,
String instanceNominalWordQuery,
String prepareScript,
String prepareScriptDelimiter,
BagOfWordsDecorator bDecorator,
String label,
Integer fold,
Integer run) |
static void |
main(String[] args) |
protected void |
prepare(String prepareScript,
String prepareScriptDelimiter,
Map<String,Object> params)
run the prepare script if defined.
|
void |
setDataSource(DataSource ds) |
void |
setKernelUtil(KernelUtil kernelUtil) |
void |
setNameToFormatterMap(Map<String,SparseDataFormatterFactory> nameToFormatterMap) |
void |
setTxTemplateNew(org.springframework.transaction.support.TransactionTemplate txTemplateNew) |
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
protected KernelUtil kernelUtil
protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate namedJdbcTemplate
protected Map<String,SparseDataFormatterFactory> nameToFormatterMap
protected org.springframework.jdbc.core.simple.SimpleJdbcTemplate simpleJdbcTemplate
protected org.springframework.transaction.support.TransactionTemplate txTemplateNew
public static void main(String[] args) throws IOException
IOException
protected void addNominalWordToInstance(SparseData sparseData, long instanceId, String word, String wordValue)
protected void addNumericWordToInstance(SparseData sparseData, long instanceId, String word, double wordValue)
public void exportData(InstanceData instanceLabel, SparseDataFormatter formatter, Properties properties, BagOfWordsDecorator bDecorator) throws IOException
IOException
public void exportData(Properties props, SparseDataFormatter formatter, BagOfWordsDecorator bDecorator) throws IOException
exportData
in interface SparseDataExporter
IOException
public void exportData(String propertiesFile, String format) throws IOException, InvalidPropertiesFormatException
exportData
in interface SparseDataExporter
IOException
InvalidPropertiesFormatException
public DataSource getDataSource(DataSource ds)
public KernelUtil getKernelUtil()
public Map<String,SparseDataFormatterFactory> getNameToFormatterMap()
protected void prepare(String prepareScript, String prepareScriptDelimiter, Map<String,Object> params)
prepareScript
- sequence of sql statements to be executed with named params.prepareScriptDelimiter
- delimiter separating the sql statements.params
- for named parameters in sql statements.protected void getNominalInstanceWords(String sql, String prepareScript, String prepareScriptDelimiter, SparseData sparseData, Map<String,Object> params)
sql
- result set has 3 columns. 1st column - integer - instance id.
2nd column - word. 3rd column - word value.instanceWordMap
- map of instance id to word-word value.wordValueMap
- map of word to valid values for the word.protected void getNumericInstanceWords(String sql, String prepareScript, String prepareScriptDelimiter, SparseData sparseData, Map<String,Object> params)
sql
- result 1st column: instance id, 2nd column: word, 3rd column:
numeric word valueinstanceNumericWords
- map of instance id - [map word - word value] to be populatedpublic org.springframework.transaction.support.TransactionTemplate getTxTemplateNew()
protected SparseData loadData(InstanceData instanceLabel, String instanceNumericWordQuery, String instanceNominalWordQuery, String prepareScript, String prepareScriptDelimiter, BagOfWordsDecorator bDecorator, String label, Integer fold, Integer run)
instanceLabel
- instance data: label - fold - instance id - class mapinstanceNumericWordQuery
- query to get numeric attributesinstanceNominalWordQuery
- query to get nominal attributesprepareScript
- prepare script to be executed in same tx as instance attribute
queriesprepareScriptDelimiter
- delimiter for statements in prepare scriptbDecorator
- decorator to add attributeslabel
- fold
- run
- public void setDataSource(DataSource ds)
public void setKernelUtil(KernelUtil kernelUtil)
public void setNameToFormatterMap(Map<String,SparseDataFormatterFactory> nameToFormatterMap)
public void setTxTemplateNew(org.springframework.transaction.support.TransactionTemplate txTemplateNew)
Copyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.