Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/DBMaker.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/DBMaker.java
r29363 r29484 60 60 protected byte[] _xteaEncryptionKey = null; 61 61 62 protected boolean _freeSpaceReclaimDisabled = false;62 protected int _freeSpaceReclaimQ = 5; 63 63 64 64 protected boolean _checksumEnabled = false; … … 124 124 .deleteFilesAfterClose() 125 125 .closeOnJvmShutdown() 126 . journalDisable()126 .writeAheadLogDisable() 127 127 .make() 128 128 .getTreeMap("temp"); … … 139 139 .deleteFilesAfterClose() 140 140 .closeOnJvmShutdown() 141 . journalDisable()141 .writeAheadLogDisable() 142 142 .make() 143 143 .getHashMap("temp"); … … 154 154 .deleteFilesAfterClose() 155 155 .closeOnJvmShutdown() 156 . journalDisable()156 .writeAheadLogDisable() 157 157 .make() 158 158 .getTreeSet("temp"); … … 169 169 .deleteFilesAfterClose() 170 170 .closeOnJvmShutdown() 171 . journalDisable()171 .writeAheadLogDisable() 172 172 .make() 173 173 .getHashSet("temp"); … … 210 210 * @return this builder 211 211 */ 212 public DBMaker journalDisable(){212 public DBMaker writeAheadLogDisable(){ 213 213 this._journalEnabled = false; 214 214 return this; … … 485 485 486 486 /** 487 * In this mode existing free space is not reused, 488 * but records are added to the end of the store. 489 * <p/> 490 * This slightly improves write performance as store does not have 491 * to traverse list of free records to find and reuse existing position. 492 * <p/> 493 * It also decreases chance for store corruption, as existing data 494 * are not overwritten with new record. 495 * <p/> 496 * When this mode is used for longer time, store becomes fragmented. 497 * It is necessary to run defragmentation then. 498 * <p/> 499 * NOTE: this mode is not append-only, just small setting for update-in-place storage. 500 * 501 * 502 * @return this builder 503 */ 504 public DBMaker freeSpaceReclaimDisable(){ 505 this._freeSpaceReclaimDisabled = true; 487 * Set free space reclaim Q. It is value from 0 to 10, indicating how eagerly MapDB 488 * searchs for free space inside store to reuse, before expanding store file. 489 * 0 means that no free space will be reused and store file will just grow (effectively append only). 490 * 10 means that MapDB tries really hard to reuse free space, even if it may hurt performance. 491 * Default value is 5; 492 * 493 * 494 * @return this builder 495 */ 496 public DBMaker freeSpaceReclaimQ(int q){ 497 if(q<0||q>10) throw new IllegalArgumentException("wrong Q"); 498 this._freeSpaceReclaimQ = q; 506 499 return this; 507 500 } … … 536 529 * @return this builder 537 530 */ 538 public DBMaker powerSavingModeEnable(){539 this._powerSavingMode = true;540 return this;541 }531 // public DBMaker powerSavingModeEnable(){ 532 // this._powerSavingMode = true; 533 // return this; 534 // } 542 535 543 536 … … 559 552 throw new UnsupportedOperationException("Can not open in-memory DB in read-only mode."); 560 553 561 if(_readOnly && !_file.exists() ){554 if(_readOnly && !_file.exists() && !_appendStorage){ 562 555 throw new UnsupportedOperationException("Can not open non-existing file in read-only mode."); 563 556 } … … 571 564 572 565 engine = _journalEnabled ? 573 new StorageJournaled(folFac, _freeSpaceReclaimDisabled, _deleteFilesAfterClose, _failOnWrongHeader, _readOnly): 574 new StorageDirect(folFac, _freeSpaceReclaimDisabled, _deleteFilesAfterClose , _failOnWrongHeader, _readOnly); 566 //TODO add extra params 567 //new StoreWAL(folFac, _freeSpaceReclaimDisabled, _deleteFilesAfterClose, _failOnWrongHeader, _readOnly): 568 //new StoreDirect(folFac, _freeSpaceReclaimDisabled, _deleteFilesAfterClose , _failOnWrongHeader, _readOnly); 569 new StoreWAL(folFac, _readOnly,_deleteFilesAfterClose): 570 new StoreDirect(folFac, _readOnly,_deleteFilesAfterClose); 575 571 }else{ 576 572 if(_file==null) throw new UnsupportedOperationException("Append Storage format is not supported with in-memory dbs"); 577 engine = new StorageAppend(_file, _RAF, _readOnly, !_journalEnabled); 578 } 573 engine = new StoreAppend(_file, _RAF, _readOnly, !_journalEnabled); 574 } 575 576 if(_checksumEnabled){ 577 engine = new ByteTransformEngine(engine, Serializer.CRC32_CHECKSUM); 578 } 579 580 if(_xteaEncryptionKey!=null){ 581 engine = new ByteTransformEngine(engine, new EncryptionXTEA(_xteaEncryptionKey)); 582 } 583 584 585 if(_compressionEnabled){ 586 engine = new ByteTransformEngine(engine, CompressLZF.SERIALIZER); 587 } 588 579 589 580 590 AsyncWriteEngine engineAsync = null; … … 584 594 } 585 595 586 if(_checksumEnabled){587 engine = new ByteTransformEngine(engine, Serializer.CRC32_CHECKSUM);588 }589 590 if(_xteaEncryptionKey!=null){591 engine = new ByteTransformEngine(engine, new EncryptionXTEA(_xteaEncryptionKey));592 }593 594 595 if(_compressionEnabled){596 engine = new ByteTransformEngine(engine, CompressLZF.SERIALIZER);597 }598 596 599 597 engine = new SnapshotEngine(engine); … … 625 623 @Override 626 624 public void run() { 625 626 // for JOSM plugin ImageryCache 627 org.openstreetmap.josm.plugins.imagerycache.TileDAOMapDB.dbNotAvailable = true; 627 628 if(!engine2.isClosed()) 628 629 engine2.close();
Note:
See TracChangeset
for help on using the changeset viewer.