use of org.knime.base.data.bitvector.MultiString2BitVectorCellFactory in project knime-core by knime.
the class CreateBitVectorNodeModel method createMultiColumnCellFactory.
private BitVectorCellFactory createMultiColumnCellFactory(final BufferedDataTable data, final ExecutionContext exec, final ColumnType columnType, final BitVectorType vectorType, final String[] multiCols) throws CanceledExecutionException, InvalidSettingsException {
final DataColumnSpec colSpec = createMultiColumnOutputSpec(data.getDataTableSpec(), multiCols, vectorType);
// get the indices for included columns
final int[] colIndices = new int[multiCols.length];
int idx = 0;
for (String colName : multiCols) {
int index = data.getDataTableSpec().findColumnIndex(colName);
if (index < 0) {
throw new IllegalArgumentException("Column " + colName + " is not available in input table. Please re-configure the node.");
}
colIndices[idx++] = index;
}
final BitVectorCellFactory factory;
if (ColumnType.MULTI_NUMERICAL.equals(columnType)) {
// calculate bits from numeric data
if (m_useMean.getBooleanValue()) {
// either from a percentage of the mean
final double meanFactor = m_meanPercentage.getIntValue() / 100.0;
final double[] meanValues = calculateMeanValues(exec.createSubProgress(0.5), data, colIndices);
factory = new Numeric2BitVectorMeanCellFactory(vectorType, colSpec, meanFactor, meanValues, colIndices);
} else {
// or dependent on fixed threshold
factory = new Numeric2BitVectorThresholdCellFactory(vectorType, colSpec, m_threshold.getDoubleValue(), colIndices);
}
} else if (ColumnType.MULTI_STRING.equals(columnType)) {
final boolean setMatching = SetMatching.MATCHING.equals(SetMatching.get(m_mscSetMatching.getStringValue()));
factory = new MultiString2BitVectorCellFactory(vectorType, colSpec, m_mscCaseSensitiv.getBooleanValue(), m_mscHasWildcards.getBooleanValue(), m_mscRegex.getBooleanValue(), setMatching, m_mscPattern.getStringValue(), colIndices);
} else {
throw new IllegalStateException("Not implemeted column type " + columnType.getText());
}
return factory;
}
Aggregations