Пример #1
0
 def blockToBinarySeries(kvIter):
     label = None
     keyPacker = None
     buf = StringIO()
     for seriesKey, series in kvIter:
         if keyPacker is None:
             keyPacker = struct.Struct('h'*len(seriesKey))
             label = SimpleBlocks.getBinarySeriesNameForKey(seriesKey) + ".bin"
         buf.write(keyPacker.pack(*seriesKey))
         buf.write(series.tostring())
     val = buf.getvalue()
     buf.close()
     return [(label, val)]
Пример #2
0
 def blockToBinarySeries(kvIter):
     label = None
     keyPacker = None
     buf = StringIO()
     for seriesKey, series in kvIter:
         if keyPacker is None:
             keyPacker = struct.Struct('h'*len(seriesKey))
             label = SimpleBlocks.getBinarySeriesNameForKey(seriesKey) + ".bin"
         buf.write(keyPacker.pack(*seriesKey))
         buf.write(series.tostring())
     val = buf.getvalue()
     buf.close()
     return [(label, val)]
Пример #3
0
 def partitionToBinarySeries(kvIter):
     """ Collects all Series records in a partition into a single binary series record. """
     keypacker = None
     firstKey = None
     buf = StringIO.StringIO()
     for seriesKey, series in kvIter:
         if keypacker is None:
             keypacker = struct.Struct('h'*len(seriesKey))
             firstKey = seriesKey
         # print >> sys.stderr, seriesKey, series, series.tostring().encode('hex')
         buf.write(keypacker.pack(*seriesKey))
         buf.write(series.tostring())
     val = buf.getvalue()
     buf.close()
     # we might have an empty partition, in which case firstKey will still be None
     if firstKey is None:
         return iter([])
     else:
         label = SimpleBlocks.getBinarySeriesNameForKey(firstKey) + ".bin"
         return iter([(label, val)])
Пример #4
0
 def partitionToBinarySeries(kvIter):
     """ Collects all Series records in a partition into a single binary series record. """
     keypacker = None
     firstKey = None
     buf = StringIO.StringIO()
     for seriesKey, series in kvIter:
         if keypacker is None:
             keypacker = struct.Struct('h' * len(seriesKey))
             firstKey = seriesKey
         # print >> sys.stderr, seriesKey, series, series.tostring().encode('hex')
         buf.write(keypacker.pack(*seriesKey))
         buf.write(series.tostring())
     val = buf.getvalue()
     buf.close()
     # we might have an empty partition, in which case firstKey will still be None
     if firstKey is None:
         return iter([])
     else:
         label = SimpleBlocks.getBinarySeriesNameForKey(
             firstKey) + ".bin"
         return iter([(label, val)])