⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hbplustreebytes.py

📁 R树与B树的混合树
💻 PY
字号:

"""
BPlus tree implementation mapping strings to bytes (non-unicode python strings) with fixed key length
"""
import types, BplusTreeLong, BplusTreeBytes, xBplusTreeBytes, string
from BplusTreeLong import BplusTreeException, BplusTreeBadKeyValue, BplusTreeKeyMissing, ENCODER, DECODER

def Initialize(treefilename, blockfilename, KeyLength,
               CultureId=BplusTreeLong.INVARIANTCULTUREID,
               nodesize=BplusTreeBytes.DEFAULTNODESIZE,
               buffersize=BplusTreeBytes.DEFAULTBLOCKSIZE):
    return BplusTreeBytes.Initialize(treefilename, blockfilename, KeyLength,
               CultureId,nodesize,buffersize, initFunction=hBplusTreeBytes)

def ReOpen(treefilename, blockfilename, access="r+b"):
    return BplusTreeBytes.ReOpen(treefilename, blockfilename, access, initFunction=hBplusTreeBytes)

def ReadOnly(treefilename, blockfilename):
    return BplusTreeBytes.ReadOnly(treefilename, blockfilename, initFunction=hBplusTreeBytes)


class hBplusTreeBytes(xBplusTreeBytes.xBplusTreeBytes):
    def PrefixForByteCount(this, s, maxbytecount):
        resultbytes = list(range(maxbytecount))
        i = 0
        invert = False
        for inputchar in s:
            inputbyte = ord(inputchar)
            outputindex = i % maxbytecount
            outputbyte = resultbytes[outputindex]
            rotator = (i/maxbytecount) % 8
            if (rotator):
                hipart = inputbyte<<rotator
                lowpart = inputbyte>>(8-rotator)
                inputbyte = hipart | lowpart
            outputbyte = (inputbyte ^ outputbyte) % 127
            if inputbyte&128:
                invert = not invert
            if invert:
                outputbyte = (outputbyte^127) % 128
            resultbytes[outputindex] = outputbyte
            i+=1
        resultchrs = map(chr, resultbytes)
        resultbytes = string.join(resultchrs, "")
        (result, dummy) = ENCODER(resultbytes)
        return result

    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -