Skip to content

Commit 6aa4ac4

Browse files
author
MPCoreDeveloper
committed
Updated roadmap , updated structure of files
1 parent b9ea5cc commit 6aa4ac4

File tree

54 files changed

+6914
-1557
lines changed

Some content is hidden

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

54 files changed

+6914
-1557
lines changed

SharpCoreDB/TestPageBasedSelect.csx renamed to SharpCoreDB.Tests/Scripts/TestPageBasedSelect.csx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// ? RELOCATED: Moved from SharpCoreDB (main project) to SharpCoreDB.Tests/Scripts/
2+
// Original: SharpCoreDB/TestPageBasedSelect.csx
3+
// New: SharpCoreDB.Tests/Scripts/TestPageBasedSelect.csx
4+
// Date: December 2025
5+
// Reason: Test scripts belong in test project, not production code
6+
17
// Quick test to verify PageBased SELECT works
28
using SharpCoreDB.Core;
39
using SharpCoreDB.DataStructures;
@@ -26,7 +32,7 @@ try
2632
// Test 1: SELECT * (full table scan)
2733
Console.WriteLine("\nTest 1: SELECT * FROM Users");
2834
var allRows = db.ExecuteQuery("SELECT * FROM Users");
29-
Console.WriteLine($" Found {allRows.Count} rows");
35+
Console.WriteLine($" ? Found {allRows.Count} rows");
3036
foreach (var row in allRows)
3137
{
3238
Console.WriteLine($" - Id={row["Id"]}, Name={row["Name"]}, Age={row["Age"]}");
@@ -35,7 +41,7 @@ try
3541
// Test 2: SELECT with WHERE (primary key lookup)
3642
Console.WriteLine("\nTest 2: SELECT * FROM Users WHERE Id = 3");
3743
var pkRow = db.ExecuteQuery("SELECT * FROM Users WHERE Id = 3");
38-
Console.WriteLine($" Found {pkRow.Count} rows");
44+
Console.WriteLine($" ? Found {pkRow.Count} rows");
3945
if (pkRow.Count > 0)
4046
{
4147
Console.WriteLine($" - Id={pkRow[0]["Id"]}, Name={pkRow[0]["Name"]}, Age={pkRow[0]["Age"]}");
@@ -44,7 +50,7 @@ try
4450
// Test 3: SELECT with WHERE (full scan with filter)
4551
Console.WriteLine("\nTest 3: SELECT * FROM Users WHERE Age > 30");
4652
var filteredRows = db.ExecuteQuery("SELECT * FROM Users WHERE Age > 30");
47-
Console.WriteLine($" Found {filteredRows.Count} rows");
53+
Console.WriteLine($" ? Found {filteredRows.Count} rows");
4854
foreach (var row in filteredRows)
4955
{
5056
Console.WriteLine($" - Id={row["Id"]}, Name={row["Name"]}, Age={row["Age"]}");
@@ -54,15 +60,15 @@ try
5460
Console.WriteLine("\nTest 4: UPDATE Users SET Age = 31 WHERE Id = 2");
5561
db.Execute("UPDATE Users SET Age = 31 WHERE Id = 2");
5662
var updated = db.ExecuteQuery("SELECT * FROM Users WHERE Id = 2");
57-
Console.WriteLine($" Updated age: {updated[0]["Age"]}");
63+
Console.WriteLine($" ? Updated age: {updated[0]["Age"]}");
5864

5965
// Test 5: DELETE
6066
Console.WriteLine("\nTest 5: DELETE FROM Users WHERE Id = 5");
6167
db.Execute("DELETE FROM Users WHERE Id = 5");
6268
var remaining = db.ExecuteQuery("SELECT * FROM Users");
63-
Console.WriteLine($" Remaining rows: {remaining.Count}");
69+
Console.WriteLine($" ? Remaining rows: {remaining.Count}");
6470

65-
Console.WriteLine("\n All tests passed!");
71+
Console.WriteLine("\n? All tests passed!");
6672
}
6773
finally
6874
{

SharpCoreDB/DataStructures/Table.BatchUpdate.cs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -581,29 +581,6 @@ private static string FormatValue(object? value)
581581
};
582582
}
583583

584-
/// <summary>
585-
/// 🔥 NEW: Executes typed UpdateBatch for a single PRIMARY KEY update.
586-
/// This is the fast path that achieves 5-7x speedup.
587-
/// </summary>
588-
private static bool ExecuteTypedUpdate<TId, TValue>(
589-
Table table,
590-
string idColumn,
591-
string updateColumn,
592-
List<(TId id, TValue value)> updates)
593-
where TId : notnull
594-
where TValue : notnull
595-
{
596-
try
597-
{
598-
table.UpdateBatch(idColumn, updateColumn, updates);
599-
return true;
600-
}
601-
catch
602-
{
603-
return false;
604-
}
605-
}
606-
607584
/// <summary>
608585
/// 🔥 NEW: Batch update with multiple columns using strongly-typed ID and dynamic values.
609586
/// Optimized for PRIMARY KEY lookups with multiple column updates.
@@ -643,10 +620,10 @@ public int UpdateBatchMultiColumn<TId>(
643620
.Distinct()
644621
.ToList();
645622

646-
foreach (var col in allUpdateColumns)
623+
var missingColumns = allUpdateColumns.Where(col => !Columns.Contains(col)).ToList();
624+
if (missingColumns.Count > 0)
647625
{
648-
if (!Columns.Contains(col))
649-
throw new ArgumentException($"Column '{col}' not found");
626+
throw new ArgumentException($"Column(s) '{string.Join(", ", missingColumns)}' not found");
650627
}
651628

652629
var engine = GetOrCreateStorageEngine();
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,31 @@
22
// Copyright (c) 2025-2026 MPCoreDeveloper and GitHub Copilot. All rights reserved.
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
// </copyright>
5+
6+
// ✅ RELOCATED: Moved from root to DataStructures/
7+
// Original: SharpCoreDB/Ulid.cs
8+
// New: SharpCoreDB/DataStructures/Ulid.cs
9+
// Date: December 2025
10+
// Reason: Data structure belongs with other data structures (TableInfo, ColumnInfo, etc.)
11+
512
namespace SharpCoreDB;
613

714
using SharpCoreDB.Base32Encoding;
815
using System.Security.Cryptography;
916

1017
/// <summary>
1118
/// Represents a Universally Unique Lexicographically Sortable Identifier (ULID).
19+
/// Modern C# 14 record type with Span-based operations.
20+
///
21+
/// Location: DataStructures/Ulid.cs
22+
/// Purpose: Time-sortable unique identifier generation and parsing
23+
/// Features: Record type, Span&lt;T&gt; for zero-allocation, cryptographic randomness
1224
/// </summary>
1325
/// <param name="Value">The string value of the ULID.</param>
1426
public record Ulid(string Value)
1527
{
1628
/// <summary>
17-
/// Initializes a new instance of the <see cref="Ulid"/> class.
18-
/// Initializes a new instance of Ulid with an empty value.
29+
/// Initializes a new instance of the <see cref="Ulid"/> class with an empty value.
1930
/// </summary>
2031
public Ulid()
2132
: this(string.Empty)
@@ -53,6 +64,7 @@ public static Ulid NewUlid(DateTime timestamp)
5364

5465
/// <summary>
5566
/// Creates a new ULID with the specified timestamp in milliseconds since Unix epoch.
67+
/// Uses Span&lt;T&gt; for zero-allocation generation.
5668
/// </summary>
5769
/// <param name="timestamp">The timestamp in milliseconds.</param>
5870
/// <returns>A new Ulid instance.</returns>
@@ -93,7 +105,6 @@ public static DateTime GetTimestampFromUlid(Ulid ulid)
93105
}
94106

95107
ReadOnlySpan<byte> bytes = Base32.Decode(ulid.Value[..10]);
96-
97108
long timestamp = ExtractTimestamp(bytes);
98109

99110
return DateTime.UnixEpoch.AddMilliseconds(timestamp);
@@ -116,11 +127,10 @@ public long ToEpoch()
116127
{
117128
if (string.IsNullOrEmpty(this.Value) || this.Value.Length != 26)
118129
{
119-
return 0; // if the value is empty or not 26 characters long, return 0
130+
return 0;
120131
}
121132

122133
ReadOnlySpan<byte> bytes = Base32.Decode(this.Value[..10]);
123-
124134
return ExtractTimestamp(bytes);
125135
}
126136

@@ -133,6 +143,9 @@ public long ToUnixTime()
133143
return this.ToEpoch();
134144
}
135145

146+
/// <summary>
147+
/// Extracts timestamp from byte span.
148+
/// </summary>
136149
private static long ExtractTimestamp(ReadOnlySpan<byte> bytes)
137150
{
138151
long timestamp = 0;

SharpCoreDB/Database.BatchUpdateDeferredIndexes.cs

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)