@@ -86,14 +86,15 @@ public class ODatabaseImport extends ODatabaseImpExpAbstract {
86
86
public static final String EXPORT_IMPORT_MAP_TREE_STATE_EXT = ".eihtsf" ;
87
87
public static final String EXPORT_IMPORT_MAP_BF_EXT = ".eihtb" ;
88
88
89
- private Map <OPropertyImpl , String > linkedClasses = new HashMap <OPropertyImpl , String >();
90
- private Map <OClass , String > superClasses = new HashMap <OClass , String >();
91
- private OJSONReader jsonReader ;
92
- private ORecordInternal <?> record ;
93
- private boolean schemaImported = false ;
94
- private int exporterVersion = -1 ;
95
- private ORID schemaRecordId ;
96
- private ORID indexMgrRecordId ;
89
+ protected Map <OPropertyImpl , String > linkedClasses = new HashMap <OPropertyImpl , String >();
90
+ protected Map <OClass , String > superClasses = new HashMap <OClass , String >();
91
+ protected OJSONReader jsonReader ;
92
+ protected ORecordInternal <?> record ;
93
+ protected boolean schemaImported = false ;
94
+ protected int exporterVersion = -1 ;
95
+ protected ORID schemaRecordId ;
96
+ protected ORID indexMgrRecordId ;
97
+ protected boolean deleteRIDMapping = true ;
97
98
98
99
private OLocalHashTable <OIdentifiable , OIdentifiable > exportImportHashTable ;
99
100
@@ -131,10 +132,17 @@ public ODatabaseImport(final ODatabaseDocument database, final InputStream iStre
131
132
@ Override
132
133
public ODatabaseImport setOptions (String iOptions ) {
133
134
super .setOptions (iOptions );
134
-
135
135
return this ;
136
136
}
137
137
138
+ @ Override
139
+ protected void parseSetting (final String option , final List <String > items ) {
140
+ if (option .equalsIgnoreCase ("-deleteRIDMapping" ))
141
+ deleteRIDMapping = Boolean .parseBoolean (items .get (0 ));
142
+ else
143
+ super .parseSetting (option , items );
144
+ }
145
+
138
146
public ODatabaseImport importDatabase () {
139
147
try {
140
148
if (!(database .getStorage () instanceof OStorageLocalAbstract )) {
@@ -180,6 +188,9 @@ else if (tag.equals("manualIndexes"))
180
188
exportImportHashTable .close ();
181
189
database .setStatus (STATUS .OPEN );
182
190
191
+ if (isDeleteRIDMapping ())
192
+ removeExportImportRIDsMap ();
193
+
183
194
listener .onMessage ("\n \n Database import completed in " + ((System .currentTimeMillis () - time )) + " ms" );
184
195
185
196
} catch (Exception e ) {
@@ -896,7 +907,7 @@ private void rewriteLinksInImportedDocuments() throws IOException {
896
907
OPhysicalPosition [] positions = cluster .ceilingPositions (new OPhysicalPosition (OClusterPositionFactory .INSTANCE .valueOf (0 )));
897
908
while (positions .length > 0 ) {
898
909
for (OPhysicalPosition position : positions ) {
899
- ORecord record = database .load (new ORecordId (clusterId , position .clusterPosition ));
910
+ ORecord <?> record = database .load (new ORecordId (clusterId , position .clusterPosition ));
900
911
if (record instanceof ODocument ) {
901
912
ODocument document = (ODocument ) record ;
902
913
rewriteLinksInDocument (document );
@@ -925,19 +936,30 @@ private void rewriteLinksInDocument(ODocument document) {
925
936
}
926
937
927
938
public ODatabaseImport removeExportImportRIDsMap () {
939
+ listener .onMessage ("\n Deleting RID Mapping table..." );
928
940
exportImportHashTable .delete ();
929
- return this ;
941
+ listener .onMessage ("OK\n " );
942
+ return this ;
930
943
}
931
944
932
945
public void close () {
933
946
database .declareIntent (null );
934
947
}
935
948
949
+ public boolean isDeleteRIDMapping () {
950
+ return deleteRIDMapping ;
951
+ }
952
+
953
+ public void setDeleteRIDMapping (boolean deleteRIDMapping ) {
954
+ this .deleteRIDMapping = deleteRIDMapping ;
955
+ }
956
+
936
957
private static class RewritersFactory {
937
958
public static final RewritersFactory INSTANCE = new RewritersFactory ();
938
959
939
960
private OLocalHashTable <OIdentifiable , OIdentifiable > exportImportHashTable ;
940
961
962
+ @ SuppressWarnings ("unchecked" )
941
963
public <T > FieldRewriter <T > findRewriter (ODocument document , String fieldName , T value ) {
942
964
if (value == null )
943
965
return new IdentityRewriter <T >();
@@ -1010,9 +1032,9 @@ public T rewriteValue(T value) {
1010
1032
}
1011
1033
}
1012
1034
1013
- private static class ListRewriter implements FieldRewriter <List > {
1035
+ private static class ListRewriter implements FieldRewriter <List <?> > {
1014
1036
@ Override
1015
- public List rewriteValue (List listValue ) {
1037
+ public List <?> rewriteValue (List <?> listValue ) {
1016
1038
boolean wasRewritten = false ;
1017
1039
List <Object > result = new ArrayList <Object >(listValue .size ());
1018
1040
for (Object listItem : listValue ) {
@@ -1109,11 +1131,11 @@ public OMVRBTreeRIDSet rewriteValue(OMVRBTreeRIDSet setValue) {
1109
1131
}
1110
1132
}
1111
1133
1112
- private static class SetRewriter implements FieldRewriter <Set > {
1134
+ private static class SetRewriter implements FieldRewriter <Set <?> > {
1113
1135
@ Override
1114
- public Set rewriteValue (Set setValue ) {
1136
+ public Set <?> rewriteValue (Set <?> setValue ) {
1115
1137
boolean wasRewritten = false ;
1116
- Set result = new HashSet ();
1138
+ Set < Object > result = new HashSet < Object > ();
1117
1139
for (Object item : setValue ) {
1118
1140
FieldRewriter <Object > fieldRewriter = RewritersFactory .INSTANCE .findRewriter (null , null , item );
1119
1141
Object newItem = fieldRewriter .rewriteValue (item );
0 commit comments