Skip to content

Commit

Permalink
hardcode mobile_attributes schema
Browse files Browse the repository at this point in the history
  • Loading branch information
timvw committed Nov 9, 2023
1 parent 51e5d69 commit 98f9ff4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/main/resources/mobile_attributes_headers.tsv

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ case class MobileAttributeValuesContributor(lookupFilesByName: Map[String, File]
private case class SimpleLookupRule(lookupfileName: String, phyiscalColumnName: String, resultSchemaField: StructField)

private lazy val mobileAttributesSchema = {
val fullSchema = MobileAttributes.getSchema()
StructType(fullSchema.fields.filter(x => x.name != "mobile_id"))
StructType(MobileAttributes.schema.fields.filter(x => x.name != "mobile_id"))
}

private val simpleLookupRules = List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,59 @@ package be.icteam.adobe.analytics.datafeed.util

import org.apache.spark.sql.types.{StringType, StructField, StructType}

import scala.io.Source

case object MobileAttributes {

def getHeaders(): List[String] = {
val in = getClass.getResourceAsStream("/mobile_attributes_headers.tsv")
Source.fromInputStream(in).getLines().flatMap(_.split('\t')).toList
}

def getSchema(): StructType = {
val headerFields = getHeaders().map(x => StructField(x, StringType))
StructType(headerFields)
}
val schema: StructType = StructType(Array(
StructField("mobile_id", StringType),
StructField("Manufacturer", StringType),
StructField("Device", StringType),
StructField("Device_Type", StringType),
StructField("Operating_System", StringType),
StructField("Diagonal_Screen_Size", StringType),
StructField("Screen_Height", StringType),
StructField("Screen_Width", StringType),
StructField("Cookie_Support", StringType),
StructField("Color_Depth", StringType),
StructField("MP3_Audio_Support", StringType),
StructField("AAC_Audio_Support", StringType),
StructField("AMR_Audio_Support", StringType),
StructField("Midi_Monophonic_Audio_Support", StringType),
StructField("Midi_Polyphonic_Audio_Support", StringType),
StructField("QCELP_Audio_Support", StringType),
StructField("GIF87_Image_Support", StringType),
StructField("GIF89a_Image_Support", StringType),
StructField("PNG_Image_Support", StringType),
StructField("JPG_Image_Support", StringType),
StructField("3GPP_Video_Support", StringType),
StructField("MPEG4_Video_Support", StringType),
StructField("3GPP2_Video_Support", StringType),
StructField("WMV_Video_Support", StringType),
StructField("MPEG4_Part_2_Video_Support", StringType),
StructField("Stream_MP4_AAC_LC_Video_Support", StringType),
StructField("Stream_3GP_H264_Level_10b_Video_Support", StringType),
StructField("Stream_3GP_AAC_LC_Video_Support", StringType),
StructField("3GP_AAC_LC_Video_Support", StringType),
StructField("Stream_MP4_H264_Level_11_Video_Support", StringType),
StructField("Stream_MP4_H264_Level_13_Video_Support", StringType),
StructField("Stream_3GP_H264_Level_12_Video_Support", StringType),
StructField("Stream_3GP_H264_Level_11_Video_Support", StringType),
StructField("Stream_3GP_H264_Level_10_Video_Support", StringType),
StructField("Stream_3GP_H264_Level_13_Video_Support", StringType),
StructField("3GP_AMR_NB_Video_Support", StringType),
StructField("3GP_AMR_WB_Video_Support", StringType),
StructField("MP4_H264_Level_11_Video_Support", StringType),
StructField("3GP_H263_Video_Support", StringType),
StructField("MP4_H264_Level_13_Video_Support", StringType),
StructField("Stream_3GP_H263_Video_Support", StringType),
StructField("Stream_3GP_AMR_WB_Video_Support", StringType),
StructField("3GP_H264_Level_10b_Video_Support", StringType),
StructField("MP4_ACC_LC_Video_Support", StringType),
StructField("Stream_3GP_AMR_NB_Video_Support", StringType),
StructField("3GP_H264_Level_10_Video_Support", StringType),
StructField("3GP_H264_Level_13_Video_Support", StringType),
StructField("3GP_H264_Level_11_Video_Support", StringType),
StructField("3GP_H264_Level_12_Video_Support", StringType),
StructField("Stream_HTTP_Live_Streaming_Video_Support", StringType)
))

}

This file was deleted.

0 comments on commit 98f9ff4

Please sign in to comment.