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 »

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 »

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 »

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 »

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: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to read file from database?

Post by shooltz[BayesFusion] »

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 »

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: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to read file from database?

Post by shooltz[BayesFusion] »

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 »

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