Search in sources :

Example 86 with StringValue

use of org.apache.flink.types.StringValue in project flink by apache.

the class ValueCollectionDataSets method getStringDataSet.

public static DataSet<StringValue> getStringDataSet(ExecutionEnvironment env) {
    List<StringValue> data = new ArrayList<>();
    data.add(new StringValue("Hi"));
    data.add(new StringValue("Hello"));
    data.add(new StringValue("Hello world"));
    data.add(new StringValue("Hello world, how are you?"));
    data.add(new StringValue("I am fine."));
    data.add(new StringValue("Luke Skywalker"));
    data.add(new StringValue("Random comment"));
    data.add(new StringValue("LOL"));
    Collections.shuffle(data);
    return env.fromCollection(data);
}
Also used : ArrayList(java.util.ArrayList) StringValue(org.apache.flink.types.StringValue)

Example 87 with StringValue

use of org.apache.flink.types.StringValue in project flink by apache.

the class ValueCollectionDataSets method getPojoWithCollection.

public static DataSet<PojoWithCollection> getPojoWithCollection(ExecutionEnvironment env) {
    List<PojoWithCollection> data = new ArrayList<>();
    List<Pojo1> pojosList1 = new ArrayList<>();
    pojosList1.add(new Pojo1("a", "aa"));
    pojosList1.add(new Pojo1("b", "bb"));
    List<Pojo1> pojosList2 = new ArrayList<>();
    pojosList2.add(new Pojo1("a2", "aa2"));
    pojosList2.add(new Pojo1("b2", "bb2"));
    PojoWithCollection pwc1 = new PojoWithCollection();
    pwc1.pojos = pojosList1;
    pwc1.key = new IntValue(0);
    pwc1.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN);
    pwc1.scalaBigInt = BigInt.int2bigInt(10);
    pwc1.bigDecimalKeepItNull = null;
    // use calendar to make it stable across time zones
    GregorianCalendar gcl1 = new GregorianCalendar(2033, 04, 18);
    pwc1.sqlDate = new java.sql.Date(gcl1.getTimeInMillis());
    pwc1.mixed = new ArrayList<Object>();
    Map<StringValue, IntValue> map = new HashMap<>();
    map.put(new StringValue("someKey"), new IntValue(1));
    pwc1.mixed.add(map);
    pwc1.mixed.add(new File("/this/is/wrong"));
    pwc1.mixed.add("uhlala");
    PojoWithCollection pwc2 = new PojoWithCollection();
    pwc2.pojos = pojosList2;
    pwc2.key = new IntValue(0);
    pwc2.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN);
    pwc2.scalaBigInt = BigInt.int2bigInt(31104000);
    pwc2.bigDecimalKeepItNull = null;
    GregorianCalendar gcl2 = new GregorianCalendar(1976, 4, 3);
    // 1976
    pwc2.sqlDate = new java.sql.Date(gcl2.getTimeInMillis());
    data.add(pwc1);
    data.add(pwc2);
    return env.fromCollection(data);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) StringValue(org.apache.flink.types.StringValue) IntValue(org.apache.flink.types.IntValue) File(java.io.File)

Example 88 with StringValue

use of org.apache.flink.types.StringValue in project flink by apache.

the class ValueCollectionDataSets method getSmallNestedTupleDataSet.

public static DataSet<Tuple2<Tuple2<IntValue, IntValue>, StringValue>> getSmallNestedTupleDataSet(ExecutionEnvironment env) {
    List<Tuple2<Tuple2<IntValue, IntValue>, StringValue>> data = new ArrayList<>();
    data.add(new Tuple2<>(new Tuple2<>(new IntValue(1), new IntValue(1)), new StringValue("one")));
    data.add(new Tuple2<>(new Tuple2<>(new IntValue(2), new IntValue(2)), new StringValue("two")));
    data.add(new Tuple2<>(new Tuple2<>(new IntValue(3), new IntValue(3)), new StringValue("three")));
    TupleTypeInfo<Tuple2<Tuple2<IntValue, IntValue>, StringValue>> type = new TupleTypeInfo<>(new TupleTypeInfo<Tuple2<IntValue, IntValue>>(ValueTypeInfo.INT_VALUE_TYPE_INFO, ValueTypeInfo.INT_VALUE_TYPE_INFO), ValueTypeInfo.STRING_VALUE_TYPE_INFO);
    return env.fromCollection(data, type);
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) ArrayList(java.util.ArrayList) StringValue(org.apache.flink.types.StringValue) IntValue(org.apache.flink.types.IntValue) TupleTypeInfo(org.apache.flink.api.java.typeutils.TupleTypeInfo)

Aggregations

StringValue (org.apache.flink.types.StringValue)88 Test (org.junit.Test)61 IntValue (org.apache.flink.types.IntValue)35 LongValue (org.apache.flink.types.LongValue)21 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)15 Record (org.apache.flink.types.Record)13 TupleTypeInfo (org.apache.flink.api.java.typeutils.TupleTypeInfo)12 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)11 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)11 DoubleValue (org.apache.flink.types.DoubleValue)11 Value (org.apache.flink.types.Value)10 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)9 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)7 Plan (org.apache.flink.api.common.Plan)7 Configuration (org.apache.flink.configuration.Configuration)7 FileInputSplit (org.apache.flink.core.fs.FileInputSplit)7 NoSuchElementException (java.util.NoSuchElementException)6 File (java.io.File)5 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)5