Revision 45819
Added by Giorgos Alexiou about 7 years ago
LodImportMapper.java | ||
---|---|---|
45 | 45 |
protected void setup(Mapper.Context context) throws IOException, InterruptedException { |
46 | 46 |
|
47 | 47 |
this.fileName = context.getConfiguration().get("lod.inputFile"); |
48 |
this.lastExecutionDate = context.getConfiguration().get("lod.lastExecutionDate"); |
|
49 | 48 |
|
50 | 49 |
this.hadoopConf = context.getConfiguration(); |
51 | 50 |
|
52 |
if (fileName.contains("entities")) { |
|
53 |
defaultGraph = hadoopConf.get("lod.defaultGraph"); |
|
54 |
entitiesPerQuery = Integer.parseInt(hadoopConf.get("lod.entitiesPerQuery")); |
|
55 |
} else { |
|
56 |
defaultGraph = hadoopConf.get("lod.relationsGraph"); |
|
57 |
entitiesPerQuery = Integer.parseInt(hadoopConf.get("lod.relationsPerQuery")); |
|
58 |
} |
|
59 |
|
|
60 |
baseURI = hadoopConf.get("lod.baseURI"); |
|
61 |
|
|
62 | 51 |
try { |
63 | 52 |
DB db = new DB(); |
64 | 53 |
ds = db.getDatasource(hadoopConf.get("lod.conLine"), hadoopConf.get("lod.username"), hadoopConf.get("lod.password"), "1", "1", "1"); |
... | ... | |
70 | 59 |
stmt1 = conn.createStatement(); |
71 | 60 |
stmt1.execute("__dbf_set ('enable_qp', 1)"); |
72 | 61 |
stmt1.close(); |
62 |
conn.close(); |
|
73 | 63 |
|
74 |
|
|
75 | 64 |
} catch (Exception e) { |
76 | 65 |
log.error(e.toString(), e); |
77 | 66 |
|
... | ... | |
87 | 76 |
if (split.length > 1) { |
88 | 77 |
Text outputKey = null; |
89 | 78 |
Text outputValue = null; |
90 |
String resourceURI = ""; |
|
91 | 79 |
try { |
92 | 80 |
outputKey = new Text(split[1]); |
93 | 81 |
outputValue = new Text(value.toString().replace("\\", " ")); |
94 |
resourceURI = baseURI + split[0] + "/" + split[1]; |
|
95 | 82 |
} catch (Exception e) { |
96 | 83 |
log.error(split.toString(), e); |
97 | 84 |
} |
... | ... | |
110 | 97 |
@Override |
111 | 98 |
protected void cleanup(Context context) throws IOException, InterruptedException { |
112 | 99 |
super.cleanup(context); |
113 |
try { |
|
114 |
conn.close(); |
|
115 |
} catch (SQLException e) { |
|
116 |
log.error(e.toString(), e); |
|
100 |
if(conn!=null){ |
|
101 |
try { |
|
102 |
conn.close(); |
|
103 |
} catch (SQLException e) { |
|
104 |
log.error(e.toString(), e); |
|
105 |
} |
|
117 | 106 |
} |
118 |
|
|
119 | 107 |
} |
120 | 108 |
|
121 | 109 |
private void writeOut(Context context, Text outputKey, Text outputValue) throws IOException, InterruptedException { |
Also available in: Unified diff
performance improvements + language to datasource