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.

615 lines
19 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>iterator - 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 iterator</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/iterator"</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 iterator provides interface and implementation to traverse over
  68. contents of a database.
  69. </p>
  70. </div>
  71. </div>
  72. <div id="pkg-index" class="toggleVisible">
  73. <div class="collapsed">
  74. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  75. </div>
  76. <div class="expanded">
  77. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  78. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  79. <div id="manual-nav">
  80. <dl>
  81. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  82. <dd><a href="index.html#Array">type Array</a></dd>
  83. <dd><a href="index.html#ArrayIndexer">type ArrayIndexer</a></dd>
  84. <dd><a href="index.html#BasicArray">type BasicArray</a></dd>
  85. <dd><a href="index.html#CommonIterator">type CommonIterator</a></dd>
  86. <dd><a href="index.html#ErrorCallbackSetter">type ErrorCallbackSetter</a></dd>
  87. <dd><a href="index.html#Iterator">type Iterator</a></dd>
  88. <dd>&nbsp; &nbsp; <a href="index.html#NewArrayIterator">func NewArrayIterator(array Array) Iterator</a></dd>
  89. <dd>&nbsp; &nbsp; <a href="index.html#NewEmptyIterator">func NewEmptyIterator(err error) Iterator</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#NewIndexedIterator">func NewIndexedIterator(index IteratorIndexer, strict bool) Iterator</a></dd>
  91. <dd>&nbsp; &nbsp; <a href="index.html#NewMergedIterator">func NewMergedIterator(iters []Iterator, cmp comparer.Comparer, strict bool) Iterator</a></dd>
  92. <dd><a href="index.html#IteratorIndexer">type IteratorIndexer</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#NewArrayIndexer">func NewArrayIndexer(array ArrayIndexer) IteratorIndexer</a></dd>
  94. <dd><a href="index.html#IteratorSeeker">type IteratorSeeker</a></dd>
  95. </dl>
  96. </div><!-- #manual-nav -->
  97. <h4>Package files</h4>
  98. <p>
  99. <span style="font-size:90%">
  100. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go">array_iter.go</a>
  101. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go">indexed_iter.go</a>
  102. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go">iter.go</a>
  103. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go">merged_iter.go</a>
  104. </span>
  105. </p>
  106. </div><!-- .expanded -->
  107. </div><!-- #pkg-index -->
  108. <div id="pkg-callgraph" class="toggle" style="display: none">
  109. <div class="collapsed">
  110. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  111. </div> <!-- .expanded -->
  112. <div class="expanded">
  113. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  114. <p>
  115. In the call graph viewer below, each node
  116. is a function belonging to this package
  117. and its children are the functions it
  118. calls&mdash;perhaps dynamically.
  119. </p>
  120. <p>
  121. The root nodes are the entry points of the
  122. package: functions that may be called from
  123. outside the package.
  124. There may be non-exported or anonymous
  125. functions among them if they are called
  126. dynamically from another package.
  127. </p>
  128. <p>
  129. Click a node to visit that function's source code.
  130. From there you can visit its callers by
  131. clicking its declaring <code>func</code>
  132. token.
  133. </p>
  134. <p>
  135. Functions may be omitted if they were
  136. determined to be unreachable in the
  137. particular programs or tests that were
  138. analyzed.
  139. </p>
  140. <!-- Zero means show all package entry points. -->
  141. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  142. </div>
  143. </div> <!-- #pkg-callgraph -->
  144. <h2 id="pkg-variables">Variables</h2>
  145. <pre>var (
  146. <span id="ErrIterReleased">ErrIterReleased</span> = <a href="../../../../../errors/index.html">errors</a>.<a href="../../../../../errors/index.html#New">New</a>(&#34;leveldb/iterator: iterator released&#34;)
  147. )</pre>
  148. <h2 id="Array">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go?s=620:741#L14">Array</a></h2>
  149. <pre>type Array interface {
  150. <a href="index.html#BasicArray">BasicArray</a>
  151. <span class="comment">// Index returns key/value pair with index of i.</span>
  152. Index(i <a href="../../../../../builtin/index.html#int">int</a>) (key, value []<a href="../../../../../builtin/index.html#byte">byte</a>)
  153. }</pre>
  154. <p>
  155. Array is the interface that wraps BasicArray and basic Index method.
  156. </p>
  157. <h2 id="ArrayIndexer">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go?s=813:931#L22">ArrayIndexer</a></h2>
  158. <pre>type ArrayIndexer interface {
  159. <a href="index.html#BasicArray">BasicArray</a>
  160. <span class="comment">// Get returns a new data iterator with index of i.</span>
  161. Get(i <a href="../../../../../builtin/index.html#int">int</a>) <a href="index.html#Iterator">Iterator</a>
  162. }</pre>
  163. <p>
  164. Array is the interface that wraps BasicArray and basic Get method.
  165. </p>
  166. <h2 id="BasicArray">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go?s=340:546#L4">BasicArray</a></h2>
  167. <pre>type BasicArray interface {
  168. <span class="comment">// Len returns length of the array.</span>
  169. Len() <a href="../../../../../builtin/index.html#int">int</a>
  170. <span class="comment">// Search finds smallest index that point to a key that is greater</span>
  171. <span class="comment">// than or equal to the given key.</span>
  172. Search(key []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#int">int</a>
  173. }</pre>
  174. <p>
  175. BasicArray is the interface that wraps basic Len and Search method.
  176. </p>
  177. <h2 id="CommonIterator">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go?s=1587:2091#L42">CommonIterator</a></h2>
  178. <pre>type CommonIterator interface {
  179. <a href="index.html#IteratorSeeker">IteratorSeeker</a>
  180. <span class="comment">// util.Releaser is the interface that wraps basic Release method.</span>
  181. <span class="comment">// When called Release will releases any resources associated with the</span>
  182. <span class="comment">// iterator.</span>
  183. <a href="../util/index.html">util</a>.<a href="../util/index.html#Releaser">Releaser</a>
  184. <span class="comment">// util.ReleaseSetter is the interface that wraps the basic SetReleaser</span>
  185. <span class="comment">// method.</span>
  186. <a href="../util/index.html">util</a>.<a href="../util/index.html#ReleaseSetter">ReleaseSetter</a>
  187. <span class="comment">// TODO: Remove this when ready.</span>
  188. Valid() <a href="../../../../../builtin/index.html#bool">bool</a>
  189. <span class="comment">// Error returns any accumulated error. Exhausting all the key/value pairs</span>
  190. <span class="comment">// is not considered to be an error.</span>
  191. Error() <a href="../../../../../builtin/index.html#error">error</a>
  192. }</pre>
  193. <p>
  194. CommonIterator is the interface that wraps common iterator methods.
  195. </p>
  196. <h2 id="ErrorCallbackSetter">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go?s=3285:3476#L91">ErrorCallbackSetter</a></h2>
  197. <pre>type ErrorCallbackSetter interface {
  198. <span class="comment">// SetErrorCallback allows set an error callback of the corresponding</span>
  199. <span class="comment">// iterator. Use nil to clear the callback.</span>
  200. SetErrorCallback(f func(err <a href="../../../../../builtin/index.html#error">error</a>))
  201. }</pre>
  202. <p>
  203. ErrorCallbackSetter is the interface that wraps basic SetErrorCallback
  204. method.
  205. </p>
  206. <p>
  207. ErrorCallbackSetter implemented by indexed and merged iterator.
  208. </p>
  209. <h2 id="Iterator">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go?s=2627:3128#L73">Iterator</a></h2>
  210. <pre>type Iterator interface {
  211. <a href="index.html#CommonIterator">CommonIterator</a>
  212. <span class="comment">// Key returns the key of the current key/value pair, or nil if done.</span>
  213. <span class="comment">// The caller should not modify the contents of the returned slice, and</span>
  214. <span class="comment">// its contents may change on the next call to any &#39;seeks method&#39;.</span>
  215. Key() []<a href="../../../../../builtin/index.html#byte">byte</a>
  216. <span class="comment">// Value returns the key of the current key/value pair, or nil if done.</span>
  217. <span class="comment">// The caller should not modify the contents of the returned slice, and</span>
  218. <span class="comment">// its contents may change on the next call to any &#39;seeks method&#39;.</span>
  219. Value() []<a href="../../../../../builtin/index.html#byte">byte</a>
  220. }</pre>
  221. <p>
  222. Iterator iterates over a DB&#39;s key/value pairs in key order.
  223. </p>
  224. <p>
  225. When encounter an error any &#39;seeks method&#39; will return false and will
  226. yield no key/value pairs. The error can be queried by calling the Error
  227. method. Calling Release is still necessary.
  228. </p>
  229. <p>
  230. An iterator must be released after use, but it is not necessary to read
  231. an iterator until exhaustion.
  232. Also, an iterator is not necessarily safe for concurrent use, but it is
  233. safe to use multiple iterators concurrently, with each in a dedicated
  234. goroutine.
  235. </p>
  236. <h3 id="NewArrayIterator">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go?s=2972:3015#L160">NewArrayIterator</a></h3>
  237. <pre>func NewArrayIterator(array <a href="index.html#Array">Array</a>) <a href="index.html#Iterator">Iterator</a></pre>
  238. <p>
  239. NewArrayIterator returns an iterator from the given array.
  240. </p>
  241. <h3 id="NewEmptyIterator">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go?s=4397:4438#L120">NewEmptyIterator</a></h3>
  242. <pre>func NewEmptyIterator(err <a href="../../../../../builtin/index.html#error">error</a>) <a href="index.html#Iterator">Iterator</a></pre>
  243. <p>
  244. NewEmptyIterator creates an empty iterator. The err parameter can be
  245. nil, but if not nil the given err will be returned by Error method.
  246. </p>
  247. <h3 id="NewIndexedIterator">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go?s=4276:4344#L230">NewIndexedIterator</a></h3>
  248. <pre>func NewIndexedIterator(index <a href="index.html#IteratorIndexer">IteratorIndexer</a>, strict <a href="../../../../../builtin/index.html#bool">bool</a>) <a href="index.html#Iterator">Iterator</a></pre>
  249. <p>
  250. NewIndexedIterator returns an &#39;indexed iterator&#39;. An index is iterator
  251. that returns another iterator, a &#39;data iterator&#39;. A &#39;data iterator&#39; is the
  252. iterator that contains actual key/value pairs.
  253. </p>
  254. <p>
  255. If strict is true the any &#39;corruption errors&#39; (i.e errors.IsCorrupted(err) == true)
  256. won&#39;t be ignored and will halt &#39;indexed iterator&#39;, otherwise the iterator will
  257. continue to the next &#39;data iterator&#39;. Corruption on &#39;index iterator&#39; will not be
  258. ignored and will halt the iterator.
  259. </p>
  260. <h3 id="NewMergedIterator">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go?s=5622:5707#L287">NewMergedIterator</a></h3>
  261. <pre>func NewMergedIterator(iters []<a href="index.html#Iterator">Iterator</a>, cmp <a href="../comparer/index.html">comparer</a>.<a href="../comparer/index.html#Comparer">Comparer</a>, strict <a href="../../../../../builtin/index.html#bool">bool</a>) <a href="index.html#Iterator">Iterator</a></pre>
  262. <p>
  263. NewMergedIterator returns an iterator that merges its input. Walking the
  264. resultant iterator will return all key/value pairs of all input iterators
  265. in strictly increasing key order, as defined by cmp.
  266. The input&#39;s key ranges may overlap, but there are assumed to be no duplicate
  267. keys: if iters[i] contains a key k then iters[j] will not contain that key k.
  268. None of the iters may be nil.
  269. </p>
  270. <p>
  271. If strict is true the any &#39;corruption errors&#39; (i.e errors.IsCorrupted(err) == true)
  272. won&#39;t be ignored and will halt &#39;merged iterator&#39;, otherwise the iterator will
  273. continue to the next &#39;input iterator&#39;.
  274. </p>
  275. <h2 id="IteratorIndexer">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go?s=455:604#L6">IteratorIndexer</a></h2>
  276. <pre>type IteratorIndexer interface {
  277. <a href="index.html#CommonIterator">CommonIterator</a>
  278. <span class="comment">// Get returns a new data iterator for the current position, or nil if</span>
  279. <span class="comment">// done.</span>
  280. Get() <a href="index.html#Iterator">Iterator</a>
  281. }</pre>
  282. <p>
  283. IteratorIndexer is the interface that wraps CommonIterator and basic Get
  284. method. IteratorIndexer provides index for indexed iterator.
  285. </p>
  286. <h3 id="NewArrayIndexer">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go?s=3235:3291#L169">NewArrayIndexer</a></h3>
  287. <pre>func NewArrayIndexer(array <a href="index.html#ArrayIndexer">ArrayIndexer</a>) <a href="index.html#IteratorIndexer">IteratorIndexer</a></pre>
  288. <p>
  289. NewArrayIndexer returns an index iterator from the given array.
  290. </p>
  291. <h2 id="IteratorSeeker">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go?s=526:1514#L12">IteratorSeeker</a></h2>
  292. <pre>type IteratorSeeker interface {
  293. <span class="comment">// First moves the iterator to the first key/value pair. If the iterator</span>
  294. <span class="comment">// only contains one key/value pair then First and Last would moves</span>
  295. <span class="comment">// to the same key/value pair.</span>
  296. <span class="comment">// It returns whether such pair exist.</span>
  297. First() <a href="../../../../../builtin/index.html#bool">bool</a>
  298. <span class="comment">// Last moves the iterator to the last key/value pair. If the iterator</span>
  299. <span class="comment">// only contains one key/value pair then First and Last would moves</span>
  300. <span class="comment">// to the same key/value pair.</span>
  301. <span class="comment">// It returns whether such pair exist.</span>
  302. Last() <a href="../../../../../builtin/index.html#bool">bool</a>
  303. <span class="comment">// Seek moves the iterator to the first key/value pair whose key is greater</span>
  304. <span class="comment">// than or equal to the given key.</span>
  305. <span class="comment">// It returns whether such pair exist.</span>
  306. <span class="comment">//</span>
  307. <span class="comment">// It is safe to modify the contents of the argument after Seek returns.</span>
  308. Seek(key []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#bool">bool</a>
  309. <span class="comment">// Next moves the iterator to the next key/value pair.</span>
  310. <span class="comment">// It returns whether the iterator is exhausted.</span>
  311. Next() <a href="../../../../../builtin/index.html#bool">bool</a>
  312. <span class="comment">// Prev moves the iterator to the previous key/value pair.</span>
  313. <span class="comment">// It returns whether the iterator is exhausted.</span>
  314. Prev() <a href="../../../../../builtin/index.html#bool">bool</a>
  315. }</pre>
  316. <p>
  317. IteratorSeeker is the interface that wraps the &#39;seeks method&#39;.
  318. </p>
  319. <div id="footer">
  320. Build version go1.6.<br>
  321. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  322. the content of this page is licensed under the
  323. Creative Commons Attribution 3.0 License,
  324. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  325. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  326. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  327. </div>
  328. </div><!-- .container -->
  329. </div><!-- #page -->
  330. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  331. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.js"></script>
  332. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.js"></script>
  333. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.edit.js"></script>
  334. <script type="text/javascript" src="../../../../../../lib/godoc/godocs.js"></script>
  335. </body>
  336. </html>