package edu.umass.cs.ciir.waltz.io.galago;

import edu.umass.cs.ciir.waltz.io.streams.SkipInputStream;
import edu.umass.cs.ciir.waltz.io.streams.StaticStream;
import org.lemurproject.galago.utility.btree.disk.DiskBTreeIterator;
import org.lemurproject.galago.utility.buffer.CachedBufferDataStream;
import org.lemurproject.galago.utility.buffer.ReadableBuffer;

import java.io.IOException;

/**
* @author jfoley
*/
class ReadableBufferStaticStream implements StaticStream {
  private final long start;
  private final long end;
  private final ReadableBuffer file;

  public ReadableBufferStaticStream(DiskBTreeIterator iterator) throws IOException {
    this.start = iterator.getValueStart();
    this.end = iterator.getValueEnd();
    this.file = iterator.input;
  }

  @Override
  public SkipInputStream getNewStream() {
    return new GalagoSkipInputStream(new CachedBufferDataStream(file, start, end));
  }

  @Override
  public long length() {
    return end - start;
  }
}

@@ -558,16 +558,71 @@
  file;%0A%0A
+  // Convenience method, probably shouldn't be here...%0A
   public
@@ -710,16 +710,24 @@
 this
-.start =
+(iterator.input,
  ite
@@ -751,24 +751,9 @@
 rt()
-;%0A    this.end =
+,
  ite
@@ -775,40 +775,179 @@
 nd()
+)
 ;%0A  
-  this.file = iterator.input
+%7D%0A  public ReadableBufferStaticStream(ReadableBuffer file, long start, long end) throws IOException %7B%0A    this.start = start;%0A    this.end = end;%0A    this.file = file
 ;%0A  

Make a better public constructor for that thing.