I'm using a custom IOutputter to write the results of my U-SQL script to a a local database:
OUTPUT @dataset
TO "/path/somefilename_{*}.file"
USING new CustomOutputter()
public class CustomOutputter: IOutputter
{
public CustomOutputter()
{
myCustomDatabase.Open("databasefile.database");
}
public override void Output(IRow input, IUnstructuredWriter output)
{
}
}
Is there any possibility to replace "databasefile.database" with the specified output file path "/path/somefilename_{*}.file" ?
Since I'm not able to pass output.BaseStream
to the database I can't find a way to properly write to the correct file name.
UPDATE How I copy the local DB file to the ADLA provided outputstream:
public override void Close()
{
using (var fs = File.Open("databasefile.database", FileMode.Open))
{
byte[] buffer = new byte[65536];
int read;
while ((read = fs.Read(buffer, 0, buffer.Length)) > 0)
{
this.output.BaseStream.Write(buffer, 0, read);
this.output.BaseStream.Flush();
}
}
}