本文整理汇总了Scala中org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema类的典型用法代码示例。如果您正苦于以下问题:Scala GenericRowWithSchema类的具体用法?Scala GenericRowWithSchema怎么用?Scala GenericRowWithSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GenericRowWithSchema类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: GDBRowIterator
//设置package包名称以及导入依赖的类
package com.esri.gdb
import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
import org.apache.spark.sql.types.StructType
class GDBRowIterator(indexIter: Iterator[IndexInfo], dataBuffer: DataBuffer, fields: Array[Field], schema: StructType)
extends Iterator[Row] with Serializable {
val numFieldsWithNullAllowed = fields.count(_.nullable)
val nullValueMasks = new Array[Byte]((numFieldsWithNullAllowed / 8.0).ceil.toInt)
def hasNext() = indexIter.hasNext
def next() = {
val index = indexIter.next()
val numBytes = dataBuffer.seek(index.seek).readBytes(4).getInt
val byteBuffer = dataBuffer.readBytes(numBytes)
0 until nullValueMasks.length foreach (nullValueMasks(_) = byteBuffer.get)
var bit = 0
val values = fields.map(field => {
if (field.nullable) {
val i = bit >> 3
val m = 1 << (bit & 7)
bit += 1
if ((nullValueMasks(i) & m) == 0) {
field.readValue(byteBuffer, index.objectID)
}
else {
null // TODO - Do not like null here - but...it is nullable !
}
} else {
field.readValue(byteBuffer, index.objectID)
}
}
)
new GenericRowWithSchema(values, schema)
}
}