Package org.apache.pig.piggybank.storage.IndexedStorage.IndexedStorageInputFormat

Examples of org.apache.pig.piggybank.storage.IndexedStorage.IndexedStorageInputFormat.IndexedStorageRecordReader


         * (faster than doing a Utils sort).
     */
    private void sortReader(int startIndex) {
        int idx = startIndex;
        while (idx < this.readers.length - 1) {
            IndexedStorageRecordReader reader1 = this.readers[idx];
            IndexedStorageRecordReader reader2 = this.readers[idx+1];
            if (this.readerComparator.compare(reader1, reader2) <= 0) {
                return;
            }
            this.readers[idx] = reader2;
            this.readers[idx+1] = reader1;
View Full Code Here


        if (this.readers == null) {
            return super.getNext();
        }

        while (currentReaderIndexStart < this.readers.length) {
            IndexedStorageRecordReader r = this.readers[currentReaderIndexStart];

            this.prepareToRead(r, null);
            Tuple tuple = super.getNext();
            if (tuple == null) {
                currentReaderIndexStart++;
                r.close();
                continue; //next Reader
            }

            //if we haven't yet initialized the indexManager (by reading the first index key)
            if (r.indexManager.lastIndexKeyTuple == null) {

                //initialize the indexManager
                if (r.indexManager.ReadIndex() == null) {
                    //There should never be a case where there is a non-null record - but no corresponding index.
                    throw new IOException("Missing Index for Tuple: " + tuple);
                }
            }

            r.indexManager.numberOfTuples--;

            if (r.indexManager.numberOfTuples == 0) {
                if (r.indexManager.ReadIndex() == null) {
                    r.close();
                    currentReaderIndexStart++;
                } else {
                    //Since the index of the current reader was increased, we may need to push the
                    //current reader back in the sorted list of readers.
                    sortReader(currentReaderIndexStart);
View Full Code Here

            int idx = 0;
            Iterator<FileSplit> it = fileSplits.iterator();
            while (it.hasNext()) {
                FileSplit fileSplit = it.next();
                TaskAttemptContext context = HadoopShims.createTaskAttemptContext(conf, id);
                IndexedStorageRecordReader r = (IndexedStorageRecordReader) inputFormat.createRecordReader(fileSplit, context);
                r.initialize(fileSplit, context);
                this.readers[idx] = r;
                idx++;
            }

            Arrays.sort(this.readers, this.readerComparator);
View Full Code Here

        /* Keeps track of the last (if any) reader where seekNear was called */
        int lastIndexModified = -1;

        int idx = currentReaderIndexStart;
        while (idx < this.readers.length) {
            IndexedStorageRecordReader r = this.readers[idx];

            /* The key falls within the range of the reader index */
            if (keys.compareTo(r.indexManager.maxIndexKeyTuple) <= 0 && keys.compareTo(r.indexManager.minIndexKeyTuple) >= 0) {
                r.seekNear(keys);
                lastIndexModified = idx;

            /* The key is greater than the current range of the reader index */
            } else if (keys.compareTo(r.indexManager.maxIndexKeyTuple) > 0) {
                currentReaderIndexStart++;
View Full Code Here

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return new IndexedStorageRecordReader(im);
        }
View Full Code Here

         * (faster than doing a Utils sort).
   */
  private void sortReader(int startIndex) {
    int idx = startIndex;
    while (idx < this.readers.length - 1) {
      IndexedStorageRecordReader reader1 = this.readers[idx];
      IndexedStorageRecordReader reader2 = this.readers[idx+1];
      if (this.readerComparator.compare(reader1, reader2) <= 0) {
        return;
      }
      this.readers[idx] = reader2;
      this.readers[idx+1] = reader1;
View Full Code Here

    if (this.readers == null) {
      return super.getNext();
    }

    while (currentReaderIndexStart < this.readers.length) {
      IndexedStorageRecordReader r = this.readers[currentReaderIndexStart];

      this.prepareToRead(r, null);
      Tuple tuple = super.getNext();
      if (tuple == null) {
        currentReaderIndexStart++;
        r.close();
        continue; //next Reader
      }
   
      //if we haven't yet initialized the indexManager (by reading the first index key) 
      if (r.indexManager.lastIndexKeyTuple == null) {

        //initialize the indexManager
        if (r.indexManager.ReadIndex() == null) {
          //There should never be a case where there is a non-null record - but no corresponding index.
          throw new IOException("Missing Index for Tuple: " + tuple);
        }
      }

      r.indexManager.numberOfTuples--;

      if (r.indexManager.numberOfTuples == 0) {
        if (r.indexManager.ReadIndex() == null) {
          r.close();
          currentReaderIndexStart++;
        } else {
          //Since the index of the current reader was increased, we may need to push the
          //current reader back in the sorted list of readers.
          sortReader(currentReaderIndexStart);
View Full Code Here

      int idx = 0;
      Iterator<FileSplit> it = fileSplits.iterator();
      while (it.hasNext()) {
        FileSplit fileSplit = it.next();
        TaskAttemptContext context = HadoopShims.createTaskAttemptContext(conf, id);
        IndexedStorageRecordReader r = (IndexedStorageRecordReader) inputFormat.createRecordReader(fileSplit, context);
        r.initialize(fileSplit, context);
        this.readers[idx] = r;
        idx++;
      }

      Arrays.sort(this.readers, this.readerComparator);
View Full Code Here

    /* Keeps track of the last (if any) reader where seekNear was called */
    int lastIndexModified = -1;

    int idx = currentReaderIndexStart;
    while (idx < this.readers.length) {
      IndexedStorageRecordReader r = this.readers[idx];

      /* The key falls within the range of the reader index */
      if (keys.compareTo(r.indexManager.maxIndexKeyTuple) <= 0 && keys.compareTo(r.indexManager.minIndexKeyTuple) >= 0) {
        r.seekNear(keys);
        lastIndexModified = idx;

      /* The key is greater than the current range of the reader index */
      } else if (keys.compareTo(r.indexManager.maxIndexKeyTuple) > 0) {
        currentReaderIndexStart++;
View Full Code Here

      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return new IndexedStorageRecordReader(im);
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.piggybank.storage.IndexedStorage.IndexedStorageInputFormat.IndexedStorageRecordReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.