Update of /cvsroot/freevo/kaa/vfs/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20319/src

Modified Files:
        db.py 
Log Message:
Use buffer (BLOB) for pickles, and use binary protocol for much faster
pickling.


Index: db.py
===================================================================
RCS file: /cvsroot/freevo/kaa/vfs/src/db.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** db.py       22 Aug 2005 17:20:57 -0000      1.1
--- db.py       22 Aug 2005 18:39:34 -0000      1.2
***************
*** 16,20 ****
          id              INTEGER PRIMARY KEY AUTOINCREMENT, 
          name            TEXT UNIQUE,
!         attrs_pickle    TEXT
      );
  
--- 16,20 ----
          id              INTEGER PRIMARY KEY AUTOINCREMENT, 
          name            TEXT UNIQUE,
!         attrs_pickle    BLOB
      );
  
***************
*** 121,125 ****
                  cur_type_attrs.update(new_attrs)
                  self._db_query("UPDATE types SET attrs_pickle=? WHERE id=?",
!                            (cPickle.dumps(cur_type_attrs), cur_type_id))
                  return
  
--- 121,125 ----
                  cur_type_attrs.update(new_attrs)
                  self._db_query("UPDATE types SET attrs_pickle=? WHERE id=?",
!                            (buffer(cPickle.dumps(cur_type_attrs, 2)), 
cur_type_id))
                  return
  
***************
*** 140,144 ****
                  ("size", int, ATTR_SIMPLE),
                  ("mtime", int, ATTR_SEARCHABLE),
!                 ("pickle", str, ATTR_SEARCHABLE),
              ) + tuple(attr_list)
  
--- 140,144 ----
                  ("size", int, ATTR_SIMPLE),
                  ("mtime", int, ATTR_SEARCHABLE),
!                 ("pickle", buffer, ATTR_SEARCHABLE),
              ) + tuple(attr_list)
  
***************
*** 153,157 ****
              # column in the table, not a pickled value.
              if flags:
!                 sql_types = {str: "TEXT", int: "INTEGER", float: "FLOAT"}
                  assert(type in sql_types)
                  create_stmt += "%s %s" % (name, sql_types[type])
--- 153,158 ----
              # column in the table, not a pickled value.
              if flags:
!                 sql_types = {str: "TEXT", int: "INTEGER", float: "FLOAT", 
!                              buffer: "BLOB", unicode: "TEXT"}
                  assert(type in sql_types)
                  create_stmt += "%s %s" % (name, sql_types[type])
***************
*** 163,168 ****
              attrs[name] = (type, flags)
  
!         create_stmt = create_stmt[:-1]
!         create_stmt += ")"
          self._db_query(create_stmt)
  
--- 164,168 ----
              attrs[name] = (type, flags)
  
!         create_stmt = create_stmt[:-1] + ")"
          self._db_query(create_stmt)
  
***************
*** 170,174 ****
          # dictionary.
          self._db_query("INSERT OR REPLACE INTO types VALUES(NULL, ?, ?)", 
!                        (type_name, cPickle.dumps(attrs)))
  
          if new_attrs:
--- 170,174 ----
          # dictionary.
          self._db_query("INSERT OR REPLACE INTO types VALUES(NULL, ?, ?)", 
!                        (type_name, buffer(cPickle.dumps(attrs, 2))))
  
          if new_attrs:
***************
*** 208,212 ****
      def _load_object_types(self):
          for id, name, attrs in self._db_query("SELECT * from types"):
!             self._object_types[name] = id, 
cPickle.loads(attrs.encode("utf-8"))
      
  
--- 208,212 ----
      def _load_object_types(self):
          for id, name, attrs in self._db_query("SELECT * from types"):
!             self._object_types[name] = id, cPickle.loads(str(attrs))
      
  
***************
*** 233,237 ****
  
          if len(attrs_copy) > 0:
!             values[columns.index("pickle")] = cPickle.dumps(attrs_copy)
          else:
              values[columns.index("pickle")] = None
--- 233,237 ----
  
          if len(attrs_copy) > 0:
!             values[columns.index("pickle")] = 
buffer(cPickle.dumps(attrs_copy, 2))
          else:
              values[columns.index("pickle")] = None
***************
*** 290,294 ****
          assert(row)
          if row[0]:
!             row_attrs = cPickle.loads(row[0].encode("utf-8"))
              row_attrs.update(attrs)
              attrs = row_attrs
--- 290,294 ----
          assert(row)
          if row[0]:
!             row_attrs = cPickle.loads(str(row[0]))
              row_attrs.update(attrs)
              attrs = row_attrs
***************
*** 365,369 ****
                  result["type"] = type_name
                  if result["pickle"]:
!                     pickle = cPickle.loads(result["pickle"].encode("utf-8"))
                      del result["pickle"]
                      result.update(pickle)
--- 365,369 ----
                  result["type"] = type_name
                  if result["pickle"]:
!                     pickle = cPickle.loads(str(result["pickle"]))
                      del result["pickle"]
                      result.update(pickle)



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to