def open(filename)
      # Get header & check.
      @filename = filename
      @file = fileOpen(@filename)
      @header = DBHEADER.decode(@file.read(SIZEOF_DBHEADER))

      # Holds the page buf if we read all pages
      @read_buf = nil

      # Check header version - simple warning if less than 8.
      if @header["version"] < 8
        msg = "MiqBerkeleyDB: Database header version is less than 8."
        if $log
          $log.warn(msg)
        else
          puts "WARNING: " + msg
        end
      end

      # We don't support encryption.
      raise "MiqBerkeleyDB: This database uses encryption." if @header["encrypt_alg"] != 0

      # Open db type (only hash for now, may expand to plugins in the future).
      @db = case @header["magic"]
            when DB_HASHMAGIC then   MiqBdbHashDatabase.new(self)
            when DB_BTREEMAGIC then  MiqBdbBtreeDatabase.new(self)
            when DB_QAMMAGIC then    raise "MiqBerkeleyDB: Database type is Queue"
            when DB_LOGMAGIC then    raise "MiqBerkeleyDB: Database type is Log"
            when DB_RENAMEMAGIC then raise "MiqBerkeleyDB: Database type is Rename"
            else                     raise "MiqBerkeleyDB: Database type #{@header['magic']} is not supported"
            end
    end
def open(filename)
      # Get header & check.
      @filename = filename
      @file = fileOpen(@filename)
      @header = DBHEADER.decode(@file.read(SIZEOF_DBHEADER))

      # Holds the page buf if we read all pages
      @read_buf = nil

      # Check header version - simple warning if less than 8.
      if @header["version"] < 8
        msg = "MiqBerkeleyDB: Database header version is less than 8."
        if $log
          $log.warn(msg)
        else
          puts "WARNING: " + msg
        end
      end

      # We don't support encryption.
      raise "MiqBerkeleyDB: This database uses encryption." if @header["encrypt_alg"] != 0

      # Open db type (only hash for now, may expand to plugins in the future).
      @db = case @header["magic"]
            when DB_HASHMAGIC then   MiqBdbHashDatabase.new(self)
            when DB_BTREEMAGIC then  MiqBdbBtreeDatabase.new(self)
            when DB_QAMMAGIC then    raise "MiqBerkeleyDB: Database type is Queue"
            when DB_LOGMAGIC then    raise "MiqBerkeleyDB: Database type is Log"
            when DB_RENAMEMAGIC then raise "MiqBerkeleyDB: Database type is Rename"
            else                     raise "MiqBerkeleyDB: Database type #{@header['magic']} is not supported"
            end
    end
Open the database