public class ParseResult extends Object implements Iterable<Map.Entry<org.apache.hadoop.io.Text,Parse>>
Text
, Parse
> pairs.
Parsers may return multiple results, which correspond to parts or other associated documents related to the original URL.
There will be usually one parse result that corresponds directly to the original URL, and possibly many (or none) results that correspond to derived URLs (or sub-URLs).
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
ParseResult(String originalUrl)
Create a container for parse results.
|
Modifier and Type | Method and Description |
---|---|
static ParseResult |
createParseResult(String url,
Parse parse)
Convenience method for obtaining
ParseResult from a single
Parse output. |
void |
filter()
Remove all results where status is not successful (as determined
by ParseStatus#isSuccess()).
|
Parse |
get(String key)
Retrieve a single parse output.
|
Parse |
get(org.apache.hadoop.io.Text key)
Retrieve a single parse output.
|
boolean |
isEmpty()
Checks whether the result is empty.
|
boolean |
isSuccess()
A convenience method which returns true only if all parses are successful.
|
Iterator<Map.Entry<org.apache.hadoop.io.Text,Parse>> |
iterator()
Iterate over all entries in the <url, Parse> map.
|
void |
put(String key,
ParseText text,
ParseData data)
Store a result of parsing.
|
void |
put(org.apache.hadoop.io.Text key,
ParseText text,
ParseData data)
Store a result of parsing.
|
int |
size()
Return the number of parse outputs (both successful and failed)
|
public ParseResult(String originalUrl)
originalUrl
- the original url from which all parse results
have been obtained.public static ParseResult createParseResult(String url, Parse parse)
ParseResult
from a single
Parse
output.url
- canonical url.parse
- single parse output.public boolean isEmpty()
public int size()
public Parse get(String key)
key
- sub-url under which the parse output is stored.public Parse get(org.apache.hadoop.io.Text key)
key
- sub-url under which the parse output is stored.public void put(org.apache.hadoop.io.Text key, ParseText text, ParseData data)
key
- URL or sub-url of this parse resulttext
- plain text resultdata
- corresponding parse metadata of this resultpublic void put(String key, ParseText text, ParseData data)
key
- URL or sub-url of this parse resulttext
- plain text resultdata
- corresponding parse metadata of this resultpublic Iterator<Map.Entry<org.apache.hadoop.io.Text,Parse>> iterator()
public void filter()
public boolean isSuccess()
ParseStatus#isSuccess()
.Copyright © 2014 The Apache Software Foundation