def Dump(this):
     L = []
     a = L.append
     if this.isLeaf:
         a(chr(LEAF))
     else:
         a(chr(NONLEAF))
     keys = this.ChildKeys
     numbers = this.ChildBufferNumbers
     #print "<br>keys", keys
     #print "<br>numbers", numbers, "<br>"
     maxLength = this.owner.KeyLength
     maxKeyPayload = maxLength - BufferFile.SHORTSTORAGE
     a(BufferFile.StoreLong(numbers[0]))
     for KeyIndex in xrange(this.Size):
         # store the key
         theKey = keys[KeyIndex]
         if theKey is None:
             a(BufferFile.StoreShort(-1))
             a("X" * maxKeyPayload)
         else:
             (coded, nchars) = ENCODER(theKey)
             lcoded = len(coded)
             if (lcoded > maxKeyPayload):
                 raise BplusTreeException, "too many bytes in key " + repr(
                     coded)
             a(BufferFile.StoreShort(lcoded))
             padded = coded + "X" * (maxKeyPayload - lcoded)
             a(padded)
         # store the seek
         a(BufferFile.StoreLong(numbers[KeyIndex + 1]))
     result = string.join(L, "")
     #print "<br>", this.MyBufferNumber, "raw dump", repr(result), "<br>"
     return result
 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, "")
Esempio n. 3
0
 def SetBuffer(this, bufferNumber, type, thebuffer, NextBufferNumber):
     #print "<br>setting", bufferNumber, type, repr(thebuffer), NextBufferNumber
     if (this.buffersize < len(thebuffer)):
         raise LinkedFileException, "too much data"
     fullbuffer = (chr(type) +
                   BufferFile.StoreLong(NextBufferNumber)) + thebuffer
     this.buffers.setBuffer(bufferNumber, fullbuffer)
 def deallocateBuffer(this, buffernumber):
     #freesize = 1+BufferFile.LONGSTORAGE
     buffer = this.buffers.getBuffer(buffernumber, 1)
     #print "<br>     DEALLOCATING", buffernumber, "<br>"
     if ord(buffer) == FREE:
         raise BplusTreeException, "attempt to free buffer marked free already"
     buffer = chr(FREE) + BufferFile.StoreLong(this.freeHeadSeek)
     this.buffers.setBuffer(buffernumber, buffer)
     this.freeHeadSeek = buffernumber
Esempio n. 5
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, "")