コード例 #1
0
  private Object nextInternal() {
    //    if(!hasNext()){
    //      throw new NoSuchElementException("LeadsIntermediateIterator the iterator does not have
    // next");
    //    }
    //    System.err.println("in next ");
    //    log.error(baseIntermKey.toString());
    if (baseIntermKey == null || chunkIterator == null) {
      throw new NoSuchElementException("LeadIntermediateIterator no more Elements");
      // return null;
    }
    V returnValue = (V) intermediateDataCache.get(new ComplexIntermediateKey(baseIntermKey));
    if (returnValue == null) {

      if (chunkIterator.hasNext()) {
        currentChunk = chunkIterator.next();
        baseIntermKey = new ComplexIntermediateKey(currentChunk);
        return nextInternal();
      } else {
        baseIntermKey = null;
        currentChunk = null;
        throw new NoSuchElementException("LeadIntermediateIterator no more Elements");
      }
      //      System.err.println("\n\n\nERROR NULL GET FROM intermediate data cache " +
      // baseIntermKey.toString() + "\n cache size = " + intermediateDataCache.size());
      //      throw new NoSuchElementException("LeadsIntermediateIterator read from cache returned
      // NULL");
    } else {
      baseIntermKey.next();
    }
    //    baseIntermKey = baseIntermKey.next();
    //    Object o = intermediateDataCache.get(baseIntermKey);
    //    if(o == null){
    //
    //    if(!intermediateDataCache.containsKey(new ComplexIntermediateKey(baseIntermKey))){
    //      if(chunkIterator.hasNext()) {
    //        currentChunk = chunkIterator.next();
    //        baseIntermKey = new ComplexIntermediateKey(currentChunk);
    //      }
    //      else{
    //        baseIntermKey = null;
    //        currentChunk = null;
    //      }
    //
    //
    //    }
    if (returnValue != null) {
      //      System.err.println("out next ");
      return returnValue;
    } else {
      //      if(chunkIterator.hasNext()) {
      //        System.err.println("TbaseInterm Key is not contained and chunkIterator has NeXt");
      //        System.err.println(this.toString());
      //      }
      //      currentChunk = null;
      throw new NoSuchElementException("LeadsIntermediateIterator return Value NULL at the end");
    }
  }