Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.Tuple


        {
            TupleInputStream tuples = new TupleInputStream(input);
            writer.write(new MetadataWrapper(tuples.readTupleMetadata()));
            while (true)
            {
                Tuple tuple = tuples.readTuple();
                writer.write(tuple);
            }
        }
        catch (EOFException e)
        {
View Full Code Here


        assertEquals(ControlBlock.LIST_BEGIN, blocks.next());
        assertTrue(blocks.hasNext());
        Object block = blocks.next();
        assertTrue(block instanceof MetadataWrapper);
        assertTrue(blocks.hasNext());
        Tuple tuple = (Tuple)blocks.next();
        assertEquals(0, tuple.getInt(0));
        assertEquals("A", tuple.getString(1));
        assertTrue(blocks.hasNext());
        tuple = (Tuple)blocks.next();
        assertEquals(0, tuple.getInt(0));
        assertEquals("B", tuple.getString(1));
        assertTrue(blocks.hasNext());
        tuple = (Tuple)blocks.next();
        assertEquals(0, tuple.getInt(0));
        assertEquals("C", tuple.getString(1));
        assertTrue(blocks.hasNext());
        assertEquals(ControlBlock.LIST_END, blocks.next());
        assertTrue(!blocks.hasNext());
    }
View Full Code Here

        assertEquals(ControlBlock.LIST_BEGIN, blocks.next());
        assertTrue(blocks.hasNext());
        Object block = blocks.next();
        assertTrue(block instanceof MetadataWrapper);
        assertTrue(blocks.hasNext());
        Tuple tuple = (Tuple)blocks.next();
        assertEquals(1, tuple.getInt(0));
        assertTrue(blocks.hasNext());
        tuple = (Tuple)blocks.next();
        assertEquals(2, tuple.getInt(0));
        assertTrue(blocks.hasNext());
        tuple = (Tuple)blocks.next();
        assertEquals(3, tuple.getInt(0));
        assertTrue(blocks.hasNext());
        assertEquals(ControlBlock.LIST_END, blocks.next());
        assertTrue(!blocks.hasNext());
    }
View Full Code Here

                    20);
        columns.add(col);
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
        List<Object> elements = new ArrayList<Object>();
        elements.add(new Float(10));
        Tuple tuple1 = new SimpleTuple(elements);
        elements = new ArrayList<Object>();
        elements.add(new Float(20));
        Tuple tuple2 = new SimpleTuple(elements);
        elements = new ArrayList<Object>();
        elements.add(new Float(30));
        Tuple tuple3 = new SimpleTuple(elements);
        MockInputPipe input = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        new MetadataWrapper(metadata),
                        tuple1, tuple2, tuple3,
View Full Code Here

                    20);
        columns.add(col);
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
        List elements = new ArrayList();
        elements.add(new Float(10));
        Tuple tuple1 = new SimpleTuple(elements);
        elements = new ArrayList();
        elements.add(new Float(20));
        Tuple tuple2 = new SimpleTuple(elements);
        elements = new ArrayList();
        elements.add(new Float(30));
        Tuple tuple3 = new SimpleTuple(elements);
        MockInputPipe input = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        new MetadataWrapper(metadata),
                        tuple1, tuple2, tuple3,
