MCPcopy Create free account
hub / github.com/apache/nutch / read

Method read

src/java/org/apache/nutch/host/HostDbReader.java:44–71  ·  view source on GitHub ↗
(String key)

Source from the content-addressed store, hash-verified

42 .getLogger(MethodHandles.lookup().lookupClass());
43
44 private void read(String key) throws ClassNotFoundException, IOException,
45 Exception {
46
47 DataStore<String, Host> datastore = StorageUtils.createWebStore(getConf(),
48 String.class, Host.class);
49
50 Query<String, Host> query = datastore.newQuery();
51 // possibly add a contraint to the query
52 if (key != null) {
53 query.setKey(TableUtil.reverseUrl(key));
54 }
55 // query.setFields(Host._ALL_FIELDS);
56 Result<String, Host> result = datastore.execute(query);
57
58 while (result.next()) {
59 String hostName = null;
60 try {
61 hostName = TableUtil.unreverseUrl(result.getKey());
62 Host host = result.get();
63 System.out.println(hostName);
64 System.out.println(host);
65 } catch (Exception e) {
66 LOG.error("Failed to get host from hostname {}: {}", hostName, e.getMessage());
67 }
68 }
69 result.close();
70 datastore.close();
71 }
72
73 public static void main(String[] args) throws Exception {
74 int res = ToolRunner.run(NutchConfiguration.create(), new HostDbReader(),

Callers 1

runMethod · 0.95

Calls 10

createWebStoreMethod · 0.95
reverseUrlMethod · 0.95
unreverseUrlMethod · 0.95
getKeyMethod · 0.80
errorMethod · 0.80
getMethod · 0.65
closeMethod · 0.65
getConfMethod · 0.45
nextMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected