Exemplo n.º 1
0
def decode_arg(arg, allocsize):
    addr = bytearray.fromhex(arg)
    version = addr[0]
    print(arg + ': ')
    if version != 1:
        print('**** ERROR: unknown version ' + str(version))
    addr = bytes(addr[1:])

    # The number of values in a checkpoint may be 14 or 18. In the latter case, the checkpoint is
    # for a tiered Btree, and contains object ids for each of the four references in the checkpoint.
    # In the former case, the checkpoint is for a regular (local, single file) Btree, and there are
    # no objects. Based on what is present, we show them slightly appropriately.

    # First, we get the largest number of ints that can be decoded.
    result = []
    iformat = 'iiiiiiiiiiiiii'
    result_len = 0
    while True:
        try:
            result = unpack(iformat, addr)
            result_len = len(result)
        except:
            break
        iformat += 'i'

    # Then we check the number of results against what we expect.
    if result_len == 14:
        ref_cnt = 3  # no object ids
    elif result_len == 18:
        ref_cnt = 4  # has object ids
    else:
        if result_len == 0:
            result_len = 'unknown'
        print('**** ERROR: number of integers to decode ({}) '.format(
            result_len) + 'does not match expected checkpoint format')
        return
    pos = 0

    # Now that we know whether the references have object ids, we can show them.
    for refname in ['root', 'alloc', 'avail', 'discard']:
        show_ref(result[pos:pos + ref_cnt], refname, allocsize)
        pos += ref_cnt
    file_size = result[pos]
    ckpt_size = result[pos + 1]
    show_one('file size', file_size)
    show_one('checkpoint size', ckpt_size)
Exemplo n.º 2
0
def decode_arg(arg, allocsize):
    addr = bytearray.fromhex(arg)
    version = addr[0]
    print(arg + ': ')
    if version != 1:
        print('**** ERROR: unknown version ' + str(version))
    addr = bytes(addr[1:])
    result = unpack('iiiiiiiiiiiiii', addr)
    if len(result) != 14:
        print('**** ERROR: result len unexpected: ' + str(len(result)))
    show_triple(result[0:3], 'root', allocsize)
    show_triple(result[3:6], 'alloc', allocsize)
    show_triple(result[6:9], 'avail', allocsize)
    show_triple(result[9:12], 'discard', allocsize)
    file_size = result[12]
    ckpt_size = result[13]
    show_one('file size', file_size)
    show_one('checkpoint size', ckpt_size)
Exemplo n.º 3
0
def decode_arg(arg, allocsize):
    addr = bytearray.fromhex(arg)
    version = addr[0]
    print(arg + ': ')
    if version != 1:
        print('**** ERROR: unknown version ' + str(version))
    addr = addr[1:]
    result = unpack('iiiiiiiiiiiiii',addr)
    if len(result) != 14:
        print('**** ERROR: result len unexpected: ' + str(len(result)))
    show_triple(result[0:3], 'root', allocsize)
    show_triple(result[3:6], 'alloc', allocsize)
    show_triple(result[6:9], 'avail', allocsize)
    show_triple(result[9:12], 'discard', allocsize)
    file_size = result[12]
    ckpt_size = result[13]
    show_one('file size', file_size)
    show_one('checkpoint size', ckpt_size)
Exemplo n.º 4
0
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

# A quick sanity test of an installation via 'pip install wiredtiger'.
# This program only uses the packing API.

import sys
from wiredtiger.packing import unpack, pack

testval = '8281e420f2fa4a8381e40c5855ca808080808080e22fc0e20fc0'
# Jump through hoops to make code work for Py2 + Py3
x = bytes(bytearray.fromhex(testval))

unpacked = unpack('iiiiiiiiiiiiii',x)
unexpect = [2, 1, 552802954, 3, 1, 207123978, 0, 0, 0, 0, 0, 0, 20480, 12288]
#print(str(unpacked)))
if unpacked != unexpect:
    raise Exception('BAD RESULT FOR UNPACK')

packed = pack('iiii', 1, 2, 3, 4)
expect = b'\x81\x82\x83\x84'
#print(str(packed)))
if packed != expect:
    raise Exception('BAD RESULT FOR PACK')

print('testpack success.')