Skip to content
Snippets Groups Projects
Commit 689eae37 authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

More test changes.

parent 35979308
No related branches found
No related tags found
No related merge requests found
peek.py 0 → 100755
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
from __future__ import unicode_literals
"""
Test script to peek in db files.
"""
import struct
import os
import mmap
filename = 'metrics/gauge_livesum_40272.db'
f = open(filename, 'a+b')
capacity = os.fstat(f.fileno()).st_size
m = mmap.mmap(f.fileno(), capacity)
used = struct.unpack_from(b'i', m, 0)[0]
pos = 8
while pos < used:
encoded_len = struct.unpack_from(b'i', m, pos)[0]
pos += 4
encoded = struct.unpack_from('{0}s'.format(encoded_len).encode(), m, pos)[0]
padded_len = encoded_len + (8 - (encoded_len + 4) % 8)
pos += padded_len
value = struct.unpack_from(b'd', m, pos)[0]
print("Entry: %s = %d" % (encoded, value))
pos += 8
f.close()
print("Capacity %s" % capacity)
print("Used %d" % used)
# frozen_string_literal: true
source "https://rubygems.org"
gem 'mmap', git: 'https://github.com/lyda/mmap.git', :branch => 'non-global-version'
#gem 'mmap', :path => '/Users/kevin/src/p4g/mmap'
GIT
remote: https://github.com/lyda/mmap.git
revision: 379bdbd2c848e96d8f89e954663b8c26529b8919
branch: non-global-version
specs:
mmap (0.2.7)
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
mmap!
BUNDLED WITH
1.14.3
require 'mmap'
mmap = Mmap.new(__FILE__)
mmap.advise(Mmap::MADV_SEQUENTIAL)
mmap.each do |line|
puts line
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment