Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.Tuple


            Map<Integer, List<Object>> nominalValues)
        throws ActivityUserException,
               ActivityProcessingException,
               ActivityTerminatedException
    {
        Tuple tuple;
        // create instances metadata
        TupleMetadata metadata =
            (TupleMetadata)tuples.getMetadataWrapper().getMetadata();
        ArrayList<Attribute> attributes = getAttributes(metadata, nominalValues);
        // initial capacity of 100
View Full Code Here


     * @throws ActivityUserException
     * @throws ActivityProcessingException
     * @throws ActivityTerminatedException
     */
    private TupleMetadata prepareMetadata(FullListTupleListIterator itemsIterator) throws ActivityUserException, ActivityProcessingException, ActivityTerminatedException {
      Tuple item;
      List<ColumnMetadata> columns = new ArrayList<ColumnMetadata>();
      while((item = (Tuple)itemsIterator.nextValue()) != null) {
        columns.add(new SimpleColumnMetadata(item.getString(1), TupleTypes._STRING,
                    0,
                    ColumnMetadata.COLUMN_NO_NULLS,
                    0));       
      }
      TupleMetadata metadata = new SimpleTupleMetadata(columns);
View Full Code Here

     * @throws ActivityProcessingException
     * @throws ActivityTerminatedException
     */
    private Set<Entry<Integer, String[]>> prepareList(TupleListIterator customers, TupleMetadata listMetadata, Integer keyIndex, Integer productIndex) throws ActivityUserException, ActivityProcessingException, ActivityTerminatedException {
      Map<Integer, String[]> customersMap = new HashMap<Integer, String[]>();
      Tuple tuple;
      String[] tmpList;
   
      while((tuple = (Tuple)customers.nextValue())!= null)
      {
        if(customersMap.containsKey((Integer)tuple.getInt(keyIndex)))
          tmpList = customersMap.get((Integer)tuple.getInt(keyIndex));
         
       
       
        else {
          tmpList = new String[listMetadata.getColumnCount()];
          Collections.fill(Arrays.asList(tmpList), "FALSE");
          customersMap.put((Integer)tuple.getInt(keyIndex), tmpList);
        }
      int index = listMetadata.getColumnMetadataPosition(tuple.getString(productIndex));
      if(index != -1)
        tmpList[index] = "TRUE";
     
      }
     
View Full Code Here

        TupleListIterator expectedInput = (TupleListIterator)iterationData[0];
        TupleListIterator actualInput = (TupleListIterator)iterationData[1];
        Map<Object, Map<Object, Long>> confusionMatrix =
            new HashMap<Object, Map<Object,Long>>();
        SortedSet<Object> actualValues = new TreeSet<Object>();
        Tuple expected;
        while ((expected = (Tuple)expectedInput.nextValue()) != null)
        {
            Tuple actual = (Tuple)actualInput.nextValue();
            if (actual == null)
            {
                throw new UnmatchedActivityInputsException(
                        new String[] {INPUT_EXPECTED, INPUT_PREDICTED},
                        new Object[] {expected, ControlBlock.NO_MORE_DATA});
            }
            // we're assuming there are no more than Integer.MAX_VALUE classes
            Object predicted = actual.getObject(0);
            Object exp = expected.getObject(0);
            Map<Object, Long> map = confusionMatrix.get(exp);
            actualValues.add(predicted);
            if (map == null)
            {
                Map<Object, Long> counts = new HashMap<Object, Long>();
                confusionMatrix.put(exp, counts);
                counts.put(predicted, 1L);
            }
            else
            {
                Long count = map.get(predicted);
                if (count == null)
                {
                    map.put(predicted, 1L);
                }
                else
                {
                    map.put(predicted, count+1);
                }
            }
        }
        Object obj = actualInput.nextValue();
        if (obj != null)
        {
            throw new UnmatchedActivityInputsException(
                    new String[] {INPUT_EXPECTED, INPUT_PREDICTED},
                    new Object[] {ControlBlock.NO_MORE_DATA, obj});
        }
       
        List<ColumnMetadata> columns = new ArrayList<ColumnMetadata>();
        columns.add(
                new SimpleColumnMetadata(
                        "class",
                        TupleTypes._STRING,
                        0,
                        ColumnMetadata.COLUMN_NO_NULLS,
                        0));
        for (Object object : actualValues)
        {
            columns.add(
                    new SimpleColumnMetadata(
                            object.toString(),
                            TupleTypes._LONG,
                            0,
                            ColumnMetadata.COLUMN_NO_NULLS,
                            0));
        }
        TupleMetadata metadata = new SimpleTupleMetadata(columns);
        try
        {
            mOutput.write(ControlBlock.LIST_BEGIN);
            mOutput.write(new MetadataWrapper(metadata));
            for (Object key : confusionMatrix.keySet())
            {
                List<Object> elements = new ArrayList<Object>();
                elements.add(key.toString());
                Map<Object, Long> counts = confusionMatrix.get(key);
                for (Object value : actualValues)
                {
                    Long count = counts.get(value);
                    if (count == null)
                    {
                        elements.add(0L);
                    }
                    else
                    {
                        elements.add(count);
                    }
                }
                Tuple tuple = new SimpleTuple(elements);
                mOutput.write(tuple);
            }
            mOutput.write(ControlBlock.LIST_END);
       
        }
View Full Code Here

           
           
           
            mResultOutput.write(new MetadataWrapper(outMetadata));
            for(List<Object> v:values) {
              Tuple t = new SimpleTuple(v);
              mResultOutput.write(t);
            }
            mResultOutput.write(ControlBlock.LIST_END);
            iterativeStageComplete();
    }
View Full Code Here

        {
            throw new ActivityUserException(e);
        }
        try
        {
          Tuple tuple;
       
          tree.getOptions().setViaCLIString(options);
          tree.prepareForUse();
          Calendar cal = Calendar.getInstance();
          this.startTime = cal.getTimeInMillis();
View Full Code Here

          output.write(new MetadataWrapper(new SimpleTupleMetadata(listColumnMetadata)));

          for(int i=0;i<numberTuples;i++){
                    // Create the tuple tuple consisting of the above data
                    // and the metadata.
                    Tuple tuple = new SimpleTuple(data);
                    output.write(tuple);
          }
          output.write(ControlBlock.LIST_END);
         
        } catch (PipeClosedException e) {
View Full Code Here

        while(i<listColumnMetadata.size() && it.hasNext()){
          QueryResults rst = (QueryResults) it.next();
          lst.add(rst.getValue());
          i++;
        }
        Tuple tuple = new SimpleTuple(lst);
                output.write(tuple);
      }
     
            if (includeListMarkers)
            {
View Full Code Here

                    else
                    {
                        lst.add(node.toString());
                    }
                }
                Tuple tuple = new SimpleTuple(lst);
                System.out.println(tuple);
            }

            if (includeListMarkers)
            {
View Full Code Here

        TupleMetadata meta = (TupleMetadata) ((MetadataWrapper) blocks.get(1)).getMetadata();
       
        assertEquals("column name is different", name, meta.getColumnMetadata(0).getName());
        assertEquals("column type is different", type, meta.getColumnMetadata(0).getType());
       
       Tuple tuple = (Tuple) blocks.get(3);
       assertEquals("data1 is different", data1, tuple.getString(0));
          
       tuple = (Tuple) blocks.get(4);
       assertEquals("data2 is different", data2, tuple.getString(0));
    }
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.