本文整理汇总了Java中org.knime.core.data.DataRow类的典型用法代码示例。如果您正苦于以下问题:Java DataRow类的具体用法?Java DataRow怎么用?Java DataRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataRow类属于org.knime.core.data包,在下文中一共展示了DataRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ActiveLearnLoopEndNodeModel
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
*
*/
protected ActiveLearnLoopEndNodeModel() {
super(new PortType[] { BufferedDataTable.TYPE,
BufferedDataTable.TYPE_OPTIONAL, },
new PortType[] { BufferedDataTable.TYPE });
m_isExecuting = false;
m_isTerminated = false;
// empty row map if no input data is present, yet.
m_rowMap = new HashMap<RowKey, DataRow>();
m_classModel = new ClassModel();
m_curIterationIndex = 0;
}
示例2: getValueAt
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object getValueAt(final int row, final int col) {
if (m_rows.size() == 0) { // this will probably not be called if,
// but making sure anyway
return null;
}
if (col == 0) {
return getRowKeyOf(row);
} else if (col == m_classColumnIndex) {
return m_listener.m_classMap.get(getRowKeyOf(row));
}
final DataRow data = m_rows.get(row); // get the row
return data.getCell(col - 1); // return the column (<-1> because
// first column is RowID and is not
// contained in data)
}
示例3: initializeClassMap
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Reads the classes from the ground truth table and adds them to the class
* map.
*
* @param inData
* @throws InvalidSettingsException
*/
private void initializeClassMap(final BufferedDataTable[] inData)
throws InvalidSettingsException {
final int classColIdxLabeledTable = NodeUtils.autoColumnSelection(
inData[LABELED_PORT].getDataTableSpec(),
m_groundTruthColumnModel, StringValue.class, this.getClass());
// initialize all classes map
m_allClassesMap = new HashMap<>((int)inData[LABELED_PORT].size());
for (final DataRow row : inData[LABELED_PORT]) {
m_allClassesMap.put(row.getKey(),
((StringCell) row.getCell(classColIdxLabeledTable))
.getStringValue());
}
}
示例4: createCellFactory
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Creates a CellFactory for the class column.
*
* @param colName
* the name of the class column
* @return CellFactory for the class column.
*/
private CellFactory createCellFactory(final String colName) {
return new CellFactory() {
@Override
public void setProgress(final int curRowNr, final int rowCount,
final RowKey lastKey, final ExecutionMonitor exec) {
exec.setProgress((double) curRowNr / rowCount);
}
@Override
public DataColumnSpec[] getColumnSpecs() {
return new DataColumnSpec[] {
new DataColumnSpecCreator(colName, StringCell.TYPE)
.createSpec() };
}
@Override
public DataCell[] getCells(final DataRow row) {
throw new IllegalStateException(
new IllegalAccessException("This shouldn't be called"));
}
};
}
示例5: createResRearranger
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* {@inheritDoc} Variance based score.
*/
@Override
protected ColumnRearranger createResRearranger(final DataTableSpec inSpec)
throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final DataColumnSpec newColSpec =
new DataColumnSpecCreator("Variance Score", DoubleCell.TYPE)
.createSpec();
// utility object that performs the calculation
rearranger.append(new SingleCellFactory(newColSpec) {
final List<Integer> m_selectedIndicies =
NodeTools.getIndicesFromFilter(inSpec, m_columnFilterModel,
DoubleValue.class, VarianceScorerNodeModel.class);
@Override
public DataCell getCell(final DataRow row) {
return new DoubleCell(MathUtils.variance(
NodeTools.toDoubleArray(row, m_selectedIndicies)));
}
});
return rearranger;
}
示例6: createResRearranger
import org.knime.core.data.DataRow; //导入依赖的package包/类
private ColumnRearranger createResRearranger(final DataTableSpec inSpec) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
rearranger.append(new CellFactory() {
@Override
public void setProgress(final int curRowNr, final int rowCount,
final RowKey lastKey, final ExecutionMonitor exec) {
exec.setProgress((double) curRowNr / rowCount);
}
@Override
public DataColumnSpec[] getColumnSpecs() {
return new DataColumnSpec[] {
new DataColumnSpecCreator("Graph Density Score",
DoubleCell.TYPE).createSpec() };
}
@Override
public DataCell[] getCells(final DataRow row) {
return new DataCell[] { new DoubleCell(
m_dataPoints.get(row.getKey()).getDensity()) };
}
});
return rearranger;
}
示例7: getCells
import org.knime.core.data.DataRow; //导入依赖的package包/类
@Override
public DataCell[] getCells(final DataRow row) {
final NoveltyScores noveltyScores = m_model.scoreTestData(row);
final double score = noveltyScores.getScores()[0] / m_normalizer;
final double[] nullspaceCoordinates =
noveltyScores.getCoordinates().getRow(0);
final ArrayList<DataCell> cells = new ArrayList<DataCell>();
if (m_appendNoveltyScore) {
cells.add(new DoubleCell(score));
}
if (m_appendNullspaceCoordinates) {
for (final double coord : nullspaceCoordinates) {
cells.add(new DoubleCell(coord));
}
}
if (cells.isEmpty()) {
return new DataCell[] {};
}
return cells.toArray(new DataCell[cells.size()]);
}
示例8: readDataRow
import org.knime.core.data.DataRow; //导入依赖的package包/类
private double[] readDataRow(final DataRow row) {
final double[] data = new double[row.getNumCells()];
for (int i = 0; i < row.getNumCells(); i++) {
final DataCell cell = row.getCell(i);
if (cell.isMissing()) {
throw new IllegalArgumentException(
"Missing values are not supported.");
} else if (!cell.getType().isCompatible(DoubleValue.class)) {
throw new IllegalArgumentException(
"Only numerical data types are currently supported.");
} else {
data[i] = ((DoubleValue) cell).getDoubleValue();
}
}
return data;
}
示例9: isPairRDD
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Check if table contain JavaPairRDD object. Only for RddTables. Other
* tables will throw a ClassCastException.
*
* @param table
* <code>BufferedDataTable</code>
* @throws IndexOutOfBoundsException
* If <code>table</code> contains more than one cell
* @throws ClassCastException
* If <code>table</code> isn't a RddTable
* @return
*/
public static Boolean isPairRDD(BufferedDataTable table) {
String[] names = table.getSpec().getColumnNames();
if (names.length != 1) {
throw new IndexOutOfBoundsException(
"table should contain only one cells");
}
CloseableRowIterator it = table.iterator();
DataRow firstRow = it.next();
try {
RddCell rddCell = (RddCell) firstRow.getCell(0);
return false;
} catch (ClassCastException e) {
PairRddCell pairRddCell = (PairRddCell) firstRow.getCell(0);
return true;
}
}
示例10: isRDDTable
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Check if table contains JavaRDDLike object
*
* @param table
* <code>BufferedDataTable</code>
* @return
*/
public static Boolean isRDDTable(BufferedDataTable table) {
String[] names = table.getSpec().getColumnNames();
if (names.length != 1) {
// RDD table should contain just one column
return false;
}
CloseableRowIterator it = table.iterator();
DataRow firstRow = it.next();
if (it.hasNext()) {
// RDD table should contain just one row
return false;
}
try {
RddCell rddCell = (RddCell) firstRow.getCell(0);
return true;
} catch (Exception e) {
try {
PairRddCell pairRddCell = (PairRddCell) firstRow.getCell(0);
return true;
} catch (Exception ee) {
return false;
}
}
}
示例11: execute
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Execute the snippet.
*
* @param table
* the data table at the inport
* @param flowVariableRepository
* the flow variables at the inport
* @param exec
* the execution context to report progress
* @return the table for the output
* @throws InvalidSettingsException
* when settings are inconsistent with the table or the flow
* variables at the input
* @throws CanceledExecutionException
* when execution is canceled by the user
*/
public BufferedDataTable execute(final BufferedDataTable table,
final FlowVariableRepository flowVariableRepository,
final ExecutionContext exec) throws CanceledExecutionException,
InvalidSettingsException {
OutColList outFields = m_fields.getOutColFields();
if (outFields.size() > 0) {
ColumnRearranger rearranger = createRearranger(
table.getDataTableSpec(), flowVariableRepository,
table.getRowCount());
return exec.createColumnRearrangeTable(table, rearranger, exec);
} else {
CellFactory factory = new JavaSnippetCellFactory(this,
table.getDataTableSpec(), flowVariableRepository,
table.getRowCount());
for (DataRow row : table) {
factory.getCells(row);
}
return table;
}
}
示例12: createRDD
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Creates JavaRDD from BufferedDataTable
*
* @param data
* <code>BufferedDataTable</code> to parallelize
* @param colIndices
* selected columns
* @return <code>JavaRDD</code>
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private JavaRDD createRDD(BufferedDataTable data, int[] colIndices) {
// make a copy of data
ArrayList copyOfData = new ArrayList(data.getRowCount());
CloseableRowIterator rowIt = data.iterator();
while (rowIt.hasNext()) {
DataRow nextRow = rowIt.next();
copyOfData.add(getCellValue(nextRow.getCell(colIndices[0])));
}
// create sparkContext and parallelize collection
JavaSparkContext sparkContext = SparkContexter.getSparkContext(m_master
.getStringValue());
return sparkContext.parallelize(copyOfData);
}
示例13: createPairRDD
import org.knime.core.data.DataRow; //导入依赖的package包/类
/**
* Creates JavaPairRDD from BufferedDataTable
*
* @param data
* <code>BufferedDataTable</code> to parallelize
* @param colIndices
* selected columns
* @return <code>JavaPairRDD</code>
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private JavaPairRDD createPairRDD(BufferedDataTable data, int[] colIndices) {
// make a copy of data
ArrayList copyOfData = new ArrayList(data.getRowCount());
CloseableRowIterator rowIt = data.iterator();
while (rowIt.hasNext()) {
DataRow nextRow = rowIt.next();
// Scala Tuple2 as key-value pair
copyOfData.add(new Tuple2(getCellValue(nextRow
.getCell(colIndices[0])), getCellValue(nextRow
.getCell(colIndices[1]))));
}
// create sparkContext and parallelize collection
JavaSparkContext sparkContext = SparkContexter.getSparkContext(m_master
.getStringValue());
return JavaPairRDD.fromJavaRDD(sparkContext.parallelize(copyOfData));
}
示例14: endElement
import org.knime.core.data.DataRow; //导入依赖的package包/类
@Override
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
throws SAXException
{
if(builder!=null)
{
DataRow row=new DefaultRow(RowKey.createRowKey(++rowOut),new IntCell(Integer.parseInt(builder.toString())));
container.addRowToTable(row);
exec.setProgress("ESearch "+(rowOut));
try {
exec.checkCanceled();
} catch (CanceledExecutionException e) {
throw new SAXException(e);
}
}
builder=null;
}
示例15: getMutation
import org.knime.core.data.DataRow; //导入依赖的package包/类
public Mutation getMutation(DataRow row)
{
String ref="A";
String alt="A";
if(useRefAlt)
{
ref= StringCell.class.cast(row.getCell(this.refColumn)).getStringValue();
alt= StringCell.class.cast(row.getCell(this.altColumn)).getStringValue();
}
return new Mutation(
new Position(
StringCell.class.cast(row.getCell(this.chromColumn)).getStringValue(),
IntCell.class.cast(row.getCell(this.positionColumn)).getIntValue()
),
ref, alt
);
}