fun inferType(tuples: TupleSet, field: String): Class<*>? { return if (tuples is Table) { (tuples as Table).getColumnType(field) } else { var type: Class<*>? = null var type2: Class<*>? = null val iter: Iterator<*> = tuples.tuples() while (iter.hasNext()) { val t: Tuple = iter.next() as Tuple if (type == null) { type = t.getColumnType(field) } else if (type != t.getColumnType(field).also { type2 = it }) { if (type2!!.isAssignableFrom(type)) { type = type2 } else require(type.isAssignableFrom(type2)) { "The data field [$field] does not have a consistent type across provided Tuples" } } } type } }
Infer the data field type across all tuples in a TupleSet .