当前位置: 首页>>代码示例>>Java>>正文


Java DataTableSpec.findColumnIndex方法代码示例

本文整理汇总了Java中org.knime.core.data.DataTableSpec.findColumnIndex方法的典型用法代码示例。如果您正苦于以下问题:Java DataTableSpec.findColumnIndex方法的具体用法?Java DataTableSpec.findColumnIndex怎么用?Java DataTableSpec.findColumnIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.knime.core.data.DataTableSpec的用法示例。


在下文中一共展示了DataTableSpec.findColumnIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: silentOptionalAutoColumnSelection

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * If setting holds a valid column name returns the column index. If not
 * search the first compatible column and return the index.
 *
 * @param inSpec
 * @param model
 * @param valueClass
 * @param except
 *            columns that should not be chosen e.g. because they are
 *            already in use
 * @return The column index, maybe -1, if not found
 */
public static final int silentOptionalAutoColumnSelection(
        final DataTableSpec inSpec, final SettingsModelString model,
        final Class<? extends DataValue> valueClass,
        final Integer... except) {

    int i = inSpec.findColumnIndex(model.getStringValue());
    if ((i > -1)
            && inSpec.getColumnSpec(i).getType().isCompatible(valueClass)) {
        return i;
    }
    i = autoOptionalColumnSelection(inSpec, model, valueClass, except);

    return i;

}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:28,代码来源:NodeUtils.java

示例2: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
protected DataTableSpec[] configure(DataTableSpec[] inSpecs)
		throws InvalidSettingsException {
	if(inSpecs==null || inSpecs.length!=1)
		{
		throw new InvalidSettingsException("Expected one table");
		}
	
	DataTableSpec in=inSpecs[0];
	int index;
	if((index=in.findColumnIndex("ID"))==-1)
		{
		throw new InvalidSettingsException("Node "+this.getNodeName()+" column \"ID\"");
		}
	if(!in.getColumnSpec(index).getType().equals(StringCell.TYPE))
		{
		throw new InvalidSettingsException("column \"ID\" is not a string");
		}
	
	return new DataTableSpec[]{in,in};
	}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:22,代码来源:HavingIdNodeModel.java

示例3: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
  protected DataTableSpec[] configure(DataTableSpec[] inSpecs)
  		throws InvalidSettingsException {
  	if(inSpecs==null || inSpecs.length!=1)
  		{
  		throw new InvalidSettingsException("Expected one table");
  		}
  	
  	DataTableSpec in=inSpecs[0];
  	int chromCol= in.findColumnIndex(m_chromCol.getColumnName());
if(chromCol==-1) throw new InvalidSettingsException("Cannot find column for chrom");
if(!(in.getColumnSpec(chromCol).getType().equals(IntCell.TYPE) ||
		in.getColumnSpec(chromCol).getType().equals(StringCell.TYPE)
   ))
	{
	throw new InvalidSettingsException("Bad type for chrom:"+in.getColumnSpec(chromCol).getType());
	}
DataTableSpec spec2= ReplacedColumnsTable.createTableSpec(in,
		new DataColumnSpecCreator(in.getColumnSpec(chromCol).getName(),StringCell.TYPE).createSpec(),
		chromCol);
  	
  	return new DataTableSpec[]{spec2};
  	}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:24,代码来源:NormalizeChromNodeModel.java

