Adding Pipes
This commit is contained in:
@@ -133,21 +133,29 @@ type
|
||||
// A field definition for a scalar record.
|
||||
TScalarRecordField = TPair<IKeyword, TScalar.TKind>;
|
||||
IScalarRecordDefinition = IKeywordMapping<TScalar.TKind>;
|
||||
IScalarRecord = IKeywordMapping<TScalar>;
|
||||
|
||||
TScalarRecord = class(TInterfacedObject, IScalarRecord)
|
||||
IScalarRecord = interface(IKeywordMapping<TScalar>)
|
||||
{$region 'private'}
|
||||
function GetDef: IScalarRecordDefinition;
|
||||
{$endregion}
|
||||
property Def: IScalarRecordDefinition read GetDef;
|
||||
end;
|
||||
|
||||
TScalarRecord = class(TInterfacedObject, IKeywordMapping<TScalar>, IScalarRecord)
|
||||
type
|
||||
TRegistry = TKeywordMappingRegistry<TScalar.TKind>;
|
||||
private
|
||||
FDef: IScalarRecordDefinition;
|
||||
FData: TArray<TScalar.TValue>;
|
||||
FDef: IScalarRecordDefinition;
|
||||
|
||||
function IndexOf(const Key: IKeyword): Integer;
|
||||
function GetCount: Integer;
|
||||
function GetDef: IScalarRecordDefinition;
|
||||
function GetItems(Idx: Integer): TPair<IKeyword, TScalar>;
|
||||
function GetFields(const Key: IKeyword): TScalar;
|
||||
public
|
||||
constructor Create(const ADef: IScalarRecordDefinition; const AData: TArray<TScalar.TValue>);
|
||||
property Def: IScalarRecordDefinition read GetDef;
|
||||
end;
|
||||
|
||||
ISeries = interface
|
||||
@@ -179,27 +187,25 @@ type
|
||||
procedure Add(const Item: TScalar.TValue; Lookback: Int64 = -1);
|
||||
end;
|
||||
|
||||
IScalarRecordSeries = interface
|
||||
IScalarRecordSeries = interface(IKeywordMapping<ISeries>)
|
||||
{$region 'private'}
|
||||
function GetCount: Int64;
|
||||
function GetDef: IScalarRecordDefinition;
|
||||
function GetFields(const Key: IKeyword): ISeries;
|
||||
function GetTotalCount: Int64;
|
||||
{$endregion}
|
||||
property Count: Int64 read GetCount;
|
||||
property Def: IScalarRecordDefinition read GetDef;
|
||||
property Fields[const Key: IKeyword]: ISeries read GetFields; default;
|
||||
property TotalCount: Int64 read GetTotalCount;
|
||||
end;
|
||||
|
||||
IWriteableScalarRecordSeries = interface(IScalarRecordSeries)
|
||||
{$region 'private'}
|
||||
function GetRecordCount: Int64;
|
||||
function GetTotalCount: Int64;
|
||||
{$endregion}
|
||||
procedure Add(const Item: IScalarRecord; Lookback: Int64 = -1);
|
||||
procedure Add(const Item: IKeywordMapping<TScalar>; Lookback: Int64 = -1);
|
||||
property RecordCount: Int64 read GetRecordCount;
|
||||
property TotalCount: Int64 read GetTotalCount;
|
||||
end;
|
||||
|
||||
// A series of scalar records, optimized for memory and access speed.
|
||||
TScalarRecordSeries = class(TInterfacedObject, IWriteableScalarRecordSeries)
|
||||
TScalarRecordSeries = class(TInterfacedObject, IWriteableScalarRecordSeries, IKeywordMapping<ISeries>)
|
||||
type
|
||||
TMemberSeries = class(TGenericContainedObject<TScalarRecordSeries>, ISeries)
|
||||
private
|
||||
@@ -218,19 +224,24 @@ type
|
||||
FArray: TChunkArray<TScalar.TValue>;
|
||||
FFields: TArray<TMemberSeries>;
|
||||
FTotalCount: Int64;
|
||||
function GetCount: Int64; inline;
|
||||
|
||||
function GetItems(Idx: Integer): TPair<IKeyword, ISeries>;
|
||||
function GetCount: Integer;
|
||||
function IndexOf(const Key: IKeyword): Integer;
|
||||
|
||||
function GetRecordCount: Int64; inline;
|
||||
function GetFields(const Key: IKeyword): ISeries;
|
||||
function GetDef: IScalarRecordDefinition; inline;
|
||||
function GetTotalCount: Int64; inline;
|
||||
function GetItemRef(Idx: Integer): TChunkArray<TScalar.TValue>.PT; inline;
|
||||
function GetMapping: IKeywordMapping<ISeries>;
|
||||
public
|
||||
constructor Create(const ADef: IScalarRecordDefinition);
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure Add(const Item: IScalarRecord; Lookback: Int64 = -1);
|
||||
procedure Add(const Item: IKeywordMapping<TScalar>; Lookback: Int64 = -1);
|
||||
|
||||
property Count: Int64 read GetCount;
|
||||
property Fields[const Key: IKeyword]: ISeries read GetFields; default;
|
||||
property RecordCount: Int64 read GetRecordCount;
|
||||
property Def: IScalarRecordDefinition read GetDef;
|
||||
property TotalCount: Int64 read GetTotalCount;
|
||||
end;
|
||||
@@ -803,7 +814,7 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TScalarRecordSeries.Add(const Item: IScalarRecord; Lookback: Int64 = -1);
|
||||
procedure TScalarRecordSeries.Add(const Item: IKeywordMapping<TScalar>; Lookback: Int64 = -1);
|
||||
begin
|
||||
var lb := FDef.Count * Integer(Lookback);
|
||||
for var i := 0 to FDef.Count - 1 do
|
||||
@@ -820,7 +831,7 @@ begin
|
||||
Result := FFields[elem];
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.GetCount: Int64;
|
||||
function TScalarRecordSeries.GetRecordCount: Int64;
|
||||
begin
|
||||
Result := FArray.Count div FDef.Count;
|
||||
end;
|
||||
@@ -836,11 +847,32 @@ begin
|
||||
Result := FArray.ItemRef[(FArray.Count - len) - (Idx * len)];
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.GetMapping: IKeywordMapping<ISeries>;
|
||||
begin
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.GetTotalCount: Int64;
|
||||
begin
|
||||
Result := FTotalCount;
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.GetCount: Integer;
|
||||
begin
|
||||
Result := Length(FFields);
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.GetItems(Idx: Integer): TPair<IKeyword, ISeries>;
|
||||
begin
|
||||
Result.Key := FDef.Items[Idx].Key;
|
||||
Result.Value := FFields[Idx];
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.IndexOf(const Key: IKeyword): Integer;
|
||||
begin
|
||||
Result := FDef.IndexOf(Key);
|
||||
end;
|
||||
|
||||
{ TScalar.TKindHelper }
|
||||
|
||||
function TScalar.TKindHelper.ToString: string;
|
||||
@@ -907,7 +939,7 @@ end;
|
||||
|
||||
function TScalarRecordSeries.TMemberSeries.GetCount: Int64;
|
||||
begin
|
||||
Result := RecordSeries.Count;
|
||||
Result := RecordSeries.RecordCount;
|
||||
end;
|
||||
|
||||
function TScalarRecordSeries.TMemberSeries.GetItems(Idx: Integer): TScalar;
|
||||
@@ -998,6 +1030,11 @@ begin
|
||||
Result := FDef.Count;
|
||||
end;
|
||||
|
||||
function TScalarRecord.GetDef: IScalarRecordDefinition;
|
||||
begin
|
||||
Result := FDef;
|
||||
end;
|
||||
|
||||
function TScalarRecord.GetFields(const Key: IKeyword): TScalar;
|
||||
var
|
||||
idx: Integer;
|
||||
|
||||
Reference in New Issue
Block a user