How to read file from database?

The engine.
Post Reply
musicpxg
Posts: 19
Joined: Sat Feb 16, 2013 6:24 am

How to read file from database?

Post by musicpxg » Sun Feb 17, 2013 4:29 pm

I want to save and read XSDL file to/from database. Is it possible?
Smile introduces readfile() to load XSDL file from disk. How can it read from a database? Is there any other readfile function available?

Thank you very much!

Martijn
Posts: 76
Joined: Sun May 29, 2011 12:23 am

Re: How to read file from database?

Post by Martijn » Sun Feb 17, 2013 6:01 pm

Hi,

The SMILE library does not have the ability to read from a database directly.
In general, you would have to implement that yourself (in your own code) and, using the SMILE library, construct the DSL_network object from what you have read from your database.

Are you storing whole xdsl files in your database?
If so, maybe you can read it from your db, create a temporary file and then read it with SMILE.

Best,

Martijn

musicpxg
Posts: 19
Joined: Sat Feb 16, 2013 6:24 am

Re: How to read file from database?

Post by musicpxg » Mon Feb 18, 2013 12:40 am

Hi Martijn,

Thank you very much! I think your suggestions are right. If SMILE only have the readfile() function to obtain XDSL file, it is a good idea to save a temp file and then use readfile();
Actually, I wanted to use database to save hundreds of XSDL files to improve computing performance and reduce file count in disk. Now, I think it is no necessary to use database.

Thank you!
Young

orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

Re: How to read file from database?

Post by orzech » Wed Feb 20, 2013 1:57 pm

Hi,

Just my two cents ;) It would be great to have a SMILE function which could get the data from a stream instead of a file. You can always open a file as a stream but you cannot load your data from a custom source (i.e. encoded XDSL file stored on disk / in memory / database).

Kind Regards,
Piotr

shooltz[BayesFusion]
Site Admin
Posts: 1247
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to read file from database?

Post by shooltz[BayesFusion] » Wed Feb 20, 2013 2:34 pm

orzech wrote:Just my two cents ;) It would be great to have a SMILE function which could get the data from a stream instead of a file. You can always open a file as a stream but you cannot load your data from a custom source (i.e. encoded XDSL file stored on disk / in memory / database).
Streaming XDSL files is definitely implementable within reasonable time/cost range, with stream defined as a very simple abstract class with 2 or 3 methods. User's application would have to provide the derived stream class reading the actual bytes from database, memory, cloud or any serializable data source.

Other file formats are legacy and depend heavily on stdio.

orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

Re: How to read file from database?

Post by orzech » Sat Feb 23, 2013 4:16 pm

Hi,

Thank you for your response. That would be absolutely great. But even easier, it would be totally sufficient to provide a method which reads XDSL file from an array of raw bytes instead of a file path. This way the user's application could read from any source, store and preprocess data in the memory and then pass it to SMILE for loading. :)

Cheers,
Piotr
shooltz wrote:
orzech wrote:Just my two cents ;) It would be great to have a SMILE function which could get the data from a stream instead of a file. You can always open a file as a stream but you cannot load your data from a custom source (i.e. encoded XDSL file stored on disk / in memory / database).
Streaming XDSL files is definitely implementable within reasonable time/cost range, with stream defined as a very simple abstract class with 2 or 3 methods. User's application would have to provide the derived stream class reading the actual bytes from database, memory, cloud or any serializable data source.

Other file formats are legacy and depend heavily on stdio.

shooltz[BayesFusion]
Site Admin
Posts: 1247
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to read file from database?

Post by shooltz[BayesFusion] » Wed Mar 06, 2013 11:39 pm

orzech wrote:But even easier, it would be totally sufficient to provide a method which reads XDSL file from an array of raw bytes instead of a file path.
Current SMILE release supports this feature with DSL_network::ReadString and DSL_network::WriteString.

orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

Re: How to read file from database?

Post by orzech » Mon Mar 11, 2013 7:02 pm

That's great! I need to check this out. :)

Post Reply