/** * Shallow tuple copy. * @return A new Tuple with the same fields as this. */ @Override @SuppressWarnings("unchecked") public Tuple1<T0> copy() { return new Tuple1<>(this.f0); }
@Override public Tuple1<Long> map(Long value) throws Exception { return Tuple1.of(value); }
@Override public Tuple1<Integer> map(Tuple1<Integer> value) throws Exception { if (value.f0.equals(23)) { return new Tuple1<Integer>(value.<Integer> getField(0)); } else if (value.f0.equals(22)) { Tuple1<Integer> inputContainer = new Tuple1<Integer>(); inputContainer.f0 = value.f0; return new Tuple1<Integer>(inputContainer.<Integer> getField(0)); } else { return value; } } }
@Override public Tuple1<T0> map(Tuple3<T0, T1, T2> triple) throws Exception { reuseTuple.setFields(triple.f0); return reuseTuple; } }
@SuppressWarnings("unchecked") @Override public Tuple1<Tuple1<String>> map(Tuple1<Tuple1<String>> value) throws Exception { ((Tuple1<String>) value.getField(Integer.parseInt("2."))).f0 = "Hello"; return value; } }
@Override public Tuple1<T0> map(Tuple3<T0, T1, T2> triple) throws Exception { reuseTuple.setFields(triple.f0); return reuseTuple; } }
/** * Creates a new tuple and assigns the given values to the tuple's fields. * This is more convenient than using the constructor, because the compiler can * infer the generic type arguments implicitly. For example: * {@code Tuple3.of(n, x, s)} * instead of * {@code new Tuple3<Integer, Double, String>(n, x, s)} */ public static <T0> Tuple1<T0> of(T0 value0) { return new Tuple1<>(value0); } }
public static void copyToLocal(final URI remotePath, final File localPath) throws Exception { // Do it in another Thread because HDFS can deadlock if being interrupted while copying String threadName = "HDFS Copy from " + remotePath + " to " + localPath; final Tuple1<Exception> asyncException = Tuple1.of(null); Thread copyThread = new Thread(threadName) { @Override public void run() { try { Configuration hadoopConf = HadoopFileSystem.getHadoopConfiguration(); FileSystem fs = FileSystem.get(remotePath, hadoopConf); fs.copyToLocalFile(new Path(remotePath), new Path(localPath.getAbsolutePath())); } catch (Exception t) { asyncException.f0 = t; } } }; copyThread.setDaemon(true); copyThread.start(); copyThread.join(); if (asyncException.f0 != null) { throw asyncException.f0; } } }
public Tuple1<K> map(K key) throws Exception { return new Tuple1<>(key); } }
final Tuple1<Exception> asyncException = Tuple1.of(null);
public Tuple1Builder<T0> add(T0 value0){ tuples.add(new Tuple1<>(value0)); return this; }
udf.flatMap(Tuple1.of(embedding), new ListCollector<>(result));
@Override public Tuple1<String> map(byte[] value) throws Exception { //5 = string type byte + string size return new Tuple1<>(new String(value, 5, value.length - 5, ConfigConstants.DEFAULT_CHARSET)); } }
public Tuple1<String> map(String value) { String[] tokens = value.split("\\s+"); String songId = tokens[1].substring(1); return new Tuple1<>(songId); } }
@Override public Tuple1<Long> map(Long value) throws Exception { return new Tuple1<>(value); } });
@Override public Tuple1<Long> map(Long value) throws Exception { return new Tuple1<Long>(value); } }
@Override public Tuple1<Long> map(Long l) throws Exception { return new Tuple1<Long>(l); } }
@Override public Tuple1<Integer> map(CustomType value) throws Exception { return new Tuple1<Integer>(value.myInt); } }
@Override public Tuple1<String> map(String value) throws Exception { return new Tuple1<>(value); } });