示例4: createOutSpec

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
private DataTableSpec[] createOutSpec(final DataTableSpec inSpec)
        throws InvalidSettingsException {

    // locate class column
    String classColumnName;
    if (m_appendClassCollumnModel.getBooleanValue()) {
        classColumnName = m_customClassCollumnNameModel.getStringValue();
    } else {
        classColumnName = m_classLabelColumnModel.getStringValue();
    }

    // Fall back
    if (!m_appendClassCollumnModel.getBooleanValue()
            && !inSpec.containsName(classColumnName)) {
        classColumnName =
                inSpec.getColumnNames()[NodeUtils.autoColumnSelection(
                        inSpec, m_classLabelColumnModel, StringValue.class,
                        ActiveLearnLoopStartNodeModel.class)];
    }

    // Create outspecs
    final DataTableSpec spec =
            createColumnRearranger(inSpec, classColumnName).createSpec();

    m_classColIdx = spec.findColumnIndex(classColumnName);

    final DataTableSpecCreator labeledRowsSpecCreator =
            new DataTableSpecCreator(spec);
    if (m_appendIterationModel.getBooleanValue()) {
        labeledRowsSpecCreator.addColumns(
                new DataColumnSpecCreator("Iteration", IntCell.TYPE)
                        .createSpec());
    }
    return new DataTableSpec[] { spec, labeledRowsSpecCreator.createSpec(),
            spec };
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:37,代码来源:ActiveLearnLoopStartNodeModel.java

示例5: createColumnRearranger

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * Creates the createColumnRearranger for the output tables.
 *
 * @param inSpec
 *            the tableSpec
 * @param columnName
 *            the name of the class column.
 * @return the createColumnRearranger with the appended
 */
private ColumnRearranger createColumnRearranger(final DataTableSpec inSpec,
        final String columnName) {
    final ColumnRearranger rearranger = new ColumnRearranger(inSpec);

    // append the
    if (m_appendClassCollumnModel.getBooleanValue()) {
        rearranger.append(createCellFactory(
                m_customClassCollumnNameModel.getStringValue()));
    } else {
        final int classLabelColIdx = inSpec.findColumnIndex(columnName);
        rearranger.replace(createCellFactory(columnName), classLabelColIdx);
    }
    return rearranger;
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:24,代码来源:ActiveLearnLoopStartNodeModel.java

示例6: createRearranger

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/** The rearranger is the working horse for creating the ouput table. */
private ColumnRearranger createRearranger(final DataTableSpec spec,
		final FlowVariableRepository flowVariableRepository,
		final int rowCount) throws InvalidSettingsException {
	int offset = spec.getNumColumns();
	CellFactory factory = new JavaSnippetCellFactory(this, spec,
			flowVariableRepository, rowCount);
	ColumnRearranger c = new ColumnRearranger(spec);
	// add factory to the column rearranger
	c.append(factory);

	// define which new columns do replace others
	OutColList outFields = m_fields.getOutColFields();
	for (int i = outFields.size() - 1; i >= 0; i--) {
		OutCol field = outFields.get(i);
		int index = spec.findColumnIndex(field.getKnimeName());
		if (index >= 0) {
			if (field.getReplaceExisting()) {
				c.remove(index);
				c.move(offset + i - 1, index);
			} else {
				throw new InvalidSettingsException("Field \""
						+ field.getJavaName() + "\" is configured to "
						+ "replace no existing columns.");
			}
		}
	}

	return c;
}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:31,代码来源:JavaSnippet.java

示例7: getQuery

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
protected String getQuery(DataRow row,DataTableSpec spec)
throws ExecuteException
{
String query=m_term.getStringValue();
int i=0;
while(i< query.length())
	{
	int j=query.indexOf("##",i);
	if(j==-1 || j+2==query.length())
		{
		break;
		}
	int k=query.indexOf("##",j+2);
	if(k==-1 || k==j+2)
		{
		break;
		}
	String colName=query.substring(j+2, k);
	int n=spec.findColumnIndex(colName);
	if(n==-1) throw new ExecuteException("Cannot find "+colName+" in columns");
	DataCell cell=row.getCell(n);
	if(cell.isMissing()) return null;
	String replace=String.valueOf(cell);
	
	query=query.substring(0,j)+replace+query.substring(k+2);
	i=j+2+replace.length();
	}
return query;
}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:30,代码来源:AbstractNcbiEUtilsNodeModel.java

示例8: getPositionColumns

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
private void getPositionColumns(PositionColumns g,final DataTableSpec dataTableSpec) throws IllegalArgumentException
{
g.chrom=dataTableSpec.findColumnIndex("CHROM");
if(g.chrom==-1) throw new IllegalArgumentException("Cannot find column \"CHROM\"");
g.position=dataTableSpec.findColumnIndex("POS");
if(g.position==-1) throw new IllegalArgumentException("Cannot find column \"POS\"");
}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:8,代码来源:AbstractVCFNodeModel.java

示例9: getMutationColumns

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
private void getMutationColumns(MutationColumns g,final DataTableSpec dataTableSpec) throws IllegalArgumentException
{
getPositionColumns(g,dataTableSpec);
g.ref=dataTableSpec.findColumnIndex("REF");
if(g.ref==-1) throw new IllegalArgumentException("Cannot find column \"REF\"");
g.alt=dataTableSpec.findColumnIndex("ALT");
if(g.alt==-1) throw new IllegalArgumentException("Cannot find column \"ALT\"");
}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:9,代码来源:AbstractVCFNodeModel.java

示例10: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
protected DataTableSpec[] configure(DataTableSpec[] inSpecs)
		throws InvalidSettingsException
	{    	
	if(inSpecs==null || inSpecs.length!=2)
		{
		throw new InvalidSettingsException("expected two tables");
		}
	DataTableSpec spec1=inSpecs[0];
	DataTableSpec spec2=inSpecs[1];
	if(spec1.getNumColumns()!=spec2.getNumColumns())
		{
		throw new InvalidSettingsException("not the same number of columns:"+
				"top:"+spec1.getNumColumns()+" bottom:"+spec2.getNumColumns()
				);
		}
	for(int i=0;i< spec1.getNumColumns();++i)
		{
		DataColumnSpec col1=spec1.getColumnSpec(i);
		int j=spec2.findColumnIndex(col1.getName());
		if(j==-1) throw new InvalidSettingsException("Cannot find column "+col1.getName()+" in 2nd table");
		DataColumnSpec col2=spec2.getColumnSpec(j);
		if(!col1.getType().equals(col2.getType()))
			{
			throw new InvalidSettingsException("not the same type for columns "+col2.getName());
			}	
		}
	return new DataTableSpec[]{inSpecs[0]};
	}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:30,代码来源:CatNodeModel.java

示例11: findColumnIndex

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/** throws an InvalidSettingsException if column was not found */
  public int findColumnIndex(DataTableSpec dataTableSpec,String name)
throws InvalidSettingsException
{
int index;
if((index=dataTableSpec.findColumnIndex(name))==-1)
	{
	throw new InvalidSettingsException("Node "+this.getNodeName()+": cannot find column title= \""+name+"\"");
	}
return index;
}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:12,代码来源:AbstractNodeModel.java

示例12: autoColumnSelection

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * If setting holds a valid column name returns the column index. If not
 * search the first compatible column and return the index. A logger warning
 * is given to indicate the automatic selection in contrast to
 * {@link NodeUtils#silentOptionalAutoColumnSelection}.
 *
 * @param inSpec
 *            the spec
 * @param model
 *            the model
 * @param valueClass
 *            the value class that is chosen
 * @param nodeModelClass
 *            node model class to be able to set right logger message
 * @param except
 *            columns that should not be chosen e.g. because they are
 *            already in use
 * @return the column index, never -1, a {@link InvalidSettingsException} is
 *         thrown instead
 * @throws InvalidSettingsException
 *             the invalid settings exception
 */
public static final int autoColumnSelection(final DataTableSpec inSpec,
        final SettingsModelString model,
        final Class<? extends DataValue> valueClass,
        final Class<? extends NodeModel> nodeModelClass,
        final Integer... except) throws InvalidSettingsException {

    int i = inSpec.findColumnIndex(model.getStringValue());
    if ((i > -1)
            && inSpec.getColumnSpec(i).getType().isCompatible(valueClass)) {
        return i;
    } else {
        i = autoOptionalColumnSelection(inSpec, model, valueClass, except);
        if (i > -1) {
            NodeLogger.getLogger(nodeModelClass)
                    .warn("No column specified as "
                            + valueClass.getSimpleName()
                            + ": auto detection suggested column "
                            + inSpec.getColumnSpec(i).getName());
        } else {
            String errorMessage = "";
            final StringBuilder sb = new StringBuilder();
            if (except.length > 0) {
                if (except.length > 1) {
                    sb.append(" (columns: ");
                    for (int j = 0; j < except.length; j++) {
                        sb.append(except[j]);
                        sb.append(", ");
                    }
                    errorMessage =
                            sb.toString().substring(0, sb.length() - 2);
                    errorMessage +=
                            " have already been chosen or have been excluded "
                                    + "from automatic selection for some other reason)";
                } else {
                    errorMessage += " (column: " + except[0]
                            + " has already been chosen or has been "
                            + "excluded from automatic selection for some other reason)";
                }
            }

            throw new InvalidSettingsException(model.getKey()
                    + ": No column of type " + valueClass.getSimpleName()
                    + " available!" + errorMessage);
        }

        return i;
    }

}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:72,代码来源:NodeUtils.java

示例13: execute

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @throws IndexOutOfBoundsException
 *             If number of selected columns is zero
 * @throws InvalidSettingsException
 *             If no column with given name in table
 */
@SuppressWarnings("rawtypes")
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
		final ExecutionContext exec) throws Exception {

	// read input table
	BufferedDataTable data = inData[0];
	DataTableSpec dataSpec = data.getDataTableSpec();

	// apply column filter
	FilterResult filterResult = m_columns.applyTo(dataSpec);
	List<String> includes = Arrays.asList(filterResult.getIncludes());
	int numColumns = includes.size();
	String[] names = includes.toArray(new String[numColumns]);

	if (numColumns == 0) {
		throw new IndexOutOfBoundsException("Number of columns is 0");
	}
	if (numColumns > 2) {
		setWarningMessage("Only two first columns will be used as key-value pair");
	}

	final int[] colIndices = new int[names.length];
	for (int i = 0; i < names.length; i++) {
		int index = dataSpec.findColumnIndex(names[i]);
		if (index < 0) {
			throw new InvalidSettingsException("No column \"" + names[i]
					+ "\" in input table");
		}
		colIndices[i] = index;
	}

	// create RDD
	JavaRDDLike rdd;
	BufferedDataTable[] out;
	if (numColumns == 1) {
		rdd = createRDD(data, colIndices);
		out = new BufferedDataTable[] { TableCellUtils.setRDD(exec, rdd,
				false) };
	} else {
		rdd = createPairRDD(data, colIndices);
		out = new BufferedDataTable[] { TableCellUtils.setRDD(exec, rdd,
				true) };
	}

	// update viewer
	rddViewer = new RddViewer(out[0], exec);

	return out;

}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:60,代码来源:TableToRDDNodeModel.java

示例14: execute

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
       
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		int qualColumn= inDataTableSpec.findColumnIndex("QUAL");
		if(qualColumn==-1) throw new IllegalArgumentException("Cannot find column \"QUAL\"");
		if(inDataTableSpec.getColumnSpec(qualColumn).getType()!=DoubleCell.TYPE)
    		{
    		throw new IllegalArgumentException("column \"QUAL\" is not a double");
    		}
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		double qual=DoubleCell.class.cast(row.getCell(qualColumn)).getDoubleValue();

        		if(	qual>= m_minQual.getDoubleValue()
        			)
					{
					container1.addRowToTable(row);
					}
				else
					{
					container2.addRowToTable(row);
					}
        		exec.checkCanceled();
            	exec.setProgress(nRow/total,"Filtering....");
        		}
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:81,代码来源:QualNodeModel.java

示例15: execute

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
       
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		int idColumn= inDataTableSpec.findColumnIndex("ID");
		if(idColumn==-1) throw new IllegalArgumentException("Cannot find column \"ID\"");
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		String ID=StringCell.class.cast(row.getCell(idColumn)).getStringValue();
				
				
        		if(!(ID.isEmpty() || ID.equals(".")))
					{
					container1.addRowToTable(row);
					}
				else
					{
					container2.addRowToTable(row);
					}
        		}
        	exec.checkCanceled();
           	exec.setProgress(nRow/total,"Filtering....");
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:77,代码来源:HavingIdNodeModel.java


注:本文中的org.knime.core.data.DataTableSpec.findColumnIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。