@@ -127,8 +127,11 @@ private void loadDocuments(final SourceSchema sourceSchema, final Parser parser,
127127
128128 final MutableDocument document = database .newDocument (settings .documentTypeName );
129129
130- for (final AnalyzedProperty prop : properties )
131- document .set (prop .getName (), row [prop .getIndex ()]);
130+ for (final AnalyzedProperty prop : properties ) {
131+ final String value = row [prop .getIndex ()];
132+ if (value != null && !value .isEmpty ())
133+ document .set (prop .getName (), value );
134+ }
132135
133136 document .save ();
134137 context .createdDocuments .incrementAndGet ();
@@ -154,44 +157,34 @@ private void loadDocuments(final SourceSchema sourceSchema, final Parser parser,
154157 private void loadVertices (final SourceSchema sourceSchema , final Parser parser , final Database database ,
155158 final ImporterContext context , final ImporterSettings settings ) throws ImportException {
156159
157- if (settings .typeIdProperty == null ) {
158- LogManager .instance ()
159- .log (this , Level .INFO , "Property id was not defined. Set `-typeIdProperty <name>`. Importing is aborted" , null ,
160- settings .vertexTypeName , settings .typeIdProperty );
161- throw new IllegalArgumentException ("Property id was not defined. Set `-typeIdProperty <name>`. Importing is aborted" );
162- }
163-
164160 final AnalyzedEntity entity = sourceSchema .getSchema ().getEntity (settings .vertexTypeName );
165161 if (entity == null ) {
166162 LogManager .instance ().log (this , Level .INFO , "Vertex type '%s' not defined" , null , settings .vertexTypeName );
167163 return ;
168164 }
169165
170- final AnalyzedProperty id = entity .getProperty (settings .typeIdProperty );
166+ int idIndex = -1 ;
167+ if (settings .typeIdProperty != null ) {
168+ final AnalyzedProperty id = entity .getProperty (settings .typeIdProperty );
171169
172- if (id == null ) {
173- LogManager .instance ()
174- .log (this , Level .INFO , "Property Id '%s.%s' is null. Importing is aborted" , null , settings .vertexTypeName ,
175- settings .typeIdProperty );
176- throw new IllegalArgumentException (
177- "Property Id '" + settings .vertexTypeName + "." + settings .typeIdProperty + "' is null. Importing is aborted" );
178- }
170+ if (id == null ) {
171+ LogManager .instance ()
172+ .log (this , Level .INFO , "Property Id '%s.%s' is null. Importing is aborted" , null , settings .vertexTypeName ,
173+ settings .typeIdProperty );
174+ throw new IllegalArgumentException (
175+ "Property Id '" + settings .vertexTypeName + "." + settings .typeIdProperty + "' is null. Importing is aborted" );
176+ }
179177
180- long expectedVertices = settings .expectedVertices ;
181- if (expectedVertices <= 0 )
182- expectedVertices = (int ) (sourceSchema .getSource ().totalSize / entity .getAverageRowLength ());
183- if (expectedVertices <= 0 )
184- expectedVertices = 1000000 ;
185- else if (expectedVertices > Integer .MAX_VALUE )
186- expectedVertices = Integer .MAX_VALUE ;
187-
188- // Ensure the typeIdProperty has a unique index for edge resolution
189- if (!database .getSchema ().getType (settings .vertexTypeName ).existsProperty (settings .typeIdProperty ))
190- database .transaction (
191- () -> database .getSchema ().getType (settings .vertexTypeName ).createProperty (settings .typeIdProperty , com .arcadedb .schema .Type .STRING ));
192- if (database .getSchema ().getType (settings .vertexTypeName ).getIndexesByProperties (settings .typeIdProperty ).isEmpty ())
193- database .transaction (
194- () -> database .getSchema ().getType (settings .vertexTypeName ).createTypeIndex (Schema .INDEX_TYPE .LSM_TREE , true , settings .typeIdProperty ));
178+ idIndex = id .getIndex ();
179+
180+ // Ensure the typeIdProperty has a unique index for edge resolution
181+ if (!database .getSchema ().getType (settings .vertexTypeName ).existsProperty (settings .typeIdProperty ))
182+ database .transaction (
183+ () -> database .getSchema ().getType (settings .vertexTypeName ).createProperty (settings .typeIdProperty , com .arcadedb .schema .Type .STRING ));
184+ if (database .getSchema ().getType (settings .vertexTypeName ).getIndexesByProperties (settings .typeIdProperty ).isEmpty ())
185+ database .transaction (
186+ () -> database .getSchema ().getType (settings .vertexTypeName ).createTypeIndex (Schema .INDEX_TYPE .LSM_TREE , true , settings .typeIdProperty ));
187+ }
195188
196189 final AbstractParser <?> csvParser = createCSVParser (settings );
197190
@@ -209,8 +202,6 @@ else if (expectedVertices > Integer.MAX_VALUE)
209202 DatabaseFactory .getDefaultCharset ())) {
210203 csvParser .beginParsing (inputFileReader );
211204
212- final int idIndex = id .getIndex ();
213-
214205 final List <AnalyzedProperty > properties = new ArrayList <>();
215206 if (!settings .vertexPropertiesInclude .isEmpty () && !settings .vertexPropertiesInclude .equalsIgnoreCase ("*" )) {
216207 final String [] includes = settings .vertexPropertiesInclude .split ("," );
@@ -231,18 +222,21 @@ else if (expectedVertices > Integer.MAX_VALUE)
231222 if (skipEntries > 0 && line < skipEntries )
232223 continue ;
233224
234- if (idIndex >= row .length ) {
225+ if (idIndex >= 0 && idIndex >= row .length ) {
235226 LogManager .instance ()
236227 .log (this , Level .INFO , "Property Id is configured on property %d but cannot be found on current record. Skip it" ,
237228 null , idIndex );
238229 continue ;
239230 }
240231
241232 final MutableVertex v = database .newVertex (settings .vertexTypeName );
242- v .set (settings .typeIdProperty , row [idIndex ]);
233+ if (idIndex >= 0 )
234+ v .set (settings .typeIdProperty , row [idIndex ]);
243235 for (int p = 0 ; p < properties .size (); ++p ) {
244236 final AnalyzedProperty prop = properties .get (p );
245- v .set (prop .getName (), row [prop .getIndex ()]);
237+ final String value = row [prop .getIndex ()];
238+ if (value != null && !value .isEmpty ())
239+ v .set (prop .getName (), value );
246240 }
247241 database .async ().createRecord (v , doc -> context .createdVertices .incrementAndGet ());
248242 }
0 commit comments