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();
}
}
}
I am not sure what you try to achieve.
Outputters (and UDOs in general) cannot leave their containers (VMs) when executed in ADLA (local execution has no such limit at this point). So connecting to a database outside the container is going to be blocked and I am not sure what it helps to write data into a database in a transient VM/container.
The UDO model has a well-defined model to write to files that live in either ADLS or WASB by writing the data in the
input
row(set) into theoutput
's stream. You can write into local files, but again, these files will cease to exist after the vertex finishes execution.Given this information, could you please rephrase?
Update based on clarifying comment
you have two options to generate a database from a rowset: