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.

558 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>table - 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 table</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/table"</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 table allows read and write sorted key/value.
  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#ErrCorrupted">type ErrCorrupted</a></dd>
  82. <dd>&nbsp; &nbsp; <a href="index.html#ErrCorrupted.Error">func (e *ErrCorrupted) Error() string</a></dd>
  83. <dd><a href="index.html#Reader">type Reader</a></dd>
  84. <dd>&nbsp; &nbsp; <a href="index.html#NewReader">func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.NamespaceGetter, bpool *util.BufferPool, o *opt.Options) (*Reader, error)</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Find">func (r *Reader) Find(key []byte, filtered bool, ro *opt.ReadOptions) (rkey, value []byte, err error)</a></dd>
  86. <dd>&nbsp; &nbsp; <a href="index.html#Reader.FindKey">func (r *Reader) FindKey(key []byte, filtered bool, ro *opt.ReadOptions) (rkey []byte, err error)</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Get">func (r *Reader) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)</a></dd>
  88. <dd>&nbsp; &nbsp; <a href="index.html#Reader.NewIterator">func (r *Reader) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator</a></dd>
  89. <dd>&nbsp; &nbsp; <a href="index.html#Reader.OffsetOf">func (r *Reader) OffsetOf(key []byte) (offset int64, err error)</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Release">func (r *Reader) Release()</a></dd>
  91. <dd><a href="index.html#Writer">type Writer</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#NewWriter">func NewWriter(f io.Writer, o *opt.Options) *Writer</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Append">func (w *Writer) Append(key, value []byte) error</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Writer.BlocksLen">func (w *Writer) BlocksLen() int</a></dd>
  95. <dd>&nbsp; &nbsp; <a href="index.html#Writer.BytesLen">func (w *Writer) BytesLen() int</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Close">func (w *Writer) Close() error</a></dd>
  97. <dd>&nbsp; &nbsp; <a href="index.html#Writer.EntriesLen">func (w *Writer) EntriesLen() int</a></dd>
  98. </dl>
  99. </div><!-- #manual-nav -->
  100. <h4>Package files</h4>
  101. <p>
  102. <span style="font-size:90%">
  103. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go">reader.go</a>
  104. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/table.go">table.go</a>
  105. <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go">writer.go</a>
  106. </span>
  107. </p>
  108. </div><!-- .expanded -->
  109. </div><!-- #pkg-index -->
  110. <div id="pkg-callgraph" class="toggle" style="display: none">
  111. <div class="collapsed">
  112. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  113. </div> <!-- .expanded -->
  114. <div class="expanded">
  115. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  116. <p>
  117. In the call graph viewer below, each node
  118. is a function belonging to this package
  119. and its children are the functions it
  120. calls&mdash;perhaps dynamically.
  121. </p>
  122. <p>
  123. The root nodes are the entry points of the
  124. package: functions that may be called from
  125. outside the package.
  126. There may be non-exported or anonymous
  127. functions among them if they are called
  128. dynamically from another package.
  129. </p>
  130. <p>
  131. Click a node to visit that function's source code.
  132. From there you can visit its callers by
  133. clicking its declaring <code>func</code>
  134. token.
  135. </p>
  136. <p>
  137. Functions may be omitted if they were
  138. determined to be unreachable in the
  139. particular programs or tests that were
  140. analyzed.
  141. </p>
  142. <!-- Zero means show all package entry points. -->
  143. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  144. </div>
  145. </div> <!-- #pkg-callgraph -->
  146. <h2 id="pkg-variables">Variables</h2>
  147. <pre>var (
  148. <span id="ErrNotFound">ErrNotFound</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#ErrNotFound">ErrNotFound</a>
  149. <span id="ErrReaderReleased">ErrReaderReleased</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;leveldb/table: reader released&#34;)
  150. <span id="ErrIterReleased">ErrIterReleased</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;leveldb/table: iterator released&#34;)
  151. )</pre>
  152. <p>
  153. Reader errors.
  154. </p>
  155. <h2 id="ErrCorrupted">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=986:1072#L28">ErrCorrupted</a></h2>
  156. <pre>type ErrCorrupted struct {
  157. Pos <a href="../../../../../builtin/index.html#int64">int64</a>
  158. Size <a href="../../../../../builtin/index.html#int64">int64</a>
  159. Kind <a href="../../../../../builtin/index.html#string">string</a>
  160. Reason <a href="../../../../../builtin/index.html#string">string</a>
  161. }</pre>
  162. <p>
  163. ErrCorrupted describes error due to corruption. This error will be wrapped
  164. with errors.ErrCorrupted.
  165. </p>
  166. <h3 id="ErrCorrupted.Error">func (*ErrCorrupted) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=1074:1111#L35">Error</a></h3>
  167. <pre>func (e *<a href="index.html#ErrCorrupted">ErrCorrupted</a>) Error() <a href="../../../../../builtin/index.html#string">string</a></pre>
  168. <h2 id="Reader">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=11326:11757#L501">Reader</a></h2>
  169. <pre>type Reader struct {
  170. <span class="comment">// contains filtered or unexported fields</span>
  171. }</pre>
  172. <p>
  173. Reader is a table reader.
  174. </p>
  175. <h3 id="NewReader">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=24837:24986#L1010">NewReader</a></h3>
  176. <pre>func NewReader(f <a href="../../../../../io/index.html">io</a>.<a href="../../../../../io/index.html#ReaderAt">ReaderAt</a>, size <a href="../../../../../builtin/index.html#int64">int64</a>, fd <a href="../storage/index.html">storage</a>.<a href="../storage/index.html#FileDesc">FileDesc</a>, cache *<a href="../cache/index.html">cache</a>.<a href="../cache/index.html#NamespaceGetter">NamespaceGetter</a>, bpool *<a href="../util/index.html">util</a>.<a href="../util/index.html#BufferPool">BufferPool</a>, o *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#Options">Options</a>) (*<a href="index.html#Reader">Reader</a>, <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  177. <p>
  178. NewReader creates a new initialized table reader for the file.
  179. The fi, cache and bpool is optional and can be nil.
  180. </p>
  181. <p>
  182. The returned table reader instance is safe for concurrent use.
  183. </p>
  184. <h3 id="Reader.Find">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=22053:22154#L906">Find</a></h3>
  185. <pre>func (r *<a href="index.html#Reader">Reader</a>) Find(key []<a href="../../../../../builtin/index.html#byte">byte</a>, filtered <a href="../../../../../builtin/index.html#bool">bool</a>, ro *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#ReadOptions">ReadOptions</a>) (rkey, value []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  186. <p>
  187. Find finds key/value pair whose key is greater than or equal to the
  188. given key. It returns ErrNotFound if the table doesn&#39;t contain
  189. such pair.
  190. If filtered is true then the nearest &#39;block&#39; will be checked against
  191. &#39;filter data&#39; (if present) and will immediately return ErrNotFound if
  192. &#39;filter data&#39; indicates that such pair doesn&#39;t exist.
  193. </p>
  194. <p>
  195. The caller may modify the contents of the returned slice as it is its
  196. own copy.
  197. It is safe to modify the contents of the argument after Find returns.
  198. </p>
  199. <h3 id="Reader.FindKey">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=22698:22795#L919">FindKey</a></h3>
  200. <pre>func (r *<a href="index.html#Reader">Reader</a>) FindKey(key []<a href="../../../../../builtin/index.html#byte">byte</a>, filtered <a href="../../../../../builtin/index.html#bool">bool</a>, ro *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#ReadOptions">ReadOptions</a>) (rkey []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  201. <p>
  202. FindKey finds key that is greater than or equal to the given key.
  203. It returns ErrNotFound if the table doesn&#39;t contain such key.
  204. If filtered is true then the nearest &#39;block&#39; will be checked against
  205. &#39;filter data&#39; (if present) and will immediately return ErrNotFound if
  206. &#39;filter data&#39; indicates that such key doesn&#39;t exist.
  207. </p>
  208. <p>
  209. The caller may modify the contents of the returned slice as it is its
  210. own copy.
  211. It is safe to modify the contents of the argument after Find returns.
  212. </p>
  213. <h3 id="Reader.Get">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=23132:23211#L930">Get</a></h3>
  214. <pre>func (r *<a href="index.html#Reader">Reader</a>) Get(key []<a href="../../../../../builtin/index.html#byte">byte</a>, ro *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#ReadOptions">ReadOptions</a>) (value []<a href="../../../../../builtin/index.html#byte">byte</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  215. <p>
  216. Get gets the value for the given key. It returns errors.ErrNotFound
  217. if the table does not contain the key.
  218. </p>
  219. <p>
  220. The caller may modify the contents of the returned slice as it is its
  221. own copy.
  222. It is safe to modify the contents of the argument after Find returns.
  223. </p>
  224. <h3 id="Reader.NewIterator">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=18924:19010#L783">NewIterator</a></h3>
  225. <pre>func (r *<a href="index.html#Reader">Reader</a>) NewIterator(slice *<a href="../util/index.html">util</a>.<a href="../util/index.html#Range">Range</a>, ro *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#ReadOptions">ReadOptions</a>) <a href="../iterator/index.html">iterator</a>.<a href="../iterator/index.html#Iterator">Iterator</a></pre>
  226. <p>
  227. NewIterator creates an iterator from the table.
  228. </p>
  229. <p>
  230. Slice allows slicing the iterator to only contains keys in the given
  231. range. A nil Range.Start is treated as a key before all keys in the
  232. table. And a nil Range.Limit is treated as a key after all keys in
  233. the table.
  234. </p>
  235. <p>
  236. The returned iterator is not safe for concurrent use and should be released
  237. after use.
  238. </p>
  239. <p>
  240. Also read Iterator documentation of the leveldb/iterator package.
  241. </p>
  242. <h3 id="Reader.OffsetOf">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=23579:23642#L950">OffsetOf</a></h3>
  243. <pre>func (r *<a href="index.html#Reader">Reader</a>) OffsetOf(key []<a href="../../../../../builtin/index.html#byte">byte</a>) (offset <a href="../../../../../builtin/index.html#int64">int64</a>, err <a href="../../../../../builtin/index.html#error">error</a>)</pre>
  244. <p>
  245. OffsetOf returns approximate offset for the given key.
  246. </p>
  247. <p>
  248. It is safe to modify the contents of the argument after Get returns.
  249. </p>
  250. <h3 id="Reader.Release">func (*Reader) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/reader.go?s=24289:24315#L985">Release</a></h3>
  251. <pre>func (r *<a href="index.html#Reader">Reader</a>) Release()</pre>
  252. <p>
  253. Release implements util.Releaser.
  254. It also close the file if it is an io.Closer.
  255. </p>
  256. <h2 id="Writer">type <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=2846:3425#L129">Writer</a></h2>
  257. <pre>type Writer struct {
  258. <span class="comment">// contains filtered or unexported fields</span>
  259. }</pre>
  260. <p>
  261. Writer is a table writer.
  262. </p>
  263. <h3 id="NewWriter">func <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=8384:8435#L343">NewWriter</a></h3>
  264. <pre>func NewWriter(f <a href="../../../../../io/index.html">io</a>.<a href="../../../../../io/index.html#Writer">Writer</a>, o *<a href="../opt/index.html">opt</a>.<a href="../opt/index.html#Options">Options</a>) *<a href="index.html#Writer">Writer</a></pre>
  265. <p>
  266. NewWriter creates a new initialized table writer for the file.
  267. </p>
  268. <p>
  269. Table writer is not safe for concurrent use.
  270. </p>
  271. <h3 id="Writer.Append">func (*Writer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=5579:5627#L227">Append</a></h3>
  272. <pre>func (w *<a href="index.html#Writer">Writer</a>) Append(key, value []<a href="../../../../../builtin/index.html#byte">byte</a>) <a href="../../../../../builtin/index.html#error">error</a></pre>
  273. <p>
  274. Append appends key/value pair to the table. The keys passed must
  275. be in increasing order.
  276. </p>
  277. <p>
  278. It is safe to modify the contents of the arguments after Append returns.
  279. </p>
  280. <h3 id="Writer.BlocksLen">func (*Writer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=6290:6322#L254">BlocksLen</a></h3>
  281. <pre>func (w *<a href="index.html#Writer">Writer</a>) BlocksLen() <a href="../../../../../builtin/index.html#int">int</a></pre>
  282. <p>
  283. BlocksLen returns number of blocks written so far.
  284. </p>
  285. <h3 id="Writer.BytesLen">func (*Writer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=6601:6632#L269">BytesLen</a></h3>
  286. <pre>func (w *<a href="index.html#Writer">Writer</a>) BytesLen() <a href="../../../../../builtin/index.html#int">int</a></pre>
  287. <p>
  288. BytesLen returns number of bytes written so far.
  289. </p>
  290. <h3 id="Writer.Close">func (*Writer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=6810:6840#L276">Close</a></h3>
  291. <pre>func (w *<a href="index.html#Writer">Writer</a>) Close() <a href="../../../../../builtin/index.html#error">error</a></pre>
  292. <p>
  293. Close will finalize the table. Calling Append is not possible
  294. after Close, but calling BlocksLen, EntriesLen and BytesLen
  295. is still possible.
  296. </p>
  297. <h3 id="Writer.EntriesLen">func (*Writer) <a href="http://localhost:6060/src/github.com/syndtr/goleveldb/leveldb/table/writer.go?s=6491:6524#L264">EntriesLen</a></h3>
  298. <pre>func (w *<a href="index.html#Writer">Writer</a>) EntriesLen() <a href="../../../../../builtin/index.html#int">int</a></pre>
  299. <p>
  300. EntriesLen returns number of entries added so far.
  301. </p>
  302. <div id="footer">
  303. Build version go1.6.<br>
  304. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  305. the content of this page is licensed under the
  306. Creative Commons Attribution 3.0 License,
  307. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  308. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  309. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  310. </div>
  311. </div><!-- .container -->
  312. </div><!-- #page -->
  313. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  314. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.js"></script>
  315. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.js"></script>
  316. <script type="text/javascript" src="../../../../../../lib/godoc/jquery.treeview.edit.js"></script>
  317. <script type="text/javascript" src="../../../../../../lib/godoc/godocs.js"></script>
  318. </body>
  319. </html>