예제 #1
0
 /**
  * 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());
     }
   }
 }
예제 #2
0
 @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());
     }
   }
 }
예제 #3
0
 @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());
   }
 }
예제 #4
0
 @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;
   }
 }
예제 #5
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;
     }
   }
 }
예제 #6
0
 @Override
 public void close() throws IOException {
   factory.close();
 }
예제 #7
0
 @Override
 public float getProgress() throws IOException {
   return factory.getProgress();
 }
예제 #8
0
 @Override
 public boolean nextKeyValue() throws IOException {
   val.setSeed(r.nextLong());
   return factory.next(null, val);
 }