-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xrootd: how to read raw bigendian bytes? #912
Comments
I think I want whatever function that fills: Lines 59 to 63 in 04a2d5f
so that I can build buffer on the other language's side to not anger GC god and fill that buffer with raw, bigendian bytes |
decoding big/little endian is done with the https://go.dev/play/p/hLqhICaF1d6 I think reaching down to |
Yeah indeed. But to read some data, I need to to use something from here right? Which is why I want to read raw bytes, without being encoded, which is to say ReadAt is too high-level for my usage. Are you saying there is a way to use connection/file handler even more directly? |
My understanding of the stack: flowchart TD
A["ReadAt()"] --> |"pass p []byte"| B["ReadAtContext()"]
B --> |var| C(resp Data: p)
B --> |var| D(req resp)
C --> D
D --> E["sendSession()"]
E --> |&resq, req| F["session.Send()"]
F --> |var| G(wBuffer)
G --> buf1["header.MarshalXrd(&wBuffer)"]
G --> buf2["req.MarshalXrd(&wBuffer)"]
buf1 --> data1("data := wBuffer.Bytes()")
buf2 --> data1("data := wBuffer.Bytes()")
data1 --> returnfinal["resp.UnmarshalXrd(xrdenc.NewRBuffer(data))"]
|
IIUC what you want to do, you first read some data from the underlying file descriptor (into a func readU16(f io.ReaderAt) uint16 {
var buf = make([]byte, 2)
_, err := f.ReadAt(buf, offset)
if err != nil { ... }
return binary.BigEndian.Uint16(buf)
} |
oh... I might have fooled myself because the magic bytes ( |
yeah, the magic string is a 4-byte array of |
ok, thanks, I think this is all I need then. Closing, thanks for bearing with my confusion. I see the vectorized read |
Hi,
I'm trying to write a
c-shared
wrapper withhep/xrootd
, I basically got it working, the application boils down to:I would allocate on the other language's side and pass a pointer to Go. However, due to how the rest of the other language's library is designed, we need to read big-endian raw bytes for each basket. because
if you imagine the branch is a vector of Float16, you need to group bytes before conducting byte swap. I'm wondering if there's a way (maybe a lower level API?) to achieve this
The text was updated successfully, but these errors were encountered: