You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

464 lines
15 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>memdb - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package memdb</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "github.com/syndtr/goleveldb/leveldb/memdb"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package memdb provides in-memory key/value database implementation.
  68. </p>
  69. </div>
  70. </div>
  71. <div id="pkg-index" class="toggleVisible">
  72. <div class="collapsed">
  73. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  74. </div>
  75. <div class="expanded">
  76. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  77. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  78. <div id="manual-nav">
  79. <dl>
  80. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  81. <dd><a href="index.html#DB">type DB</a></dd>
  82. <dd>&nbsp; &nbsp; <a href="index.html#New">func New(cmp comparer.BasicComparer, capacity int) *DB</a></dd>
  83. <dd>&nbsp; &nbsp; <a href="index.html#DB.Capacity">func (p *DB) Capacity() int</a></dd>
  84. <dd>&nbsp; &nbsp; <a href="index.html#DB.Contains">func (p *DB) Contains(key []byte) bool</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#DB.Delete">func (p *DB) Delete(key []byte) error</a></dd>
  86. <dd>&nbsp; &nbsp; <a href="index.html#DB.Find">func (p *DB) Find(key []byte) (rkey, value []byte, err error)</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#DB.Free">func (p *DB) Free() int</a></dd>
  88. <dd>&nbsp; &nbsp; <a href="index.html#DB.Get">func (p *DB) Get(key []byte) (value []byte, err error)</a></dd>
  89. <dd>&nbsp; &nbsp; <a href="index.html#DB.Len">func (p *DB) Len() int</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#DB.NewIterator">func (p *DB) NewIterator(slice *util.Range) iterator.Iterator</a></dd>
  91. <dd>&nbsp; &nbsp; <a href="index.html#DB.Put">func (p *DB) Put(key []byte, value []byte) error</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#DB.Reset">func (p *DB) Reset()</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#DB.Size">func (p *DB) Size() int</a></dd>
  94. </dl>
  95. </div><!-- #manual-nav -->
  96. <h4>Package files</h4>
  97. <p>
  98. <span style="font-size:90%">
  99. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go">memdb.go</a>
  100. </span>
  101. </p>
  102. </div><!-- .expanded -->
  103. </div><!-- #pkg-index -->
  104. <div id="pkg-callgraph" class="toggle" style="display: none">
  105. <div class="collapsed">
  106. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  107. </div> <!-- .expanded -->
  108. <div class="expanded">
  109. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  110. <p>
  111. In the call graph viewer below, each node
  112. is a function belonging to this package
  113. and its children are the functions it
  114. calls&mdash;perhaps dynamically.
  115. </p>
  116. <p>
  117. The root nodes are the entry points of the
  118. package: functions that may be called from
  119. outside the package.
  120. There may be non-exported or anonymous
  121. functions among them if they are called
  122. dynamically from another package.
  123. </p>
  124. <p>
  125. Click a node to visit that function's source code.
  126. From there you can visit its callers by
  127. clicking its declaring <code>func</code>
  128. token.
  129. </p>
  130. <p>
  131. Functions may be omitted if they were
  132. determined to be unreachable in the
  133. particular programs or tests that were
  134. analyzed.
  135. </p>
  136. <!-- Zero means show all package entry points. -->
  137. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  138. </div>
  139. </div> <!-- #pkg-callgraph -->
  140. <h2 id="pkg-variables">Variables</h2>
  141. <pre>var (
  142. <span id="ErrNotFound">ErrNotFound</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#ErrNotFound">ErrNotFound</a>
  143. <span id="ErrIterReleased">ErrIterReleased</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;leveldb/memdb: iterator released&#34;)
  144. )</pre>
  145. <p>
  146. Common errors.
  147. </p>
  148. <h2 id="DB">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=3362:3707#L172">DB</a></h2>
  149. <pre>type DB struct {
  150. <span class="comment">// contains filtered or unexported fields</span>
  151. }</pre>
  152. <p>
  153. DB is an in-memory key/value database.
  154. </p>
  155. <h3 id="New">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=10329:10383#L455">New</a></h3>
  156. <pre>func New(cmp <a href="../comparer/index.html">comparer</a>.<a href="../comparer/index.html#BasicComparer">BasicComparer</a>, capacity <a href="../../../../../builtin/index.html#int">int</a>) *<a href="index.html#DB">DB</a></pre>
  157. <p>
  158. New creates a new initialized in-memory key/value DB. The capacity
  159. is the initial key/value buffer capacity. The capacity is advisory,
  160. not enforced.
  161. </p>
  162. <p>
  163. This DB is append-only, deleting an entry would remove entry node but not
  164. reclaim KV buffer.
  165. </p>
  166. <p>
  167. The returned DB instance is safe for concurrent use.
  168. </p>
  169. <h3 id="DB.Capacity">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=8906:8933#L398">Capacity</a></h3>
  170. <pre>func (p *<a href="index.html#DB">DB</a>) Capacity() <a href="../../../../../builtin/index.html#int">int</a></pre>
  171. <p>
  172. Capacity returns keys/values buffer capacity.
  173. </p>
  174. <h3 id="DB.Contains">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=6701:6739#L334">Contains</a></h3>
  175. <pre>func (p *<a href="index.html#DB">DB</a>) Contains(key []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#bool">bool</a></pre>
  176. <p>
  177. Contains returns true if the given key are in the DB.
  178. </p>
  179. <p>
  180. It is safe to modify the contents of the arguments after Contains returns.
  181. </p>
  182. <h3 id="DB.Delete">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=6193:6230#L311">Delete</a></h3>
  183. <pre>func (p *<a href="index.html#DB">DB</a>) Delete(key []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#error">error</a></pre>
  184. <p>
  185. Delete deletes the value for the given key. It returns ErrNotFound if
  186. the DB does not contain the key.
  187. </p>
  188. <p>
  189. It is safe to modify the contents of the arguments after Delete returns.
  190. </p>
  191. <h3 id="DB.Find">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=7654:7715#L364">Find</a></h3>
  192. <pre>func (p *<a href="index.html#DB">DB</a>) Find(key []<a href="../../../../../builtin/index.html#byte">byte</a>) (rkey, value []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  193. <p>
  194. Find finds key/value pair whose key is greater than or equal to the
  195. given key. It returns ErrNotFound if the table doesn&#39;t contain
  196. such pair.
  197. </p>
  198. <p>
  199. The caller should not modify the contents of the returned slice, but
  200. it is safe to modify the contents of the argument after Find returns.
  201. </p>
  202. <h3 id="DB.Free">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=9319:9342#L414">Free</a></h3>
  203. <pre>func (p *<a href="index.html#DB">DB</a>) Free() <a href="../../../../../builtin/index.html#int">int</a></pre>
  204. <p>
  205. Free returns keys/values free buffer before need to grow.
  206. </p>
  207. <h3 id="DB.Get">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=7079:7133#L346">Get</a></h3>
  208. <pre>func (p *<a href="index.html#DB">DB</a>) Get(key []<a href="../../../../../builtin/index.html#byte">byte</a>) (value []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  209. <p>
  210. Get gets the value for the given key. It returns error.ErrNotFound if the
  211. DB does not contain the key.
  212. </p>
  213. <p>
  214. The caller should not modify the contents of the returned slice, but
  215. it is safe to modify the contents of the argument after Get returns.
  216. </p>
  217. <h3 id="DB.Len">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=9470:9492#L421">Len</a></h3>
  218. <pre>func (p *<a href="index.html#DB">DB</a>) Len() <a href="../../../../../builtin/index.html#int">int</a></pre>
  219. <p>
  220. Len returns the number of entries in the DB.
  221. </p>
  222. <h3 id="DB.NewIterator">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=8754:8815#L393">NewIterator</a></h3>
  223. <pre>func (p *<a href="index.html#DB">DB</a>) NewIterator(slice *<a href="../util/index.html">util</a>.<a href="../util/index.html#Range">Range</a>) <a href="../iterator/index.html">iterator</a>.<a href="../iterator/index.html#Iterator">Iterator</a></pre>
  224. <p>
  225. NewIterator returns an iterator of the DB.
  226. The returned iterator is not safe for concurrent use, but it is safe to use
  227. multiple iterators concurrently, with each in a dedicated goroutine.
  228. It is also safe to use an iterator concurrently with modifying its
  229. underlying DB. However, the resultant key/value pairs are not guaranteed
  230. to be a consistent snapshot of the DB at a particular point in time.
  231. </p>
  232. <p>
  233. Slice allows slicing the iterator to only contains keys in the given
  234. range. A nil Range.Start is treated as a key before all keys in the
  235. DB. And a nil Range.Limit is treated as a key after all keys in
  236. the DB.
  237. </p>
  238. <p>
  239. The iterator must be released after use, by calling Release method.
  240. </p>
  241. <p>
  242. Also read Iterator documentation of the leveldb/iterator package.
  243. </p>
  244. <h3 id="DB.Put">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=5101:5149#L267">Put</a></h3>
  245. <pre>func (p *<a href="index.html#DB">DB</a>) Put(key []<a href="../../../../../builtin/index.html#byte">byte</a>, value []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#error">error</a></pre>
  246. <p>
  247. Put sets the value for the given key. It overwrites any previous value
  248. for that key; a DB is not a multi-map.
  249. </p>
  250. <p>
  251. It is safe to modify the contents of the arguments after Put returns.
  252. </p>
  253. <h3 id="DB.Reset">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=9618:9638#L428">Reset</a></h3>
  254. <pre>func (p *<a href="index.html#DB">DB</a>) Reset()</pre>
  255. <p>
  256. Reset resets the DB to initial empty state. Allows reuse the buffer.
  257. </p>
  258. <h3 id="DB.Size">func (*DB) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go?s=9176:9199#L407">Size</a></h3>
  259. <pre>func (p *<a href="index.html#DB">DB</a>) Size() <a href="../../../../../builtin/index.html#int">int</a></pre>
  260. <p>
  261. Size returns sum of keys and values length. Note that deleted
  262. key/value will not be accounted for, but it will still consume
  263. the buffer, since the buffer is append only.
  264. </p>
  265. <div id="footer">
  266. Build version go1.6.<br>
  267. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  268. the content of this page is licensed under the
  269. Creative Commons Attribution 3.0 License,
  270. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  271. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  272. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  273. </div>
  274. </div><!-- .container -->
  275. </div><!-- #page -->
  276. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  277. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.js"></script>
  278. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.js"></script>
  279. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.edit.js"></script>
  280. <script type="text/javascript" src="../../../../../../lib/godoc/godocs.js"></script>
  281. </body>
  282. </html>