-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
LabelScanStore.java
199 lines (162 loc) · 5.65 KB
/
LabelScanStore.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
* Copyright (c) 2002-2018 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel.api.labelscan;
import java.io.File;
import java.io.IOException;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.io.pagecache.IOLimiter;
import org.neo4j.kernel.impl.store.UnderlyingStorageException;
import org.neo4j.kernel.lifecycle.Lifecycle;
import org.neo4j.storageengine.api.schema.LabelScanReader;
/**
* Stores label-->nodes mappings. It receives updates in the form of condensed label->node transaction data
* and can iterate through all nodes for any given label.
*/
public interface LabelScanStore extends Lifecycle
{
interface Monitor
{
Monitor EMPTY = new Monitor.Adaptor();
class Adaptor implements Monitor
{
@Override
public void init()
{ // empty
}
@Override
public void noIndex()
{ // empty
}
@Override
public void notValidIndex()
{ // empty
}
@Override
public void rebuilding()
{ // empty
}
@Override
public void rebuilt( long roughNodeCount )
{ // empty
}
@Override
public void recoveryCleanupRegistered()
{ // empty
}
@Override
public void recoveryCleanupStarted()
{ // empty
}
@Override
public void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ // empty
}
@Override
public void recoveryCleanupClosed()
{ // empty
}
@Override
public void recoveryCleanupFailed( Throwable throwable )
{ // empty
}
}
void init();
void noIndex();
void notValidIndex();
void rebuilding();
void rebuilt( long roughNodeCount );
void recoveryCleanupRegistered();
void recoveryCleanupStarted();
void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis );
void recoveryCleanupClosed();
void recoveryCleanupFailed( Throwable throwable );
}
/**
* From the point a {@link LabelScanReader} is created till it's {@link LabelScanReader#close() closed} the
* contents it returns cannot change, i.e. it honors repeatable reads.
*
* @return a {@link LabelScanReader} capable of retrieving nodes for labels.
*/
LabelScanReader newReader();
/**
* Acquire a writer for updating the store.
*
* @return {@link LabelScanWriter} which can modify the {@link LabelScanStore}.
*/
LabelScanWriter newWriter();
/**
* Forces all changes to disk. Called at certain points from within Neo4j for example when
* rotating the logical log. After completion of this call there cannot be any essential state that
* hasn't been forced to disk.
*
* @throws UnderlyingStorageException if there was a problem forcing the state to persistent storage.
*/
void force( IOLimiter limiter ) throws UnderlyingStorageException;
/**
* Acquire a reader for all {@link NodeLabelRange node label} ranges.
*
* @return the {@link AllEntriesLabelScanReader reader}.
*/
AllEntriesLabelScanReader allNodeLabelRanges();
ResourceIterator<File> snapshotStoreFiles() throws IOException;
/**
* @return {@code true} if there's no data at all in this label scan store, otherwise {@code false}.
* @throws IOException on I/O error.
*/
boolean isEmpty() throws IOException;
/**
* Initializes the store. After this has been called recovery updates can be processed.
*/
@Override
void init() throws IOException;
/**
* Starts the store. After this has been called updates can be processed.
*/
@Override
void start() throws IOException;
@Override
void stop() throws IOException;
/**
* Shuts down the store and all resources acquired by it.
*/
@Override
void shutdown() throws IOException;
/**
* Drops any persistent storage backing this store.
*
* @throws IOException on I/O error.
*/
void drop() throws IOException;
/**
* @return whether or not this index is read-only.
*/
boolean isReadOnly();
/**
* @return whether or not there's an existing store present for this label scan store.
* @throws IOException on I/O error checking the presence of a store.
*/
boolean hasStore() throws IOException;
/**
* Returns the path to label scan store, might be a directory or a file depending on the implementation.
*
* @return the directory or file where the label scan store is persisted.
*/
File getLabelScanStoreFile();
}