use of org.knime.core.data.def.LongCell in project knime-core by knime.
the class ColumnRowFilterPanel method getBoundCell.
/* method used from the above */
private DataCell getBoundCell(final JTextField editField, final String name) throws InvalidSettingsException {
if (editField.getText().length() <= 0) {
return null;
}
String colName = getSelectedColumnName();
if ((colName == null) || (colName.length() == 0)) {
throw new InvalidSettingsException("Invalid columns selection");
}
if (m_tSpec != null) {
final DataType origType = m_tSpec.getColumnSpec(colName).getType();
final DataType cType;
if (m_deepFiltering.isSelected() && origType.isCollectionType()) {
cType = origType.getCollectionElementType();
} else {
cType = origType;
}
if (cType.isCompatible(IntValue.class)) {
// first try making of an IntCell
try {
int lb = Integer.parseInt(editField.getText());
return new IntCell(lb);
} catch (NumberFormatException nfe) {
throw new InvalidSettingsException("Number format error in " + name + " bound number: Enter a valid integer.");
}
} else if (cType.isCompatible(LongValue.class)) {
try {
long lb = Long.parseLong(editField.getText());
return new LongCell(lb);
} catch (NumberFormatException nfe) {
throw new InvalidSettingsException("Number format error in " + name + " bound number: Enter a valid number.");
}
} else if (cType.isCompatible(DoubleValue.class)) {
try {
double lb = Double.parseDouble(editField.getText());
return new DoubleCell(lb);
} catch (NumberFormatException nfe) {
throw new InvalidSettingsException("Number format error in " + name + " bound number: enter a valid " + "float number");
}
} else {
return new StringCell(editField.getText());
}
} else {
// if we got no column type
return new StringCell(editField.getText());
}
}
use of org.knime.core.data.def.LongCell in project knime-core by knime.
the class OutputRow method createDataRow.
/**
* Create a {@link DataRow} that stores information of a right outer join.
*
* @param index The index of this row.
* @param leftIndex The index of the left row.
* @param rightIndex The index of the right row.
* @param settings The common settings object.
* @return New instance of {@link DataRow} populated with the given
* information.
*/
static DataRow createDataRow(final long index, final long leftIndex, final long rightIndex, final OutputRow.Settings settings) {
int[] survivors = settings.getSurvivors();
DataCell[] cells = new DataCell[survivors.length + 3];
int c = 0;
for (int i = 0; i < survivors.length; i++) {
cells[c] = DataType.getMissingCell();
c++;
}
cells[c] = DataType.getMissingCell();
c++;
cells[c] = new LongCell(leftIndex);
c++;
cells[c] = new LongCell(rightIndex);
RowKey rowID = new RowKey(Long.toString(index));
return new DefaultRow(rowID, cells);
}
use of org.knime.core.data.def.LongCell in project knime-core by knime.
the class LinearInterpolationStatisticTB method consumeRow.
/**
* {@inheritDoc}
*/
@Override
protected void consumeRow(final DataRow dataRow) {
DataCell cell = dataRow.getCell(getColumnIndex());
if (cell.isMissing()) {
incMissing();
} else {
for (int i = 0; i < getNumMissing(); i++) {
DataCell res;
if (getPrevious().isMissing()) {
res = cell;
} else {
if (m_isDateColumn) {
DateAndTimeValue val = (DateAndTimeValue) cell;
DateAndTimeValue prevVal = (DateAndTimeValue) getPrevious();
boolean hasDate = val.hasDate() | prevVal.hasDate();
boolean hasTime = val.hasTime() | prevVal.hasTime();
boolean hasMilis = val.hasMillis() | prevVal.hasMillis();
long prev = prevVal.getUTCTimeInMillis();
long next = val.getUTCTimeInMillis();
long lin = Math.round(prev + 1.0 * (i + 1) / (1.0 * (getNumMissing() + 1)) * (next - prev));
res = new DateAndTimeCell(lin, hasDate, hasTime, hasMilis);
} else {
DoubleValue val = (DoubleValue) cell;
double prev = ((DoubleValue) getPrevious()).getDoubleValue();
double next = val.getDoubleValue();
double lin = prev + 1.0 * (i + 1) / (1.0 * (getNumMissing() + 1)) * (next - prev);
if (getPrevious() instanceof IntValue) {
// get an int, create an int
res = new IntCell((int) Math.round(lin));
} else if (getPrevious() instanceof LongValue) {
// get an long, create an long
res = new LongCell(Math.round(lin));
} else {
res = new DoubleCell(lin);
}
}
}
addMapping(res);
}
resetMissing(cell);
}
}
use of org.knime.core.data.def.LongCell in project knime-core by knime.
the class AverageInterpolationStatisticTB method consumeRow.
/**
* {@inheritDoc}
*/
@Override
protected void consumeRow(final DataRow dataRow) {
DataCell cell = dataRow.getCell(getColumnIndex());
if (cell.isMissing()) {
incMissing();
} else {
for (int i = 0; i < getNumMissing(); i++) {
DataCell res;
if (getPrevious().isMissing()) {
res = cell;
} else {
if (m_isDateColumn) {
DateAndTimeValue val = (DateAndTimeValue) cell;
DateAndTimeValue prevVal = (DateAndTimeValue) getPrevious();
boolean hasDate = val.hasDate() | prevVal.hasDate();
boolean hasTime = val.hasTime() | prevVal.hasTime();
boolean hasMilis = val.hasMillis() | prevVal.hasMillis();
long prev = prevVal.getUTCTimeInMillis();
long next = val.getUTCTimeInMillis();
long lin = Math.round((prev + next) / 2);
res = new DateAndTimeCell(lin, hasDate, hasTime, hasMilis);
} else {
DoubleValue val = (DoubleValue) cell;
double prev = ((DoubleValue) getPrevious()).getDoubleValue();
double next = val.getDoubleValue();
double lin = (prev + next) / 2;
if (getPrevious() instanceof IntValue) {
// get an int, create an int
res = new IntCell((int) Math.round(lin));
} else if (getPrevious() instanceof LongValue) {
// get an long, create an long
res = new LongCell(Math.round(lin));
} else {
res = new DoubleCell(lin);
}
}
}
addMapping(res);
}
resetMissing(cell);
}
}
use of org.knime.core.data.def.LongCell in project knime-core by knime.
the class LinearInterpolationStatisticMB method consumeRow.
/**
* {@inheritDoc}
*/
@Override
protected void consumeRow(final DataRow dataRow) {
DataCell cell = dataRow.getCell(m_colIdx);
if (cell.isMissing()) {
m_numMissing++;
} else {
for (int i = 0; i < m_numMissing; i++) {
DataCell res;
if (m_previous.isMissing()) {
res = cell;
} else {
if (m_isDateColumn) {
DateAndTimeValue val = (DateAndTimeValue) cell;
DateAndTimeValue prevVal = (DateAndTimeValue) m_previous;
boolean hasDate = val.hasDate() | prevVal.hasDate();
boolean hasTime = val.hasTime() | prevVal.hasTime();
boolean hasMilis = val.hasMillis() | prevVal.hasMillis();
long prev = prevVal.getUTCTimeInMillis();
long next = val.getUTCTimeInMillis();
long lin = Math.round(prev + 1.0 * (i + 1) / (1.0 * (m_numMissing + 1)) * (next - prev));
res = new DateAndTimeCell(lin, hasDate, hasTime, hasMilis);
} else {
DoubleValue val = (DoubleValue) cell;
double prev = ((DoubleValue) m_previous).getDoubleValue();
double next = val.getDoubleValue();
double lin = prev + 1.0 * (i + 1) / (1.0 * (m_numMissing + 1)) * (next - prev);
if (m_previous instanceof IntValue) {
// get an int, create an int
res = new IntCell((int) Math.round(lin));
} else if (m_previous instanceof LongValue) {
// get an long, create an long
res = new LongCell(Math.round(lin));
} else {
res = new DoubleCell(lin);
}
}
}
m_values.add(res);
}
m_numMissing = 0;
m_previous = cell;
}
}
Aggregations