Package scala

Examples of scala.Tuple2


  public static Map<String, Model> toScalaModelMap(java.util.Map<String, Model> map) {
    if (null != map) {
      final Tuple2[] ts = new Tuple2[map.size()];
      int i = 0;
      for (java.util.Map.Entry<String, Model> entry : map.entrySet()) {
        ts[i] = new Tuple2(entry.getKey(), entry.getValue());
        i++;
      }
      final WrappedArray wa = Predef.wrapRefArray(ts);
      return (Map<String, Model>) Predef$.MODULE$.Map().apply(wa);
    }
View Full Code Here


   private T createTuple(Object[] data)
   {
      switch(subreaders.length)
      {
         case 2:
            return (T)new Tuple2(data[0], data[1]);
         case 3:
            return (T)new Tuple3(data[0], data[1], data[2]);
         case 4:
            return (T)new Tuple4(data[0], data[1], data[2], data[3]);
         case 5:
View Full Code Here

                  <= FIVE_MIN_MILLIS) {
                correlated.add(click);
              }
            }
            if (!correlated.isEmpty()) {
              results.add(new Tuple2(CorrelatedEvents.newBuilder()
                  .setEvent(alert)
                  .setCorrelated(correlated)
                  .build(), null));
            }
          }
View Full Code Here

    JavaPairRDD<String, Float> readings = jsc.textFile("../data/helloworld/data.csv")
      .mapToPair(new PairFunction<String, String, Float>() {
        @Override
        public Tuple2 call(String line) {
          String[] tokens = line.split("[\t,]");
          Tuple2 reading = null;
          try {
            reading = new Tuple2(
              tokens[0],
              Float.parseFloat(tokens[1]));
          } catch (Exception e) {
            logger.error("Can't parse reading file. Caught Exception: " + e.getMessage());
            System.exit(1);
View Full Code Here

      JavaPairRDD<Object, Query> indexedQueries) {
    return model.temperatures.join(indexedQueries.mapToPair(
        new PairFunction<Tuple2<Object, Query>, String, Object>() {
          @Override   // reverse the query tuples, then join
          public Tuple2 call(Tuple2<Object, Query> tuple) {
            return new Tuple2(tuple._2.day, tuple._1);
          }
        })).mapToPair(
        new PairFunction<Tuple2<String, Tuple2<Float, Object>>, Object, Float>() {
          @Override   // map result back to predictions, dropping the day
          public Tuple2 call(Tuple2<String, Tuple2<Float, Object>> tuple) {
            return new Tuple2(tuple._2._2, tuple._2._1);
          }
        });
  }
View Full Code Here

TOP

Related Classes of scala.Tuple2

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.