Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: components/leveldb/public/interfaces/leveldb.mojom

Issue 1861903002: mojo leveldb: Add an iteration interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/leveldb/public/cpp/util.cc ('k') | components/leveldb/remote_iterator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 module leveldb; 5 module leveldb;
6 6
7 import "components/filesystem/public/interfaces/directory.mojom"; 7 import "components/filesystem/public/interfaces/directory.mojom";
8 8
9 enum DatabaseError { 9 enum DatabaseError {
10 OK, 10 OK,
11 NOT_FOUND, 11 NOT_FOUND,
12 CORRUPTION, 12 CORRUPTION,
13 NOT_SUPPORTED, 13 NOT_SUPPORTED,
14 INVALID_ARGUMENT, 14 INVALID_ARGUMENT,
15 IO_ERROR 15 IO_ERROR
16 }; 16 };
17 17
18 enum BatchOperationType { 18 enum BatchOperationType {
19 PUT_KEY, 19 PUT_KEY,
20 DELETE_KEY 20 DELETE_KEY
21 }; 21 };
22 22
23 struct BatchedOperation { 23 struct BatchedOperation {
24 BatchOperationType type; 24 BatchOperationType type;
25 array<uint8> key; 25 array<uint8> key;
26 array<uint8>? value; 26 array<uint8>? value;
27 }; 27 };
28 28
29 // Options which control the behavior of a database. (This struct corresponds
30 // with the struct in leveldb's options.h.)
31 struct OpenOptions {
32 // TODO(erg): Find all comparators and copy them into the service.
33
34 // If true, the database will be created if it is missing.
35 bool create_if_missing = false;
36
37 // If true, an error is raised if the database already exists.
38 bool error_if_exists = false;
39
40 // If true, the implementation will do aggressive checking of the
41 // data it is processing and will stop early if it detects any
42 // errors.
43 bool paranoid_checks = false;
44
45 // Default size is 4 megabytes.
46 uint64 write_buffer_size = 4194304;
47
48 // Number of open files that can be used by the DB. (Note: we globally set
49 // the default here to 80 instead of leveldb's default 1000 because we don't
50 // want to consume all file descriptors. See
51 // https://code.google.com/p/chromium/issues/detail?id=227313#c11 for
52 // details.)
53 int32 max_open_files = 80;
54 };
55
29 // Service which hands out databases. 56 // Service which hands out databases.
30 interface LevelDBService { 57 interface LevelDBService {
31 // TODO(erg): What options do we want to export? All? None?
32 Open(filesystem.Directory directory, 58 Open(filesystem.Directory directory,
33 string dbname, 59 string dbname,
34 LevelDBDatabase& database) => (DatabaseError status); 60 LevelDBDatabase& database) => (DatabaseError status);
61 OpenWithOptions(OpenOptions options,
62 filesystem.Directory directory,
63 string dbname,
64 LevelDBDatabase& database) => (DatabaseError status);
35 65
36 OpenInMemory(LevelDBDatabase& database) => (DatabaseError status); 66 OpenInMemory(LevelDBDatabase& database) => (DatabaseError status);
37 }; 67 };
38 68
39 // A leveldb database. 69 // A leveldb database.
40 interface LevelDBDatabase { 70 interface LevelDBDatabase {
41 // Basic Interface ------------------------------------------------------- 71 // Basic Interface -------------------------------------------------------
42 72
43 // Sets the database entry for "key" to "value". Returns OK on success. 73 // Sets the database entry for "key" to "value". Returns OK on success.
44 Put(array<uint8> key, array<uint8> value) => (DatabaseError status); 74 Put(array<uint8> key, array<uint8> value) => (DatabaseError status);
(...skipping 13 matching lines...) Expand all
58 // Returns a handle to the current database state. 88 // Returns a handle to the current database state.
59 GetSnapshot() => (uint64 snapshot_id); 89 GetSnapshot() => (uint64 snapshot_id);
60 90
61 // Releases a previously acquired snapshot. 91 // Releases a previously acquired snapshot.
62 ReleaseSnapshot(uint64 snapshot_id); 92 ReleaseSnapshot(uint64 snapshot_id);
63 93
64 // If |key| exists at the time |snapshot_id| was taken, return OK and the 94 // If |key| exists at the time |snapshot_id| was taken, return OK and the
65 // value. Otherwise return NOT_FOUND. 95 // value. Otherwise return NOT_FOUND.
66 GetFromSnapshot(uint64 snapshot_id, array<uint8> key) 96 GetFromSnapshot(uint64 snapshot_id, array<uint8> key)
67 => (DatabaseError status, array<uint8> value); 97 => (DatabaseError status, array<uint8> value);
98
99 // Iteartors -------------------------------------------------------------
100
101 // Creates an iterator, either from the current view or from a snapshot.
102 NewIterator() => (uint64 iterator_id);
103 NewIteratorFromSnapshot(uint64 snapshot_id) => (uint64 iterator_id);
104
105 ReleaseIterator(uint64 iterator_id);
106
107 // Positions the iterator at the first key, last key, or the first key after
108 // |target|.
109 [Sync]
110 IteratorSeekToFirst(uint64 iterator_id)
111 => (bool valid, DatabaseError status, array<uint8>? key,
112 array<uint8>? value);
113 [Sync]
114 IteratorSeekToLast(uint64 iterator_id)
115 => (bool valid, DatabaseError status, array<uint8>? key,
116 array<uint8>? value);
117 [Sync]
118 IteratorSeek(uint64 iterator_id, array<uint8> target)
119 => (bool valid, DatabaseError status, array<uint8>? key,
120 array<uint8>? value);
121
122 // Moves forward or backwards in iterator space.
123 [Sync]
124 IteratorNext(uint64 iterator_id)
125 => (bool valid, DatabaseError status, array<uint8>? key,
126 array<uint8>? value);
127 [Sync]
128 IteratorPrev(uint64 iterator_id)
129 => (bool valid, DatabaseError status, array<uint8>? key,
130 array<uint8>? value);
68 }; 131 };
OLDNEW
« no previous file with comments | « components/leveldb/public/cpp/util.cc ('k') | components/leveldb/remote_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698