Package uk.org.ogsadai.tuple

Examples of uk.org.ogsadai.tuple.Tuple


      else{
      ResponsePAZ resPAZ=parseResp(respFiles[0]);
   
      //List <Tuple> tuples=new ArrayList<Tuple>();
      //for(ResponsePAZ resPAZ:res){
        Tuple t= makeTuple(resPAZ.getName(),resPAZ.getGain(),resPAZ.getGainFreq(),new SimpleBlob(prettyPrintComplex(resPAZ.getZeros())),new SimpleBlob(prettyPrintComplex(resPAZ.getPoles())));
            tuples.add(t);
      }
          MetadataWrapper metadataWrapper=new MetadataWrapper(makeTupleMetadata(new String[]{ NAME, GAIN,GAIN_FREQUENCY,ZEROS,POLES},
                      new int[] { TupleTypes._STRING, TupleTypes._DOUBLE,TupleTypes._DOUBLE,TupleTypes._ODBLOB,TupleTypes._ODBLOB }));
      //}  
View Full Code Here


    //String fileName = file;
     
    TupleListIterator tupleListIterator = (TupleListIterator) iterationData[1];
      MetadataWrapper metadataWrapper = tupleListIterator.getMetadataWrapper();
      TupleMetadata tupleMetadata = (TupleMetadata) metadataWrapper.getMetadata();
      Tuple tuple;
    try {
     
     mOutputBlockWriter = getOutput(OUTPUT_DATA);
       BlockWriter meanOut = getOutput(MEAN);
       mMetadataOutputBlockWriter = getOutput(METADATA);
       List<ResponsePAZ> responses=new ArrayList<ResponsePAZ>()
       int i=0;
       parametersMap = new HashMap<String,String>();
       while((tuple= (Tuple)tupleListIterator.nextValue())!= null){
         System.out.println("in iteration tuple");
        ResponsePAZ response= new ResponsePAZ();
        response.setName(tuple.getString(tupleMetadata,NAME));
        response.setGain(tuple.getDouble(tupleMetadata,GAIN));
        response.setGainFreq(tuple.getDouble(tupleMetadata,GAIN_FREQUENCY));
          Blob zerosB=tuple.getBlob(tupleMetadata,ZEROS);
          Blob polesB=tuple.getBlob(tupleMetadata,POLES);
        response.setZeros(zerosB.getBytes(1, (int) zerosB.length()));
          response.setPoles(polesB.getBytes(1, (int) polesB.length()));
      responses.add(response);
      JSONSerializer serializer = new JSONSerializer();
      parametersMap.put("response"+i, URLEncoder.encode(serializer.serialize(response),"UTF-8"));
View Full Code Here

    block = inputs[0].read();
    if (block != ControlBlock.NO_MORE_DATA)
    {
      if(block instanceof Tuple){

        Tuple tuple = (Tuple) block;
       
        // read the feature
        double[] data = (double[]) tuple.getObject(0);

        LOG.debug("features to be classified: size " + data.length + " ; [0] " + data[0]);
        classification = KNNclassify(data,featuresMatrix,classType,NumberOfNeighbour);

        LOG.debug("classification: " + classification);
          List elements = new ArrayList();
          elements.add(classification);
          Tuple tupleC = new SimpleTuple(elements);
        try{
          mOutput.write(tupleC);
        }
        catch (PipeTerminatedException e)
        {
View Full Code Here

  protected void processIteration(Object[] iterationData)
  throws ActivityProcessingException, ActivityTerminatedException,
  ActivityUserException {
    TupleListIterator tuples = (TupleListIterator) iterationData[0];

    Tuple tuple = null;

    while ((tuple = (Tuple) tuples.nextValue()) != null)
    {               
      // add the feature into the classifier
      double[] features= (double[]) tuple.getObject(0);
      classifier.addFeatures(features);
      LOG.debug("Features: size " + features.length + " [0] " + features[0]);
     
      // add the classType into the classifier
      classifier.addClassType(tuple.getInt(1));     
      LOG.debug("ClassType: " + tuple.getInt(1));
    }
  }
View Full Code Here

        if ((block = inputs[0].read()) != ControlBlock.NO_MORE_DATA)
        {
          Object data = block;
            List elements = new ArrayList();
            elements.add(data);
            Tuple tuple = new SimpleTuple(elements);
            try{
              mOutput.write(tuple);
            } catch (PipeClosedException e)
            {
                iterativeStageComplete();
View Full Code Here

        try
        {
            //mOutput.write(ControlBlock.LIST_BEGIN);

          Queue<Integer> randomIndexes = randomNumbers(sampleRepeat, sampleSize);
            Tuple tuple;
           
            for (long i=0;(tuple = (Tuple)tuples.nextValue()) != null;i++)
            {
              if(randomIndexes.size()>0 && i% sampleRepeat == randomIndexes.peek().intValue()){
                sampleTuples[sampleSize - randomIndexes.size()] = tuple;
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

      throws ActivityProcessingException, ActivityTerminatedException,
      ActivityUserException {
      try {
       
        TupleListIterator dataTuples = (TupleListIterator)iterationInputs[0];
        Tuple tuple;
        List<String> binNames = getBinNames((ListIterator)iterationInputs[1]);
        List<Double> aggregates = getAggregates((TupleListIterator)iterationInputs[2]);
        mOutput.write(ControlBlock.LIST_BEGIN);
        mOutput.write(prepareMetadata(dataTuples));
        while((tuple = (Tuple)dataTuples.nextValue()) != null) {
View Full Code Here

                column = new SimpleColumnMetadata("class", TupleTypes._STRING, 0, 0, 0);
            }
           
            TupleMetadata outMetadata = new SimpleTupleMetadata(Collections.singletonList(column));
            mOutput.write(new MetadataWrapper(outMetadata));
            Tuple tuple;
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
               
               
                Object result = classify(classifiers, tuple);
               
                LOG.debug("Classified " + tuple + " : " + result);
                List<?> elements = Collections.singletonList(result);
                Tuple out = new SimpleTuple(elements);
                mOutput.write(out);
            }
            mOutput.write(ControlBlock.LIST_END);
           
           
View Full Code Here

            {
                column = new SimpleColumnMetadata(resultColumnName, TupleTypes._STRING, 0, 0, 0);
            }
            TupleMetadata outMetadata = new SimpleTupleMetadata(Collections.singletonList(column));
            mOutput.write(new MetadataWrapper(outMetadata));
            Tuple tuple;
            while ((tuple = (Tuple)tuples.nextValue()) != null)
            {
                Object result;
                if (isNumeric)
                {
                    result = classifier.classifyNumeric(tuple);
                }
                else
                {
                    result = classifier.classifyTuple(tuple);
                }
                LOG.debug("Classified " + tuple + " : result = " + result);
                List<?> elements = Collections.singletonList(result);
               

                Tuple out = new SimpleTuple(elements);
                mOutput.write(out);
            }
            mOutput.write(ControlBlock.LIST_END);
        }
        catch (PipeClosedException e)
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.