-1
데이터를 읽고 튜플에서 두 번째 요소를 선택하는 코드를 작성했습니다. 두 번째 요소는 JSON 일 수 있습니다. 내가 열과 행으로 marketplaceId, 고객 ID를 등과 같은 JSON 키가 데이터 프레임을 만들려면 지금Json 키를 Spark의 열로 변환하십시오.
{"data": {"marketplaceId":7,"customerId":123,"eventTime":1471206800000,"asin":"4567","type":"OWN","region":"NA"},"uploadedDate":1471338703958}
: 아래
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.conf.Configuration;
import com.amazon.traffic.emailautomation.cafe.purchasefilter.util.CodecAwareManifestFileSystem;
import com.amazon.traffic.emailautomation.cafe.purchasefilter.util.CodecAwareManifestInputFormat;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import amazon.emr.utils.manifest.input.ManifestItemFileSystem;
import amazon.emr.utils.manifest.input.ManifestInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat ;
import scala.Tuple2;
val configuration = new Configuration(sc.hadoopConfiguration);
ManifestItemFileSystem.setImplementation(configuration);
ManifestInputFormat.setInputFormatImpl(configuration, classOf[TextInputFormat]);
val linesRdd1 = sc.newAPIHadoopFile("location", classOf[ManifestInputFormat[LongWritable,Text]], classOf[LongWritable], classOf[Text], configuration).map(tuple2 => tuple2._2.toString());
은 예입니다 코드는 JSON을 얻기 위해 그 가치를 지니고있다. 나는 이걸 어떻게 진행할 지 모르겠다. 누군가가 나를 얻을 수있는 포인터를 도울 수 있습니까?