Search in sources :

Example 76 with RowIterator

use of org.knime.core.data.RowIterator in project knime-core by knime.

the class SubgroupMinerModel method getKeys.

/**
 * {@inheritDoc}
 */
public Set<RowKey> getKeys(final RowKey key) {
    LOGGER.debug("getKeys for: " + key);
    Set<RowKey> cells = new HashSet<RowKey>();
    for (RowIterator itr = m_itemSetTable.iterator(); itr.hasNext(); ) {
        DataRow currRow = itr.next();
        if (currRow.getKey().equals(key)) {
            LOGGER.debug("found key ");
            for (int i = 1; i < currRow.getNumCells(); i++) {
                cells.add(new RowKey(currRow.getCell(i).toString()));
            }
        }
    }
    LOGGER.debug("mapping: " + cells);
    return cells;
}
Also used : RowKey(org.knime.core.data.RowKey) RowIterator(org.knime.core.data.RowIterator) DataRow(org.knime.core.data.DataRow) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 77 with RowIterator

use of org.knime.core.data.RowIterator in project knime-core by knime.

the class ParallelCoordinatesViewContent method computeDoubleValues.

private void computeDoubleValues(final DataTable data, final Vector<Map<String, Integer>> stringieMap, final ExecutionMonitor exec, final int nrRows) throws CanceledExecutionException {
    // iterate over the rows that are drawable
    int i = 0;
    // iterate over the rows
    int j = 0;
    for (RowIterator it = data.iterator(); (i < nrRows) && it.hasNext(); j++) {
        if (exec != null) {
            exec.checkCanceled();
            // we are doing only half of the job here (but the second half)
            exec.setProgress((j / nrRows / 2.0) + 1.0 / 2.0);
        }
        DataRow row = it.next();
        if (m_rowIsDrawable[j]) {
            m_doubleArray[i] = new TwoDim[m_nrVisibleColumns];
            m_keyVector[i] = row.getKey();
            m_colorVector[i] = m_inputSpec.getRowColor(row);
            m_sizes[i] = data.getDataTableSpec().getRowSize(row);
            for (int col = 0, realCol = 0; col < m_columnCount; col++) {
                if (!m_hideColumn[col]) {
                    m_doubleArray[i][realCol] = new TwoDim();
                    DataCell cell = row.getCell(col);
                    if (cell.getType().isCompatible(DoubleValue.class)) {
                        DoubleValue dcell = (DoubleValue) cell;
                        double dValue = normalize(dcell.getDoubleValue(), m_minVector[realCol], m_maxVector[realCol]);
                        m_doubleArray[i][realCol].setMin(dValue);
                        m_doubleArray[i][realCol].setMax(dValue);
                    } else if (cell.getType().isCompatible(FuzzyIntervalValue.class)) {
                        if (cell.isMissing()) {
                            m_doubleArray[i][realCol].setMin(0);
                            m_doubleArray[i][realCol].setMax(1);
                        } else {
                            FuzzyIntervalValue fcell = (FuzzyIntervalValue) cell;
                            double mincore = fcell.getMinCore();
                            double maxcore = fcell.getMaxCore();
                            m_doubleArray[i][realCol].setMin(normalize(mincore, m_minVector[realCol], m_maxVector[realCol]));
                            m_doubleArray[i][realCol].setMax(normalize(maxcore, m_minVector[realCol], m_maxVector[realCol]));
                        }
                    } else {
                        // if the column is a string one
                        // no. corresponding to the string value
                        int intValue = 0;
                        double dValue = 0;
                        intValue = ((stringieMap.get(realCol).get(cell.toString().trim()))).intValue();
                        dValue = (double) intValue / (stringieMap.get(realCol).size() - 1);
                        m_doubleArray[i][realCol].setMin(dValue);
                        m_doubleArray[i][realCol].setMax(dValue);
                        m_doubleArray[i][realCol].setStringReference(intValue);
                    }
                    realCol++;
                } else {
                // column is hidden
                // do nothing
                }
            }
            i++;
        }
    }
}
Also used : FuzzyIntervalValue(org.knime.core.data.FuzzyIntervalValue) DoubleValue(org.knime.core.data.DoubleValue) RowIterator(org.knime.core.data.RowIterator) DataCell(org.knime.core.data.DataCell) DataRow(org.knime.core.data.DataRow)

Aggregations

RowIterator (org.knime.core.data.RowIterator)77 DataRow (org.knime.core.data.DataRow)62 DataCell (org.knime.core.data.DataCell)28 DataTableSpec (org.knime.core.data.DataTableSpec)20 RowKey (org.knime.core.data.RowKey)16 DoubleValue (org.knime.core.data.DoubleValue)14 BufferedDataTable (org.knime.core.node.BufferedDataTable)13 DataColumnSpec (org.knime.core.data.DataColumnSpec)11 ArrayList (java.util.ArrayList)9 DefaultRow (org.knime.core.data.def.DefaultRow)8 PreparedStatement (java.sql.PreparedStatement)7 DataType (org.knime.core.data.DataType)6 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)6 HashSet (java.util.HashSet)5 Random (java.util.Random)5 TimeZone (java.util.TimeZone)5 DataTable (org.knime.core.data.DataTable)5 DoubleCell (org.knime.core.data.def.DoubleCell)5 StringCell (org.knime.core.data.def.StringCell)5 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)5