View Full Code Here

           ActivityProcessingException,
           ActivityTerminatedException
    {                       
        // count totalFreq, minimum, maximum, mean
        // with testing missing value
        Tuple tuple;
        while((tuple = (Tuple)mTupleList.nextValue()) != null)
        {
            for(int i=0; i<columnCount; i++)
            {
                totalFreq[i]++;               
               
                String type = colInfo[i].getDataType();
                if (type.equalsIgnoreCase("integer") ||
                        type.equalsIgnoreCase("float") ||
                        type.equalsIgnoreCase("double"))
                {
                    double value = tuple.getDouble(i);
                    if (tuple.wasNull())
                    {
                        missingData[i]++;
                    }                                       
                    else
                    {
                        recount(value, i);                                               
                    }                    
                }
                else if (type.equalsIgnoreCase("string")){                   
                    String s = tuple.getString(i);
                    if (tuple.wasNull())
                    {
                        missingData[i]++;
                    }                   
                    else {
                        // string type
                        if(hashSet[i].size() < MAX_HASH_SIZE){
                            hashSet[i].add(s);
                        }
                    }
                }
                else if (type.equalsIgnoreCase("boolean")){                   
                    boolean b = tuple.getBoolean(i);
                    if (tuple.wasNull())
                    {
                        missingData[i]++;
                    }                   
                    else {
                        //boolean type
                        if(hashSet[i].size() < MAX_HASH_SIZE){
                            hashSet[i].add(new Boolean(b));
                        }
                    }
                }
                else {                  
                    Object o = tuple.getObject(i);
                    if (tuple.wasNull())
                    {
                        missingData[i]++;                       
                    }                   
                    else{
                        if(hashSet[i].size() < MAX_HASH_SIZE){
View Full Code Here

               ActivityTerminatedException,
               ColumnNotFoundException
    {
        // recount mean with testing missing value
        // histograms and interval description
        Tuple tuple;
        while((tuple = (Tuple)mTuples.nextValue()) != null)
        {
            for(int i=0; i<columnCount; i++)
            {                             
                OPTYPE.Enum optype = mPMML.getDataDictionary().getDataFieldArray(i).getOptype();
                // categorical fields
                if (optype == OPTYPE.CATEGORICAL)
                {
                    Object o = tuple.getObject(i);
                    int index = histogram_values[i].indexOf(o);
                    if (index==-1){
                        //new object add                       
                        histogram_values[i].add(o);
                        index = histogram_values[i].size()-1;
                        histogram_frequency[i][index] = 1;                                               
                    }
                    else
                    { //object is in ArrayList, change frequency and max frequency index
                        histogram_frequency[i][index]++;
                    }
                    if (histogram_frequency[i][histogram_maxfrequency[i]]<histogram_frequency[i][index]){                   
                        histogram_maxfrequency[i] = index;
                    }                                                                                   
                }
                // continuous or ordinal fields
                else{               
                    if (interval[i]!=null){                                   
                        boolean wasNull = true;
                        double value = Double.NaN;
                        String type = colInfo[i].getDataType();
                        // Integer type
                        if (type.equalsIgnoreCase("integer")) {
                            value = tuple.getInt(i);
                            wasNull = tuple.wasNull();
                        }                       
                        // Float type
                        else if (type.equalsIgnoreCase("float")) {
                            value = tuple.getFloat(i);
                            wasNull = tuple.wasNull();
                        }                   
                        // Double type
                        else if (type.equalsIgnoreCase("double")){
                            value = tuple.getDouble(i);
                            wasNull = tuple.wasNull();
                        }
                        // if exist some value
                        if (!wasNull){
                            int j = getValidIndex(value, i);
                            if (j != -1)
View Full Code Here

        TupleListIterator values = (TupleListIterator)iterationData[0];

        Set<Integer> columns = getColumns((ListIterator)iterationData[1]);
        TupleMetadata valuesMetadata = (TupleMetadata)values.getMetadataWrapper().getMetadata();
        TupleMetadata tuplesMetadata = (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        Tuple value = getValues(values);
       
        Replace replace = new Replace(value, columns, valuesMetadata, tuplesMetadata);
       
        writeBlock(ControlBlock.LIST_BEGIN);
        writeBlock(replace.getMetadata());

        Tuple tuple;
        while ((tuple = (Tuple)tuples.nextValue()) != null)
        {
            Tuple out = replace.modify(tuple);
            writeBlock(out);
        }
       
        writeBlock(ControlBlock.LIST_END);
    }
View Full Code Here

    private Tuple getValues(TupleListIterator valuesIter)
        throws ActivityUserException,
               ActivityProcessingException,
               ActivityTerminatedException
    {
        Tuple values = (Tuple)valuesIter.nextValue();
        if (values == null)
        {
            throw new ActivityUserException(new NoValuesException());
        }
        if (valuesIter.nextValue() != null)
View Full Code Here

  public List<Double> getAggregates(TupleListIterator tuples)
  throws ColumnNotFoundException, ActivityUserException, ActivityProcessingException, ActivityTerminatedException
  {
    List<Double> aggregates = new ArrayList<Double>();
      try {
        Tuple tuple = (Tuple)tuples.nextValue();
          aggregates.add(tuple.getDouble(0));
          aggregates.add(tuple.getDouble(1));
      }
      catch(NumberFormatException exc)
      {
        throw new InvalidInputValueException(INPUT_AGGREGATES, Double.class, exc);
      }
View Full Code Here

TOP

Related Classes of uk.org.ogsadai.tuple.Tuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.