Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65686704
CountArcContentTypes.java
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
Wed, Jun 5, 13:15
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Jun 7, 13:15 (2 d)
Engine
blob
Format
Raw Data
Handle
18112297
Attached To
R1473 warcbase
CountArcContentTypes.java
View Options
package
org.warcbase.analysis
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
org.apache.hadoop.io.IntWritable
;
import
org.apache.hadoop.io.LongWritable
;
import
org.apache.hadoop.io.Text
;
import
org.apache.hadoop.mapreduce.Mapper
;
import
org.apache.hadoop.util.Tool
;
import
org.apache.hadoop.util.ToolRunner
;
import
org.apache.log4j.Logger
;
import
org.jwat.arc.ArcRecordBase
;
public
class
CountArcContentTypes
{
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
CountArcContentTypes
.
class
);
private
static
enum
Records
{
TOTAL
};
public
static
class
MyMapper
extends
Mapper
<
LongWritable
,
ArcRecordBase
,
Text
,
IntWritable
>
{
private
static
final
IntWritable
ONE
=
new
IntWritable
(
1
);
@Override
public
void
map
(
LongWritable
key
,
ArcRecordBase
record
,
Context
context
)
throws
IOException
,
InterruptedException
{
context
.
getCounter
(
Records
.
TOTAL
).
increment
(
1
);
String
type
=
record
.
getContentTypeStr
();
context
.
write
(
new
Text
(
type
),
ONE
);
}
}
/**
* Dispatches command-line arguments to the tool via the <code>ToolRunner</code>.
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
LOG
.
info
(
"Running "
+
CountArcContentTypes
.
class
.
getCanonicalName
()
+
" with args "
+
Arrays
.
toString
(
args
));
Tool
tool
=
new
GenericArcRecordCounter
(
MyMapper
.
class
);
ToolRunner
.
run
(
tool
,
args
);
}
}
Event Timeline
Log In to Comment