You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/11/10 16:25:26 UTC
[4/5] lucenenet git commit: Getting rid of most sbyte usage in public
API
Getting rid of most sbyte usage in public API
(unsigned) byte is the native C# type and what we should support really, and also for CLS compliance
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/139ad812
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/139ad812
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/139ad812
Branch: refs/heads/master
Commit: 139ad812a8079e865733ad13a52682dd333ebee9
Parents: a159335
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Mon Nov 10 17:24:49 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Mon Nov 10 17:24:49 2014 +0200
----------------------------------------------------------------------
.../Codecs/BlockTreeTermsReader.cs | 10 +--
.../Codecs/BlockTreeTermsWriter.cs | 4 +-
.../CompressingStoredFieldsReader.cs | 4 +-
.../Compressing/CompressingTermVectorsWriter.cs | 2 +-
.../Codecs/Compressing/CompressionMode.cs | 14 ++--
.../Codecs/Compressing/Compressor.cs | 2 +-
src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs | 33 ++++-----
.../Codecs/Lucene3x/Lucene3xFields.cs | 56 +++++++--------
.../Lucene3x/Lucene3xStoredFieldsReader.cs | 4 +-
.../Codecs/Lucene40/Lucene40DocValuesReader.cs | 2 +-
.../Codecs/Lucene40/Lucene40PostingsReader.cs | 2 +-
.../Lucene40/Lucene40StoredFieldsReader.cs | 2 +-
.../Lucene40/Lucene40TermVectorsReader.cs | 32 ++++-----
src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs | 7 +-
.../Codecs/Lucene41/Lucene41PostingsReader.cs | 16 ++---
.../Codecs/Lucene41/Lucene41PostingsWriter.cs | 4 +-
.../Lucene42/Lucene42DocValuesProducer.cs | 6 +-
.../Lucene45/Lucene45DocValuesProducer.cs | 6 +-
src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs | 2 +-
.../Document/CompressionTools.cs | 28 ++++----
.../Document/DocumentStoredFieldVisitor.cs | 2 +-
src/Lucene.Net.Core/Document/Field.cs | 30 ++------
src/Lucene.Net.Core/Document/StoredField.cs | 4 +-
src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs | 10 +--
src/Lucene.Net.Core/Index/ByteSliceReader.cs | 2 +-
src/Lucene.Net.Core/Index/ByteSliceWriter.cs | 6 +-
.../Index/FreqProxTermsWriterPerField.cs | 2 +-
.../Index/SortedDocValuesTermsEnum.cs | 4 +-
.../Index/SortedSetDocValuesTermsEnum.cs | 4 +-
src/Lucene.Net.Core/Index/StoredFieldVisitor.cs | 2 +-
src/Lucene.Net.Core/Index/TermsHashPerField.cs | 9 ++-
src/Lucene.Net.Core/Search/FieldComparator.cs | 4 +-
.../Search/Payloads/PayloadNearQuery.cs | 27 ++++---
.../Search/Payloads/PayloadSpanUtil.cs | 15 ++--
.../Search/Spans/NearSpansOrdered.cs | 20 +++---
.../Search/Spans/NearSpansUnordered.cs | 10 +--
.../Search/Spans/SpanNearPayloadCheckQuery.cs | 12 ++--
.../Search/Spans/SpanNotQuery.cs | 10 +--
src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs | 6 +-
.../Search/Spans/SpanPayloadCheckQuery.cs | 12 ++--
.../Search/Spans/SpanPositionCheckQuery.cs | 8 +--
src/Lucene.Net.Core/Search/Spans/Spans.cs | 3 +-
src/Lucene.Net.Core/Search/Spans/TermSpans.cs | 10 +--
src/Lucene.Net.Core/Store/DataOutput.cs | 9 ++-
src/Lucene.Net.Core/Store/FSDirectory.cs | 2 +-
.../Store/NativeFSLockFactory.cs | 2 +-
src/Lucene.Net.Core/Store/RAMOutputStream.cs | 2 +-
src/Lucene.Net.Core/Support/StringSupport.cs | 5 +-
src/Lucene.Net.Core/Util/ArrayUtil.cs | 13 ++--
.../Util/Automaton/ByteRunAutomaton.cs | 8 +--
.../Util/Automaton/CompiledAutomaton.cs | 10 +--
.../Util/Automaton/SpecialOperations.cs | 4 +-
src/Lucene.Net.Core/Util/BitUtil.cs | 12 +---
src/Lucene.Net.Core/Util/ByteBlockPool.cs | 52 +++++++-------
src/Lucene.Net.Core/Util/BytesRef.cs | 28 ++++----
src/Lucene.Net.Core/Util/BytesRefHash.cs | 12 ++--
src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs | 2 +-
src/Lucene.Net.Core/Util/Fst/FST.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/Util.cs | 2 +-
.../Util/GrowableByteArrayDataOutput.cs | 6 +-
src/Lucene.Net.Core/Util/NumericUtils.cs | 18 ++---
src/Lucene.Net.Core/Util/OpenBitSetIterator.cs | 2 +-
src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs | 18 ++---
.../Util/Packed/AbstractBlockPackedWriter.cs | 4 +-
.../Util/Packed/BlockPackedReaderIterator.cs | 6 +-
.../Util/Packed/BulkOperation.cs | 12 ++--
.../Util/Packed/BulkOperationPacked.cs | 16 ++---
.../Util/Packed/BulkOperationPacked1.cs | 8 +--
.../Util/Packed/BulkOperationPacked10.cs | 4 +-
.../Util/Packed/BulkOperationPacked11.cs | 4 +-
.../Util/Packed/BulkOperationPacked12.cs | 4 +-
.../Util/Packed/BulkOperationPacked13.cs | 4 +-
.../Util/Packed/BulkOperationPacked14.cs | 4 +-
.../Util/Packed/BulkOperationPacked15.cs | 4 +-
.../Util/Packed/BulkOperationPacked16.cs | 4 +-
.../Util/Packed/BulkOperationPacked17.cs | 4 +-
.../Util/Packed/BulkOperationPacked18.cs | 4 +-
.../Util/Packed/BulkOperationPacked19.cs | 4 +-
.../Util/Packed/BulkOperationPacked2.cs | 8 +--
.../Util/Packed/BulkOperationPacked20.cs | 4 +-
.../Util/Packed/BulkOperationPacked21.cs | 4 +-
.../Util/Packed/BulkOperationPacked22.cs | 4 +-
.../Util/Packed/BulkOperationPacked23.cs | 4 +-
.../Util/Packed/BulkOperationPacked24.cs | 4 +-
.../Util/Packed/BulkOperationPacked3.cs | 4 +-
.../Util/Packed/BulkOperationPacked4.cs | 8 +--
.../Util/Packed/BulkOperationPacked5.cs | 4 +-
.../Util/Packed/BulkOperationPacked6.cs | 4 +-
.../Util/Packed/BulkOperationPacked7.cs | 4 +-
.../Util/Packed/BulkOperationPacked8.cs | 4 +-
.../Util/Packed/BulkOperationPacked9.cs | 4 +-
.../Packed/BulkOperationPackedSingleBlock.cs | 15 ++--
src/Lucene.Net.Core/Util/Packed/PackedInts.cs | 8 +--
.../Util/Packed/PackedReaderIterator.cs | 6 +-
src/Lucene.Net.Core/Util/Packed/PackedWriter.cs | 4 +-
src/Lucene.Net.Core/Util/PagedBytes.cs | 48 ++++++-------
.../Util/RecyclingByteBlockAllocator.cs | 14 ++--
src/Lucene.Net.Core/Util/StringHelper.cs | 14 ++--
src/Lucene.Net.Core/Util/ToStringUtils.cs | 2 +-
src/Lucene.Net.Core/Util/UnicodeUtil.cs | 75 ++++++++++----------
src/Lucene.Net.Queries/TermsFilter.cs | 4 +-
.../Analysis/MockFixedLengthPayloadFilter.cs | 4 +-
.../Analysis/MockUTF16TermAttributeImpl.cs | 2 +-
.../Analysis/MockVariableLengthPayloadFilter.cs | 2 +-
.../compressing/dummy/DummyCompressingCodec.cs | 4 +-
.../lucene42/Lucene42DocValuesConsumer.cs | 2 +-
.../Codecs/ramonly/RAMOnlyPostingsFormat.cs | 12 ++--
.../Index/BaseDocValuesFormatTestCase.cs | 52 +++++++-------
.../Index/BasePostingsFormatTestCase.cs | 2 +-
.../Index/BaseStoredFieldsFormatTestCase.cs | 22 +++---
src/Lucene.Net.TestFramework/Index/DocHelper.cs | 2 +-
.../Index/FieldFilterAtomicReader.cs | 4 +-
.../Util/LuceneTestCase.cs | 4 +-
.../Util/fst/FSTTester.cs | 2 +-
src/Lucene.Net.Tests/core/Analysis/TestToken.cs | 4 +-
.../Compressing/AbstractTestCompressionMode.cs | 60 ++++++++--------
.../AbstractTestLZ4CompressionMode.cs | 14 ++--
.../Compressing/TestFastDecompressionMode.cs | 6 +-
.../Codecs/Lucene41/TestBlockPostingsFormat3.cs | 2 +-
.../core/Codecs/Lucene41/TestForUtil.cs | 4 +-
.../core/Document/TestBinaryDocument.cs | 6 +-
.../core/Document/TestDocument.cs | 2 +-
src/Lucene.Net.Tests/core/Document/TestField.cs | 2 +-
.../core/Index/Test2BBinaryDocValues.cs | 24 +++----
.../core/Index/Test2BSortedDocValues.cs | 28 ++++----
src/Lucene.Net.Tests/core/Index/Test2BTerms.cs | 2 +-
.../core/Index/Test4GBStoredFields.cs | 4 +-
.../core/Index/TestBinaryDocValuesUpdates.cs | 6 +-
.../core/Index/TestBinaryTerms.cs | 10 +--
src/Lucene.Net.Tests/core/Index/TestCodecs.cs | 4 +-
.../core/Index/TestConsistentFieldNumbers.cs | 4 +-
.../core/Index/TestDirectoryReader.cs | 2 +-
.../core/Index/TestDocValuesIndexing.cs | 8 +--
.../core/Index/TestDocumentWriter.cs | 2 +-
.../core/Index/TestIndexWriter.cs | 4 +-
.../core/Index/TestIndexWriterExceptions.cs | 2 +-
.../core/Index/TestIndexWriterUnicode.cs | 4 +-
.../core/Index/TestIndexableField.cs | 4 +-
.../core/Index/TestMultiLevelSkipList.cs | 2 +-
src/Lucene.Net.Tests/core/Index/TestPayloads.cs | 50 ++++++-------
.../core/Search/Payloads/PayloadHelper.cs | 6 +-
.../Search/Payloads/TestPayloadNearQuery.cs | 4 +-
.../Search/Payloads/TestPayloadTermQuery.cs | 8 +--
.../core/Search/Spans/JustCompileSearchSpans.cs | 4 +-
.../core/Search/Spans/MultiSpansWrapper.cs | 10 +--
.../core/Search/Spans/TestBasics.cs | 10 +--
.../core/Search/Spans/TestPayloadSpans.cs | 32 ++++-----
.../core/Search/TestPositionIncrement.cs | 10 +--
.../core/Store/TestMultiMMap.cs | 26 +++----
.../Util/Automaton/TestDeterminizeLexicon.cs | 2 +-
.../core/Util/Automaton/TestUTF32ToUTF8.cs | 6 +-
src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs | 4 +-
.../core/Util/Test2BPagedBytes.cs | 4 +-
src/Lucene.Net.Tests/core/Util/TestBytesRef.cs | 6 +-
.../core/Util/TestBytesRefHash.cs | 4 +-
.../Util/TestRecyclingByteBlockAllocator.cs | 22 +++---
.../core/Util/TestUnicodeUtil.cs | 8 +--
157 files changed, 758 insertions(+), 777 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
index b56fb28..154d23c 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
@@ -171,7 +171,7 @@ namespace Lucene.Net.Codecs
long numTerms = @in.ReadVLong();
Debug.Assert(numTerms >= 0);
int numBytes = @in.ReadVInt();
- BytesRef rootCode = new BytesRef(new sbyte[numBytes]);
+ BytesRef rootCode = new BytesRef(new byte[numBytes]);
@in.ReadBytes(rootCode.Bytes, 0, numBytes);
rootCode.Length = numBytes;
FieldInfo fieldInfo = fieldInfos.FieldInfo(field);
@@ -1395,7 +1395,7 @@ namespace Lucene.Net.Codecs
// A prefix of the common suffix overlaps with
// the suffix of the block prefix so we first
// test whether the prefix part matches:
- sbyte[] termBytes = Term_Renamed.Bytes;
+ byte[] termBytes = Term_Renamed.Bytes;
int termBytesPos = CurrentFrame.Prefix - lenInPrefix;
Debug.Assert(termBytesPos >= 0);
int termBytesPosEnd = CurrentFrame.Prefix;
@@ -2023,7 +2023,7 @@ namespace Lucene.Net.Codecs
if (!CurrentFrame.HasTerms)
{
TermExists = false;
- Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+ Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
Term_Renamed.Length = 1 + targetUpto;
// if (DEBUG) {
// System.out.println(" FAST NOT_FOUND term=" + brToString(term));
@@ -2053,7 +2053,7 @@ namespace Lucene.Net.Codecs
{
// Follow this arc
arc = nextArc;
- Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+ Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
// Aggregate output as we go:
Debug.Assert(arc.Output != null);
if (arc.Output != OuterInstance.OuterInstance.NO_OUTPUT)
@@ -2339,7 +2339,7 @@ namespace Lucene.Net.Codecs
else
{
// Follow this arc
- Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+ Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
arc = nextArc;
// Aggregate output as we go:
Debug.Assert(arc.Output != null);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
index 62f879a..f70fa8b 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
@@ -453,7 +453,7 @@ namespace Lucene.Net.Codecs
ByteSequenceOutputs outputs = ByteSequenceOutputs.Singleton;
Builder<BytesRef> indexBuilder = new Builder<BytesRef>(FST<BytesRef>.INPUT_TYPE.BYTE1, 0, 0, true, false, int.MaxValue, outputs, null, false, PackedInts.COMPACT, true, 15);
- sbyte[] bytes = new sbyte[(int)scratchBytes.FilePointer];
+ var bytes = new byte[(int)scratchBytes.FilePointer];
Debug.Assert(bytes.Length > 0);
scratchBytes.WriteTo(bytes, 0);
indexBuilder.Add(Util.ToIntsRef(Prefix, ScratchIntsRef), new BytesRef(bytes, 0, bytes.Length));
@@ -885,7 +885,7 @@ namespace Lucene.Net.Codecs
BytesRef prefix = new BytesRef(indexPrefixLength);
for (int m = 0; m < indexPrefixLength; m++)
{
- prefix.Bytes[m] = (sbyte)prevTerm.Ints[m];
+ prefix.Bytes[m] = (byte)prevTerm.Ints[m];
}
prefix.Length = indexPrefixLength;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
index 8694735..dbf42b2 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
@@ -190,14 +190,14 @@ namespace Lucene.Net.Codecs.Compressing
{
case CompressingStoredFieldsWriter.BYTE_ARR:
int length = @in.ReadVInt();
- sbyte[] data = new sbyte[length];
+ var data = new byte[length];
@in.ReadBytes(data, 0, length);
visitor.BinaryField(info, data);
break;
case CompressingStoredFieldsWriter.STRING:
length = @in.ReadVInt();
- data = new sbyte[length];
+ data = new byte[length];
@in.ReadBytes(data, 0, length);
visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString((byte[])(Array)data));
break;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
index d94e1b9..9fccb35 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
@@ -350,7 +350,7 @@ namespace Lucene.Net.Codecs.Compressing
// copy last term
if (LastTerm.Bytes.Length < term.Length)
{
- LastTerm.Bytes = new sbyte[ArrayUtil.Oversize(term.Length, 1)];
+ LastTerm.Bytes = new byte[ArrayUtil.Oversize(term.Length, 1)];
}
LastTerm.Offset = 0;
LastTerm.Length = term.Length;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
index 1da51db..be238b3 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
@@ -155,7 +155,7 @@ namespace Lucene.Net.Codecs.Compressing
// add 7 padding bytes, this is not necessary but can help decompression run faster
if (bytes.Bytes.Length < originalLength + 7)
{
- bytes.Bytes = new sbyte[ArrayUtil.Oversize(originalLength + 7, 1)];
+ bytes.Bytes = new byte[ArrayUtil.Oversize(originalLength + 7, 1)];
}
int decompressedLength = LZ4.Decompress(@in, offset + length, bytes.Bytes, 0);
if (decompressedLength > originalLength)
@@ -174,14 +174,14 @@ namespace Lucene.Net.Codecs.Compressing
private sealed class LZ4FastCompressor : Compressor
{
- internal readonly LZ4.HashTable Ht;
+ private readonly LZ4.HashTable Ht;
internal LZ4FastCompressor()
{
Ht = new LZ4.HashTable();
}
- public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+ public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
{
LZ4.Compress(bytes, off, len, @out, Ht);
}
@@ -196,7 +196,7 @@ namespace Lucene.Net.Codecs.Compressing
Ht = new LZ4.HCHashTable();
}
- public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+ public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
{
LZ4.CompressHC(bytes, off, len, @out, Ht);
}
@@ -270,8 +270,8 @@ namespace Lucene.Net.Codecs.Compressing
private class DeflateCompressor : Compressor
{
- internal readonly Deflater Compressor;
- internal byte[] Compressed;
+ private readonly Deflater Compressor;
+ private byte[] Compressed;
internal DeflateCompressor(int level)
{
@@ -279,7 +279,7 @@ namespace Lucene.Net.Codecs.Compressing
Compressed = new byte[64];
}
- public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+ public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
{
Compressor.Reset();
Compressor.SetInput((byte[])(Array)bytes, off, len);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs b/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
index 0cff06a..666e90a 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
@@ -35,6 +35,6 @@ namespace Lucene.Net.Codecs.Compressing
/// compressor to add all necessary information so that a <seealso cref="Decompressor"/>
/// will know when to stop decompressing bytes from the stream.
/// </summary>
- public abstract void Compress(sbyte[] bytes, int off, int len, DataOutput @out);
+ public abstract void Compress(byte[] bytes, int off, int len, DataOutput @out);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs b/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
index 8328fa3..e473f45 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
@@ -56,17 +56,18 @@ namespace Lucene.Net.Codecs.Compressing
return Hash(i, HASH_LOG_HC);
}
- private static int ReadInt(sbyte[] buf, int i)
+ private static int ReadInt(byte[] buf, int i)
{
- return ((buf[i] & 0xFF) << 24) | ((buf[i + 1] & 0xFF) << 16) | ((buf[i + 2] & 0xFF) << 8) | (buf[i + 3] & 0xFF);
+ return ((((sbyte)buf[i]) & 0xFF) << 24) | ((((sbyte)buf[i + 1]) & 0xFF) << 16) | ((((sbyte)buf[i + 2]) & 0xFF) << 8) |
+ (((sbyte)buf[i + 3]) & 0xFF);
}
- private static bool ReadIntEquals(sbyte[] buf, int i, int j)
+ private static bool ReadIntEquals(byte[] buf, int i, int j)
{
return ReadInt(buf, i) == ReadInt(buf, j);
}
- private static int CommonBytes(sbyte[] b, int o1, int o2, int limit)
+ private static int CommonBytes(byte[] b, int o1, int o2, int limit)
{
Debug.Assert(o1 < o2);
int count = 0;
@@ -77,7 +78,7 @@ namespace Lucene.Net.Codecs.Compressing
return count;
}
- private static int CommonBytesBackward(sbyte[] b, int o1, int o2, int l1, int l2)
+ private static int CommonBytesBackward(byte[] b, int o1, int o2, int l1, int l2)
{
int count = 0;
while (o1 > l1 && o2 > l2 && b[--o1] == b[--o2])
@@ -93,7 +94,7 @@ namespace Lucene.Net.Codecs.Compressing
/// enough to be able to hold <b>all</b> decompressed data (meaning that you
/// need to know the total decompressed length).
/// </summary>
- public static int Decompress(DataInput compressed, int decompressedLen, sbyte[] dest, int dOff)
+ public static int Decompress(DataInput compressed, int decompressedLen, byte[] dest, int dOff)
{
int destEnd = dest.Length;
@@ -172,7 +173,7 @@ namespace Lucene.Net.Codecs.Compressing
@out.WriteByte((sbyte)l);
}
- private static void EncodeLiterals(sbyte[] bytes, int token, int anchor, int literalLen, DataOutput @out)
+ private static void EncodeLiterals(byte[] bytes, int token, int anchor, int literalLen, DataOutput @out)
{
@out.WriteByte((sbyte)token);
@@ -186,13 +187,13 @@ namespace Lucene.Net.Codecs.Compressing
@out.WriteBytes(bytes, anchor, literalLen);
}
- private static void EncodeLastLiterals(sbyte[] bytes, int anchor, int literalLen, DataOutput @out)
+ private static void EncodeLastLiterals(byte[] bytes, int anchor, int literalLen, DataOutput @out)
{
int token = Math.Min(literalLen, 0x0F) << 4;
EncodeLiterals(bytes, token, anchor, literalLen, @out);
}
- private static void EncodeSequence(sbyte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput @out)
+ private static void EncodeSequence(byte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput @out)
{
int literalLen = matchOff - anchor;
Debug.Assert(matchLen >= 4);
@@ -239,7 +240,7 @@ namespace Lucene.Net.Codecs.Compressing
/// at most 16KB of memory. <code>ht</code> shouldn't be shared across threads
/// but can safely be reused.
/// </summary>
- public static void Compress(sbyte[] bytes, int off, int len, DataOutput @out, HashTable ht)
+ public static void Compress(byte[] bytes, int off, int len, DataOutput @out, HashTable ht)
{
int @base = off;
int end = off + len;
@@ -340,7 +341,7 @@ namespace Lucene.Net.Codecs.Compressing
CollectionsHelper.Fill(ChainTable, (short)0);
}
- internal int HashPointer(sbyte[] bytes, int off)
+ internal int HashPointer(byte[] bytes, int off)
{
int v = ReadInt(bytes, off);
int h = HashHC(v);
@@ -352,7 +353,7 @@ namespace Lucene.Net.Codecs.Compressing
return off - (ChainTable[off & MASK] & 0xFFFF);
}
- internal void AddHash(sbyte[] bytes, int off)
+ internal void AddHash(byte[] bytes, int off)
{
int v = ReadInt(bytes, off);
int h = HashHC(v);
@@ -366,7 +367,7 @@ namespace Lucene.Net.Codecs.Compressing
HashTable[h] = off;
}
- internal void Insert(int off, sbyte[] bytes)
+ internal void Insert(int off, byte[] bytes)
{
for (; NextToUpdate < off; ++NextToUpdate)
{
@@ -374,7 +375,7 @@ namespace Lucene.Net.Codecs.Compressing
}
}
- public bool InsertAndFindBestMatch(sbyte[] buf, int off, int matchLimit, Match match)
+ public bool InsertAndFindBestMatch(byte[] buf, int off, int matchLimit, Match match)
{
match.Start = off;
match.Len = 0;
@@ -435,7 +436,7 @@ namespace Lucene.Net.Codecs.Compressing
return match.Len != 0;
}
- public bool InsertAndFindWiderMatch(sbyte[] buf, int off, int startLimit, int matchLimit, int minLen, Match match)
+ public bool InsertAndFindWiderMatch(byte[] buf, int off, int startLimit, int matchLimit, int minLen, Match match)
{
match.Len = minLen;
@@ -477,7 +478,7 @@ namespace Lucene.Net.Codecs.Compressing
/// fix overlapping matches. <code>ht</code> shouldn't be shared across threads
/// but can safely be reused.
/// </summary>
- public static void CompressHC(sbyte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
+ public static void CompressHC(byte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
{
int srcEnd = srcOff + srcLen;
int matchLimit = srcEnd - LAST_LITERALS;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
index 26fbfa1..fed442d 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
@@ -304,23 +304,23 @@ namespace Lucene.Net.Codecs.Lucene3x
// Returns true if the unicode char is "after" the
// surrogates in UTF16, ie >= U+E000 and <= U+FFFF:
- internal bool IsHighBMPChar(sbyte[] b, int idx)
+ private bool IsHighBMPChar(byte[] b, int idx)
{
- return (b[idx] & UTF8_HIGH_BMP_LEAD) == UTF8_HIGH_BMP_LEAD;
+ return (((sbyte)b[idx]) & UTF8_HIGH_BMP_LEAD) == UTF8_HIGH_BMP_LEAD;
}
// Returns true if the unicode char in the UTF8 byte
// sequence starting at idx encodes a char outside of
// BMP (ie what would be a surrogate pair in UTF16):
- internal bool IsNonBMPChar(sbyte[] b, int idx)
+ private bool IsNonBMPChar(byte[] b, int idx)
{
- return (b[idx] & UTF8_NON_BMP_LEAD) == UTF8_NON_BMP_LEAD;
+ return (((sbyte)b[idx]) & UTF8_NON_BMP_LEAD) == UTF8_NON_BMP_LEAD;
}
- internal readonly sbyte[] Scratch = new sbyte[4];
- internal readonly BytesRef PrevTerm = new BytesRef();
- internal readonly BytesRef ScratchTerm = new BytesRef();
- internal int NewSuffixStart;
+ private readonly sbyte[] Scratch = new sbyte[4];
+ private readonly BytesRef PrevTerm = new BytesRef();
+ private readonly BytesRef ScratchTerm = new BytesRef();
+ private int NewSuffixStart;
// Swap in S, in place of E:
internal virtual bool SeekToNonBMP(SegmentTermEnum te, BytesRef term, int pos)
@@ -346,14 +346,14 @@ namespace Lucene.Net.Codecs.Lucene3x
term.Grow(4 + pos);
}
- Scratch[0] = term.Bytes[pos];
- Scratch[1] = term.Bytes[pos + 1];
- Scratch[2] = term.Bytes[pos + 2];
+ Scratch[0] = (sbyte)term.Bytes[pos];
+ Scratch[1] = (sbyte)term.Bytes[pos + 1];
+ Scratch[2] = (sbyte)term.Bytes[pos + 2];
- term.Bytes[pos] = unchecked((sbyte)0xf0);
- term.Bytes[pos + 1] = unchecked((sbyte)0x90);
- term.Bytes[pos + 2] = unchecked((sbyte)0x80);
- term.Bytes[pos + 3] = unchecked((sbyte)0x80);
+ term.Bytes[pos] = unchecked((byte)0xf0);
+ term.Bytes[pos + 1] = unchecked((byte)0x90);
+ term.Bytes[pos + 2] = unchecked((byte)0x80);
+ term.Bytes[pos + 3] = unchecked((byte)0x80);
term.Length = 4 + pos;
if (DEBUG_SURROGATES)
@@ -406,9 +406,9 @@ namespace Lucene.Net.Codecs.Lucene3x
// Restore term:
term.Length = savLength;
- term.Bytes[pos] = Scratch[0];
- term.Bytes[pos + 1] = Scratch[1];
- term.Bytes[pos + 2] = Scratch[2];
+ term.Bytes[pos] = (byte)Scratch[0];
+ term.Bytes[pos + 1] = (byte)Scratch[1];
+ term.Bytes[pos + 2] = (byte)Scratch[2];
return matches;
}
@@ -494,7 +494,7 @@ namespace Lucene.Net.Codecs.Lucene3x
if (PrevTerm.Length > NewSuffixStart && IsNonBMPChar(PrevTerm.Bytes, NewSuffixStart) && IsHighBMPChar(ScratchTerm.Bytes, NewSuffixStart))
{
// Seek type 2 -- put 0xFF at this position:
- ScratchTerm.Bytes[NewSuffixStart] = unchecked((sbyte)0xff);
+ ScratchTerm.Bytes[NewSuffixStart] = unchecked((byte)0xff);
ScratchTerm.Length = NewSuffixStart + 1;
if (DEBUG_SURROGATES)
@@ -676,13 +676,13 @@ namespace Lucene.Net.Codecs.Lucene3x
Debug.Assert(ScratchTerm.Length >= upTo + 4);
int savLength = ScratchTerm.Length;
- Scratch[0] = ScratchTerm.Bytes[upTo];
- Scratch[1] = ScratchTerm.Bytes[upTo + 1];
- Scratch[2] = ScratchTerm.Bytes[upTo + 2];
+ Scratch[0] = (sbyte)ScratchTerm.Bytes[upTo];
+ Scratch[1] = (sbyte)ScratchTerm.Bytes[upTo + 1];
+ Scratch[2] = (sbyte)ScratchTerm.Bytes[upTo + 2];
- ScratchTerm.Bytes[upTo] = UTF8_HIGH_BMP_LEAD;
- ScratchTerm.Bytes[upTo + 1] = unchecked((sbyte)0x80);
- ScratchTerm.Bytes[upTo + 2] = unchecked((sbyte)0x80);
+ ScratchTerm.Bytes[upTo] = (byte)UTF8_HIGH_BMP_LEAD;
+ ScratchTerm.Bytes[upTo + 1] = unchecked((byte)0x80);
+ ScratchTerm.Bytes[upTo + 2] = unchecked((byte)0x80);
ScratchTerm.Length = upTo + 3;
if (DEBUG_SURROGATES)
@@ -694,9 +694,9 @@ namespace Lucene.Net.Codecs.Lucene3x
// TODO: more efficient seek?
OuterInstance.TermsDict.SeekEnum(SeekTermEnum, new Term(fieldInfo.Name, ScratchTerm), true);
- ScratchTerm.Bytes[upTo] = Scratch[0];
- ScratchTerm.Bytes[upTo + 1] = Scratch[1];
- ScratchTerm.Bytes[upTo + 2] = Scratch[2];
+ ScratchTerm.Bytes[upTo] = (byte)Scratch[0];
+ ScratchTerm.Bytes[upTo + 1] = (byte)Scratch[1];
+ ScratchTerm.Bytes[upTo + 2] = (byte)Scratch[2];
ScratchTerm.Length = savLength;
// Did we find a match?
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
index fc54c30..6ced971 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
@@ -318,7 +318,7 @@ namespace Lucene.Net.Codecs.Lucene3x
else
{
int length = FieldsStream.ReadVInt();
- sbyte[] bytes = new sbyte[length];
+ var bytes = new byte[length];
FieldsStream.ReadBytes(bytes, 0, length);
if ((bits & FIELD_IS_BINARY) != 0)
{
@@ -326,7 +326,7 @@ namespace Lucene.Net.Codecs.Lucene3x
}
else
{
- visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString((byte[])(Array)bytes));
+ visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString(bytes));
}
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
index 865b6c1..1825397 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
@@ -691,7 +691,7 @@ namespace Lucene.Net.Codecs.Lucene40
long startAddress = Reader.Get(docID);
BytesRef lengthBytes = new BytesRef();
BytesReader.FillSlice(lengthBytes, startAddress, 1);
- sbyte code = lengthBytes.Bytes[lengthBytes.Offset];
+ var code = lengthBytes.Bytes[lengthBytes.Offset];
if ((code & 128) == 0)
{
// length is 1 byte
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
index 5ff23f0..58f67f8 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
@@ -1028,7 +1028,7 @@ namespace Lucene.Net.Codecs.Lucene40
if (Payload_Renamed == null)
{
Payload_Renamed = new BytesRef();
- Payload_Renamed.Bytes = new sbyte[1];
+ Payload_Renamed.Bytes = new byte[1];
}
this.LiveDocs = liveDocs;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
index 45f15b5..be570d6 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
@@ -219,7 +219,7 @@ namespace Lucene.Net.Codecs.Lucene40
else
{
int length = FieldsStream.ReadVInt();
- sbyte[] bytes = new sbyte[length];
+ var bytes = new byte[length];
FieldsStream.ReadBytes(bytes, 0, length);
if ((bits & Lucene40StoredFieldsWriter.FIELD_IS_BINARY) != 0)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
index 7b259a7..4c4b4d8 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
@@ -447,8 +447,8 @@ namespace Lucene.Net.Codecs.Lucene40
private int NumTerms;
private int NextTerm;
private int Freq;
- private BytesRef LastTerm = new BytesRef();
- private BytesRef Term_Renamed = new BytesRef();
+ private readonly BytesRef LastTerm = new BytesRef();
+ private readonly BytesRef Term_Renamed = new BytesRef();
private bool StorePositions;
private bool StoreOffsets;
private bool StorePayloads;
@@ -462,7 +462,7 @@ namespace Lucene.Net.Codecs.Lucene40
internal int[] PayloadOffsets;
internal int LastPayloadLength;
- internal sbyte[] PayloadData;
+ internal byte[] PayloadData;
// NOTE: tvf is pre-positioned by caller
public TVTermsEnum(Lucene40TermVectorsReader outerInstance)
@@ -566,7 +566,7 @@ namespace Lucene.Net.Codecs.Lucene40
totalPayloadLength += LastPayloadLength;
Debug.Assert(totalPayloadLength >= 0);
}
- PayloadData = new sbyte[totalPayloadLength];
+ PayloadData = new byte[totalPayloadLength];
Tvf.ReadBytes(PayloadData, 0, PayloadData.Length);
} // no payloads
else if (StorePositions)
@@ -715,18 +715,18 @@ namespace Lucene.Net.Codecs.Lucene40
}
}
- private class TVDocsAndPositionsEnum : DocsAndPositionsEnum
+ private sealed class TVDocsAndPositionsEnum : DocsAndPositionsEnum
{
- internal bool DidNext;
- internal int Doc = -1;
- internal int NextPos;
- internal Bits LiveDocs;
- internal int[] Positions;
- internal int[] StartOffsets;
- internal int[] EndOffsets;
- internal int[] PayloadOffsets;
- internal BytesRef Payload_Renamed = new BytesRef();
- internal sbyte[] PayloadBytes;
+ private bool DidNext;
+ private int Doc = -1;
+ private int NextPos;
+ private Bits LiveDocs;
+ private int[] Positions;
+ private int[] StartOffsets;
+ private int[] EndOffsets;
+ private int[] PayloadOffsets;
+ private readonly BytesRef Payload_Renamed = new BytesRef();
+ private byte[] PayloadBytes;
public override int Freq()
{
@@ -764,7 +764,7 @@ namespace Lucene.Net.Codecs.Lucene40
return SlowAdvance(target);
}
- public virtual void Reset(Bits liveDocs, int[] positions, int[] startOffsets, int[] endOffsets, int[] payloadLengths, sbyte[] payloadBytes)
+ public void Reset(Bits liveDocs, int[] positions, int[] startOffsets, int[] endOffsets, int[] payloadLengths, byte[] payloadBytes)
{
this.LiveDocs = liveDocs;
this.Positions = positions;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs b/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
index ffc030e..c64cff9 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
@@ -1,3 +1,4 @@
+using System.IO;
using Lucene.Net.Store;
using Lucene.Net.Support;
using Lucene.Net.Util.Packed;
@@ -164,7 +165,7 @@ namespace Lucene.Net.Codecs.Lucene41
/// <param name="encoded"> a buffer to use to encode data </param>
/// <param name="out"> the destination output </param>
/// <exception cref="IOException"> If there is a low-level I/O error </exception>
- public void WriteBlock(int[] data, sbyte[] encoded, IndexOutput @out)
+ public void WriteBlock(int[] data, byte[] encoded, IndexOutput @out)
{
if (IsAllEqual(data))
{
@@ -181,7 +182,7 @@ namespace Lucene.Net.Codecs.Lucene41
int encodedSize = EncodedSizes[numBits];
Debug.Assert(iters * encoder.ByteBlockCount() >= encodedSize);
- @out.WriteByte((sbyte)numBits);
+ @out.WriteByte((byte)numBits);
encoder.Encode(data, 0, encoded, 0, iters);
@out.WriteBytes(encoded, encodedSize);
@@ -194,7 +195,7 @@ namespace Lucene.Net.Codecs.Lucene41
/// <param name="encoded"> a buffer that can be used to store encoded data </param>
/// <param name="decoded"> where to write decoded data </param>
/// <exception cref="IOException"> If there is a low-level I/O error </exception>
- public void ReadBlock(IndexInput @in, sbyte[] encoded, int[] decoded)
+ public void ReadBlock(IndexInput @in, byte[] encoded, int[] decoded)
{
int numBits = @in.ReadByte();
Debug.Assert(numBits <= 32, numBits.ToString());
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
index 80a26bd..a8be2f1 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
@@ -294,7 +294,7 @@ namespace Lucene.Net.Codecs.Lucene41
{
private readonly Lucene41PostingsReader OuterInstance;
- internal readonly sbyte[] Encoded;
+ internal readonly byte[] Encoded;
internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -345,7 +345,7 @@ namespace Lucene.Net.Codecs.Lucene41
IndexHasPos = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
IndexHasPayloads = fieldInfo.HasPayloads();
- Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+ Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
}
public bool CanReuse(IndexInput docIn, FieldInfo fieldInfo)
@@ -598,7 +598,7 @@ namespace Lucene.Net.Codecs.Lucene41
{
private readonly Lucene41PostingsReader OuterInstance;
- internal readonly sbyte[] Encoded;
+ internal readonly byte[] Encoded;
internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -665,7 +665,7 @@ namespace Lucene.Net.Codecs.Lucene41
this.StartDocIn = outerInstance.DocIn;
this.DocIn = null;
this.PosIn = (IndexInput)outerInstance.PosIn.Clone();
- Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+ Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
IndexHasPayloads = fieldInfo.HasPayloads();
}
@@ -1065,7 +1065,7 @@ namespace Lucene.Net.Codecs.Lucene41
{
private readonly Lucene41PostingsReader OuterInstance;
- internal readonly sbyte[] Encoded;
+ internal readonly byte[] Encoded;
internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -1075,7 +1075,7 @@ namespace Lucene.Net.Codecs.Lucene41
internal readonly int[] OffsetStartDeltaBuffer;
internal readonly int[] OffsetLengthBuffer;
- internal sbyte[] PayloadBytes;
+ internal byte[] PayloadBytes;
internal int PayloadByteUpto;
internal int PayloadLength;
@@ -1154,7 +1154,7 @@ namespace Lucene.Net.Codecs.Lucene41
this.DocIn = null;
this.PosIn = (IndexInput)outerInstance.PosIn.Clone();
this.PayIn = (IndexInput)outerInstance.PayIn.Clone();
- Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+ Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
if (IndexHasOffsets)
{
@@ -1173,7 +1173,7 @@ namespace Lucene.Net.Codecs.Lucene41
if (IndexHasPayloads)
{
PayloadLengthBuffer = new int[ForUtil.MAX_DATA_SIZE];
- PayloadBytes = new sbyte[128];
+ PayloadBytes = new byte[128];
Payload_Renamed = new BytesRef();
}
else
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
index 1a8da9c..27c636a 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
@@ -104,7 +104,7 @@ namespace Lucene.Net.Codecs.Lucene41
private int LastStartOffset;
private int DocCount;
- internal readonly sbyte[] Encoded;
+ internal readonly byte[] Encoded;
private readonly ForUtil ForUtil;
private readonly Lucene41SkipWriter SkipWriter;
@@ -183,7 +183,7 @@ namespace Lucene.Net.Codecs.Lucene41
// TODO: should we try skipping every 2/4 blocks...?
SkipWriter = new Lucene41SkipWriter(MaxSkipLevels, Lucene41PostingsFormat.BLOCK_SIZE, state.SegmentInfo.DocCount, DocOut, posOut, payOut);
- Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+ Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
index 566f66a..2648940 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
@@ -495,7 +495,7 @@ namespace Lucene.Net.Codecs.Lucene42
@in.Position = 0;
Fst.GetFirstArc(FirstArc);
IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, @in, FirstArc, ScratchArc, ScratchInts);
- result.Bytes = new sbyte[output.Length];
+ result.Bytes = new byte[output.Length];
result.Offset = 0;
result.Length = 0;
Util.ToBytesRef(output, result);
@@ -639,7 +639,7 @@ namespace Lucene.Net.Codecs.Lucene42
@in.Position = 0;
Fst.GetFirstArc(FirstArc);
IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, @in, FirstArc, ScratchArc, ScratchInts);
- result.Bytes = new sbyte[output.Length];
+ result.Bytes = new byte[output.Length];
result.Offset = 0;
result.Length = 0;
Lucene.Net.Util.Fst.Util.ToBytesRef(output, result);
@@ -811,7 +811,7 @@ namespace Lucene.Net.Codecs.Lucene42
BytesReader.Position = 0;
Fst.GetFirstArc(FirstArc);
IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, BytesReader, FirstArc, ScratchArc, ScratchInts);
- ScratchBytes.Bytes = new sbyte[output.Length];
+ ScratchBytes.Bytes = new byte[output.Length];
ScratchBytes.Offset = 0;
ScratchBytes.Length = 0;
Lucene.Net.Util.Fst.Util.ToBytesRef(output, ScratchBytes);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
index 3cf7593..9719632 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
@@ -485,7 +485,7 @@ namespace Lucene.Net.Codecs.Lucene45
Data.Seek(address);
// NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
// assume "they" own the bytes after calling this!
- sbyte[] buffer = new sbyte[Bytes.MaxLength];
+ var buffer = new byte[Bytes.MaxLength];
Data.ReadBytes(buffer, 0, buffer.Length);
result.Bytes = buffer;
result.Offset = 0;
@@ -555,7 +555,7 @@ namespace Lucene.Net.Codecs.Lucene45
Data.Seek(startAddress);
// NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
// assume "they" own the bytes after calling this!
- sbyte[] buffer = new sbyte[length];
+ var buffer = new byte[length];
Data.ReadBytes(buffer, 0, buffer.Length);
result.Bytes = buffer;
result.Offset = 0;
@@ -1215,7 +1215,7 @@ namespace Lucene.Net.Codecs.Lucene45
private void SetTerm()
{
// TODO: is there a cleaner way
- term.Bytes = new sbyte[termBuffer.Length];
+ term.Bytes = new byte[termBuffer.Length];
term.Offset = 0;
term.CopyBytes(termBuffer);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs b/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
index bd4431f..7027641 100644
--- a/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
@@ -173,7 +173,7 @@ namespace Lucene.Net.Codecs
if (payload == null)
{
payload = new BytesRef();
- payload.Bytes = new sbyte[payloadLength];
+ payload.Bytes = new byte[payloadLength];
}
else if (payload.Bytes.Length < payloadLength)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/CompressionTools.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/CompressionTools.cs b/src/Lucene.Net.Core/Document/CompressionTools.cs
index 567c522..8fdf733 100644
--- a/src/Lucene.Net.Core/Document/CompressionTools.cs
+++ b/src/Lucene.Net.Core/Document/CompressionTools.cs
@@ -40,20 +40,20 @@ namespace Lucene.Net.Documents
/// specified compressionLevel (constants are defined in
/// java.util.zip.Deflater).
/// </summary>
- public static byte[] Compress(sbyte[] value, int offset, int length, int compressionLevel)
+ public static byte[] Compress(byte[] value, int offset, int length, int compressionLevel)
{
/* Create an expandable byte array to hold the compressed data.
* You cannot use an array that's the same size as the orginal because
* there is no guarantee that the compressed data will be smaller than
* the uncompressed data. */
- ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
+ var bos = new ByteArrayOutputStream(length);
Deflater compressor = SharpZipLib.CreateDeflater();
try
{
compressor.SetLevel(compressionLevel);
- compressor.SetInput((byte[])(Array)value, offset, length);
+ compressor.SetInput(value, offset, length);
compressor.Finish();
// Compress the data
@@ -73,14 +73,14 @@ namespace Lucene.Net.Documents
/// <summary>
/// Compresses the specified byte range, with default BEST_COMPRESSION level </summary>
- public static byte[] Compress(sbyte[] value, int offset, int length)
+ public static byte[] Compress(byte[] value, int offset, int length)
{
return Compress(value, offset, length, Deflater.BEST_COMPRESSION);
}
/// <summary>
/// Compresses all bytes in the array, with default BEST_COMPRESSION level </summary>
- public static byte[] Compress(sbyte[] value)
+ public static byte[] Compress(byte[] value)
{
return Compress(value, 0, value.Length, Deflater.BEST_COMPRESSION);
}
@@ -99,7 +99,7 @@ namespace Lucene.Net.Documents
/// </summary>
public static byte[] CompressString(string value, int compressionLevel)
{
- BytesRef result = new BytesRef();
+ var result = new BytesRef();
UnicodeUtil.UTF16toUTF8(value.ToCharArray(), 0, value.Length, result);
return Compress(result.Bytes, 0, result.Length, compressionLevel);
}
@@ -117,7 +117,7 @@ namespace Lucene.Net.Documents
/// Decompress the byte array previously returned by
/// compress
/// </summary>
- public static byte[] Decompress(sbyte[] value)
+ public static byte[] Decompress(byte[] value)
{
return Decompress(value, 0, value.Length);
}
@@ -126,19 +126,19 @@ namespace Lucene.Net.Documents
/// Decompress the byte array previously returned by
/// compress
/// </summary>
- public static byte[] Decompress(sbyte[] value, int offset, int length)
+ public static byte[] Decompress(byte[] value, int offset, int length)
{
// Create an expandable byte array to hold the decompressed data
- ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
+ var bos = new ByteArrayOutputStream(length);
Inflater decompressor = SharpZipLib.CreateInflater();
try
{
- decompressor.SetInput((byte[])(Array)value);
+ decompressor.SetInput(value);
// Decompress the data
- byte[] buf = new byte[1024];
+ var buf = new byte[1024];
while (!decompressor.IsFinished)
{
int count = decompressor.Inflate(buf);
@@ -156,7 +156,7 @@ namespace Lucene.Net.Documents
/// Decompress the byte array previously returned by
/// compressString back into a String
/// </summary>
- public static string DecompressString(sbyte[] value)
+ public static string DecompressString(byte[] value)
{
return DecompressString(value, 0, value.Length);
}
@@ -165,11 +165,11 @@ namespace Lucene.Net.Documents
/// Decompress the byte array previously returned by
/// compressString back into a String
/// </summary>
- public static string DecompressString(sbyte[] value, int offset, int length)
+ public static string DecompressString(byte[] value, int offset, int length)
{
byte[] bytes = Decompress(value, offset, length);
CharsRef result = new CharsRef(bytes.Length);
- UnicodeUtil.UTF8toUTF16((sbyte[])(Array)bytes, 0, bytes.Length, result);
+ UnicodeUtil.UTF8toUTF16(bytes, 0, bytes.Length, result);
return new string(result.Chars, 0, result.length);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs b/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
index 28aa5a7..7607d01 100644
--- a/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
+++ b/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
@@ -62,7 +62,7 @@ namespace Lucene.Net.Documents
this.FieldsToAdd = null;
}
- public override void BinaryField(FieldInfo fieldInfo, sbyte[] value)
+ public override void BinaryField(FieldInfo fieldInfo, byte[] value)
{
Doc.Add(new StoredField(fieldInfo.Name, value));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/Field.cs b/src/Lucene.Net.Core/Document/Field.cs
index 1c656bf..d93f0f4 100644
--- a/src/Lucene.Net.Core/Document/Field.cs
+++ b/src/Lucene.Net.Core/Document/Field.cs
@@ -185,7 +185,7 @@ namespace Lucene.Net.Documents
/// <exception cref="IllegalArgumentException"> if the field name is null,
/// or the field's type is indexed() </exception>
/// <exception cref="NullPointerException"> if the type is null </exception>
- public Field(string name, sbyte[] value, FieldType type)
+ public Field(string name, byte[] value, FieldType type)
: this(name, value, 0, value.Length, type)
{
}
@@ -203,7 +203,7 @@ namespace Lucene.Net.Documents
/// <exception cref="IllegalArgumentException"> if the field name is null,
/// or the field's type is indexed() </exception>
/// <exception cref="NullPointerException"> if the type is null </exception>
- public Field(string name, sbyte[] value, int offset, int length, FieldType type)
+ public Field(string name, byte[] value, int offset, int length, FieldType type)
: this(name, new BytesRef(value, offset, length), type)
{
}
@@ -343,28 +343,6 @@ namespace Lucene.Net.Documents
/// <summary>
/// Expert: change the value of this field. See
/// <seealso cref="#setStringValue(String)"/>.
- /// </summary>
- public virtual sbyte[] SBytesValue
- {
- set
- {
- BytesRef temp = (new BytesRef(value));
- if (!(FieldsData is BytesRef))
- {
- throw new ArgumentException("cannot change value type from " + FieldsData.GetType().Name + " to BytesRef");
- }
-
- if (Type.Indexed)
- {
- throw new ArgumentException("cannot set a BytesRef value on an indexed field");
- }
- FieldsData = temp;
- }
- }
-
- /// <summary>
- /// Expert: change the value of this field. See
- /// <seealso cref="#setStringValue(String)"/>.
///
/// <p>NOTE: the provided BytesRef is not copied so be sure
/// not to change it until you're done with this field.
@@ -954,13 +932,13 @@ namespace Lucene.Net.Documents
}
[Obsolete("Use StoredField instead.")]
- public Field(String name, sbyte[] value)
+ public Field(String name, byte[] value)
: this(name, value, TranslateFieldType(Store.YES, Index.NO, TermVector.NO))
{
}
[Obsolete("Use StoredField instead.")]
- public Field(String name, sbyte[] value, int offset, int length)
+ public Field(String name, byte[] value, int offset, int length)
: this(name, value, offset, length, TranslateFieldType(Store.YES, Index.NO, TermVector.NO))
{
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/StoredField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/StoredField.cs b/src/Lucene.Net.Core/Document/StoredField.cs
index 860a56a..c682d76 100644
--- a/src/Lucene.Net.Core/Document/StoredField.cs
+++ b/src/Lucene.Net.Core/Document/StoredField.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Documents
/// <param name="name"> field name </param>
/// <param name="value"> byte array pointing to binary content (not copied) </param>
/// <exception cref="IllegalArgumentException"> if the field name is null. </exception>
- public StoredField(string name, sbyte[] value)
+ public StoredField(string name, byte[] value)
: base(name, value, TYPE)
{
}
@@ -63,7 +63,7 @@ namespace Lucene.Net.Documents
/// <param name="offset"> starting position of the byte array </param>
/// <param name="length"> valid length of the byte array </param>
/// <exception cref="IllegalArgumentException"> if the field name is null. </exception>
- public StoredField(string name, sbyte[] value, int offset, int length)
+ public StoredField(string name, byte[] value, int offset, int length)
: base(name, value, offset, length, TYPE)
{
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs b/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
index e3cbd13..78da520 100644
--- a/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
@@ -186,10 +186,10 @@ namespace Lucene.Net.Index
int length = value + 1; // value + maxTransition
if (LinearUpperBound.Bytes.Length < length)
{
- LinearUpperBound.Bytes = new sbyte[length];
+ LinearUpperBound.Bytes = new byte[length];
}
Array.Copy(SeekBytesRef.Bytes, 0, LinearUpperBound.Bytes, 0, value);
- LinearUpperBound.Bytes[value] = (sbyte)maxInterval;
+ LinearUpperBound.Bytes[value] = (byte)maxInterval;
LinearUpperBound.Length = length;
Linear_Renamed = true;
@@ -318,7 +318,7 @@ namespace Lucene.Net.Index
// append either the next sequential char, or the minimum transition
SeekBytesRef.Grow(SeekBytesRef.Length + 1);
SeekBytesRef.Length++;
- SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (sbyte)nextChar;
+ SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (byte)nextChar;
state = transition.Dest.Number;
/*
* as long as is possible, continue down the minimal path in
@@ -338,7 +338,7 @@ namespace Lucene.Net.Index
// append the minimum transition
SeekBytesRef.Grow(SeekBytesRef.Length + 1);
SeekBytesRef.Length++;
- SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (sbyte)transition.Min;
+ SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (byte)transition.Min;
// we found a loop, record it for faster enumeration
if ((Finite == false) && !Linear_Renamed && Visited[state] == CurGen)
@@ -368,7 +368,7 @@ namespace Lucene.Net.Index
// because there is no higher character in binary sort order.
if (nextChar++ != 0xff)
{
- SeekBytesRef.Bytes[position] = (sbyte)nextChar;
+ SeekBytesRef.Bytes[position] = (byte)nextChar;
SeekBytesRef.Length = position + 1;
return position;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/ByteSliceReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/ByteSliceReader.cs b/src/Lucene.Net.Core/Index/ByteSliceReader.cs
index 410c20d..e432e93 100644
--- a/src/Lucene.Net.Core/Index/ByteSliceReader.cs
+++ b/src/Lucene.Net.Core/Index/ByteSliceReader.cs
@@ -35,7 +35,7 @@ namespace Lucene.Net.Index
{
internal ByteBlockPool Pool;
internal int BufferUpto;
- internal sbyte[] Buffer;
+ internal byte[] Buffer;
public int Upto;
internal int Limit;
internal int Level;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/ByteSliceWriter.cs b/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
index 283d93d..a6adbab 100644
--- a/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
+++ b/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
@@ -30,7 +30,7 @@ namespace Lucene.Net.Index
public sealed class ByteSliceWriter : DataOutput
{
- private sbyte[] Slice;
+ private byte[] Slice;
private int Upto;
private readonly ByteBlockPool Pool;
@@ -65,7 +65,7 @@ namespace Lucene.Net.Index
Offset0 = Pool.ByteOffset;
Debug.Assert(Slice != null);
}
- Slice[Upto++] = (sbyte)b;
+ Slice[Upto++] = (byte)b;
Debug.Assert(Upto != Slice.Length);
}
@@ -82,7 +82,7 @@ namespace Lucene.Net.Index
Offset0 = Pool.ByteOffset;
}
- Slice[Upto++] = (sbyte)b[offset++];
+ Slice[Upto++] = (byte)b[offset++];
Debug.Assert(Upto != Slice.Length);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs b/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
index c1553d5..42cf537 100644
--- a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
+++ b/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
@@ -615,7 +615,7 @@ namespace Lucene.Net.Index
if (Payload == null)
{
Payload = new BytesRef();
- Payload.Bytes = new sbyte[payloadLength];
+ Payload.Bytes = new byte[payloadLength];
}
else if (Payload.Bytes.Length < payloadLength)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs b/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
index 8b51089..6b0ec4c 100644
--- a/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
@@ -51,7 +51,7 @@ namespace Lucene.Net.Index
// TODO: is there a cleaner way?
// term.bytes may be pointing to codec-private byte[]
// storage, so we must force new byte[] allocation:
- Term_Renamed.Bytes = new sbyte[text.Length];
+ Term_Renamed.Bytes = new byte[text.Length];
Term_Renamed.CopyBytes(text);
return SeekStatus.FOUND;
}
@@ -80,7 +80,7 @@ namespace Lucene.Net.Index
// TODO: is there a cleaner way?
// term.bytes may be pointing to codec-private byte[]
// storage, so we must force new byte[] allocation:
- Term_Renamed.Bytes = new sbyte[text.Length];
+ Term_Renamed.Bytes = new byte[text.Length];
Term_Renamed.CopyBytes(text);
CurrentOrd = ord;
return true;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs b/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
index 6595e75..bdfdcb3 100644
--- a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
@@ -51,7 +51,7 @@ namespace Lucene.Net.Index
// TODO: is there a cleaner way?
// term.bytes may be pointing to codec-private byte[]
// storage, so we must force new byte[] allocation:
- Term_Renamed.Bytes = new sbyte[text.Length];
+ Term_Renamed.Bytes = new byte[text.Length];
Term_Renamed.CopyBytes(text);
return SeekStatus.FOUND;
}
@@ -80,7 +80,7 @@ namespace Lucene.Net.Index
// TODO: is there a cleaner way?
// term.bytes may be pointing to codec-private byte[]
// storage, so we must force new byte[] allocation:
- Term_Renamed.Bytes = new sbyte[text.Length];
+ Term_Renamed.Bytes = new byte[text.Length];
Term_Renamed.CopyBytes(text);
CurrentOrd = ord;
return true;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs b/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
index 94aa53a..fce544c 100644
--- a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
+++ b/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Index
/// <summary>
/// Process a binary field. </summary>
/// <param name="value"> newly allocated byte array with the binary contents. </param>
- public virtual void BinaryField(FieldInfo fieldInfo, sbyte[] value)
+ public virtual void BinaryField(FieldInfo fieldInfo, byte[] value)
{
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/TermsHashPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TermsHashPerField.cs b/src/Lucene.Net.Core/Index/TermsHashPerField.cs
index edcf09a..76342ca 100644
--- a/src/Lucene.Net.Core/Index/TermsHashPerField.cs
+++ b/src/Lucene.Net.Core/Index/TermsHashPerField.cs
@@ -280,8 +280,13 @@ namespace Lucene.Net.Index
internal void WriteByte(int stream, sbyte b)
{
+ WriteByte(stream, (byte)b);
+ }
+
+ internal void WriteByte(int stream, byte b)
+ {
int upto = IntUptos[IntUptoStart + stream];
- sbyte[] bytes = BytePool.Buffers[upto >> ByteBlockPool.BYTE_BLOCK_SHIFT];
+ var bytes = BytePool.Buffers[upto >> ByteBlockPool.BYTE_BLOCK_SHIFT];
Debug.Assert(bytes != null);
int offset = upto & ByteBlockPool.BYTE_BLOCK_MASK;
if (bytes[offset] != 0)
@@ -295,7 +300,7 @@ namespace Lucene.Net.Index
(IntUptos[IntUptoStart + stream])++;
}
- public void WriteBytes(int stream, sbyte[] b, int offset, int len)
+ public void WriteBytes(int stream, byte[] b, int offset, int len)
{
// TODO: optimize
int end = offset + len;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/FieldComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldComparator.cs b/src/Lucene.Net.Core/Search/FieldComparator.cs
index 4f6a760..32bf9f0 100644
--- a/src/Lucene.Net.Core/Search/FieldComparator.cs
+++ b/src/Lucene.Net.Core/Search/FieldComparator.cs
@@ -1412,9 +1412,9 @@ namespace Lucene.Net.Search
public sealed class TermValComparator : FieldComparator<BytesRef>
{
// sentinels, just used internally in this comparator
- internal static readonly sbyte[] MISSING_BYTES = new sbyte[0];
+ internal static readonly byte[] MISSING_BYTES = new byte[0];
- internal static readonly sbyte[] NON_MISSING_BYTES = new sbyte[0];
+ internal static readonly byte[] NON_MISSING_BYTES = new byte[0];
internal BytesRef[] Values;
internal BinaryDocValues DocTerms;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs b/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
index 081a19d..d87c277 100644
--- a/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
+++ b/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
@@ -224,23 +224,28 @@ namespace Lucene.Net.Search.Payloads
// Get the payloads associated with all underlying subspans
public virtual void GetPayloads(Spans[] subSpans)
{
- for (int i = 0; i < subSpans.Length; i++)
+ for (var i = 0; i < subSpans.Length; i++)
{
- if (subSpans[i] is NearSpansOrdered)
+ var span = subSpans[i] as NearSpansOrdered;
+ if (span != null)
{
- if (((NearSpansOrdered)subSpans[i]).PayloadAvailable)
+ if (span.PayloadAvailable)
{
- ProcessPayloads(((NearSpansOrdered)subSpans[i]).Payload, subSpans[i].Start(), subSpans[i].End());
+ ProcessPayloads(span.Payload, subSpans[i].Start(), subSpans[i].End());
}
- GetPayloads(((NearSpansOrdered)subSpans[i]).SubSpans);
+ GetPayloads(span.SubSpans);
}
- else if (subSpans[i] is NearSpansUnordered)
+ else
{
- if (((NearSpansUnordered)subSpans[i]).PayloadAvailable)
+ var unordered = subSpans[i] as NearSpansUnordered;
+ if (unordered != null)
{
- ProcessPayloads(((NearSpansUnordered)subSpans[i]).Payload, subSpans[i].Start(), subSpans[i].End());
+ if (unordered.PayloadAvailable)
+ {
+ ProcessPayloads(unordered.Payload, subSpans[i].Start(), subSpans[i].End());
+ }
+ GetPayloads(unordered.SubSpans);
}
- GetPayloads(((NearSpansUnordered)subSpans[i]).SubSpans);
}
}
}
@@ -257,9 +262,9 @@ namespace Lucene.Net.Search.Payloads
/// <param name="end"> The end position of the span being scored
/// </param>
/// <seealso cref= Spans </seealso>
- protected internal virtual void ProcessPayloads(ICollection<sbyte[]> payLoads, int start, int end)
+ protected internal virtual void ProcessPayloads(ICollection<byte[]> payLoads, int start, int end)
{
- foreach (sbyte[] thePayload in payLoads)
+ foreach (var thePayload in payLoads)
{
Scratch.Bytes = thePayload;
Scratch.Offset = 0;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs b/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
index 3772a1d..8d7a4e5 100644
--- a/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
+++ b/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.IO;
using System.Linq;
namespace Lucene.Net.Search.Payloads
@@ -59,14 +60,14 @@ namespace Lucene.Net.Search.Payloads
/// <param name="query"> rewritten query </param>
/// <returns> payloads Collection </returns>
/// <exception cref="IOException"> if there is a low-level I/O error </exception>
- public virtual ICollection<sbyte[]> GetPayloadsForQuery(Query query)
+ public virtual ICollection<byte[]> GetPayloadsForQuery(Query query)
{
- ICollection<sbyte[]> payloads = new List<sbyte[]>();
+ var payloads = new List<byte[]>();
QueryToSpanQuery(query, payloads);
return payloads;
}
- private void QueryToSpanQuery(Query query, ICollection<sbyte[]> payloads)
+ private void QueryToSpanQuery(Query query, ICollection<byte[]> payloads)
{
if (query is BooleanQuery)
{
@@ -183,10 +184,10 @@ namespace Lucene.Net.Search.Payloads
}
}
- private void GetPayloads(ICollection<sbyte[]> payloads, SpanQuery query)
+ private void GetPayloads(ICollection<byte[]> payloads, SpanQuery query)
{
IDictionary<Term, TermContext> termContexts = new Dictionary<Term, TermContext>();
- SortedSet<Term> terms = new SortedSet<Term>();
+ var terms = new SortedSet<Term>();
query.ExtractTerms(terms);
foreach (Term term in terms)
{
@@ -199,8 +200,8 @@ namespace Lucene.Net.Search.Payloads
{
if (spans.PayloadAvailable)
{
- ICollection<sbyte[]> payload = spans.Payload;
- foreach (sbyte[] bytes in payload)
+ var payload = spans.Payload;
+ foreach (var bytes in payload)
{
payloads.Add(bytes);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
index 76110e5..6089a20 100644
--- a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
+++ b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
@@ -70,7 +70,7 @@ namespace Lucene.Net.Search.Spans
private int MatchDoc = -1;
private int MatchStart = -1;
private int MatchEnd = -1;
- private List<sbyte[]> MatchPayload;
+ private List<byte[]> MatchPayload;
private readonly Spans[] SubSpansByDoc;
@@ -80,7 +80,7 @@ namespace Lucene.Net.Search.Spans
private class InPlaceMergeSorterAnonymousInnerClassHelper : InPlaceMergeSorter
{
- private NearSpansOrdered OuterInstance;
+ private readonly NearSpansOrdered OuterInstance;
public InPlaceMergeSorterAnonymousInnerClassHelper(NearSpansOrdered outerInstance)
{
@@ -117,7 +117,7 @@ namespace Lucene.Net.Search.Spans
AllowedSlop = spanNearQuery.Slop;
SpanQuery[] clauses = spanNearQuery.Clauses;
subSpans = new Spans[clauses.Length];
- MatchPayload = new List<sbyte[]>();
+ MatchPayload = new List<byte[]>();
SubSpansByDoc = new Spans[clauses.Length];
for (int i = 0; i < clauses.Length; i++)
{
@@ -155,7 +155,7 @@ namespace Lucene.Net.Search.Spans
// TODO: Remove warning after API has been finalized
// TODO: Would be nice to be able to lazy load payloads
- public override ICollection<sbyte[]> Payload
+ public override ICollection<byte[]> Payload
{
get
{
@@ -344,14 +344,14 @@ namespace Lucene.Net.Search.Spans
{
MatchStart = subSpans[subSpans.Length - 1].Start();
MatchEnd = subSpans[subSpans.Length - 1].End();
- HashSet<sbyte[]> possibleMatchPayloads = new HashSet<sbyte[]>();
+ var possibleMatchPayloads = new HashSet<byte[]>();
if (subSpans[subSpans.Length - 1].PayloadAvailable)
{
//LUCENE TO-DO UnionWith or AddAll(Set<>, IEnumerable<>)
possibleMatchPayloads.UnionWith(subSpans[subSpans.Length - 1].Payload);
}
- IList<sbyte[]> possiblePayload = null;
+ IList<byte[]> possiblePayload = null;
int matchSlop = 0;
int lastStart = MatchStart;
@@ -361,8 +361,8 @@ namespace Lucene.Net.Search.Spans
Spans prevSpans = subSpans[i];
if (CollectPayloads && prevSpans.PayloadAvailable)
{
- ICollection<sbyte[]> payload = prevSpans.Payload;
- possiblePayload = new List<sbyte[]>(payload.Count);
+ var payload = prevSpans.Payload;
+ possiblePayload = new List<byte[]>(payload.Count);
possiblePayload.AddRange(payload);
}
@@ -395,8 +395,8 @@ namespace Lucene.Net.Search.Spans
prevEnd = ppEnd;
if (CollectPayloads && prevSpans.PayloadAvailable)
{
- ICollection<sbyte[]> payload = prevSpans.Payload;
- possiblePayload = new List<sbyte[]>(payload.Count);
+ var payload = prevSpans.Payload;
+ possiblePayload = new List<byte[]>(payload.Count);
possiblePayload.AddRange(payload);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs b/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
index 7a63670..12905a4 100644
--- a/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
+++ b/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
@@ -140,11 +140,11 @@ namespace Lucene.Net.Search.Spans
return Spans.End();
}
- public override ICollection<sbyte[]> Payload
+ public override ICollection<byte[]> Payload
{
get
{
- return new List<sbyte[]>(Spans.Payload);
+ return new List<byte[]>(Spans.Payload);
}
}
@@ -315,12 +315,12 @@ namespace Lucene.Net.Search.Spans
return Max.End();
}
- public override ICollection<sbyte[]> Payload
+ public override ICollection<byte[]> Payload
{
get
{
- HashSet<sbyte[]> matchPayload = new HashSet<sbyte[]>();
- for (SpansCell cell = First; cell != null; cell = cell.Next_Renamed)
+ var matchPayload = new HashSet<byte[]>();
+ for (var cell = First; cell != null; cell = cell.Next_Renamed)
{
if (cell.PayloadAvailable)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
index bbaa8cc..47251dc 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
@@ -32,11 +32,11 @@ namespace Lucene.Net.Search.Spans
/// </summary>
public class SpanNearPayloadCheckQuery : SpanPositionCheckQuery
{
- protected internal readonly ICollection<sbyte[]> PayloadToMatch;
+ protected internal readonly ICollection<byte[]> PayloadToMatch;
/// <param name="match"> The underlying <seealso cref="SpanQuery"/> to check </param>
/// <param name="payloadToMatch"> The <seealso cref="java.util.Collection"/> of payloads to match </param>
- public SpanNearPayloadCheckQuery(SpanNearQuery match, ICollection<sbyte[]> payloadToMatch)
+ public SpanNearPayloadCheckQuery(SpanNearQuery match, ICollection<byte[]> payloadToMatch)
: base(match)
{
this.PayloadToMatch = payloadToMatch;
@@ -47,16 +47,16 @@ namespace Lucene.Net.Search.Spans
bool result = spans.PayloadAvailable;
if (result == true)
{
- ICollection<sbyte[]> candidate = spans.Payload;
+ var candidate = spans.Payload;
if (candidate.Count == PayloadToMatch.Count)
{
//TODO: check the byte arrays are the same
//hmm, can't rely on order here
int matches = 0;
- foreach (sbyte[] candBytes in candidate)
+ foreach (var candBytes in candidate)
{
//Unfortunately, we can't rely on order, so we need to compare all
- foreach (sbyte[] payBytes in PayloadToMatch)
+ foreach (var payBytes in PayloadToMatch)
{
if (Arrays.Equals(candBytes, payBytes) == true)
{
@@ -89,7 +89,7 @@ namespace Lucene.Net.Search.Spans
buffer.Append("spanPayCheck(");
buffer.Append(match.ToString(field));
buffer.Append(", payloadRef: ");
- foreach (sbyte[] bytes in PayloadToMatch)
+ foreach (var bytes in PayloadToMatch)
{
ToStringUtils.ByteArray(buffer, bytes);
buffer.Append(';');