Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F70263673
WarcRecord.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jul 6, 00:48
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Jul 8, 00:48 (2 d)
Engine
blob
Format
Raw Data
Handle
18814956
Attached To
R1473 warcbase
WarcRecord.scala
View Options
package
org.warcbase.spark.archive.io
import
java.text.SimpleDateFormat
import
org.apache.spark.SerializableWritable
import
org.archive.util.ArchiveUtils
import
org.warcbase.data.WarcRecordUtils
import
org.warcbase.io.WarcRecordWritable
import
org.warcbase.spark.matchbox.ExtractDate.DateComponent
import
org.warcbase.spark.matchbox.
{
RemoveHttpHeader
,
ExtractDate
,
ExtractDomain
}
class
WarcRecord
(
r
:
SerializableWritable
[
WarcRecordWritable
])
extends
ArchiveRecord
{
val
ISO8601
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssX"
)
val
getCrawlDate
:
String
=
ExtractDate
(
ArchiveUtils
.
get14DigitDate
(
ISO8601
.
parse
(
r
.
t
.
getRecord
.
getHeader
.
getDate
)),
DateComponent
.
YYYYMMDD
)
val
getCrawlMonth
:
String
=
ExtractDate
(
ArchiveUtils
.
get14DigitDate
(
ISO8601
.
parse
(
r
.
t
.
getRecord
.
getHeader
.
getDate
)),
DateComponent
.
YYYYMM
)
val
getContentBytes
:
Array
[
Byte
]
=
WarcRecordUtils
.
getContent
(
r
.
t
.
getRecord
)
val
getContentString
:
String
=
new
String
(
getContentBytes
)
val
getMimeType
=
WarcRecordUtils
.
getWarcResponseMimeType
(
getContentBytes
)
val
getUrl
=
r
.
t
.
getRecord
.
getHeader
.
getUrl
val
getDomain
=
ExtractDomain
(
getUrl
)
val
getImageBytes
:
Array
[
Byte
]
=
{
if
(
getContentString
.
startsWith
(
"HTTP/"
))
getContentBytes
.
slice
(
getContentString
.
indexOf
(
RemoveHttpHeader
.
headerEnd
)
+
RemoveHttpHeader
.
headerEnd
.
length
,
getContentBytes
.
length
)
else
getContentBytes
}
}
Event Timeline
Log In to Comment