Skip to content

Commit d80bdbc

Browse files
committed
add IExternalBuildableIndex interface
1 parent cc7f089 commit d80bdbc

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/InformationRetrieval.Test/Indexing/SortBasedExternalBuildableIndexTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected override ExternalIndex<string> CreateIndex(string[][] corpus)
5454
var stream = new MemoryStream();
5555
var buildableIndex = new SortBasedExternalBuildableIndex<string>(stream);
5656
IndexHelper.BuildIndex(buildableIndex, corpus);
57-
return buildableIndex.Build();
57+
return buildableIndex.BuildExternalIndex();
5858
}
5959
}
6060
}

src/InformationRetrieval/Indexing/BlockedExternalBuildableIndex.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private class BuildableIndexManager : IDisposable
151151
{
152152
private readonly string basePath;
153153
private readonly IFileSystem fileSystem;
154-
private SortBasedExternalBuildableIndex<T>? currentIndex;
154+
private IExternalBuildableIndex<T>? currentIndex;
155155
private ushort currentBlockId;
156156
private readonly IList<ExternalIndex<T>> indices;
157157

@@ -207,7 +207,7 @@ private void Build()
207207
{
208208
if (currentIndex != null)
209209
{
210-
var externalIndex = currentIndex.Build();
210+
var externalIndex = currentIndex.BuildExternalIndex();
211211
indices.Add(externalIndex);
212212
currentIndex = null;
213213
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace InformationRetrieval.Indexing
6+
{
7+
public interface IExternalBuildableIndex<T> : IBuildableIndex<T>
8+
{
9+
ExternalIndex<T> BuildExternalIndex();
10+
}
11+
}

src/InformationRetrieval/Indexing/SortBasedExternalBuildableIndex.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace InformationRetrieval.Indexing
77
{
8-
public class SortBasedExternalBuildableIndex<T> : IBuildableIndex<T>
8+
public class SortBasedExternalBuildableIndex<T> : IExternalBuildableIndex<T>
99
{
1010
private readonly IList<(DocumentId Id, T Term)> tokens;
1111
private readonly Stream postingsStream;
@@ -16,7 +16,7 @@ public SortBasedExternalBuildableIndex(Stream postingsStream)
1616
this.postingsStream = postingsStream;
1717
}
1818

19-
public ExternalIndex<T> Build()
19+
public ExternalIndex<T> BuildExternalIndex()
2020
{
2121
var composer = new ExternalIndexComposer<T>(postingsStream);
2222

@@ -39,9 +39,9 @@ public void IndexTerm(DocumentId docId, T term, int position)
3939
tokens.Add((docId, term));
4040
}
4141

42-
ISearchableIndex<T> IBuildableIndex<T>.Build()
42+
public ISearchableIndex<T> Build()
4343
{
44-
return Build();
44+
return BuildExternalIndex();
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)