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


Java DataTableSpec.getNumColumns方法代码示例

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


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

示例1: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs)
        throws InvalidSettingsException {
	
    if(inSpecs==null || inSpecs.length!=1)
    	{
    	throw new InvalidSettingsException("Expect one input.");
    	}
	DataTableSpec tableSpec=inSpecs[0];
	//check two columns (URI & samples)
	if(tableSpec.getNumColumns()<2)
		{
		throw new InvalidSettingsException("Expect two columns from "+ tableSpec.getName()+" but got "+tableSpec.getNumColumns());
		}

	return new DataTableSpec[]{new DataTableSpec(createVcfDataColumnSpec())};
	}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:21,代码来源:VCFLoaderNodeModel.java

示例2: setSpec

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * Set the input spec.
 * @param spec the data table spec of the input
 */
public void setSpec(final DataTableSpec spec) {
    DefaultListModel listModel = (DefaultListModel)getModel();
    listModel.removeAllElements();
    listModel.addElement(JavaSnippet.ROWID);
    listModel.addElement(JavaSnippet.ROWINDEX);
    listModel.addElement(JavaSnippet.ROWCOUNT);

    for (int i = 0; i < spec.getNumColumns(); i++) {
        DataColumnSpec colSpec = spec.getColumnSpec(i);
        listModel.addElement(colSpec);
    }
}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:17,代码来源:ColumnList.java

示例3: 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

示例4: 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

示例5: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs)
        throws InvalidSettingsException {

    final DataTableSpec trainingTableSpec = inSpecs[0];
    final DataTableSpec testTableSpec = inSpecs[1];

    // Check for class column
    final DataColumnSpec classColSpec =
            trainingTableSpec.getColumnSpec(m_classColumn.getStringValue());
    if (classColSpec == null
            || !classColSpec.getType().isCompatible(NominalValue.class)) {
        for (int i = trainingTableSpec.getNumColumns() - 1; i >= 0; i--) {
            if (trainingTableSpec.getColumnSpec(i).getType()
                    .isCompatible(NominalValue.class)) {
                m_classColumn.setStringValue(
                        trainingTableSpec.getColumnSpec(i).getName());
                break;
            } else if (i == 0) {
                throw new InvalidSettingsException(
                        "Table contains no nominal attribute for classification.");
            }
        }
    }

    // Check if selected columns from the training table are also in the
    // test table
    // Also check compatibility of selected columns

    final List<String> includedCols = m_columnSelection.getIncludeList();
    for (final String col : includedCols) {
        if (!trainingTableSpec.getColumnSpec(col).getType()
                .isCompatible(DoubleValue.class)) {
            throw new InvalidSettingsException(
                    "Selected columns must be compatible with DoubleValue!");
        }
        if (!testTableSpec.containsName(col)) {
            throw new InvalidSettingsException(
                    "Selected columns need also be contained in the Test Table");
        }
    }

    return createOutSpec(testTableSpec);
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:48,代码来源:LocalNoveltyScorerNodeModel.java

示例6: configure

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs)
        throws InvalidSettingsException {

    final DataTableSpec dataSpec = (DataTableSpec) inSpecs[DATA_INPORT];

    // Check class
    final DataColumnSpec colSpec =
            dataSpec.getColumnSpec(m_classColumn.getStringValue());
    if (colSpec == null
            || !colSpec.getType().isCompatible(NominalValue.class)) {
        for (int i = dataSpec.getNumColumns() - 1; i >= 0; i--) {
            if (dataSpec.getColumnSpec(i).getType()
                    .isCompatible(NominalValue.class)) {
                m_classColumn.setStringValue(
                        dataSpec.getColumnSpec(i).getName());
                break;
            } else if (i == 0) {
                throw new InvalidSettingsException(
                        "Table contains no nominal"
                                + " attribute for classification.");
            }
        }
    }

    /*
     * // Check input columns later used for training for (int i = 0; i <
     * dataSpec.getNumColumns(); i++) { if
     * (!(dataSpec.getColumnSpec(i).getType().isCompatible(DoubleValue.
     * class) ||
     * dataSpec.getColumnSpec(i).getType().isCompatible(IntValue.class) ||
     * dataSpec.getColumnSpec(i).getType() .isCompatible(LongValue.class)))
     * { throw new InvalidSettingsException(
     * "The features used for training need to be numeric"); } }
     */
    final List<String> featureNameList = m_columnSelection.getIncludeList();
    final List<String> compatibleFeatures = new LinkedList<String>();
    for (final String feature : featureNameList) {
        final DataColumnSpec featureSpec = dataSpec.getColumnSpec(feature);
        if (featureSpec.getType().isCompatible(DoubleValue.class)) {
            compatibleFeatures.add(feature);
        }
    }

    return new PortObjectSpec[] { null,
            new KNFSTPortObjectSpec(compatibleFeatures) };
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:51,代码来源:KNFSTLearnerNodeModel.java

示例7: execute

import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
protected BufferedDataTable[] execute(BufferedDataTable[] inData,
		ExecutionContext exec) throws Exception
	{
	BufferedDataContainer container1=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
		DataTableSpec spec1=inTable.getDataTableSpec();
		DataTableSpec spec2=createDataSpec();
		
        container1 = exec.createDataContainer(
        		new DataTableSpec(spec1,
        		spec2
        		));
        float total=inTable.getRowCount();
        
        
        int nRow=0;
        int outIndex=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		DataRow row=iter.next();
        		++nRow;
        		
            	
            	List<DataCell[]> cells=scan(row,spec1);
            	if(cells!=null && !cells.isEmpty())
            		{
            		for(DataCell[] r2:cells)
            			{
            			outIndex++;
            			container1.addRowToTable(new AppendedColumnRow(RowKey.createRowKey(outIndex),row,r2));
            			}
            		}
            	else
            		{
            		DataCell empty[]=new DataCell[spec2.getNumColumns()];
            		for(int i=0;i< empty.length;++i) empty[i]=DataType.getMissingCell();
            		outIndex++;
           			container1.addRowToTable(new AppendedColumnRow(RowKey.createRowKey(outIndex),row,empty));
            		}
            	exec.checkCanceled();
            	exec.setProgress(nRow/total,"NCBI....");
        		}
			} 
        catch (Exception e)
			{
        	e.printStackTrace();
			throw e;
			}
		finally
			{
			safeClose(iter);
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	}
  }
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:80,代码来源:AbstractNcbiEUtilsNodeModel.java


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