Skip to content

Commit c90f8ff

Browse files
committed
RavenDB-24810 - consolidate array types into single HybridArray implementation
1 parent 09c11fc commit c90f8ff

File tree

18 files changed

+226
-238
lines changed

18 files changed

+226
-238
lines changed

src/Lucene.Net/Index/ArrayHolder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public class ArrayHolder : IDisposable
99
{
1010
private readonly Directory _directory;
1111
private readonly string _name;
12-
private readonly IArray<long> _indexPointers;
13-
private readonly IArray<TermInfo> _termInfos;
12+
private readonly HybridArray<long> _indexPointers;
13+
private readonly HybridArray<TermInfo> _termInfos;
1414
private readonly UnmanagedIndexTerms _unmanagedIndexTerms;
1515

1616
private int _usages;
1717
private long _managedAllocations;
1818

19-
public IArray<long> IndexPointers => _indexPointers;
20-
public IArray<TermInfo> TermInfos => _termInfos;
19+
public HybridArray<long> IndexPointers => _indexPointers;
20+
public HybridArray<TermInfo> TermInfos => _termInfos;
2121
public UnmanagedIndexTerms UnmanagedIndexTerms => _unmanagedIndexTerms;
2222

2323
public static Action<long> OnArrayHolderCreated;
@@ -31,8 +31,8 @@ public ArrayHolder(int size, Directory directory, string name, FieldInfos fieldI
3131
_directory = directory;
3232
_name = name;
3333

34-
_indexPointers = HybridArray.Create<long>(size, UnmanagedStringArray.Type.TermCache);
35-
_termInfos = HybridArray.Create<TermInfo>(size, UnmanagedStringArray.Type.TermCache);
34+
_indexPointers = new HybridArray<long>(size, UnmanagedStringArray.Type.TermCache);
35+
_termInfos = new HybridArray<TermInfo>(size, UnmanagedStringArray.Type.TermCache);
3636

3737
_unmanagedIndexTerms = new UnmanagedIndexTerms(size, fieldInfos);
3838
}

src/Lucene.Net/Index/UnmanagedIndexTerms.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Lucene.Net.Index
66
public class UnmanagedIndexTerms : IDisposable
77
{
88
private readonly FieldInfos _fieldInfos;
9-
private readonly IArray<int> _fieldNumber;
9+
private readonly HybridArray<int> _fieldNumber;
1010
private readonly UnmanagedStringArray _text;
1111

1212
public int Length => _text.Length;
@@ -16,7 +16,7 @@ public class UnmanagedIndexTerms : IDisposable
1616
public UnmanagedIndexTerms(int size, FieldInfos fieldInfos)
1717
{
1818
_fieldInfos = fieldInfos;
19-
_fieldNumber = HybridArray.Create<int>(size, UnmanagedStringArray.Type.TermCache);
19+
_fieldNumber = new HybridArray<int>(size, UnmanagedStringArray.Type.TermCache);
2020
_text = new UnmanagedStringArray(size, 0, UnmanagedStringArray.Type.TermCache);
2121
}
2222

src/Lucene.Net/Search/FieldCache.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public virtual unsafe int BinarySearchLookup(System.String key)
9090
public UnmanagedStringArray lookup;
9191

9292
/// <summary>For each document, an index into the lookup array. </summary>
93-
public IArray<int> order;
93+
public HybridArray<int> order;
9494

9595
/// <summary>Creates one of these objects </summary>
96-
public StringIndex(IArray<int> values, UnmanagedStringArray lookup)
96+
public StringIndex(HybridArray<int> values, UnmanagedStringArray lookup)
9797
{
9898
this.order = values;
9999
this.lookup = lookup;
@@ -544,7 +544,7 @@ public interface FieldCache
544544
/// <returns> The values in the given field for each document.
545545
/// </returns>
546546
/// <throws> java.io.IOException If any error occurs. </throws>
547-
IArray<long> GetLongs(IndexReader reader, System.String field, IState state);
547+
HybridArray<long> GetLongs(IndexReader reader, System.String field, IState state);
548548

549549
/// <summary> Checks the internal cache for an appropriate entry, and if none is found,
550550
/// reads the terms in <c>field</c> as longs and returns an array of
@@ -561,7 +561,7 @@ public interface FieldCache
561561
/// <returns> The values in the given field for each document.
562562
/// </returns>
563563
/// <throws> IOException If any error occurs. </throws>
564-
IArray<long> GetLongs(IndexReader reader, System.String field, LongParser parser, IState state);
564+
HybridArray<long> GetLongs(IndexReader reader, System.String field, LongParser parser, IState state);
565565

566566

567567
/// <summary> Checks the internal cache for an appropriate entry, and if none is
@@ -577,7 +577,7 @@ public interface FieldCache
577577
/// <returns> The values in the given field for each document.
578578
/// </returns>
579579
/// <throws> IOException If any error occurs. </throws>
580-
IArray<double> GetDoubles(IndexReader reader, System.String field, IState state);
580+
HybridArray<double> GetDoubles(IndexReader reader, System.String field, IState state);
581581

582582
/// <summary> Checks the internal cache for an appropriate entry, and if none is found,
583583
/// reads the terms in <c>field</c> as doubles and returns an array of
@@ -594,7 +594,7 @@ public interface FieldCache
594594
/// <returns> The values in the given field for each document.
595595
/// </returns>
596596
/// <throws> IOException If any error occurs. </throws>
597-
IArray<double> GetDoubles(IndexReader reader, System.String field, DoubleParser parser, IState state);
597+
HybridArray<double> GetDoubles(IndexReader reader, System.String field, DoubleParser parser, IState state);
598598

599599
/// <summary>Checks the internal cache for an appropriate entry, and if none
600600
/// is found, reads the term values in <c>field</c> and returns an array

src/Lucene.Net/Search/FieldCacheImpl.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -607,24 +607,24 @@ protected internal override float[] CreateValue(IndexReader reader, Entry entryK
607607

608608

609609

610-
public virtual IArray<long> GetLongs(IndexReader reader, System.String field, IState state)
610+
public virtual HybridArray<long> GetLongs(IndexReader reader, System.String field, IState state)
611611
{
612612
return GetLongs(reader, field, null, state);
613613
}
614614

615615
// inherit javadocs
616-
public virtual IArray<long> GetLongs(IndexReader reader, System.String field, Lucene.Net.Search.LongParser parser, IState state)
616+
public virtual HybridArray<long> GetLongs(IndexReader reader, System.String field, Lucene.Net.Search.LongParser parser, IState state)
617617
{
618618
return _longCache.Get(reader, new Entry(field, parser), state);
619619
}
620620

621-
internal sealed class LongCache : Cache<IArray<long>>, IDisposable
621+
internal sealed class LongCache : Cache<HybridArray<long>>, IDisposable
622622
{
623623
internal LongCache(FieldCache wrapper):base(wrapper)
624624
{
625625
}
626626

627-
protected internal override IArray<long> CreateValue(IndexReader reader, Entry entryKey, IState state)
627+
protected internal override HybridArray<long> CreateValue(IndexReader reader, Entry entryKey, IState state)
628628
{
629629
Entry entry = entryKey;
630630
System.String field = entry.field;
@@ -641,7 +641,7 @@ protected internal override IArray<long> CreateValue(IndexReader reader, Entry e
641641
}
642642
}
643643

644-
var retArray = HybridArray.Create<long>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
644+
var retArray = new HybridArray<long>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
645645
TermDocs termDocs = reader.TermDocs(state);
646646
TermEnum termEnum = reader.Terms(new Term(field), state);
647647

@@ -679,7 +679,7 @@ public void Dispose()
679679
{
680680
foreach (var keyValuePair in keyValue.Value)
681681
{
682-
if (keyValuePair.Value is IArray<long> array)
682+
if (keyValuePair.Value is HybridArray<long> array)
683683
{
684684
array.Dispose();
685685
}
@@ -690,24 +690,24 @@ public void Dispose()
690690

691691

692692
// inherit javadocs
693-
public virtual IArray<double> GetDoubles(IndexReader reader, System.String field, IState state)
693+
public virtual HybridArray<double> GetDoubles(IndexReader reader, System.String field, IState state)
694694
{
695695
return GetDoubles(reader, field, null, state);
696696
}
697697

698698
// inherit javadocs
699-
public virtual IArray<double> GetDoubles(IndexReader reader, System.String field, Lucene.Net.Search.DoubleParser parser, IState state)
699+
public virtual HybridArray<double> GetDoubles(IndexReader reader, System.String field, Lucene.Net.Search.DoubleParser parser, IState state)
700700
{
701701
return _doubleCache.Get(reader, new Entry(field, parser), state);
702702
}
703703

704-
internal sealed class DoubleCache : Cache<IArray<double>>, IDisposable
704+
internal sealed class DoubleCache : Cache<HybridArray<double>>, IDisposable
705705
{
706706
internal DoubleCache(FieldCache wrapper):base(wrapper)
707707
{
708708
}
709709

710-
protected internal override IArray<double> CreateValue(IndexReader reader, Entry entryKey, IState state)
710+
protected internal override HybridArray<double> CreateValue(IndexReader reader, Entry entryKey, IState state)
711711
{
712712
Entry entry = entryKey;
713713
System.String field = entry.field;
@@ -724,7 +724,7 @@ protected internal override IArray<double> CreateValue(IndexReader reader, Entry
724724
}
725725
}
726726

727-
var retArray = HybridArray.Create<double>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
727+
var retArray = new HybridArray<double>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
728728
TermDocs termDocs = reader.TermDocs(state);
729729
TermEnum termEnum = reader.Terms(new Term(field), state);
730730

@@ -762,7 +762,7 @@ public void Dispose()
762762
{
763763
foreach (var keyValuePair in keyValue.Value)
764764
{
765-
if (keyValuePair.Value is IArray<double> array)
765+
if (keyValuePair.Value is HybridArray<double> array)
766766
{
767767
array.Dispose();
768768
}
@@ -831,7 +831,7 @@ internal StringIndexCache(FieldCache wrapper):base(wrapper)
831831
protected internal override StringIndex CreateValue(IndexReader reader, Entry entryKey, IState state)
832832
{
833833
System.String field = StringHelper.Intern(entryKey.field);
834-
var retArray = HybridArray.Create<int>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
834+
var retArray = new HybridArray<int>(reader.MaxDoc, UnmanagedStringArray.Type.Sorting);
835835

836836
var length = reader.MaxDoc + 1;
837837
UnmanagedStringArray mterms = new UnmanagedStringArray(length, 1, UnmanagedStringArray.Type.Sorting);

src/Lucene.Net/Search/FieldCacheRangeFilter.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,14 @@ private class AnonymousClassFieldCacheRangeFilter4 : FieldCacheRangeFilter<long?
388388
{
389389
private class AnonymousClassFieldCacheDocIdSet : FieldCacheDocIdSet
390390
{
391-
private void InitBlock(IArray<long> values, long inclusiveLowerPoint, long inclusiveUpperPoint, FieldCacheRangeFilter<long?> enclosingInstance)
391+
private void InitBlock(HybridArray<long> values, long inclusiveLowerPoint, long inclusiveUpperPoint, FieldCacheRangeFilter<long?> enclosingInstance)
392392
{
393393
this.values = values;
394394
this.inclusiveLowerPoint = inclusiveLowerPoint;
395395
this.inclusiveUpperPoint = inclusiveUpperPoint;
396396
this.enclosingInstance = enclosingInstance;
397397
}
398-
private IArray<long> values;
398+
private HybridArray<long> values;
399399
private long inclusiveLowerPoint;
400400
private long inclusiveUpperPoint;
401401
private FieldCacheRangeFilter<long?> enclosingInstance;
@@ -407,7 +407,7 @@ public FieldCacheRangeFilter<long?> Enclosing_Instance
407407
}
408408

409409
}
410-
internal AnonymousClassFieldCacheDocIdSet(IArray<long> values, long inclusiveLowerPoint, long inclusiveUpperPoint, FieldCacheRangeFilter<long?> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2)
410+
internal AnonymousClassFieldCacheDocIdSet(HybridArray<long> values, long inclusiveLowerPoint, long inclusiveUpperPoint, FieldCacheRangeFilter<long?> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2)
411411
: base(Param1, Param2)
412412
{
413413
InitBlock(values, inclusiveLowerPoint, inclusiveUpperPoint, enclosingInstance);
@@ -451,7 +451,7 @@ public override DocIdSet GetDocIdSet(IndexReader reader, IState state)
451451
if (inclusiveLowerPoint > inclusiveUpperPoint)
452452
return DocIdSet.EMPTY_DOCIDSET;
453453

454-
IArray<long> values = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetLongs(reader, field, (Lucene.Net.Search.LongParser)parser, state);
454+
HybridArray<long> values = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetLongs(reader, field, (Lucene.Net.Search.LongParser)parser, state);
455455
// we only request the usage of termDocs, if the range contains 0
456456
return new AnonymousClassFieldCacheDocIdSet(values, inclusiveLowerPoint, inclusiveUpperPoint, this, reader, (inclusiveLowerPoint <= 0L && inclusiveUpperPoint >= 0L));
457457
}
@@ -542,14 +542,14 @@ private class AnonymousClassFieldCacheRangeFilter6 : FieldCacheRangeFilter<doubl
542542
{
543543
private class AnonymousClassFieldCacheDocIdSet : FieldCacheDocIdSet
544544
{
545-
private void InitBlock(IArray<double> values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter<double?> enclosingInstance)
545+
private void InitBlock(HybridArray<double> values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter<double?> enclosingInstance)
546546
{
547547
this.values = values;
548548
this.inclusiveLowerPoint = inclusiveLowerPoint;
549549
this.inclusiveUpperPoint = inclusiveUpperPoint;
550550
this.enclosingInstance = enclosingInstance;
551551
}
552-
private IArray<double> values;
552+
private HybridArray<double> values;
553553
private double inclusiveLowerPoint;
554554
private double inclusiveUpperPoint;
555555
private FieldCacheRangeFilter<double?> enclosingInstance;
@@ -561,7 +561,7 @@ public FieldCacheRangeFilter<double?> Enclosing_Instance
561561
}
562562

563563
}
564-
internal AnonymousClassFieldCacheDocIdSet(IArray<double> values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter<double?> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2)
564+
internal AnonymousClassFieldCacheDocIdSet(HybridArray<double> values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter<double?> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2)
565565
: base(Param1, Param2)
566566
{
567567
InitBlock(values, inclusiveLowerPoint, inclusiveUpperPoint, enclosingInstance);
@@ -609,7 +609,7 @@ public override DocIdSet GetDocIdSet(IndexReader reader, IState state)
609609
if (inclusiveLowerPoint > inclusiveUpperPoint)
610610
return DocIdSet.EMPTY_DOCIDSET;
611611

612-
IArray<double> values = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetDoubles(reader, field, (Lucene.Net.Search.DoubleParser)parser, state);
612+
HybridArray<double> values = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetDoubles(reader, field, (Lucene.Net.Search.DoubleParser)parser, state);
613613
// we only request the usage of termDocs, if the range contains 0
614614
return new AnonymousClassFieldCacheDocIdSet(values, inclusiveLowerPoint, inclusiveUpperPoint, this, reader, (inclusiveLowerPoint <= 0.0 && inclusiveUpperPoint >= 0.0));
615615
}

src/Lucene.Net/Search/FieldComparator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public override IComparable this[int slot]
275275
public sealed class DoubleComparator:FieldComparator
276276
{
277277
private double[] values;
278-
private IArray<double> currentReaderValues;
278+
private HybridArray<double> currentReaderValues;
279279
private System.String field;
280280
private DoubleParser parser;
281281
private double bottom;
@@ -509,7 +509,7 @@ public override IComparable this[int slot]
509509
public sealed class LongComparator:FieldComparator
510510
{
511511
private long[] values;
512-
private IArray<long> currentReaderValues;
512+
private HybridArray<long> currentReaderValues;
513513
private System.String field;
514514
private LongParser parser;
515515
private long bottom;
@@ -784,7 +784,7 @@ public sealed class StringOrdValComparator:FieldComparator
784784

785785
private int currentReaderGen = - 1;
786786
private UnmanagedStringArray lookup;
787-
private IArray<int> order;
787+
private HybridArray<int> order;
788788
private System.String field;
789789

790790
private int bottomSlot = - 1;

src/Lucene.Net/Search/Function/OrdFieldSource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ public class OrdFieldSource:ValueSource
5757
{
5858
private class AnonymousClassDocValues:DocValues
5959
{
60-
public AnonymousClassDocValues(IArray<int> arr, OrdFieldSource enclosingInstance)
60+
public AnonymousClassDocValues(HybridArray<int> arr, OrdFieldSource enclosingInstance)
6161
{
6262
InitBlock(arr, enclosingInstance);
6363
}
6464

65-
private void InitBlock(IArray<int> arr, OrdFieldSource enclosingInstance)
65+
private void InitBlock(HybridArray<int> arr, OrdFieldSource enclosingInstance)
6666
{
6767
this.arr = arr;
6868
this.enclosingInstance = enclosingInstance;
6969
}
7070

71-
private IArray<int> arr;
71+
private HybridArray<int> arr;
7272
private OrdFieldSource enclosingInstance;
7373
public OrdFieldSource Enclosing_Instance
7474
{

src/Lucene.Net/Search/Function/ReverseOrdFieldSource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ public class ReverseOrdFieldSource:ValueSource
5858
{
5959
private class AnonymousClassDocValues:DocValues
6060
{
61-
public AnonymousClassDocValues(int end, IArray<int> arr, ReverseOrdFieldSource enclosingInstance)
61+
public AnonymousClassDocValues(int end, HybridArray<int> arr, ReverseOrdFieldSource enclosingInstance)
6262
{
6363
InitBlock(end, arr, enclosingInstance);
6464
}
65-
private void InitBlock(int end, IArray<int> arr, ReverseOrdFieldSource enclosingInstance)
65+
private void InitBlock(int end, HybridArray<int> arr, ReverseOrdFieldSource enclosingInstance)
6666
{
6767
this.end = end;
6868
this.arr = arr;
6969
this.enclosingInstance = enclosingInstance;
7070
}
7171
private int end;
72-
private IArray<int> arr;
72+
private HybridArray<int> arr;
7373
private ReverseOrdFieldSource enclosingInstance;
7474
public ReverseOrdFieldSource Enclosing_Instance
7575
{

0 commit comments

Comments
 (0)