-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Input.java
124 lines (109 loc) · 4.7 KB
/
Input.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
/*
* Copyright (c) 2002-2017 "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.unsafe.impl.batchimport.input;
import java.io.IOException;
import java.util.function.ToIntFunction;
import org.neo4j.unsafe.impl.batchimport.BatchImporter;
import org.neo4j.unsafe.impl.batchimport.InputIterable;
import org.neo4j.unsafe.impl.batchimport.cache.NumberArrayFactory;
import org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdGenerator;
import org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper;
import org.neo4j.values.storable.Value;
/**
* Unifies all data input given to a {@link BatchImporter} to allow for more coherent implementations.
*/
public interface Input
{
interface Estimates
{
/**
* @return estimated number of nodes for the entire input.
*/
long numberOfNodes();
/**
* @return estimated number of relationships for the entire input.
*/
long numberOfRelationships();
/**
* @return estimated number of node properties.
*/
long numberOfNodeProperties();
/**
* @return estimated number of relationship properties.
*/
long numberOfRelationshipProperties();
/**
* @return estimated size that the estimated number of node properties will require on disk.
* This is a separate estimate since it depends on the type and size of the actual properties.
*/
long sizeOfNodeProperties();
/**
* @return estimated size that the estimated number of relationship properties will require on disk.
* This is a separate estimate since it depends on the type and size of the actual properties.
*/
long sizeOfRelationshipProperties();
/**
* @return estimated number of node labels. Examples:
* <ul>
* <li>2 nodes, 1 label each ==> 2</li>
* <li>1 node, 2 labels each ==> 2</li>
* <li>2 nodes, 2 labels each ==> 4</li>
* </ul>
*/
long numberOfNodeLabels();
}
/**
* Provides all {@link InputNode input nodes} for an import. The returned {@link InputIterable iterable's}
* {@link InputIterable#iterator() iterator()} method may be called multiple times.
*
* @return an {@link InputIterable} which will provide all {@link InputNode input nodes} for the whole import.
*/
InputIterable<InputNode> nodes();
/**
* Provides all {@link InputRelationship input relationships} for an import. The returned
* {@link InputIterable iterable's} {@link InputIterable#iterator() iterator()} method may be called multiple times.
*
* @return an {@link InputIterable} which will provide all {@link InputRelationship input relationships}
* for the whole import.
*/
InputIterable<InputRelationship> relationships();
/**
* @return {@link IdMapper} which will get populated by {@link InputNode#id() input node ids}
* and later queried by {@link InputRelationship#startNode()} and {@link InputRelationship#endNode()} ids
* to resolve potentially temporary input node ids to actual node ids in the database.
* @param numberArrayFactory The factory for creating data-structures to use for caching internally in the IdMapper.
*/
IdMapper idMapper( NumberArrayFactory numberArrayFactory );
/**
* @return {@link IdGenerator} which is responsible for generating actual node ids from input node ids.
*/
IdGenerator idGenerator();
/**
* @return a {@link Collector} capable of writing {@link InputRelationship bad relationships}
* and {@link InputNode duplicate nodes} to an output stream for later handling.
*/
Collector badCollector();
/**
* @param valueSizeCalculator for calculating property sizes on disk.
* @return {@link Estimates} for this input w/o reading through it entirely.
* @throws IOException on I/O error.
*/
Estimates calculateEstimates( ToIntFunction<Value[]> valueSizeCalculator ) throws IOException;
}