You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2013/04/03 19:40:03 UTC
[20/51] [partial] Mass convert mixed tabs to spaces
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/ByteSliceReader.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/ByteSliceReader.cs b/src/core/Index/ByteSliceReader.cs
index 8b672fe..c3d2044 100644
--- a/src/core/Index/ByteSliceReader.cs
+++ b/src/core/Index/ByteSliceReader.cs
@@ -22,164 +22,164 @@ using IndexOutput = Lucene.Net.Store.IndexOutput;
namespace Lucene.Net.Index
{
-
- /* IndexInput that knows how to read the byte slices written
- * by Posting and PostingVector. We read the bytes in
- * each slice until we hit the end of that slice at which
- * point we read the forwarding address of the next slice
- * and then jump to it.*/
- public sealed class ByteSliceReader : IndexInput
- {
- internal ByteBlockPool pool;
- internal int bufferUpto;
- internal byte[] buffer;
- public int upto;
- internal int limit;
- internal int level;
- public int bufferOffset;
-
- public int endIndex;
-
- public void Init(ByteBlockPool pool, int startIndex, int endIndex)
- {
-
- System.Diagnostics.Debug.Assert(endIndex - startIndex >= 0);
- System.Diagnostics.Debug.Assert(startIndex >= 0);
- System.Diagnostics.Debug.Assert(endIndex >= 0);
-
- this.pool = pool;
- this.endIndex = endIndex;
-
- level = 0;
- bufferUpto = startIndex / DocumentsWriter.BYTE_BLOCK_SIZE;
- bufferOffset = bufferUpto * DocumentsWriter.BYTE_BLOCK_SIZE;
- buffer = pool.buffers[bufferUpto];
- upto = startIndex & DocumentsWriter.BYTE_BLOCK_MASK;
-
- int firstSize = ByteBlockPool.levelSizeArray[0];
-
- if (startIndex + firstSize >= endIndex)
- {
- // There is only this one slice to read
- limit = endIndex & DocumentsWriter.BYTE_BLOCK_MASK;
- }
- else
- limit = upto + firstSize - 4;
- }
-
- public bool Eof()
- {
- System.Diagnostics.Debug.Assert(upto + bufferOffset <= endIndex);
- return upto + bufferOffset == endIndex;
- }
-
- public override byte ReadByte()
- {
- System.Diagnostics.Debug.Assert(!Eof());
- System.Diagnostics.Debug.Assert(upto <= limit);
- if (upto == limit)
- NextSlice();
- return buffer[upto++];
- }
-
- public long WriteTo(IndexOutput @out)
- {
- long size = 0;
- while (true)
- {
- if (limit + bufferOffset == endIndex)
- {
- System.Diagnostics.Debug.Assert(endIndex - bufferOffset >= upto);
- @out.WriteBytes(buffer, upto, limit - upto);
- size += limit - upto;
- break;
- }
- else
- {
- @out.WriteBytes(buffer, upto, limit - upto);
- size += limit - upto;
- NextSlice();
- }
- }
-
- return size;
- }
-
- public void NextSlice()
- {
-
- // Skip to our next slice
- int nextIndex = ((buffer[limit] & 0xff) << 24) + ((buffer[1 + limit] & 0xff) << 16) + ((buffer[2 + limit] & 0xff) << 8) + (buffer[3 + limit] & 0xff);
-
- level = ByteBlockPool.nextLevelArray[level];
- int newSize = ByteBlockPool.levelSizeArray[level];
-
- bufferUpto = nextIndex / DocumentsWriter.BYTE_BLOCK_SIZE;
- bufferOffset = bufferUpto * DocumentsWriter.BYTE_BLOCK_SIZE;
-
- buffer = pool.buffers[bufferUpto];
- upto = nextIndex & DocumentsWriter.BYTE_BLOCK_MASK;
-
- if (nextIndex + newSize >= endIndex)
- {
- // We are advancing to the final slice
- System.Diagnostics.Debug.Assert(endIndex - nextIndex > 0);
- limit = endIndex - bufferOffset;
- }
- else
- {
- // This is not the final slice (subtract 4 for the
- // forwarding address at the end of this new slice)
- limit = upto + newSize - 4;
- }
- }
-
- public override void ReadBytes(byte[] b, int offset, int len)
- {
- while (len > 0)
- {
- int numLeft = limit - upto;
- if (numLeft < len)
- {
- // Read entire slice
- Array.Copy(buffer, upto, b, offset, numLeft);
- offset += numLeft;
- len -= numLeft;
- NextSlice();
- }
- else
- {
- // This slice is the last one
- Array.Copy(buffer, upto, b, offset, len);
- upto += len;
- break;
- }
- }
- }
+
+ /* IndexInput that knows how to read the byte slices written
+ * by Posting and PostingVector. We read the bytes in
+ * each slice until we hit the end of that slice at which
+ * point we read the forwarding address of the next slice
+ * and then jump to it.*/
+ public sealed class ByteSliceReader : IndexInput
+ {
+ internal ByteBlockPool pool;
+ internal int bufferUpto;
+ internal byte[] buffer;
+ public int upto;
+ internal int limit;
+ internal int level;
+ public int bufferOffset;
+
+ public int endIndex;
+
+ public void Init(ByteBlockPool pool, int startIndex, int endIndex)
+ {
+
+ System.Diagnostics.Debug.Assert(endIndex - startIndex >= 0);
+ System.Diagnostics.Debug.Assert(startIndex >= 0);
+ System.Diagnostics.Debug.Assert(endIndex >= 0);
+
+ this.pool = pool;
+ this.endIndex = endIndex;
+
+ level = 0;
+ bufferUpto = startIndex / DocumentsWriter.BYTE_BLOCK_SIZE;
+ bufferOffset = bufferUpto * DocumentsWriter.BYTE_BLOCK_SIZE;
+ buffer = pool.buffers[bufferUpto];
+ upto = startIndex & DocumentsWriter.BYTE_BLOCK_MASK;
+
+ int firstSize = ByteBlockPool.levelSizeArray[0];
+
+ if (startIndex + firstSize >= endIndex)
+ {
+ // There is only this one slice to read
+ limit = endIndex & DocumentsWriter.BYTE_BLOCK_MASK;
+ }
+ else
+ limit = upto + firstSize - 4;
+ }
+
+ public bool Eof()
+ {
+ System.Diagnostics.Debug.Assert(upto + bufferOffset <= endIndex);
+ return upto + bufferOffset == endIndex;
+ }
+
+ public override byte ReadByte()
+ {
+ System.Diagnostics.Debug.Assert(!Eof());
+ System.Diagnostics.Debug.Assert(upto <= limit);
+ if (upto == limit)
+ NextSlice();
+ return buffer[upto++];
+ }
+
+ public long WriteTo(IndexOutput @out)
+ {
+ long size = 0;
+ while (true)
+ {
+ if (limit + bufferOffset == endIndex)
+ {
+ System.Diagnostics.Debug.Assert(endIndex - bufferOffset >= upto);
+ @out.WriteBytes(buffer, upto, limit - upto);
+ size += limit - upto;
+ break;
+ }
+ else
+ {
+ @out.WriteBytes(buffer, upto, limit - upto);
+ size += limit - upto;
+ NextSlice();
+ }
+ }
+
+ return size;
+ }
+
+ public void NextSlice()
+ {
+
+ // Skip to our next slice
+ int nextIndex = ((buffer[limit] & 0xff) << 24) + ((buffer[1 + limit] & 0xff) << 16) + ((buffer[2 + limit] & 0xff) << 8) + (buffer[3 + limit] & 0xff);
+
+ level = ByteBlockPool.nextLevelArray[level];
+ int newSize = ByteBlockPool.levelSizeArray[level];
+
+ bufferUpto = nextIndex / DocumentsWriter.BYTE_BLOCK_SIZE;
+ bufferOffset = bufferUpto * DocumentsWriter.BYTE_BLOCK_SIZE;
+
+ buffer = pool.buffers[bufferUpto];
+ upto = nextIndex & DocumentsWriter.BYTE_BLOCK_MASK;
+
+ if (nextIndex + newSize >= endIndex)
+ {
+ // We are advancing to the final slice
+ System.Diagnostics.Debug.Assert(endIndex - nextIndex > 0);
+ limit = endIndex - bufferOffset;
+ }
+ else
+ {
+ // This is not the final slice (subtract 4 for the
+ // forwarding address at the end of this new slice)
+ limit = upto + newSize - 4;
+ }
+ }
+
+ public override void ReadBytes(byte[] b, int offset, int len)
+ {
+ while (len > 0)
+ {
+ int numLeft = limit - upto;
+ if (numLeft < len)
+ {
+ // Read entire slice
+ Array.Copy(buffer, upto, b, offset, numLeft);
+ offset += numLeft;
+ len -= numLeft;
+ NextSlice();
+ }
+ else
+ {
+ // This slice is the last one
+ Array.Copy(buffer, upto, b, offset, len);
+ upto += len;
+ break;
+ }
+ }
+ }
- public override long FilePointer
- {
- get { throw new NotImplementedException(); }
- }
+ public override long FilePointer
+ {
+ get { throw new NotImplementedException(); }
+ }
- public override long Length()
- {
- throw new NotImplementedException();
- }
- public override void Seek(long pos)
- {
- throw new NotImplementedException();
- }
+ public override long Length()
+ {
+ throw new NotImplementedException();
+ }
+ public override void Seek(long pos)
+ {
+ throw new NotImplementedException();
+ }
protected override void Dispose(bool disposing)
{
// Do nothing...
}
-
- override public Object Clone()
- {
+
+ override public Object Clone()
+ {
System.Diagnostics.Debug.Fail("Port issue:", "Let see if we need this ByteSliceReader.Clone()"); // {{Aroush-2.9}}
- return null;
- }
- }
+ return null;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/ByteSliceWriter.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/ByteSliceWriter.cs b/src/core/Index/ByteSliceWriter.cs
index 86bbca0..0d9ecd5 100644
--- a/src/core/Index/ByteSliceWriter.cs
+++ b/src/core/Index/ByteSliceWriter.cs
@@ -19,79 +19,79 @@ using Lucene.Net.Support;
namespace Lucene.Net.Index
{
- /// <summary> Class to write byte streams into slices of shared
- /// byte[]. This is used by DocumentsWriter to hold the
- /// posting list for many terms in RAM.
- /// </summary>
- public sealed class ByteSliceWriter
- {
- private byte[] slice;
- private int upto;
- private readonly ByteBlockPool pool;
-
- internal int offset0;
-
- public ByteSliceWriter(ByteBlockPool pool)
- {
- this.pool = pool;
- }
-
- /// <summary> Set up the writer to write at address.</summary>
- public void Init(int address)
- {
- slice = pool.buffers[address >> DocumentsWriter.BYTE_BLOCK_SHIFT];
- System.Diagnostics.Debug.Assert(slice != null);
- upto = address & DocumentsWriter.BYTE_BLOCK_MASK;
- offset0 = address;
- System.Diagnostics.Debug.Assert(upto < slice.Length);
- }
-
- /// <summary>Write byte into byte slice stream </summary>
- public void WriteByte(byte b)
- {
- System.Diagnostics.Debug.Assert(slice != null);
- if (slice[upto] != 0)
- {
- upto = pool.AllocSlice(slice, upto);
- slice = pool.buffer;
- offset0 = pool.byteOffset;
- System.Diagnostics.Debug.Assert(slice != null);
- }
- slice[upto++] = b;
- System.Diagnostics.Debug.Assert(upto != slice.Length);
- }
-
- public void WriteBytes(byte[] b, int offset, int len)
- {
- int offsetEnd = offset + len;
- while (offset < offsetEnd)
- {
- if (slice[upto] != 0)
- {
- // End marker
- upto = pool.AllocSlice(slice, upto);
- slice = pool.buffer;
- offset0 = pool.byteOffset;
- }
-
- slice[upto++] = b[offset++];
- System.Diagnostics.Debug.Assert(upto != slice.Length);
- }
- }
+ /// <summary> Class to write byte streams into slices of shared
+ /// byte[]. This is used by DocumentsWriter to hold the
+ /// posting list for many terms in RAM.
+ /// </summary>
+ public sealed class ByteSliceWriter
+ {
+ private byte[] slice;
+ private int upto;
+ private readonly ByteBlockPool pool;
+
+ internal int offset0;
+
+ public ByteSliceWriter(ByteBlockPool pool)
+ {
+ this.pool = pool;
+ }
+
+ /// <summary> Set up the writer to write at address.</summary>
+ public void Init(int address)
+ {
+ slice = pool.buffers[address >> DocumentsWriter.BYTE_BLOCK_SHIFT];
+ System.Diagnostics.Debug.Assert(slice != null);
+ upto = address & DocumentsWriter.BYTE_BLOCK_MASK;
+ offset0 = address;
+ System.Diagnostics.Debug.Assert(upto < slice.Length);
+ }
+
+ /// <summary>Write byte into byte slice stream </summary>
+ public void WriteByte(byte b)
+ {
+ System.Diagnostics.Debug.Assert(slice != null);
+ if (slice[upto] != 0)
+ {
+ upto = pool.AllocSlice(slice, upto);
+ slice = pool.buffer;
+ offset0 = pool.byteOffset;
+ System.Diagnostics.Debug.Assert(slice != null);
+ }
+ slice[upto++] = b;
+ System.Diagnostics.Debug.Assert(upto != slice.Length);
+ }
+
+ public void WriteBytes(byte[] b, int offset, int len)
+ {
+ int offsetEnd = offset + len;
+ while (offset < offsetEnd)
+ {
+ if (slice[upto] != 0)
+ {
+ // End marker
+ upto = pool.AllocSlice(slice, upto);
+ slice = pool.buffer;
+ offset0 = pool.byteOffset;
+ }
+
+ slice[upto++] = b[offset++];
+ System.Diagnostics.Debug.Assert(upto != slice.Length);
+ }
+ }
- public int Address
- {
- get { return upto + (offset0 & DocumentsWriter.BYTE_BLOCK_NOT_MASK); }
- }
+ public int Address
+ {
+ get { return upto + (offset0 & DocumentsWriter.BYTE_BLOCK_NOT_MASK); }
+ }
- public void WriteVInt(int i)
- {
- while ((i & ~ 0x7F) != 0)
- {
- WriteByte((byte) ((i & 0x7f) | 0x80));
- i = Number.URShift(i, 7);
- }
- WriteByte((byte) i);
- }
- }
+ public void WriteVInt(int i)
+ {
+ while ((i & ~ 0x7F) != 0)
+ {
+ WriteByte((byte) ((i & 0x7f) | 0x80));
+ i = Number.URShift(i, 7);
+ }
+ WriteByte((byte) i);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/CharBlockPool.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/CharBlockPool.cs b/src/core/Index/CharBlockPool.cs
index 0631fe0..9a35743 100644
--- a/src/core/Index/CharBlockPool.cs
+++ b/src/core/Index/CharBlockPool.cs
@@ -19,51 +19,51 @@ using System;
namespace Lucene.Net.Index
{
-
- sealed class CharBlockPool
- {
- private void InitBlock()
- {
- charUpto = DocumentsWriter.CHAR_BLOCK_SIZE;
- }
-
- public char[][] buffers = new char[10][];
- internal int numBuffer;
-
- internal int bufferUpto = - 1; // Which buffer we are upto
- public int charUpto; // Where we are in head buffer
-
- public char[] buffer; // Current head buffer
- public int charOffset = - DocumentsWriter.CHAR_BLOCK_SIZE; // Current head offset
- private readonly DocumentsWriter docWriter;
-
- public CharBlockPool(DocumentsWriter docWriter)
- {
- InitBlock();
- this.docWriter = docWriter;
- }
-
- public void Reset()
- {
- docWriter.RecycleCharBlocks(buffers, 1 + bufferUpto);
- bufferUpto = - 1;
- charUpto = DocumentsWriter.CHAR_BLOCK_SIZE;
- charOffset = - DocumentsWriter.CHAR_BLOCK_SIZE;
- }
-
- public void NextBuffer()
- {
- if (1 + bufferUpto == buffers.Length)
- {
- var newBuffers = new char[(int) (buffers.Length * 1.5)][];
- Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
- buffers = newBuffers;
- }
- buffer = buffers[1 + bufferUpto] = docWriter.GetCharBlock();
- bufferUpto++;
-
- charUpto = 0;
- charOffset += DocumentsWriter.CHAR_BLOCK_SIZE;
- }
- }
+
+ sealed class CharBlockPool
+ {
+ private void InitBlock()
+ {
+ charUpto = DocumentsWriter.CHAR_BLOCK_SIZE;
+ }
+
+ public char[][] buffers = new char[10][];
+ internal int numBuffer;
+
+ internal int bufferUpto = - 1; // Which buffer we are upto
+ public int charUpto; // Where we are in head buffer
+
+ public char[] buffer; // Current head buffer
+ public int charOffset = - DocumentsWriter.CHAR_BLOCK_SIZE; // Current head offset
+ private readonly DocumentsWriter docWriter;
+
+ public CharBlockPool(DocumentsWriter docWriter)
+ {
+ InitBlock();
+ this.docWriter = docWriter;
+ }
+
+ public void Reset()
+ {
+ docWriter.RecycleCharBlocks(buffers, 1 + bufferUpto);
+ bufferUpto = - 1;
+ charUpto = DocumentsWriter.CHAR_BLOCK_SIZE;
+ charOffset = - DocumentsWriter.CHAR_BLOCK_SIZE;
+ }
+
+ public void NextBuffer()
+ {
+ if (1 + bufferUpto == buffers.Length)
+ {
+ var newBuffers = new char[(int) (buffers.Length * 1.5)][];
+ Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
+ buffers = newBuffers;
+ }
+ buffer = buffers[1 + bufferUpto] = docWriter.GetCharBlock();
+ bufferUpto++;
+
+ charUpto = 0;
+ charOffset += DocumentsWriter.CHAR_BLOCK_SIZE;
+ }
+ }
}
\ No newline at end of file