Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
can I do the equivalent of a C cast on an array in F#?

I have large array of this type:

type TradeData =    
    {
        Timestamp:          DateTime
        Instrument:         Instrument
        Price:              decimal
        Quantity:           decimal
        Direction:          Direction
    }

We're talking about several gigabytes loaded every time during debugging. The data is stored on the disk in binary using FSPickler which is much faster than Json, but it still takes a long time to load. I sped it up by slicing the file into chunks of 1h and loading them in parallel, but we're still taking 15-20 seconds at the start of every debugging session.

What I would like to know is if I can put the data in an array, write the array as a binary blob. Then I'd load the blob and do something like:

myData = (TradeData *) pBinaryBlob

I'm not sure if this is doable under dotnet, or if each object really needs to be initialized independently.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This can probably be done provided you use structs rather than objects. If you have already serialised the file as objects you may need to re-serialise the file once to bit-align with the structs or carefully annotate your struct with the necessary byte alignments.

If you read the FileStream into byte buffers I'd then look at using either nativeptr<'T> or (ReadOnly)Span<'T> and MemoryMarshal.Cast to perform an unsafe conversion.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!