def makeHeader(this):
     result = [HEADERPREFIX]
     result.append(chr(VERSION))
     result.append(BufferFile.StoreInt(this.NodeSize))
     result.append(BufferFile.StoreInt(this.KeyLength))
     result.append(BufferFile.StoreInt(INVARIANTCULTUREID))
     result.append(BufferFile.StoreLong(this.rootSeek))
     result.append(BufferFile.StoreLong(this.freeHeadSeek))
     return string.join(result, "")
Пример #2
0
 def StoreNewChunk(this, fromString):
     length = len(fromString)
     #print "StoreNewChunk", length
     currentBufferNumber = this.AllocateBuffer()
     result = currentBufferNumber
     CurrentBufferType = HEAD
     # store header with length info
     firstlength = min(length, this.buffersize - BufferFile.INTSTORAGE)
     buffer = BufferFile.StoreInt(length) + fromString[:firstlength]
     stored = firstlength
     while stored < length:
         # store intermediate or head
         nextBufferNumber = this.AllocateBuffer()
         this.SetBuffer(currentBufferNumber, CurrentBufferType, buffer,
                        nextBufferNumber)
         nextlength = min(this.buffersize, length - stored)
         nextstored = stored + nextlength
         buffer = fromString[stored:nextstored]
         stored = nextstored
         currentBufferNumber = nextBufferNumber
         CurrentBufferType = BODY
     # store tail
     this.SetBuffer(currentBufferNumber, CurrentBufferType, buffer,
                    NULLBUFFERPOINTER)
     return result
Пример #3
0
 def dump(this):
     allbytes = []
     keys = this.keys
     values = this.values
     for index in xrange(len(this.keys)):
         thisKey = keys[index]
         thisValue = this.values[index]
         keyPrefix = BufferFile.StoreInt(len(thisKey))
         (keybytes, dummy) = ENCODER(thisKey)
         allbytes.append(keyPrefix)
         allbytes.append(keybytes)
         valuePrefix = BufferFile.StoreInt(len(thisValue))
         (valuebytes, dummy) = ENCODER(thisValue)
         allbytes.append(valuePrefix)
         allbytes.append(valuebytes)
     #print allbytes
     return string.join(allbytes, "")
Пример #4
0
 def makeHeader(this):
     #return HEADERPREFIX+chr(VERSION)+BufferFile.StoreInt(
     L = [
         HEADERPREFIX,
         chr(VERSION),
         BufferFile.StoreInt(this.buffersize),
         BufferFile.StoreLong(this.FreeListHead)
     ]
     return string.join(L, "")