23 namespace Lucene.Net.Index
34 internal int bufferUpto;
35 internal byte[] buffer;
46 System.Diagnostics.Debug.Assert(endIndex - startIndex >= 0);
47 System.Diagnostics.Debug.Assert(startIndex >= 0);
48 System.Diagnostics.Debug.Assert(endIndex >= 0);
51 this.endIndex = endIndex;
56 buffer = pool.
buffers[bufferUpto];
61 if (startIndex + firstSize >= endIndex)
67 limit = upto + firstSize - 4;
72 System.Diagnostics.Debug.Assert(upto + bufferOffset <= endIndex);
73 return upto + bufferOffset == endIndex;
76 public override byte ReadByte()
78 System.Diagnostics.Debug.Assert(!Eof());
79 System.Diagnostics.Debug.Assert(upto <= limit);
82 return buffer[upto++];
90 if (limit + bufferOffset == endIndex)
92 System.Diagnostics.Debug.Assert(endIndex - bufferOffset >= upto);
93 @out.WriteBytes(buffer, upto, limit - upto);
99 @out.WriteBytes(buffer, upto, limit - upto);
100 size += limit - upto;
108 public void NextSlice()
112 int nextIndex = ((buffer[limit] & 0xff) << 24) + ((buffer[1 + limit] & 0xff) << 16) + ((buffer[2 + limit] & 0xff) << 8) + (buffer[3 + limit] & 0xff);
120 buffer = pool.buffers[bufferUpto];
123 if (nextIndex + newSize >= endIndex)
126 System.Diagnostics.Debug.Assert(endIndex - nextIndex > 0);
127 limit = endIndex - bufferOffset;
133 limit = upto + newSize - 4;
137 public override void ReadBytes(byte[] b,
int offset,
int len)
141 int numLeft = limit - upto;
145 Array.Copy(buffer, upto, b, offset, numLeft);
153 Array.Copy(buffer, upto, b, offset, len);
160 public override long FilePointer
162 get {
throw new NotImplementedException(); }
165 public override long Length()
167 throw new NotImplementedException();
169 public override void Seek(
long pos)
171 throw new NotImplementedException();
174 protected override void Dispose(
bool disposing)
179 override public Object Clone()
181 System.Diagnostics.Debug.Fail(
"Port issue:",
"Let see if we need this ByteSliceReader.Clone()");