Skip to content

Commit c427ef1

Browse files
author
Jade Wang
committed
fix(csharp): resolve merge conflicts in StatementExecutionResultFetcher
- Remove merge conflict markers - Remove duplicate constructors - Clean up interleaved code from manifest-based and Result-based implementations - Keep correct implementation using GetStatementResponse.Result and next_chunk_index chain
1 parent a438a4a commit c427ef1

File tree

1 file changed

+1
-81
lines changed

1 file changed

+1
-81
lines changed

csharp/src/Reader/CloudFetch/StatementExecutionResultFetcher.cs

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,11 @@ internal class StatementExecutionResultFetcher : BaseResultFetcher
5151
/// <param name="client">The Statement Execution API client.</param>
5252
/// <param name="statementId">The statement ID for fetching results.</param>
5353
/// <param name="initialResponse">The initial GetStatement response containing the first result.</param>
54-
<<<<<<< HEAD
5554
public StatementExecutionResultFetcher(
5655
IStatementExecutionClient client,
5756
string statementId,
5857
GetStatementResponse initialResponse)
5958
: base(null, null) // Resources will be injected via Initialize()
60-
/// <param name="manifest">The result manifest containing chunk information.</param>
61-
=======
62-
>>>>>>> defec99 (fix(csharp): use GetStatementResponse.Result and follow next_chunk_index chain)
63-
public StatementExecutionResultFetcher(
64-
IStatementExecutionClient client,
65-
string statementId,
66-
GetStatementResponse initialResponse)
67-
: base(null, null) // Resources will be injected via Initialize()
68-
/// <param name="manifest">The result manifest containing chunk information.</param>
69-
public StatementExecutionResultFetcher(
70-
IStatementExecutionClient client,
71-
string statementId,
72-
ResultManifest manifest)
73-
: base(null, null) // Resources will be injected via Initialize()
7459
{
7560
_client = client ?? throw new ArgumentNullException(nameof(client));
7661
_statementId = statementId ?? throw new ArgumentNullException(nameof(statementId));
@@ -161,7 +146,6 @@ protected override async Task FetchAllResultsAsync(CancellationToken cancellatio
161146
var currentResult = _initialResponse.Result;
162147

163148
if (currentResult == null)
164-
if (_manifest.TotalChunkCount == 0)
165149
{
166150
// No result data available
167151
_hasMoreResults = false;
@@ -177,43 +161,8 @@ protected override async Task FetchAllResultsAsync(CancellationToken cancellatio
177161
if (currentResult.ExternalLinks != null && currentResult.ExternalLinks.Any())
178162
{
179163
foreach (var link in currentResult.ExternalLinks)
180-
// Process all chunks - the manifest may only contain a subset for large result sets
181-
// Keep track of which chunk indices we've processed
182-
var processedChunkIndices = new HashSet<int>();
183-
184-
// First, process chunks from the manifest
185-
if (_manifest.Chunks != null && _manifest.Chunks.Count > 0)
186-
{
187-
foreach (var chunk in _manifest.Chunks)
188-
{
189-
cancellationToken.ThrowIfCancellationRequested();
190-
processedChunkIndices.Add(chunk.ChunkIndex);
191-
192-
// Check if chunk has external links in the manifest
193-
if (chunk.ExternalLinks != null && chunk.ExternalLinks.Any())
194164
{
195-
// Manifest-based fetching: all links available upfront
196-
foreach (var link in chunk.ExternalLinks)
197-
{
198-
CreateAndAddDownloadResult(link, cancellationToken);
199-
}
200-
}
201-
else
202-
{
203-
// Incremental chunk fetching: fetch external links for this chunk
204-
// This handles cases where the manifest doesn't contain all links upfront
205-
var resultData = await _client.GetResultChunkAsync(
206-
_statementId,
207-
chunk.ChunkIndex,
208-
cancellationToken).ConfigureAwait(false);
209-
210-
if (resultData.ExternalLinks != null && resultData.ExternalLinks.Any())
211-
{
212-
foreach (var link in resultData.ExternalLinks)
213-
{
214-
CreateAndAddDownloadResult(link, cancellationToken);
215-
}
216-
}
165+
CreateAndAddDownloadResult(link, cancellationToken);
217166
}
218167
}
219168

@@ -238,35 +187,6 @@ protected override async Task FetchAllResultsAsync(CancellationToken cancellatio
238187
{
239188
// No more chunks to fetch
240189
currentResult = null;
241-
}
242-
243-
// If the manifest is incomplete (common for large result sets), fetch remaining chunks
244-
// The manifest.Chunks list may not contain all chunks for large results
245-
if (processedChunkIndices.Count < _manifest.TotalChunkCount)
246-
{
247-
// Fetch the missing chunk indices
248-
for (int chunkIndex = 0; chunkIndex < _manifest.TotalChunkCount; chunkIndex++)
249-
{
250-
cancellationToken.ThrowIfCancellationRequested();
251-
252-
if (processedChunkIndices.Contains(chunkIndex))
253-
{
254-
continue; // Already processed this chunk
255-
}
256-
257-
// Fetch this chunk
258-
var resultData = await _client.GetResultChunkAsync(
259-
_statementId,
260-
chunkIndex,
261-
cancellationToken).ConfigureAwait(false);
262-
263-
if (resultData.ExternalLinks != null && resultData.ExternalLinks.Any())
264-
{
265-
foreach (var link in resultData.ExternalLinks)
266-
{
267-
CreateAndAddDownloadResult(link, cancellationToken);
268-
}
269-
}
270190
}
271191
}
272192

0 commit comments

Comments
 (0)