file IO operations

85 views
Skip to first unread message

Vadim Skubilin

unread,
Sep 27, 2015, 1:13:15 PM9/27/15
to Kdb+ Personal Developers
Hello to all.
Can this code be converted from c# into code in kdb?
I had read about read1, but I did not see anything about position of stream for writing.

        static int GetInt32(string path, int index)
        {
            FileStream stream = new FileStream(path, FileMode.Open);

            stream.Position = index * 4;

            byte[] bytes = new byte[4];

            stream.Read(bytes, 0, 4);

            int value = BitConverter.ToInt32(bytes, 0);

            stream.Close();

            return value;
        }

        static void SetInt32(string path, int index, int value)
        {
            FileStream stream = new FileStream(path, FileMode.OpenOrCreate);

            stream.Position = index * 4;

            byte[] bytes = BitConverter.GetBytes(value);

            stream.Write(bytes, 0, 4);

            stream.Close();
        }


Yan Yan

unread,
Sep 27, 2015, 10:04:54 PM9/27/15
to Kdb+ Personal Developers
I use the dd linux command. I have yet to find any built-in kdb functions to do that.

Vadim Skubilin

unread,
Sep 28, 2015, 5:49:34 AM9/28/15
to Kdb+ Personal Developers
I am Windows user, so I do not have this command...

Andrew Kozyrev

unread,
Sep 28, 2015, 5:55:41 AM9/28/15
to Kdb+ Personal Developers
Hi,

read1 supports (file;offset;length) format.

WBR, Andrey Kozyrev 

skuvv

unread,
Sep 28, 2015, 5:58:39 AM9/28/15
to personal...@googlegroups.com
Hello Andrew.
Yes I know about read0/read1, I already wrote about this.

--
You received this message because you are subscribed to a topic in the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/personal-kdbplus/bK1AmUq1ciU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to personal-kdbpl...@googlegroups.com.
To post to this group, send email to personal...@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.

Yan Yan

unread,
Sep 28, 2015, 6:31:38 AM9/28/15
to Kdb+ Personal Developers
If you are on windows, use cygwin dd.exe, C stdio, or C++ fstream to perform random writes.
Reply all
Reply to author
Forward
0 new messages