~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.h

  • Committer: Brian Aker
  • Date: 2010-10-26 21:56:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1886.
  • Revision ID: brian@tangent.org-20101026215622-6fcmp520ouj5446p
Update Key to work a bit faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
{
59
59
public:
60
60
  typedef message::Table::TableType Type;
61
 
  typedef std::vector<char> Key;
 
61
 
 
62
  class Key
 
63
  {
 
64
    std::vector<char> key_buffer;
 
65
    size_t hash_value;
 
66
 
 
67
  public:
 
68
 
 
69
    Key() :
 
70
      hash_value(0)
 
71
    {
 
72
    }
 
73
 
 
74
    const char *vector() const
 
75
    {
 
76
      return &key_buffer[0];
 
77
    }
 
78
 
 
79
    std::vector<char> &vectorPtr()
 
80
    {
 
81
      return key_buffer;
 
82
    }
 
83
 
 
84
    void set(size_t resize_arg, const std::string &a, const std::string &b);
 
85
 
 
86
    friend bool operator==(const Key &left, const Key &right)
 
87
    {
 
88
      if (left.hash_value == right.hash_value and left.key_buffer.size() == right.key_buffer.size())
 
89
      {
 
90
        if (memcmp(&left.key_buffer[0], &right.key_buffer[0], left.key_buffer.size()) == 0)
 
91
          return true;
 
92
      }
 
93
 
 
94
      return false;
 
95
    }
 
96
 
 
97
    friend bool operator<(const Key &left, const Key &right)
 
98
    {
 
99
      return left.key_buffer < right.key_buffer;
 
100
    }
 
101
 
 
102
    size_t size() const
 
103
    {
 
104
      return key_buffer.size();
 
105
    }
 
106
 
 
107
    size_t getHashValue() const
 
108
    {
 
109
      return hash_value;
 
110
    }
 
111
  };
 
112
 
62
113
private:
63
114
 
64
115
  Type type;
235
286
};
236
287
 
237
288
std::size_t hash_value(TableIdentifier const& b);
 
289
std::size_t hash_value(TableIdentifier::Key const& b);
238
290
 
239
291
typedef std::vector <TableIdentifier> TableIdentifiers;
240
292