Skip to content

Commit f06a074

Browse files
committed
Release v2.0.2 — Result types
1 parent 4c4b83b commit f06a074

19 files changed

Lines changed: 26 additions & 22 deletions

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This project follows [Semantic Versioning](https://semver.org/).
1212
| Area | v1 behaviour | v2 behaviour |
1313
|------|-------------|-------------|
1414
| **Constructor** | `new JetDatabaseReader(path)` | `AccessReader.Open(path)` — factory method required |
15-
| **`ReadTable()`** | Returned `(headers, rows, schema)` tuple | **Renamed** to `ReadTablePreview()` |
15+
| **`ReadTable()`** | Returned `(headers, rows, schema)` tuple | Now an overload — `ReadTable(string, int)` returns `TableResult` |
1616
| **`ReadTableAsDataTable()`** | Returned `DataTable` with `string` columns | **Renamed** to `ReadTableAsStringDataTable()` |
1717
| **`StreamRows()`** | Returned `IEnumerable<string[]>` | Now returns `IEnumerable<object[]>` with native CLR types |
1818
| **`ReadAllTables()`** | Returned `DataTable` with `string` columns | Now returns `DataTable` with typed CLR columns |
@@ -23,7 +23,9 @@ This project follows [Semantic Versioning](https://semver.org/).
2323
| Method | Description |
2424
|--------|-------------|
2525
| `ReadTable()` | Primary read method — typed `DataTable` (replaces `ReadTableAsDataTableTyped`) |
26+
| `ReadTable(string, int)` | Sampled-rows overload — returns `TableResult` (headers, rows, schema) |
2627
| `ReadTableAsync()` | Async typed `DataTable` |
28+
| `ReadTableAsync(string, int)` | Async sampled-rows overload — returns `Task<TableResult>` |
2729
| `StreamRowsAsStrings()` | Compatibility streaming — `IEnumerable<string[]>` |
2830
| `ReadAllTablesAsStrings()` | Bulk read with string columns |
2931
| `ReadAllTablesAsStringsAsync()` | Async bulk read with string columns |
@@ -36,6 +38,8 @@ This project follows [Semantic Versioning](https://semver.org/).
3638
| `TableQuery.Count()` / `CountAsStrings()` | Count per chain |
3739
| `GetColumnMetadata()` | Rich per-column metadata with CLR type |
3840
| `GetStatistics()` / `GetStatisticsAsync()` | Database-level statistics + cache hit rate |
41+
| `TableResult` | Result type for sampled-rows overload — `Headers`, `Rows`, `Schema` |
42+
| `TableColumn` | Schema entry — `Name`, `TypeName`, `SizeDesc` |
3943

4044
### 🔧 Improvements
4145

@@ -68,11 +72,12 @@ DataTable dt = r.ReadTableAsDataTable("Orders");
6872
// v2
6973
DataTable dt = r.ReadTableAsStringDataTable("Orders");
7074

71-
// ── Preview with schema ──────────────────────────────────────────────
75+
// ── Sample with schema ──────────────────────────────────────────────
7276
// v1
7377
var (h, rows, schema) = r.ReadTable("Orders", maxRows: 10);
7478
// v2
75-
var (h, rows, schema) = r.ReadTablePreview("Orders", maxRows: 10);
79+
TableResult p = r.ReadTable("Orders", 10);
80+
// p.Headers / p.Rows / p.Schema[i].Name, .TypeName, .SizeDesc
7681
7782
// ── Stream rows (typed) ──────────────────────────────────────────────
7883
// v1
File renamed without changes.

JetDatabaseReader.Tests/AccessReaderCoreTests.cs renamed to JetDatabaseReader.Tests/Core/AccessReaderCoreTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void ReadTable_Preview_HeadersMatchSchemaColumnNames(string path)
244244
using var reader = TestDatabases.Open(path);
245245
string table = reader.ListTables()[0];
246246

247-
TablePreviewResult preview = reader.ReadTable(table, maxRows: 10);
247+
TableResult preview = reader.ReadTable(table, maxRows: 10);
248248

249249
preview.Headers.Should().HaveCount(preview.Schema.Count);
250250
for (int i = 0; i < preview.Headers.Count; i++)
@@ -259,7 +259,7 @@ public void ReadTable_Preview_RowCount_DoesNotExceedMaxRows(string path)
259259
string table = reader.ListTables()[0];
260260
const int max = 5;
261261

262-
TablePreviewResult preview = reader.ReadTable(table, maxRows: max);
262+
TableResult preview = reader.ReadTable(table, maxRows: max);
263263

264264
preview.Rows.Should().HaveCountLessThanOrEqualTo(max);
265265
}
@@ -271,7 +271,7 @@ public void ReadTable_Preview_EachRow_HasSameColumnCountAsHeaders(string path)
271271
using var reader = TestDatabases.Open(path);
272272
string table = reader.ListTables()[0];
273273

274-
TablePreviewResult preview = reader.ReadTable(table, maxRows: 20);
274+
TableResult preview = reader.ReadTable(table, maxRows: 20);
275275

276276
foreach (var row in preview.Rows)
277277
row.Should().HaveCount(preview.Headers.Count);
File renamed without changes.
File renamed without changes.
File renamed without changes.

JetDatabaseReader.Tests/AccessReaderStreamTests.cs renamed to JetDatabaseReader.Tests/Stream/AccessReaderStreamTests.cs

File renamed without changes.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,29 +773,29 @@ public long GetRealRowCount(string tableName)
773773
/// Returns column headers, sampled rows (as strings), and per-column schema.
774774
/// Useful for previewing table structure and data.
775775
/// </summary>
776-
public TablePreviewResult ReadTable(string tableName, int maxRows)
776+
public TableResult ReadTable(string tableName, int maxRows)
777777
{
778778
CatalogEntry entry = GetCatalogEntry(tableName);
779779

780780
if (entry == null)
781-
return new TablePreviewResult
781+
return new TableResult
782782
{
783783
Headers = new List<string>(),
784784
Rows = new List<List<string>>(),
785-
Schema = new List<TablePreviewColumn>()
785+
Schema = new List<TableColumn>()
786786
};
787787

788788
TableDef td = ReadTableDef(entry.TDefPage);
789789
if (td == null || td.Columns.Count == 0)
790-
return new TablePreviewResult
790+
return new TableResult
791791
{
792792
Headers = new List<string>(),
793793
Rows = new List<List<string>>(),
794-
Schema = new List<TablePreviewColumn>()
794+
Schema = new List<TableColumn>()
795795
};
796796

797797
var headers = td.Columns.ConvertAll(c => c.Name);
798-
var schema = td.Columns.ConvertAll(c => new TablePreviewColumn
798+
var schema = td.Columns.ConvertAll(c => new TableColumn
799799
{
800800
Name = c.Name,
801801
TypeName = TypeCodeToName(c.Type),
@@ -817,7 +817,7 @@ public TablePreviewResult ReadTable(string tableName, int maxRows)
817817
}
818818
}
819819

820-
return new TablePreviewResult { Headers = headers, Rows = rows, Schema = schema };
820+
return new TableResult { Headers = headers, Rows = rows, Schema = schema };
821821
}
822822

823823
private static string TypeCodeToName(byte t)
@@ -1188,7 +1188,7 @@ public Task<DataTable> ReadTableAsync(string tableName = null, IProgress<int> pr
11881188
/// Async overload of <see cref="ReadTable(string, int)"/>.
11891189
/// Reads up to <paramref name="maxRows"/> rows and schema information asynchronously.
11901190
/// </summary>
1191-
public Task<TablePreviewResult> ReadTableAsync(string tableName, int maxRows)
1191+
public Task<TableResult> ReadTableAsync(string tableName, int maxRows)
11921192
{
11931193
return Task.Run(() => ReadTable(tableName, maxRows));
11941194
}
File renamed without changes.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ public interface IAccessReader : IDisposable
5656
/// Reads up to <paramref name="maxRows"/> rows from the table named
5757
/// <paramref name="tableName"/> (case-insensitive).
5858
/// Returns column headers, sampled rows (as strings), and per-column schema.
59-
/// Useful for previewing table structure and data.
6059
/// </summary>
61-
TablePreviewResult ReadTable(string tableName, int maxRows);
60+
TableResult ReadTable(string tableName, int maxRows);
6261

6362
/// <summary>
6463
/// Async overload of <see cref="ReadTable(string, int)"/>.
6564
/// Reads up to <paramref name="maxRows"/> rows and schema information asynchronously.
6665
/// </summary>
67-
Task<TablePreviewResult> ReadTableAsync(string tableName, int maxRows);
66+
Task<TableResult> ReadTableAsync(string tableName, int maxRows);
6867

6968
/// <summary>
7069
/// Yields rows from <paramref name="tableName"/> as properly typed object arrays without collecting them all in memory.

0 commit comments

Comments
 (0)