Pipes and test scripts

This commit is contained in:
Michael Schimmel
2025-12-26 13:47:10 +01:00
parent 8b765487ae
commit 185f8273dd
23 changed files with 1477 additions and 572 deletions
+14 -2
View File
@@ -26,6 +26,8 @@ type
// The 8-byte storage for the scalar value
PValue = ^TValue;
TValue = record
class operator Implicit(A: Int64): TValue; overload;
class operator Implicit(A: Double): TValue; overload;
case TKind of
TKind.Ordinal, TKind.Keyword, TKind.Boolean: (AsInt64: Int64);
TKind.Float, TKind.DateTime: (AsDouble: Double);
@@ -190,19 +192,19 @@ type
IScalarRecordSeries = interface(IKeywordMapping<ISeries>)
{$region 'private'}
function GetDef: IScalarRecordDefinition;
function GetTotalCount: Int64;
{$endregion}
property Def: IScalarRecordDefinition read GetDef;
property TotalCount: Int64 read GetTotalCount;
end;
IWriteableScalarRecordSeries = interface(IScalarRecordSeries)
{$region 'private'}
function GetRecordCount: Int64;
function GetTotalCount: Int64;
{$endregion}
procedure Add(const Item: IKeywordMapping<TScalar>; Lookback: Int64 = -1); overload;
procedure Add(const Items: array of TScalar.TValue; Lookback: Int64 = -1); overload;
property RecordCount: Int64 read GetRecordCount;
property TotalCount: Int64 read GetTotalCount;
end;
// A series of scalar records, optimized for memory and access speed.
@@ -1071,6 +1073,16 @@ begin
Result := FDef.IndexOf(Key);
end;
class operator TScalar.TValue.Implicit(A: Int64): TValue;
begin
Result.AsInt64 := A;
end;
class operator TScalar.TValue.Implicit(A: Double): TValue;
begin
Result.AsDouble := A;
end;
initialization
Assert(sizeof(TScalar.TValue) = 8);
-1
View File
@@ -9,7 +9,6 @@ uses
System.SyncObjs,
Myc.Data.Scalar,
Myc.Data.Keyword,
Myc.Data.Value,
Myc.Core.Notifier;
type
+23
View File
@@ -9,6 +9,7 @@ uses
Myc.Utils,
Myc.Data.Scalar,
Myc.Data.Series,
Myc.Data.Stream,
Myc.Data.Keyword;
type
@@ -24,6 +25,7 @@ type
vkMethod,
vkInterface,
vkPointer,
vkStream,
vkGeneric
);
@@ -86,6 +88,9 @@ type
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue; static; inline;
class function FromSeries(const AValue: ISeries): TDataValue; static; inline;
// New Factory for Streams
class function FromStream(const AStream: IStream): TDataValue; static; inline;
// --- Existing Accessors ---
function AsScalar: TScalar; inline;
function AsMethod: TFunc; inline;
@@ -96,6 +101,9 @@ type
function AsSeries: ISeries; inline;
function AsObject: TObject; overload; inline;
// New Accessor for Streams
function AsStream: IStream; inline;
function ToString: String;
property IsVoid: Boolean read GetIsVoid;
property Kind: TDataValueKind read FKind;
@@ -141,6 +149,7 @@ begin
vkInterface: Result := 'Interface';
vkPointer: Result := 'Pointer';
vkGeneric: Result := 'Generic';
vkStream: Result := 'Stream';
else
Result := 'Unknown';
end;
@@ -273,6 +282,12 @@ begin
Result.FInterface := AValue;
end;
class function TDataValue.FromStream(const AStream: IStream): TDataValue;
begin
Result.FKind := vkStream;
Result.FInterface := AStream;
end;
class function TDataValue.Map(const SourceSeries: ISeries; const MapperFunc: TFunc): ISeries;
begin
Result := TMapSeries.Create(SourceSeries, MapperFunc);
@@ -285,6 +300,13 @@ begin
Result := ISeries(FInterface);
end;
function TDataValue.AsStream: IStream;
begin
if (FKind <> vkStream) then
raise EInvalidCast.Create('Cannot read value as Stream.');
Result := IStream(FInterface);
end;
function TDataValue.AsMethod: TFunc;
begin
if (FKind <> vkMethod) then
@@ -443,6 +465,7 @@ begin
sb.Free;
end;
end;
vkStream: Result := '<stream>';
vkVoid: Result := '<void>';
vkMethod: Result := '<method>';
vkGeneric: Result := '<generic>';