File: vector_read.py

package info (click to toggle)
xrootd 5.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,956 kB
  • sloc: cpp: 244,425; sh: 2,691; python: 1,980; ansic: 1,027; perl: 814; makefile: 272
file content (28 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Read scattered data chunks in one operation
-------------------------------------------

Produces the following output::

  <buffer: 'The XROOTD project aims at giving high p', length: 40, offset: 0>
  <buffer: 'erformance, scalable  fault tolerant acc', length: 40, offset: 40>
  <buffer: 'ess to data repositories of many kinds', length: 38, offset: 80>

"""
from XRootD import client
from XRootD.client.flags import OpenFlags

with client.File() as f:
  print f.open('root://localhost//tmp/eggs', OpenFlags.UPDATE)

  f.write(r'The XROOTD project aims at giving high performance, scalable '
          +' fault tolerant access to data repositories of many kinds')

  size = f.stat()[1].size
  v = [(0, 40), (40, 40), (80, size - 80)]

  status, response = f.vector_read(chunks=v)
  print status

  for chunk in response.chunks:
    print chunk