{"id":3131,"date":"2020-03-23T09:09:05","date_gmt":"2020-03-23T08:09:05","guid":{"rendered":"https:\/\/myoceane.fr\/?p=3131"},"modified":"2020-03-23T09:25:46","modified_gmt":"2020-03-23T08:25:46","slug":"spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4","status":"publish","type":"post","link":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/","title":{"rendered":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n\n<p style=\"text-align: justify;\">\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u6211\u5011\u5229\u7528 Java + Spark \u5c55\u793a\u4e00\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u8981\u8655\u7406\u7684\u8cc7\u6599\u7528 Json \u7684\u683c\u5f0f\u63cf\u8ff0\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:json\">[\n  {\n    \"category\": \"airport\",\n    \"type\": \"title\"\n  },\n  {\n    \"category\": \"airport\",\n    \"type\": \"vocabulary\",\n    \"uids\": [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"16\",\"17\",\"18\"]\n  },\n  {\n    \"category\": \"airport\",\n    \"type\": \"alphabet\"\n  },\n  {\n    \"category\": \"airport\",\n    \"type\": \"sentence\",\n    \"uids\": [\"13\",\"14\",\"15\"]\n  }\n]<\/pre>\n\n\n\n<p>\u5229\u7528 SparkSession (spark-core_2.11) \u8b80\u6a94\u6848\u4e26\u4e14 show \u51fa\u4f86\u7684\u8cc7\u6599\u5448\u73fe\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:java\">SparkSession sparkSession = SparkSession.builder().master(\"local\")\n                                        .appName(\"Spark Session Example\").getOrCreate();\n\nDataset&lt;Row&gt; input = sparkSession.read().json(\"file.json\");<br>input.printSchema();\ninput.show();<\/pre>\n\n\n\n<pre class=\"lang:bash\">+--------+----------+--------------------+\n|category|      type|                uids|\n+--------+----------+--------------------+\n| airport|     title|                null|\n| airport|vocabulary|[1, 2, 3, 4, 5, 6...|\n| airport|  alphabet|                null|\n| airport|  sentence|        [13, 14, 15]|\n+--------+----------+--------------------+<\/pre>\n\n\n\n<p>\u5047\u8a2d\u6211\u5011\u60f3\u8981\u5c0d uids \u9019\u4e00\u500b Array \u505a\u4fee\u6539\uff0c\u6b64\u6642\u6211\u5011\u6703\u9700\u8981\u7528\u5230 MapFunction \u7684\u51fd\u5f0f\uff0c\u5047\u8a2d\u6211\u5011\u53ea\u60f3\u8981\u53d6 Array \u88e1\u9762\u7684\u7b2c\u4e00\u8207\u7b2c\u4e8c\u500b\u503c\uff0c\u6b64\u6642 MapFunction \u6703\u985e\u4f3c\u4ee5\u4e0b\u6240\u793a\u7684\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre class=\"lang:java\">StructType outputType = DataTypes.createStructType(Arrays.asList(\n    DataTypes.createStructField(\"category\", DataTypes.StringType, true),\n    DataTypes.createStructField(\"type\", DataTypes.StringType, true),\n    DataTypes.createStructField(\"uids\", DataTypes.createArrayType(DataTypes.StringType), true)\n));\nDataset&lt;Row&gt; out = in.map((MapFunction&lt;Row, Row&gt;) (Row rowInput) -&gt; {\n    List&lt;Object&gt; output = new ArrayList&lt;&gt;();\n    output.add(rowInput.getAs(\"category\"));\n    output.add(rowInput.getAs(\"type\"));\n    List&lt;String&gt; uids = rowInput.getList(rowInput.fieldIndex(\"uids\"));\n    if (uids == null){\n        output.add(null);\n    } else {\n        output.add(uids.subList(0,1).toArray());\n    }\n    return RowFactory.create(output.toArray());\n}, RowEncoder.apply(outputType));<\/pre>\n\n\n\n<p>\u4f46\u662f\u57f7\u884c\u7684\u6642\u5019\u767c\u751f\u4ee5\u4e0b NullPointerException \u7684\u932f\u8aa4\u8a0a\u606f\uff01<\/p>\n<pre class=\"lang:bash\">Caused by: java.lang.NullPointerException\n\tat scala.collection.convert.Wrappers$IterableWrapperTrait$class.size(Wrappers.scala:24)\n\tat scala.collection.convert.Wrappers$SeqWrapper.size(Wrappers.scala:65)\n\tat java.util.SubList.&lt;init&gt;(AbstractList.java:621)\n\tat java.util.AbstractList.subList(AbstractList.java:484)<\/pre>\n\n\n\n<p style=\"text-align: justify;\">\u5982\u679c\u8a73\u7d30\u53bb\u67e5\u770b getList() \u7684 Spark Row \u7684<a href=\"https:\/\/spark.apache.org\/docs\/2.3.0\/api\/java\/org\/apache\/spark\/sql\/Row.html#getList-int-\">\u51fd\u5f0f\u8aaa\u660e<\/a>\uff0c\u6703\u767c\u73fe getList \u51fd\u5f0f\u6703\u56de\u50b3 List&lt;T&gt; \u4ee5\u4e0a\u7684\u4f7f\u7528\u65b9\u6cd5\u4e26\u6c92\u6709\u908f\u8f2f\u4e0a\u7684\u932f\u8aa4\uff0c\u5373\u4fbf\u6211\u5011\u6709\u6aa2\u67e5 uids \u662f\u5426\u70ba null \u4f46\u662f\u9084\u662f\u767c\u751f NullPointerException\u3002\u6b64\u6642\u4f7f\u7528 scala.collection.mutable.WrappedArray \u4e26\u5c07\u7a0b\u5f0f\u7a0d\u5fae\u4fee\u6539\u5982\u4ee5\u4e0b\u5373\u53ef\u4ee5\u4f7f\u7528\uff01<\/p>\n<pre class=\"lang:java\">WrappedArray&lt;String&gt; uids = rowInput.getAs(\"uids\");\nif (uids == null){\n    output.add(null);\n} else {\n    output.add(Arrays.copyOfRange((String[]) uids.array(), 0, 2));\n}<\/pre>\n\n\n\n<p>\u5099\u8a3b\uff1a\u4e5f\u53ef\u4ee5\u4f7f\u7528 JavaConversions.SeqAsJavaList \u7b49\u7b49\u5176\u4ed6\u7684\u51fd\u5f0f\u5e6b\u5fd9\u5c07 uids \u8f49\u63db\u6210 List&lt;String&gt;\uff1a<\/p>\n<pre class=\"lang:bash\">List&lt;String&gt; uids = JavaConversions.seqAsJavaList(uidsArray.toSeq());<\/pre>\n\n\n\n<p>\u5099\u8a3b\uff1a\u5176\u4ed6 Spark \u5e38\u898b\u7684\u554f\u984c\u4e5f\u53ef\u4ee5\u53c3\u8003<a href=\"https:\/\/myoceane.fr\/index.php\/spark-%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c%e8%88%87%e8%a8%8e%e8%ab%96\/\">\u9023\u7d50<\/a>\uff01<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,14],"tags":[153,154,151,152],"class_list":["post-3131","post","type-post","status-publish","format-standard","hentry","category-bigdata-ml","category-it-technology","tag-getlist","tag-nullpointerexception","tag-row","tag-spark"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane<\/title>\n<meta name=\"description\" content=\"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-\u7684\u96b1\u85cf\u932f\u8aa4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane\" \/>\n<meta property=\"og:description\" content=\"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01\" \/>\n<meta property=\"og:url\" content=\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-\u7684\u96b1\u85cf\u932f\u8aa4\/\" \/>\n<meta property=\"og:site_name\" content=\"\u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-23T08:09:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-23T08:25:46+00:00\" \/>\n<meta name=\"author\" content=\"\u6ab8\u6aac\u7238\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6ab8\u6aac\u7238\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/\"},\"author\":{\"name\":\"\u6ab8\u6aac\u7238\",\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b\"},\"headline\":\"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\",\"datePublished\":\"2020-03-23T08:09:05+00:00\",\"dateModified\":\"2020-03-23T08:25:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/\"},\"wordCount\":51,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b\"},\"keywords\":[\"getList\",\"NullPointerException\",\"Row\",\"Spark\"],\"articleSection\":[\"Big Data &amp; Machine Learning\",\"IT Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/\",\"url\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/\",\"name\":\"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane\",\"isPartOf\":{\"@id\":\"https:\/\/myoceane.fr\/#website\"},\"datePublished\":\"2020-03-23T08:09:05+00:00\",\"dateModified\":\"2020-03-23T08:25:46+00:00\",\"description\":\"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01\",\"breadcrumb\":{\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/myoceane.fr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/myoceane.fr\/#website\",\"url\":\"https:\/\/myoceane.fr\/\",\"name\":\"M-Y-Oceane \u60f3\u65b9\u6d89\u6cd5\u3002\u91cf\u74f6\u5916\u7684\u5929\u7a7a\",\"description\":\"\u60f3\u65b9\u6d89\u6cd5, France, Taiwan, Health, Information Technology\",\"publisher\":{\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/myoceane.fr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b\",\"name\":\"\u6ab8\u6aac\u7238\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6cc678684664f8ad45a8d56a6630b183?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6cc678684664f8ad45a8d56a6630b183?s=96&d=mm&r=g\",\"caption\":\"\u6ab8\u6aac\u7238\"},\"logo\":{\"@id\":\"https:\/\/myoceane.fr\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/myoceane.fr\/index.php\/author\/johnny5584767gmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane","description":"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-\u7684\u96b1\u85cf\u932f\u8aa4\/","og_locale":"en_US","og_type":"article","og_title":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane","og_description":"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01","og_url":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-\u7684\u96b1\u85cf\u932f\u8aa4\/","og_site_name":"\u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane","article_published_time":"2020-03-23T08:09:05+00:00","article_modified_time":"2020-03-23T08:25:46+00:00","author":"\u6ab8\u6aac\u7238","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u6ab8\u6aac\u7238","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#article","isPartOf":{"@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/"},"author":{"name":"\u6ab8\u6aac\u7238","@id":"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b"},"headline":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4","datePublished":"2020-03-23T08:09:05+00:00","dateModified":"2020-03-23T08:25:46+00:00","mainEntityOfPage":{"@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/"},"wordCount":51,"commentCount":0,"publisher":{"@id":"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b"},"keywords":["getList","NullPointerException","Row","Spark"],"articleSection":["Big Data &amp; Machine Learning","IT Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/","url":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/","name":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4 - \u60f3\u65b9\u6d89\u6cd5 - \u91cf\u74f6\u5916\u7684\u5929\u7a7a M-Y-Oceane","isPartOf":{"@id":"https:\/\/myoceane.fr\/#website"},"datePublished":"2020-03-23T08:09:05+00:00","dateModified":"2020-03-23T08:25:46+00:00","description":"\u5728\u958b\u767c Java Spark \u7684\u6642\u5019\uff0c\u5e38\u5e38\u6703\u9700\u8981\u8f49\u63db Dataset \u6216\u662f DataFrame\uff0c\u5c0d\u65bc\u6bd4\u8f03\u5927\u7684\u8868\u683c\u683c\u5f0f\u8b8a\u63db (Schema Change)\uff0c\u901a\u5e38\u6703\u4f7f\u7528\u5230 JavaRDD \u8207 Row\uff0c\u958b\u767c\u6642\u7528\u5230\u6bd4\u8f03\u8907\u96dc\u7684\u8cc7\u6599\u7d50\u69cb\u50cf\u662f List \u6216\u662f Map \u7b49\u7b49\u7684\u6642\u5019\uff0c\u6709\u6642\u5019\u767c\u751f\u932f\u8aa4\u4e26\u4e0d\u77e5\u9053\u8981\u5982\u4f55\u9664\u932f\uff1f\u672c\u7bc7\u60f3\u8981\u5c55\u793a\u985e\u5225 Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4\u5728\u4f7f\u7528\u7684\u6642\u5019\u767c\u751f\u7121\u6cd5\u7406\u89e3\u7684 NullPointerException \u73fe\u8c61\u4e26\u4e14\u5176\u89e3\u6c7a\u7684\u65b9\u6cd5\uff01","breadcrumb":{"@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/myoceane.fr\/index.php\/spark-row-getlist-%e7%9a%84%e9%9a%b1%e8%97%8f%e9%8c%af%e8%aa%a4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/myoceane.fr\/"},{"@type":"ListItem","position":2,"name":"[Spark] Row: getList() \u7684\u96b1\u85cf\u932f\u8aa4"}]},{"@type":"WebSite","@id":"https:\/\/myoceane.fr\/#website","url":"https:\/\/myoceane.fr\/","name":"M-Y-Oceane \u60f3\u65b9\u6d89\u6cd5\u3002\u91cf\u74f6\u5916\u7684\u5929\u7a7a","description":"\u60f3\u65b9\u6d89\u6cd5, France, Taiwan, Health, Information Technology","publisher":{"@id":"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/myoceane.fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/myoceane.fr\/#\/schema\/person\/4a4552fb8c27693083d465e12db7658b","name":"\u6ab8\u6aac\u7238","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/myoceane.fr\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6cc678684664f8ad45a8d56a6630b183?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6cc678684664f8ad45a8d56a6630b183?s=96&d=mm&r=g","caption":"\u6ab8\u6aac\u7238"},"logo":{"@id":"https:\/\/myoceane.fr\/#\/schema\/person\/image\/"},"url":"https:\/\/myoceane.fr\/index.php\/author\/johnny5584767gmail-com\/"}]}},"amp_enabled":false,"_links":{"self":[{"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/posts\/3131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/comments?post=3131"}],"version-history":[{"count":41,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/posts\/3131\/revisions"}],"predecessor-version":[{"id":3322,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/posts\/3131\/revisions\/3322"}],"wp:attachment":[{"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/media?parent=3131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/categories?post=3131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myoceane.fr\/index.php\/wp-json\/wp\/v2\/tags?post=3131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}