/** * get an Iterator containing the abouts for the nativeItem * * @param nativeItem * @return an Iterator containing the list of about values for this nativeItem */ private Iterator getAbouts(Map<String, Object> nativeItem) throws OAIInternalServerError { StatementResultSet stmtRs = null; try { List<String> abouts = new ArrayList<String>(); if (aboutQuery != null) { RecordFactory rf = getRecordFactory(); String oaiIdentifier = rf.getOAIIdentifier(nativeItem); stmtRs = new StatementResultSet(populateAboutQuery(oaiIdentifier)); while (stmtRs.next()) { Map<String, Object> aboutMap = stmtRs.getColumnValues(); abouts.add((String) aboutMap.get(aboutValueLabel)); } } return abouts.iterator(); } catch (SQLException e) { LOGGER.error("An Exception occured", e); throw new OAIInternalServerError(e.getMessage()); } finally { try { stmtRs.close(); } catch (SQLException e) { LOGGER.error("An Exception occured", e); throw new OAIInternalServerError(e.getMessage()); } } }
@Override public void cleanup(Context context) throws IOException, InterruptedException { for (RecordFactory factory : reduces) { key.setSeed(r.nextLong()); while (factory.next(key, val)) { context.write(key, val); key.setSeed(r.nextLong()); } } }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { val.setSeed(r.nextLong()); while (factory.next(null, val)) { context.write(NullWritable.get(), val); val.setSeed(r.nextLong()); } }
@Override public void map(NullWritable ignored, GridmixRecord rec, Context context) throws IOException, InterruptedException { acc += ratio; while (acc >= 1.0 && !reduces.isEmpty()) { key.setSeed(r.nextLong()); val.setSeed(r.nextLong()); final int idx = r.nextInt(reduces.size()); final RecordFactory f = reduces.get(idx); if (!f.next(key, val)) { reduces.remove(idx); continue; } context.write(key, val); acc -= 1.0; } }
@Override protected void reduce(GridmixKey key, Iterable<GridmixRecord> values, Context context) throws IOException, InterruptedException { for (GridmixRecord ignored : values) { acc += ratio; while (acc >= 1.0 && factory.next(null, val)) { context.write(NullWritable.get(), val); acc -= 1.0; } } }
@Override public void close() throws IOException { factory.close(); }
@Override public float getProgress() throws IOException { return factory.getProgress(); }
@Override public boolean nextKeyValue() throws IOException { val.setSeed(r.nextLong()); return factory.next(null, val); }