Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Lets NuGet/login request a GitHub OIDC token.
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
9.0.x
8.0.x
7.0.x
6.0.x
- name: Display dotnet version
run: dotnet --version
- name: Restore dependencies
Expand All @@ -30,8 +32,23 @@ jobs:
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
working-directory: ./src
- name: Pack
run: dotnet pack ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj --configuration Release --no-build --output ../artifacts/packages
working-directory: ./src
- name: Upload packages
uses: actions/upload-artifact@v7
with:
name: nuget-packages
path: artifacts/packages/
# Exchange the OIDC token immediately before publishing for a short-lived API key.
# Requires a matching NuGet.org trusted publishing policy created by koculu.
- name: NuGet login
uses: NuGet/login@v1
id: login
with:
user: koculu
- name: Publish the package to nuget.org
run: dotnet nuget push ZoneTree.FullTextSearch/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
# Pushing a .nupkg also pushes the .snupkg symbol package next to it.
run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
working-directory: ./src
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public void AddRecord_ShouldAddRecordToIndex()
Assert.That(searchResult, Contains.Item(record));
}

[Test]
public void DeleteRecord_ShouldRemoveRecordFromIndex()
[TestCase(false)]
[TestCase(true)]
public void DeleteRecord_ShouldRemoveRecordFromIndex(bool useSecondaryIndex)
{
var dataPath = "data/DeleteRecord_ShouldRemoveRecordFromIndex";
var dataPath = $"data/DeleteRecord_ShouldRemoveRecordFromIndex_{useSecondaryIndex}";
if (Directory.Exists(dataPath))
Directory.Delete(dataPath, true);
using var searchEngine = new HashedSearchEngine<int>(dataPath);
using var searchEngine = new HashedSearchEngine<int>(dataPath, useSecondaryIndex: useSecondaryIndex);

// Arrange
int record = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/ZoneTree.FullTextSearch/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<Authors>Ahmed Yasin Koculu</Authors>
<PackageId>ZoneTree.FullTextSearch</PackageId>
<Title>ZoneTree.FullTextSearch</Title>
<ProductVersion>1.0.9.0</ProductVersion>
<Version>1.0.9.0</Version>
<ProductVersion>1.1.0.0</ProductVersion>
<Version>1.1.0.0</Version>
<Authors>Ahmed Yasin Koculu</Authors>
<AssemblyTitle>ZoneTree.FullTextSearch</AssemblyTitle>
<Description>ZoneTree.FullTextSearch is an open-source library that extends ZoneTree to provide efficient full-text search capabilities. It offers a fast, embedded search engine suitable for applications that require high performance and do not rely on external databases.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@
if (tokenComparer == null)
tokenComparer = ComponentsForKnownTypes.GetComparer<TToken>();
var fileStreamProvider = advancedOptions?.FileStreamProvider;
// Composite keys support custom comparers, so no compatible Bloom-filter hasher can be assumed.
// Advanced factory configurators can supply a hasher and enable the filter explicitly.
var factory1 = new ZoneTreeFactory<CompositeKeyOfTokenRecordPrevious<TRecord, TToken>, byte>(fileStreamProvider)
.SetDataDirectory($"{dataPath}/index1")
.SetMutableSegmentBloomFilterBitsPerItem(0)
.SetIsDeletedDelegate(
(in CompositeKeyOfTokenRecordPrevious<TRecord, TToken> key, in byte value) => value == 1)
.SetMarkValueDeletedDelegate((ref byte x) => x = 1)
Expand All @@ -134,6 +137,7 @@
{
var factory2 = new ZoneTreeFactory<CompositeKeyOfRecordToken<TRecord, TToken>, byte>(fileStreamProvider)
.SetDataDirectory($"{dataPath}/index2")
.SetMutableSegmentBloomFilterBitsPerItem(0)
.SetIsDeletedDelegate(
(in CompositeKeyOfRecordToken<TRecord, TToken> key, in byte value) => value == 1)
.SetMarkValueDeletedDelegate((ref byte x) => x = 1)
Expand Down Expand Up @@ -161,7 +165,7 @@
/// </summary>
public void ThrowIfIndexIsDropped()
{
if (isDropped) throw new Exception($"{nameof(

Check warning on line 168 in src/ZoneTree.FullTextSearch/Index/IndexOfTokenRecordPreviousToken.cs

View workflow job for this annotation

GitHub Actions / build

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
IndexOfTokenRecordPreviousToken<TRecord, TToken>)} is dropped.");
}

Expand Down
6 changes: 1 addition & 5 deletions src/ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ZoneTree" Version="1.8.7" />
<PackageReference Include="ZoneTree" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading