in code/KustoCopyConsole/Storage/LogStorage.cs [94:136]
private async static Task<long> FetchShardCountAsync(
IFileSystem fileSystem,
CancellationToken ct)
{
using (var stream = await fileSystem.OpenReadAsync(INDEX_PATH, ct))
{
if (stream == null)
{
return 0;
}
else
{
using (var reader = new StreamReader(stream))
{
var headerText = await reader.ReadLineAsync();
var indexText = await reader.ReadLineAsync();
var header = headerText != null
? JsonSerializer.Deserialize<VersionHeader>(
headerText,
HeaderJsonContext.Default.VersionHeader)
: null;
var indexInfo = indexText != null
? JsonSerializer.Deserialize<IndexInfo>(
indexText,
HeaderJsonContext.Default.IndexInfo)
: null;
if (header == null)
{
throw new InvalidDataException("Index blob doesn't contain header");
}
if (indexInfo == null)
{
throw new InvalidDataException(
"Index blob doesn't contain index information");
}
return indexInfo.ShardCount;
}
}
}
}