Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.Tuple


   
    public void testSimpleSplit() throws Exception
    {
        ConditionalSplitActivity activity = new ConditionalSplitActivity();
       
        Tuple tupleTrue1 = createTuple(new Object[] {1, 3});
        Tuple tupleTrue2 = createTuple(new Object[] {4, 5});
        Tuple tupleTrue3 = createTuple(new Object[] {10, 100});
       
        Tuple tupleFalse1 = createTuple(new Object[] {5, 1});
        Tuple tupleFalse2 = createTuple(new Object[] {6, -5});
        MockInputPipe dataInput = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        createTupleMetadata(),
                        tupleTrue1,
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 PipeIOException
     * @throws PipeClosedException
     */
    private Set<Entry<Integer, String[]>> prepareList(TupleListIterator customers, TupleMetadata listMetadata, Integer keyIndex, Integer productIndex) throws ActivityUserException, ActivityProcessingException, ActivityTerminatedException, PipeClosedException, PipeIOException, PipeTerminatedException {
      Map<Integer, String[]> customersMap = new HashMap<Integer, String[]>();
      Tuple tuple;
      String[] tmpList;
      int prevIndex = 0;
      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), "f");
          customersMap.put((Integer)tuple.getInt(keyIndex), tmpList);
        }
      int index = listMetadata.getColumnMetadataPosition(tuple.getString(productIndex));
     
      if(index != -1)
        tmpList[index] = "t";
      if(index!=prevIndex) {

View Full Code Here

            ActivityUserException
    {
        String data = (String) iterationData[0];
        List elements = new ArrayList();
        elements.add(data);
        Tuple tuple = new SimpleTuple(elements);
       
        try{
        mOutput.write(tuple);
        }
        catch (PipeClosedException e)
View Full Code Here

        activity.process();

        System.out.println(output.getActualBlocks());
        List actual = output.getActualBlocks();
        assertEquals(ControlBlock.LIST_BEGIN, actual.get(0));
        Tuple tuple = (Tuple)actual.get(2);
        assertEquals(1, tuple.getInt(0));
        List list = (List)tuple.getObject(1);
        assertEquals(2, list.size());
        assertEquals("30", list.get(0));
        assertEquals("90", list.get(1));
        tuple = (Tuple)actual.get(3);
        assertEquals(2, tuple.getInt(0));
        list = (List)tuple.getObject(1);
        assertEquals(1, list.size());
        assertEquals("10 20", list.get(0));
        assertEquals(ControlBlock.LIST_END, actual.get(4));
    }
View Full Code Here

            mBlockType = EXPECT_TUPLE;
            break;
           
        case EXPECT_TUPLE:
            Assert.assertTrue("Expected tuple", block instanceof Tuple);
            Tuple tuple = (Tuple) block;
            for (int i = 0; i < mColumns.length; i++)
            {
                ComparableTuple current = new ComparableTuple(tuple, mColumns);
                if (mPrevious != null)
                {
View Full Code Here

        }
        String base = command.toString();
        TupleListIterator tuples = (TupleListIterator)iterationData[iterationData.length-1];
        try
        {  
            Tuple tuple;
            boolean haveWrittenMetadata = false;
            mOutput.write(ControlBlock.LIST_BEGIN);
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
                command = new StringBuffer();
                command.append(base);
                for (int i=0; i<tuple.getColumnCount(); i++)
                {
                    command.append(" ");
                    command.append(tuple.getObject(i).toString());
                }
                LOG.debug("Executing command: " + command.toString());
                String output = executeScript(command.toString());
                Tuple outputTuple = getTuple(output);
                if (!haveWrittenMetadata)
                {
                    mOutput.write(getMetadata(outputTuple));
                    haveWrittenMetadata = true;
                }
View Full Code Here

       
        List actualBlocks = output.getActualBlocks();
        System.out.println(actualBlocks);
        assertEquals(ControlBlock.LIST_BEGIN, actualBlocks.get(0));
        assertEquals(ControlBlock.LIST_END, actualBlocks.get(actualBlocks.size()-1));
        Tuple tuple1 = (Tuple)actualBlocks.get(2);
        assertEquals("no", tuple1.getString(0));
        // no - maybe
        assertEquals(1, tuple1.getLong(1));
        // no - no
        assertEquals(2, tuple1.getLong(2));
        // no - yes
        assertEquals(1, tuple1.getLong(3));
        Tuple tuple2 = (Tuple)actualBlocks.get(3);
        assertEquals("yes", tuple2.getString(0));
        // yes - maybe
        assertEquals(0, tuple2.getLong(1));
        // yes - no
        assertEquals(1, tuple2.getLong(2));
        // yes - yes
        assertEquals(2, tuple2.getLong(3));
        Tuple tuple3 = (Tuple)actualBlocks.get(4);
        assertEquals("maybe", tuple3.getString(0));
        // maybe - maybe
        assertEquals(0, tuple3.getLong(1));
        // maybe - no
        assertEquals(0, tuple3.getLong(2));
        // maybe - yes
        assertEquals(1, tuple3.getLong(3));
    }
View Full Code Here

        assertTrue(iterator.hasNext());
        assertTrue(iterator.next() instanceof MetadataWrapper);
        for (int i=0; i<10; i++)
        {
            assertTrue(iterator.hasNext());
            Tuple tuple = (Tuple)iterator.next();
            int group = tuple.getInt(0);
            long count = tuple.getLong(2);
            assertEquals(count*group, tuple.getLong(1));
            assertEquals((double)group, tuple.getDouble(3));
            assertEquals(99, tuple.getInt(4));
            assertEquals(0, tuple.getInt(5));
        }
        assertTrue(iterator.hasNext());
        assertEquals(ControlBlock.LIST_END, iterator.next());
       
    }
View Full Code Here

                    else
                    {
                        lst.add(node.toString());
                    }
                }
                Tuple tuple = new SimpleTuple(lst);
                LOG.debug("Tuple: " + tuple);
                output.write(tuple);
            }

            if (includeListMarkers)
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.