Skip to content

Commit 9d07a99

Browse files
committed
Community + refactoring
1 parent ba8d595 commit 9d07a99

File tree

69 files changed

+1072
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1072
-355
lines changed

src/ManagedCode.GraphRag.Postgres/GraphRagConfigExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
31
using GraphRag.Config;
42

53
namespace GraphRag.Storage.Postgres;

src/ManagedCode.GraphRag.Postgres/PostgresExplainService.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
41
using System.Text;
5-
using System.Threading;
6-
using System.Threading.Tasks;
72
using Microsoft.Extensions.Logging;
83

94
namespace GraphRag.Storage.Postgres;
105

11-
public sealed class PostgresExplainService
6+
public sealed class PostgresExplainService(PostgresGraphStore graphStore, ILogger<PostgresExplainService> logger)
127
{
13-
private readonly PostgresGraphStore _graphStore;
14-
private readonly ILogger<PostgresExplainService> _logger;
15-
16-
public PostgresExplainService(PostgresGraphStore graphStore, ILogger<PostgresExplainService> logger)
17-
{
18-
_graphStore = graphStore ?? throw new ArgumentNullException(nameof(graphStore));
19-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
20-
}
8+
private readonly PostgresGraphStore _graphStore = graphStore ?? throw new ArgumentNullException(nameof(graphStore));
9+
private readonly ILogger<PostgresExplainService> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
2110

2211
public async Task<string> GetFormattedPlanAsync(string cypherQuery, IReadOnlyDictionary<string, object?>? parameters = null, CancellationToken cancellationToken = default)
2312
{

src/ManagedCode.GraphRag.Postgres/PostgresGraphIngestionBenchmark.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Diagnostics;
4-
using System.Globalization;
5-
using System.IO;
6-
using System.Threading;
7-
using System.Threading.Tasks;
82
using Microsoft.Extensions.Logging;
93

104
namespace GraphRag.Storage.Postgres;
115

12-
public sealed class PostgresGraphIngestionBenchmark
6+
public sealed class PostgresGraphIngestionBenchmark(PostgresGraphStore graphStore, ILogger<PostgresGraphIngestionBenchmark> logger)
137
{
14-
private readonly PostgresGraphStore _graphStore;
15-
private readonly ILogger<PostgresGraphIngestionBenchmark> _logger;
16-
17-
public PostgresGraphIngestionBenchmark(PostgresGraphStore graphStore, ILogger<PostgresGraphIngestionBenchmark> logger)
18-
{
19-
_graphStore = graphStore ?? throw new ArgumentNullException(nameof(graphStore));
20-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
21-
}
8+
private readonly PostgresGraphStore _graphStore = graphStore ?? throw new ArgumentNullException(nameof(graphStore));
9+
private readonly ILogger<PostgresGraphIngestionBenchmark> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
2210

2311
public async Task<PostgresIngestionBenchmarkResult> RunAsync(Stream csvStream, PostgresIngestionBenchmarkOptions options, CancellationToken cancellationToken = default)
2412
{
@@ -31,7 +19,7 @@ public async Task<PostgresIngestionBenchmarkResult> RunAsync(Stream csvStream, P
3119
}
3220

3321
using var reader = new StreamReader(csvStream, leaveOpen: true);
34-
var headerLine = await reader.ReadLineAsync().ConfigureAwait(false);
22+
var headerLine = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
3523
if (string.IsNullOrWhiteSpace(headerLine))
3624
{
3725
return new PostgresIngestionBenchmarkResult(0, 0, TimeSpan.Zero, options.EnsurePropertyIndexes);
@@ -63,7 +51,7 @@ public async Task<PostgresIngestionBenchmarkResult> RunAsync(Stream csvStream, P
6351
var relationshipsWritten = 0;
6452

6553
string? line;
66-
while ((line = await reader.ReadLineAsync().ConfigureAwait(false)) is not null)
54+
while ((line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false)) is not null)
6755
{
6856
cancellationToken.ThrowIfCancellationRequested();
6957
if (string.IsNullOrWhiteSpace(line))

src/ManagedCode.GraphRag.Postgres/PostgresGraphStore.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
21
using System.Collections;
32
using System.Collections.Concurrent;
4-
using System.Collections.Generic;
53
using System.Globalization;
6-
using System.Linq;
74
using System.Runtime.CompilerServices;
85
using System.Text;
96
using System.Text.Json;
@@ -482,10 +479,7 @@ private static string BuildGraphNameLiteral(string graphName)
482479

483480
private static NpgsqlParameter CreateAgTypeParameter(string name, string jsonPayload)
484481
{
485-
if (jsonPayload is null)
486-
{
487-
throw new ArgumentNullException(nameof(jsonPayload));
488-
}
482+
ArgumentNullException.ThrowIfNull(jsonPayload);
489483

490484
return new NpgsqlParameter(name, NpgsqlDbType.Unknown)
491485
{

src/ManagedCode.GraphRag.Postgres/PostgresGraphStoreConfig.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
41
namespace GraphRag.Storage.Postgres;
52

63
public sealed class PostgresGraphStoreConfig
@@ -16,5 +13,5 @@ public sealed class PostgresGraphStoreConfig
1613
public Dictionary<string, string[]> EdgePropertyIndexes { get; set; } = new(StringComparer.OrdinalIgnoreCase);
1714

1815
public bool MakeDefault { get; set; }
19-
= false;
16+
2017
}

src/ManagedCode.GraphRag.Postgres/PostgresIngestionBenchmarkOptions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
41
namespace GraphRag.Storage.Postgres;
52

63
public sealed class PostgresIngestionBenchmarkOptions

src/ManagedCode.GraphRag.Postgres/PostgresIngestionBenchmarkResult.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace GraphRag.Storage.Postgres;
42

53
public sealed record PostgresIngestionBenchmarkResult(

src/ManagedCode.GraphRag.Postgres/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
41
using GraphRag.Config;
52
using GraphRag.Graphs;
63
using Microsoft.Extensions.DependencyInjection;

src/ManagedCode.GraphRag/Cache/IPipelineCache.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System.Collections.Generic;
2-
using System.Threading;
3-
using System.Threading.Tasks;
4-
51
namespace GraphRag.Cache;
62

73
public interface IPipelineCache

src/ManagedCode.GraphRag/Cache/InMemoryPipelineCache.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
21
using System.Collections.Concurrent;
3-
using System.Collections.Generic;
4-
using System.Threading;
5-
using System.Threading.Tasks;
62

73
namespace GraphRag.Cache;
84

0 commit comments

Comments
 (0)