@@ -30,31 +30,15 @@ public static SerializableEntityTable ValidateColumnRowsAreAligned(this Serializ
3030 return et ;
3131 }
3232
33- public static string ValidateCanConcatBuffers ( this INamedBuffer thisBuffer , INamedBuffer otherBuffer )
34- {
35- var thisPrefix = SerializableEntityTable . GetTypeFromName ( thisBuffer . Name ) ;
36- if ( string . IsNullOrEmpty ( thisPrefix ) )
37- throw new Exception ( "NamedBuffer prefix not found" ) ;
38-
39- var otherPrefix = SerializableEntityTable . GetTypeFromName ( otherBuffer . Name ) ;
40- if ( string . IsNullOrEmpty ( otherPrefix ) )
41- throw new Exception ( "NamedBuffer prefix not found" ) ;
42-
43- if ( thisPrefix != otherPrefix )
44- throw new Exception ( "NamedBuffer prefixes are not equal" ) ;
45-
46- return thisPrefix ;
47- }
48-
4933 public static T [ ] RemapData < T > ( this T [ ] self , List < int > remapping = null )
5034 => remapping ? . Select ( x => self [ x ] ) ? . ToArray ( ) ?? self ;
5135
5236 public static IBuffer ToBuffer < T > ( this T [ ] array ) where T : unmanaged
5337 => new Buffer < T > ( array ) ;
5438
55- public const string UnknownNamedBufferPrefix = "Unknown NamedBuffer prefix" ;
39+ private const string UnknownNamedBufferPrefix = "Unknown NamedBuffer prefix" ;
5640
57- public static object GetDataColumnValue ( this IBuffer dataColumn , string typePrefix , int rowIndex )
41+ private static object GetDataColumnValue ( this IBuffer dataColumn , string typePrefix , int rowIndex )
5842 {
5943 switch ( typePrefix )
6044 {
@@ -123,7 +107,7 @@ public static INamedBuffer CopyDataColumn(this INamedBuffer dataColumn, List<int
123107 return new NamedBuffer ( dataColumn . CopyDataColumn ( typePrefix , remapping ) , dataColumn . Name ) ;
124108 }
125109
126- public static IBuffer Concat < T > ( this IBuffer thisBuffer , IBuffer otherBuffer ) where T : unmanaged
110+ private static IBuffer Concat < T > ( this IBuffer thisBuffer , IBuffer otherBuffer ) where T : unmanaged
127111 => thisBuffer . AsArray < T > ( ) . Concat ( otherBuffer . AsArray < T > ( ) ) . ToArray ( ) . ToBuffer ( ) ;
128112
129113 public static IBuffer ConcatDataColumnBuffers ( this IBuffer thisBuffer , IBuffer otherBuffer , string typePrefix )
@@ -145,60 +129,6 @@ public static IBuffer ConcatDataColumnBuffers(this IBuffer thisBuffer, IBuffer o
145129 }
146130 }
147131
148- public static INamedBuffer ConcatDataColumns ( this INamedBuffer thisColumn , INamedBuffer otherColumn )
149- {
150- var typePrefix = thisColumn . ValidateCanConcatBuffers ( otherColumn ) ;
151- var combinedBuffer = thisColumn . ConcatDataColumnBuffers ( otherColumn , typePrefix ) ;
152- return new NamedBuffer ( combinedBuffer , thisColumn . Name ) ;
153- }
154-
155- public static List < T > ConcatColumns < T > (
156- this IReadOnlyList < T > thisColumnList ,
157- IReadOnlyList < T > otherColumnList ,
158- Func < T , T , T > concatFunc ) where T : INamedBuffer
159- {
160- var mergedColumns = new List < T > ( ) ;
161-
162- foreach ( var thisColumn in thisColumnList )
163- {
164- var otherColumn = otherColumnList . FirstOrDefault ( c => c . Name == thisColumn . Name ) ;
165- if ( otherColumn == null )
166- continue ;
167-
168- var newNamedBuffer = concatFunc ( thisColumn , otherColumn ) ;
169-
170- mergedColumns . Add ( newNamedBuffer ) ;
171- }
172-
173- return mergedColumns ;
174- }
175-
176- public static List < INamedBuffer > ConcatDataColumns ( this IReadOnlyList < INamedBuffer > thisColumnList , IReadOnlyList < INamedBuffer > otherColumnList )
177- => thisColumnList . ConcatColumns ( otherColumnList ,
178- ( a , b ) => a . ConcatDataColumns ( b ) ) ;
179-
180- public static List < NamedBuffer < int > > ConcatIntColumns ( this IReadOnlyList < NamedBuffer < int > > thisColumnList , IReadOnlyList < NamedBuffer < int > > otherColumnList )
181- => thisColumnList . ConcatColumns ( otherColumnList ,
182- ( a , b ) => new NamedBuffer < int > ( a . GetTypedData ( ) . Concat ( b . GetTypedData ( ) ) . ToArray ( ) , a . Name ) ) ;
183-
184- /// <summary>
185- /// Returns a concatenated SerializableEntityTable based on the column names of thisTable.
186- /// </summary>
187- public static SerializableEntityTable Concat (
188- this SerializableEntityTable thisTable ,
189- SerializableEntityTable otherTable )
190- {
191- var concatenated = new SerializableEntityTable
192- {
193- Name = thisTable . Name ,
194- IndexColumns = thisTable . IndexColumns . ConcatIntColumns ( otherTable . IndexColumns ) ,
195- StringColumns = thisTable . StringColumns . ConcatIntColumns ( otherTable . StringColumns ) ,
196- DataColumns = thisTable . DataColumns . ConcatDataColumns ( otherTable . DataColumns ) ,
197- } ;
198- concatenated . ValidateColumnRowsAreAligned ( ) ;
199- return concatenated ;
200- }
201-
202132 public static T [ ] GetColumnValues < T > ( this INamedBuffer nb ) where T : unmanaged
203133 => nb . AsArray < T > ( ) ;
204134
0 commit comments