]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under both the GPLv2 (found in the | |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
5 | ||
6 | package org.rocksdb; | |
7 | ||
8 | public class SstFileReader extends RocksObject { | |
9 | static { | |
10 | RocksDB.loadLibrary(); | |
11 | } | |
12 | ||
13 | public SstFileReader(final Options options) { | |
14 | super(newSstFileReader(options.nativeHandle_)); | |
15 | } | |
16 | ||
17 | /** | |
18 | * Returns an iterator that will iterate on all keys in the default | |
19 | * column family including both keys in the DB and uncommitted keys in this | |
20 | * transaction. | |
21 | * | |
22 | * Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is read | |
23 | * from the DB but will NOT change which keys are read from this transaction | |
24 | * (the keys in this transaction do not yet belong to any snapshot and will be | |
25 | * fetched regardless). | |
26 | * | |
27 | * Caller is responsible for deleting the returned Iterator. | |
28 | * | |
29 | * @param readOptions Read options. | |
30 | * | |
31 | * @return instance of iterator object. | |
32 | */ | |
33 | public SstFileReaderIterator newIterator(final ReadOptions readOptions) { | |
34 | assert (isOwningHandle()); | |
35 | long iter = newIterator(nativeHandle_, readOptions.nativeHandle_); | |
36 | return new SstFileReaderIterator(this, iter); | |
37 | } | |
38 | ||
39 | /** | |
40 | * Prepare SstFileReader to read a file. | |
41 | * | |
42 | * @param filePath the location of file | |
43 | * | |
44 | * @throws RocksDBException thrown if error happens in underlying | |
45 | * native library. | |
46 | */ | |
47 | public void open(final String filePath) throws RocksDBException { | |
48 | open(nativeHandle_, filePath); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Verify checksum | |
53 | * | |
54 | * @throws RocksDBException if the checksum is not valid | |
55 | */ | |
56 | public void verifyChecksum() throws RocksDBException { | |
57 | verifyChecksum(nativeHandle_); | |
58 | } | |
59 | ||
60 | /** | |
61 | * Get the properties of the table. | |
62 | * | |
63 | * @return the properties | |
64 | * | |
65 | * @throws RocksDBException if an error occurs whilst getting the table | |
66 | * properties | |
67 | */ | |
68 | public TableProperties getTableProperties() throws RocksDBException { | |
69 | return getTableProperties(nativeHandle_); | |
70 | } | |
71 | ||
72 | @Override protected final native void disposeInternal(final long handle); | |
73 | private native long newIterator(final long handle, final long readOptionsHandle); | |
74 | ||
75 | private native void open(final long handle, final String filePath) | |
76 | throws RocksDBException; | |
77 | ||
78 | private native static long newSstFileReader(final long optionsHandle); | |
79 | private native void verifyChecksum(final long handle) throws RocksDBException; | |
80 | private native TableProperties getTableProperties(final long handle) | |
81 | throws RocksDBException; | |
82 | } |