1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2008 Oracle. All rights reserved. 5 * 6 * $Id: DatabaseConfig.java,v 12.18 2008/04/02 13:43:38 bschmeck Exp $ 7 */ 8 9package com.sleepycat.db; 10 11import com.sleepycat.db.internal.Db; 12import com.sleepycat.db.internal.DbConstants; 13import com.sleepycat.db.internal.DbEnv; 14import com.sleepycat.db.internal.DbTxn; 15import com.sleepycat.db.internal.DbUtil; 16 17/** 18Specify the attributes of a database. 19*/ 20public class DatabaseConfig implements Cloneable { 21 /* 22 * For internal use, final to allow null as a valid value for 23 * the config parameter. 24 */ 25 /** 26 An instance created using the default constructor is initialized 27 with the system's default settings. 28 */ 29 public static final DatabaseConfig DEFAULT = new DatabaseConfig(); 30 31 /* package */ 32 static DatabaseConfig checkNull(DatabaseConfig config) { 33 return (config == null) ? DEFAULT : config; 34 } 35 36 /* Parameters */ 37 private DatabaseType type = DatabaseType.UNKNOWN; 38 private int mode = 0644; 39 private int btMinKey = 0; 40 private int byteOrder = 0; 41 private long cacheSize = 0L; 42 private int cacheCount = 0; 43 private java.io.OutputStream errorStream = null; 44 private String errorPrefix = null; 45 private int hashFillFactor = 0; 46 private int hashNumElements = 0; 47 private java.io.OutputStream messageStream = null; 48 private int pageSize = 0; 49 private String password = null; 50 private CacheFilePriority priority = null; 51 private int queueExtentSize = 0; 52 private int recordDelimiter = 0; 53 private int recordLength = 0; 54 private int recordPad = -1; // Zero is a valid, non-default value. 55 private java.io.File recordSource = null; 56 57 /* Flags */ 58 private boolean allowCreate = false; 59 private boolean btreeRecordNumbers = false; 60 private boolean checksum = false; 61 private boolean readUncommitted = false; 62 private boolean encrypted = false; 63 private boolean exclusiveCreate = false; 64 private boolean multiversion = false; 65 private boolean noMMap = false; 66 private boolean queueInOrder = false; 67 private boolean readOnly = false; 68 private boolean renumbering = false; 69 private boolean reverseSplitOff = false; 70 private boolean sortedDuplicates = false; 71 private boolean snapshot = false; 72 private boolean unsortedDuplicates = false; 73 private boolean transactional = false; 74 private boolean transactionNotDurable = false; 75 private boolean truncate = false; 76 private boolean xaCreate = false; 77 78 private java.util.Comparator btreeComparator = null; 79 private BtreePrefixCalculator btreePrefixCalculator = null; 80 private java.util.Comparator duplicateComparator = null; 81 private FeedbackHandler feedbackHandler = null; 82 private ErrorHandler errorHandler = null; 83 private MessageHandler messageHandler = null; 84 private java.util.Comparator hashComparator = null; 85 private Hasher hasher = null; 86 private RecordNumberAppender recnoAppender = null; 87 private PanicHandler panicHandler = null; 88 89 /** 90 An instance created using the default constructor is initialized with 91 the system's default settings. 92 */ 93 public DatabaseConfig() { 94 } 95 96 /** 97 * Returns a copy of this configuration object. 98 */ 99 public DatabaseConfig cloneConfig() { 100 try { 101 return (DatabaseConfig) super.clone(); 102 } catch (CloneNotSupportedException willNeverOccur) { 103 return null; 104 } 105 } 106 107 /** 108 Configure the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method to create 109 the database if it does not already exist. 110 <p> 111 @param allowCreate 112 If true, configure the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method to 113 create the database if it does not already exist. 114 */ 115 public void setAllowCreate(final boolean allowCreate) { 116 this.allowCreate = allowCreate; 117 } 118 119 /** 120Return true if the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method is configured 121 to create the database if it does not already exist. 122<p> 123This method may be called at any time during the life of the application. 124<p> 125@return 126True if the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method is configured 127 to create the database if it does not already exist. 128 */ 129 public boolean getAllowCreate() { 130 return allowCreate; 131 } 132 133 /** 134 By default, a byte by byte lexicographic comparison is used for 135 btree keys. To customize the comparison, supply a different 136 Comparator. 137 <p> 138 The <code>compare</code> method is passed the byte arrays representing 139 keys that are stored in the database. If you know how your data is 140 organized in the byte array, then you can write a comparison routine that 141 directly examines the contents of the arrays. Otherwise, you have to 142 reconstruct your original objects, and then perform the comparison. 143 */ 144 public void setBtreeComparator(final java.util.Comparator btreeComparator) { 145 this.btreeComparator = btreeComparator; 146 } 147 148 public java.util.Comparator getBtreeComparator() { 149 return btreeComparator; 150 } 151 152 /** 153 Set the minimum number of key/data pairs intended to be stored on any 154 single Btree leaf page. 155 <p> 156 This value is used to determine if key or data items will be stored 157 on overflow pages instead of Btree leaf pages. The value must be 158 at least 2; if the value is not explicitly set, a value of 2 is used. 159 <p> 160 This method configures a database, not only operations performed using 161the specified {@link com.sleepycat.db.Database Database} handle. 162 <p> 163 This method may not be called after the database is opened. 164If the database already exists when it is opened, 165the information specified to this method will be ignored. 166 <p> 167 @param btMinKey 168 The minimum number of key/data pairs intended to be stored on any 169 single Btree leaf page. 170 */ 171 public void setBtreeMinKey(final int btMinKey) { 172 this.btMinKey = btMinKey; 173 } 174 175 /** 176Return the minimum number of key/data pairs intended to be stored 177 on any single Btree leaf page. 178<p> 179This method may be called at any time during the life of the application. 180<p> 181@return 182The minimum number of key/data pairs intended to be stored 183 on any single Btree leaf page. 184 */ 185 public int getBtreeMinKey() { 186 return btMinKey; 187 } 188 189 /** 190 Set the byte order for integers in the stored database metadata. 191 <p> 192 The host byte order of the machine where the process is running will 193 be used if no byte order is set. 194 <p> 195 <b> 196 The access methods provide no guarantees about the byte ordering of the 197 application data stored in the database, and applications are 198 responsible for maintaining any necessary ordering. 199 </b> 200 <p> 201 This method configures a database, not only operations performed using 202the specified {@link com.sleepycat.db.Database Database} handle. 203 <p> 204 This method may not be called after the database is opened. 205If the database already exists when it is opened, 206the information specified to this method will be ignored. 207 If creating additional databases in a single physical file, information 208 specified to this method will be ignored and the byte order of the 209 existing databases will be used. 210 <p> 211 @param byteOrder 212 The byte order as an integer; for example, big endian order is the 213 number 4,321, and little endian order is the number 1,234. 214 */ 215 public void setByteOrder(final int byteOrder) { 216 this.byteOrder = byteOrder; 217 } 218 219 /** 220Return the database byte order; a byte order of 4,321 indicates a 221 big endian order, and a byte order of 1,234 indicates a little 222 endian order. 223<p> 224This method may be called at any time during the life of the application. 225<p> 226@return 227The database byte order; a byte order of 4,321 indicates a 228 big endian order, and a byte order of 1,234 indicates a little 229 endian order. 230 */ 231 public int getByteOrder() { 232 return byteOrder; 233 } 234 235 /** 236 Return if the underlying database files were created on an architecture 237 of the same byte order as the current one. 238 <p> 239 This information may be used to determine whether application data 240 needs to be adjusted for this architecture or not. 241 <p> 242 This method may not be called before the 243database has been opened. 244 <p> 245 @return 246 Return false if the underlying database files were created on an 247 architecture of the same byte order as the current one, and true if 248 they were not (that is, big-endian on a little-endian machine, or 249 vice versa). 250 */ 251 public boolean getByteSwapped() { 252 return byteOrder != 0 && byteOrder != DbUtil.default_lorder(); 253 } 254 255 /** 256 Set the Btree prefix callback. The prefix callback is used to determine 257 the amount by which keys stored on the Btree internal pages can be 258 safely truncated without losing their uniqueness. See the 259 <a href="{@docRoot}/../ref/am_conf/bt_prefix.html" target="_top">Btree prefix 260 comparison</a> section of the Berkeley DB Reference Guide for more 261 details about how this works. The usefulness of this is data-dependent, 262 but can produce significantly reduced tree sizes and search times in 263 some data sets. 264 <p> 265 If no prefix callback or key comparison callback is specified by the 266 application, a default lexical comparison function is used to calculate 267 prefixes. If no prefix callback is specified and a key comparison 268 callback is specified, no prefix function is used. It is an error to 269 specify a prefix function without also specifying a Btree key comparison 270 function. 271 */ 272 public void setBtreePrefixCalculator( 273 final BtreePrefixCalculator btreePrefixCalculator) { 274 this.btreePrefixCalculator = btreePrefixCalculator; 275 } 276 277 /** 278Return the Btree prefix callback. 279<p> 280This method may be called at any time during the life of the application. 281<p> 282@return 283The Btree prefix callback. 284 */ 285 public BtreePrefixCalculator getBtreePrefixCalculator() { 286 return btreePrefixCalculator; 287 } 288 289 /** 290 Set the size of the shared memory buffer pool, that is, the size of the 291cache. 292<p> 293The cache should be the size of the normal working data set of the 294application, with some small amount of additional memory for unusual 295situations. (Note: the working set is not the same as the number of 296pages accessed simultaneously, and is usually much larger.) 297<p> 298The default cache size is 256KB, and may not be specified as less than 29920KB. Any cache size less than 500MB is automatically increased by 25% 300to account for buffer pool overhead; cache sizes larger than 500MB are 301used as specified. The current maximum size of a single cache is 4GB. 302(All sizes are in powers-of-two, that is, 256KB is 2^18 not 256,000.) 303<p> 304Because databases opened within database environments use the cache 305specified to the environment, it is an error to attempt to configure a 306cache size in a database created within an environment. 307<p> 308This method may not be called after the database is opened. 309<p> 310This method may be called at any time during the life of the application. 311<p> 312@param cacheSize 313The size of the shared memory buffer pool, that is, the size of the 314cache. 315<p> 316<p> 317@throws DatabaseException if a failure occurs. 318 */ 319 public void setCacheSize(final long cacheSize) { 320 this.cacheSize = cacheSize; 321 } 322 323 /** 324Return the size of the shared memory buffer pool, that is, the cache. 325<p> 326This method may be called at any time during the life of the application. 327<p> 328@return 329The size of the shared memory buffer pool, that is, the cache. 330 */ 331 public long getCacheSize() { 332 return cacheSize; 333 } 334 335 /** 336 Set the number of shared memory buffer pools, that is, the number of 337caches. 338<p> 339It is possible to specify caches larger than 4GB and/or large enough 340they cannot be allocated contiguously on some architectures. For 341example, some releases of Solaris limit the amount of memory that may 342be allocated contiguously by a process. This method allows applications 343to break the cache broken up into a number of equally sized, separate 344pieces of memory. 345<p> 346<p> 347Because databases opened within database environments use the cache 348specified to the environment, it is an error to attempt to configure 349multiple caches in a database created within an environment. 350<p> 351This method may not be called after the database is opened. 352<p> 353This method may be called at any time during the life of the application. 354<p> 355@param cacheCount 356The number of shared memory buffer pools, that is, the number of caches. 357<p> 358<p> 359@throws DatabaseException if a failure occurs. 360 */ 361 public void setCacheCount(final int cacheCount) { 362 this.cacheCount = cacheCount; 363 } 364 365 /** 366Return the number of shared memory buffer pools, that is, the number 367 of caches. 368<p> 369This method may be called at any time during the life of the application. 370<p> 371@return 372The number of shared memory buffer pools, that is, the number 373 of caches. 374 */ 375 public int getCacheCount() { 376 return cacheCount; 377 } 378 379 /** 380 Configure the database environment to do checksum verification of 381 pages read into the cache from the backing filestore. 382 <p> 383 Berkeley DB uses the SHA1 Secure Hash Algorithm if encryption is 384 also configured for this database, and a general hash algorithm if 385 it is not. 386 <p> 387 Calling this method only affects the specified {@link com.sleepycat.db.Database Database} handle 388(and any other library handles opened within the scope of that handle). 389 <p> 390 If the database already exists when the database is opened, any database 391configuration specified by this method 392will be ignored. 393 If creating additional databases in a file, the checksum behavior 394 specified must be consistent with the existing databases in the file or 395 an error will be returned. 396 <p> 397 @param checksum 398 If true, configure the database environment to do checksum verification 399 of pages read into the cache from the backing filestore. 400 A value of false is illegal to this method, that is, once set, the 401configuration cannot be cleared. 402 */ 403 public void setChecksum(final boolean checksum) { 404 this.checksum = checksum; 405 } 406 407 /** 408Return true if the database environment is configured to do checksum 409 verification of pages read into the cache from the backing 410 filestore. 411<p> 412This method may be called at any time during the life of the application. 413<p> 414@return 415True if the database environment is configured to do checksum 416 verification of pages read into the cache from the backing 417 filestore. 418 */ 419 public boolean getChecksum() { 420 return checksum; 421 } 422 423 /** 424 Configure the database to support read uncommitted. 425 <p> 426 Read operations on the database may request the return of modified 427 but not yet committed data. This flag must be specified on all 428 {@link com.sleepycat.db.Database Database} handles used to perform read uncommitted or database 429 updates, otherwise requests for read uncommitted may not be honored and 430 the read may block. 431 <p> 432 @param readUncommitted 433 If true, configure the database to support read uncommitted. 434 */ 435 public void setReadUncommitted(final boolean readUncommitted) { 436 this.readUncommitted = readUncommitted; 437 } 438 439 /** 440Return true if the database is configured to support read uncommitted. 441<p> 442This method may be called at any time during the life of the application. 443<p> 444@return 445True if the database is configured to support read uncommitted. 446 */ 447 public boolean getReadUncommitted() { 448 return readUncommitted; 449 } 450 451 /** 452 Configure the database to support read uncommitted. 453 <p> 454 Read operations on the database may request the return of modified 455 but not yet committed data. This flag must be specified on all 456 {@link com.sleepycat.db.Database Database} handles used to perform read uncommitted or database 457 updates, otherwise requests for read uncommitted may not be honored and 458 the read may block. 459 <p> 460 @param dirtyRead 461 If true, configure the database to support read uncommitted. 462 <p> 463 @deprecated This has been replaced by {@link #setReadUncommitted} to conform to ANSI 464 database isolation terminology. 465 */ 466 public void setDirtyRead(final boolean dirtyRead) { 467 setReadUncommitted(dirtyRead); 468 } 469 470 /** 471Return true if the database is configured to support read uncommitted. 472<p> 473This method may be called at any time during the life of the application. 474<p> 475@return 476True if the database is configured to support read uncommitted. 477 <p> 478 @deprecated This has been replaced by {@link #getReadUncommitted} to conform to ANSI 479 database isolation terminology. 480 */ 481 public boolean getDirtyRead() { 482 return getReadUncommitted(); 483 } 484 485 /** 486 Set the duplicate data item comparison callback. The comparison 487 function is called whenever it is necessary to compare a data item 488 specified by the application with a data item currently stored in the 489 database. This comparator is only used if 490 {@link com.sleepycat.db.DatabaseConfig#setSortedDuplicates DatabaseConfig.setSortedDuplicates} is also configured. 491 <p> 492 If no comparison function is specified, the data items are compared 493 lexically, with shorter data items collating before longer data items. 494 <p> 495 The <code>compare</code> method is passed the byte arrays representing 496 data items in the database. If you know how your data is organized in 497 the byte array, then you can write a comparison routine that directly 498 examines the contents of the arrays. Otherwise, you have to 499 reconstruct your original objects, and then perform the comparison. 500 <p> 501 @param duplicateComparator 502 the comparison callback for duplicate data items. 503 */ 504 public void setDuplicateComparator( 505 final java.util.Comparator duplicateComparator) { 506 this.duplicateComparator = duplicateComparator; 507 } 508 509 public java.util.Comparator getDuplicateComparator() { 510 return duplicateComparator; 511 } 512 513 /** 514 Set the password used to perform encryption and decryption. 515 <p> 516 Because databases opened within environments use the password 517 specified to the environment, it is an error to attempt to set a 518 password in a database created within an environment. 519 <p> 520 Berkeley DB uses the Rijndael/AES (also known as the Advanced 521 Encryption Standard and Federal Information Processing 522 Standard (FIPS) 197) algorithm for encryption or decryption. 523 */ 524 public void setEncrypted(final String password) { 525 this.password = password; 526 } 527 528 /** 529Return true if the database has been configured to perform encryption. 530<p> 531This method may be called at any time during the life of the application. 532<p> 533@return 534True if the database has been configured to perform encryption. 535 */ 536 public boolean getEncrypted() { 537 return (password != null); 538 } 539 540 /** 541 Set the function to be called if an error occurs. 542<p> 543When an error occurs in the Berkeley DB library, an exception is thrown. 544In some cases, however, the error information returned to the 545application may be insufficient to completely describe the cause of the 546error, especially during initial application debugging. 547<p> 548The {@link com.sleepycat.db.EnvironmentConfig#setErrorHandler EnvironmentConfig.setErrorHandler} and {@link com.sleepycat.db.DatabaseConfig#setErrorHandler DatabaseConfig.setErrorHandler} methods are used to enhance the mechanism for reporting 549error messages to the application. In some cases, when an error occurs, 550Berkeley DB will invoke the ErrorHandler's object error method. It is 551up to this method to display the error message in an appropriate manner. 552<p> 553Alternatively, applications can use {@link com.sleepycat.db.EnvironmentConfig#setErrorStream EnvironmentConfig.setErrorStream} and {@link com.sleepycat.db.DatabaseConfig#setErrorStream DatabaseConfig.setErrorStream} to 554display the additional information via an output stream. Applications 555should not mix these approaches. 556<p> 557This error-logging enhancement does not slow performance or significantly 558increase application size, and may be run during normal operation as well 559as during application debugging. 560<p> 561For {@link com.sleepycat.db.Database Database} handles opened inside of database environments, 562calling this method affects the entire environment and is equivalent to 563calling {@link com.sleepycat.db.EnvironmentConfig#setErrorHandler EnvironmentConfig.setErrorHandler}. 564<p> 565This method may be called at any time during the life of the application. 566<p> 567@param errorHandler 568The function to be called if an error occurs. 569 */ 570 public void setErrorHandler(final ErrorHandler errorHandler) { 571 this.errorHandler = errorHandler; 572 } 573 574 /** 575Return the function to be called if an error occurs. 576<p> 577This method may be called at any time during the life of the application. 578<p> 579@return 580The function to be called if an error occurs. 581 */ 582 public ErrorHandler getErrorHandler() { 583 return errorHandler; 584 } 585 586 /** 587 Set the prefix string that appears before error messages. 588<p> 589For {@link com.sleepycat.db.Database Database} handles opened inside of database environments, 590calling this method affects the entire environment and is equivalent to 591calling {@link com.sleepycat.db.EnvironmentConfig#setErrorPrefix EnvironmentConfig.setErrorPrefix}. 592<p> 593This method may be called at any time during the life of the application. 594<p> 595@param errorPrefix 596The prefix string that appears before error messages. 597 */ 598 public void setErrorPrefix(final String errorPrefix) { 599 this.errorPrefix = errorPrefix; 600 } 601 602 /** 603Return the prefix string that appears before error messages. 604<p> 605This method may be called at any time during the life of the application. 606<p> 607@return 608The prefix string that appears before error messages. 609 */ 610 public String getErrorPrefix() { 611 return errorPrefix; 612 } 613 614 /** 615 Set an OutputStream for displaying error messages. 616<p> 617When an error occurs in the Berkeley DB library, an exception is thrown. 618In some cases, however, the error information returned to the 619application may be insufficient to completely describe the cause of the 620error, especially during initial application debugging. 621<p> 622The {@link com.sleepycat.db.EnvironmentConfig#setErrorStream EnvironmentConfig.setErrorStream} and 623{@link com.sleepycat.db.DatabaseConfig#setErrorStream DatabaseConfig.setErrorStream} methods are used to enhance 624the mechanism for reporting error messages to the application by setting 625a OutputStream to be used for displaying additional Berkeley DB error 626messages. In some cases, when an error occurs, Berkeley DB will output 627an additional error message to the specified stream. 628<p> 629The error message will consist of the prefix string and a colon 630("<b>:</b>") (if a prefix string was previously specified using 631{@link com.sleepycat.db.EnvironmentConfig#setErrorPrefix EnvironmentConfig.setErrorPrefix} or {@link com.sleepycat.db.DatabaseConfig#setErrorPrefix DatabaseConfig.setErrorPrefix}), an error string, and a trailing newline character. 632<p> 633Setting errorStream to null unconfigures the interface. 634<p> 635Alternatively, applications can use {@link com.sleepycat.db.EnvironmentConfig#setErrorHandler EnvironmentConfig.setErrorHandler} and {@link com.sleepycat.db.DatabaseConfig#setErrorHandler DatabaseConfig.setErrorHandler} to capture 636the additional error information in a way that does not use output 637streams. Applications should not mix these approaches. 638<p> 639This error-logging enhancement does not slow performance or significantly 640increase application size, and may be run during normal operation as well 641as during application debugging. 642<p> 643This method may be called at any time during the life of the application. 644<p> 645@param errorStream 646The application-specified OutputStream for error messages. 647 */ 648 public void setErrorStream(final java.io.OutputStream errorStream) { 649 this.errorStream = errorStream; 650 } 651 652 /** 653Return the an OutputStream for displaying error messages. 654<p> 655This method may be called at any time during the life of the application. 656<p> 657@return 658The an OutputStream for displaying error messages. 659 */ 660 public java.io.OutputStream getErrorStream() { 661 return errorStream; 662 } 663 664 /** 665 Configure the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method to fail if 666 the database already exists. 667 <p> 668 The exclusiveCreate mode is only meaningful if specified with the 669 allowCreate mode. 670 <p> 671 @param exclusiveCreate 672 If true, configure the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method to 673 fail if the database already exists. 674 */ 675 public void setExclusiveCreate(final boolean exclusiveCreate) { 676 this.exclusiveCreate = exclusiveCreate; 677 } 678 679 /** 680Return true if the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method is configured 681 to fail if the database already exists. 682<p> 683This method may be called at any time during the life of the application. 684<p> 685@return 686True if the {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} method is configured 687 to fail if the database already exists. 688 */ 689 public boolean getExclusiveCreate() { 690 return exclusiveCreate; 691 } 692 693 /** 694 Set an object whose methods are called to provide feedback. 695<p> 696Some operations performed by the Berkeley DB library can take 697non-trivial amounts of time. This method can be used by applications 698to monitor progress within these operations. When an operation is 699likely to take a long time, Berkeley DB will call the object's methods 700with progress information. 701<p> 702It is up to the object's methods to display this information in an 703appropriate manner. 704<p> 705This method configures only operations performed using a single a 706{@link com.sleepycat.db.Environment Environment} handle 707<p> 708This method may be called at any time during the life of the application. 709<p> 710@param feedbackHandler 711An object whose methods are called to provide feedback. 712 */ 713 public void setFeedbackHandler(final FeedbackHandler feedbackHandler) { 714 this.feedbackHandler = feedbackHandler; 715 } 716 717 /** 718Return the object's methods to be called to provide feedback. 719<p> 720This method may be called at any time during the life of the application. 721<p> 722@return 723The object's methods to be called to provide feedback. 724 */ 725 public FeedbackHandler getFeedbackHandler() { 726 return feedbackHandler; 727 } 728 729 /** 730 Set the desired density within the hash table. 731 <p> 732 If no value is specified, the fill factor will be selected dynamically 733 as pages are filled. 734 <p> 735 The density is an approximation of the number of keys allowed to 736 accumulate in any one bucket, determining when the hash table grows or 737 shrinks. If you know the average sizes of the keys and data in your 738 data set, setting the fill factor can enhance performance. A reasonable 739 rule computing fill factor is to set it to the following: 740 <blockquote><pre> 741 (pagesize - 32) / (average_key_size + average_data_size + 8) 742 </pre></blockquote> 743 <p> 744 This method configures a database, not only operations performed using 745the specified {@link com.sleepycat.db.Database Database} handle. 746 <p> 747 This method may not be called after the database is opened. 748If the database already exists when it is opened, 749the information specified to this method will be ignored. 750 <p> 751 @param hashFillFactor 752 The desired density within the hash table. 753 */ 754 public void setHashFillFactor(final int hashFillFactor) { 755 this.hashFillFactor = hashFillFactor; 756 } 757 758 /** 759Return the hash table density. 760<p> 761This method may be called at any time during the life of the application. 762<p> 763@return 764The hash table density. 765 */ 766 public int getHashFillFactor() { 767 return hashFillFactor; 768 } 769 770 /** 771 Set the Hash key comparison function. The comparison function is called 772 whenever it is necessary to compare a key specified by the application with 773 a key currently stored in the database. 774 <p> 775 If no comparison function is specified, a byte-by-byte comparison is 776 performed. 777 <p> 778 The <code>compare</code> method is passed the byte arrays representing 779 keys that are stored in the database. If you know how your data is 780 organized in the byte array, then you can write a comparison routine that 781 directly examines the contents of the arrays. Otherwise, you have to 782 reconstruct your original objects, and then perform the comparison. 783 */ 784 public void setHashComparator(final java.util.Comparator hashComparator) { 785 this.hashComparator = hashComparator; 786 } 787 788 /** 789Return the Comparator used to compare keys in a Hash database. 790<p> 791This method may be called at any time during the life of the application. 792<p> 793@return 794The Comparator used to compare keys in a Hash database. 795 */ 796 public java.util.Comparator getHashComparator() { 797 return hashComparator; 798 } 799 800 /** 801 Set a database-specific hash function. 802 <p> 803 If no hash function is specified, a default hash function is used. 804 Because no hash function performs equally well on all possible data, 805 the user may find that the built-in hash function performs poorly 806 with a particular data set. 807 <p> 808 This method configures operations performed using the specified 809{@link com.sleepycat.db.Database Database} object, not all operations performed on the underlying 810database. 811 <p> 812 This method may not be called after the database is opened. 813If the database already exists when it is opened, 814the information specified to this method must be the same as that 815historically used to create the database or corruption can occur. 816 <p> 817 @param hasher 818 A database-specific hash function. 819 */ 820 public void setHasher(final Hasher hasher) { 821 this.hasher = hasher; 822 } 823 824 /** 825Return the database-specific hash function. 826<p> 827This method may be called at any time during the life of the application. 828<p> 829@return 830The database-specific hash function. 831 */ 832 public Hasher getHasher() { 833 return hasher; 834 } 835 836 /** 837 Set an estimate of the final size of the hash table. 838 <p> 839 In order for the estimate to be used when creating the database, the 840 {@link com.sleepycat.db.DatabaseConfig#setHashFillFactor DatabaseConfig.setHashFillFactor} method must also be called. 841 If the estimate or fill factor are not set or are set too low, hash 842 tables will still expand gracefully as keys are entered, although a 843 slight performance degradation may be noticed. 844 <p> 845 This method configures a database, not only operations performed using 846the specified {@link com.sleepycat.db.Database Database} handle. 847 <p> 848 This method may not be called after the database is opened. 849If the database already exists when it is opened, 850the information specified to this method will be ignored. 851 <p> 852 @param hashNumElements 853 An estimate of the final size of the hash table. 854 */ 855 public void setHashNumElements(final int hashNumElements) { 856 this.hashNumElements = hashNumElements; 857 } 858 859 /** 860Return the estimate of the final size of the hash table. 861<p> 862This method may be called at any time during the life of the application. 863<p> 864@return 865The estimate of the final size of the hash table. 866 */ 867 public int getHashNumElements() { 868 return hashNumElements; 869 } 870 871 /** 872 Set a function to be called with an informational message. 873<p> 874There are interfaces in the Berkeley DB library which either directly 875output informational messages or statistical information, or configure 876the library to output such messages when performing other operations, 877{@link com.sleepycat.db.EnvironmentConfig#setVerboseDeadlock EnvironmentConfig.setVerboseDeadlock} for example. 878<p> 879The {@link com.sleepycat.db.EnvironmentConfig#setMessageHandler EnvironmentConfig.setMessageHandler} and 880{@link com.sleepycat.db.DatabaseConfig#setMessageHandler DatabaseConfig.setMessageHandler} methods are used to display 881these messages for the application. 882<p> 883Setting messageHandler to null unconfigures the interface. 884<p> 885Alternatively, you can use {@link com.sleepycat.db.EnvironmentConfig#setMessageStream EnvironmentConfig.setMessageStream} 886and {@link com.sleepycat.db.DatabaseConfig#setMessageStream DatabaseConfig.setMessageStream} to send the additional 887information directly to an output streams. You should not mix these 888approaches. 889<p> 890For {@link com.sleepycat.db.Database Database} handles opened inside of database environments, 891calling this method affects the entire environment and is equivalent to 892calling {@link com.sleepycat.db.EnvironmentConfig#setMessageHandler EnvironmentConfig.setMessageHandler}. 893<p> 894This method may be called at any time during the life of the application. 895<p> 896@param messageHandler 897The application-specified function for informational messages. 898 */ 899 public void setMessageHandler(final MessageHandler messageHandler) { 900 this.messageHandler = messageHandler; 901 } 902 903 /** 904Return the function to be called with an informational message. 905<p> 906This method may be called at any time during the life of the application. 907<p> 908@return 909The function to be called with an informational message. 910 */ 911 public MessageHandler getMessageHandler() { 912 return messageHandler; 913 } 914 915 /** 916 Set an OutputStream for displaying informational messages. 917<p> 918There are interfaces in the Berkeley DB library which either directly 919output informational messages or statistical information, or configure 920the library to output such messages when performing other operations, 921{@link com.sleepycat.db.EnvironmentConfig#setVerboseDeadlock EnvironmentConfig.setVerboseDeadlock} for example. 922<p> 923The {@link com.sleepycat.db.EnvironmentConfig#setMessageStream EnvironmentConfig.setMessageStream} and 924{@link com.sleepycat.db.DatabaseConfig#setMessageStream DatabaseConfig.setMessageStream} methods are used to display 925these messages for the application. In this case, the message will 926include a trailing newline character. 927<p> 928Setting messageStream to null unconfigures the interface. 929<p> 930Alternatively, you can use {@link com.sleepycat.db.EnvironmentConfig#setMessageHandler EnvironmentConfig.setMessageHandler} 931and {@link com.sleepycat.db.DatabaseConfig#setMessageHandler DatabaseConfig.setMessageHandler} to capture the additional 932information in a way that does not use output streams. You should not 933mix these approaches. 934<p> 935For {@link com.sleepycat.db.Database Database} handles opened inside of database environments, 936calling this method affects the entire environment and is equivalent to 937calling {@link com.sleepycat.db.EnvironmentConfig#setMessageStream EnvironmentConfig.setMessageStream}. 938<p> 939This method may be called at any time during the life of the application. 940<p> 941@param messageStream 942The application-specified OutputStream for informational messages. 943 */ 944 public void setMessageStream(final java.io.OutputStream messageStream) { 945 this.messageStream = messageStream; 946 } 947 948 /** 949Return the an OutputStream for displaying informational messages. 950<p> 951This method may be called at any time during the life of the application. 952<p> 953@return 954The an OutputStream for displaying informational messages. 955 */ 956 public java.io.OutputStream getMessageStream() { 957 return messageStream; 958 } 959 960 /** 961 On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files 962 created by the database open are created with mode <code>mode</code> 963 (as described in the <code>chmod</code>(2) manual page) and modified 964 by the process' umask value at the time of creation (see the 965 <code>umask</code>(2) manual page). Created files are owned by the 966 process owner; the group ownership of created files is based on the 967 system and directory defaults, and is not further specified by Berkeley 968 DB. System shared memory segments created by the database open are 969 created with mode <code>mode</code>, unmodified by the process' umask 970 value. If <code>mode</code> is 0, the database open will use a default 971 mode of readable and writable by both owner and group. 972 <p> 973 On Windows systems, the mode parameter is ignored. 974 <p> 975 @param mode 976 the mode used to create files 977 */ 978 public void setMode(final int mode) { 979 this.mode = mode; 980 } 981 982 /** 983Return the mode used to create files. 984<p> 985This method may be called at any time during the life of the application. 986<p> 987@return 988The mode used to create files. 989 */ 990 public long getMode() { 991 return mode; 992 } 993 994 /** 995 Configured the database with support for multiversion concurrency control. 996 This will cause updates to the database to follow a copy-on-write 997 protocol, which is required to support Snapshot Isolation. See 998 {@link TransactionConfig#setSnapshot}) for more information. 999 Multiversion access requires that the database be opened 1000 in a transaction and is not supported for queue databases. 1001 <p> 1002 @param multiversion 1003 If true, configure the database with support for multiversion concurrency 1004 control. 1005 */ 1006 public void setMultiversion(final boolean multiversion) { 1007 this.multiversion = multiversion; 1008 } 1009 1010 /** 1011Return true if the database is configured for multiversion concurrency control. 1012<p> 1013This method may be called at any time during the life of the application. 1014<p> 1015@return 1016True if the database is configured for multiversion concurrency control. 1017 */ 1018 public boolean getMultiversion() { 1019 return multiversion; 1020 } 1021 1022 /** 1023 Configure the library to not map this database into memory. 1024 <p> 1025 @param noMMap 1026 If true, configure the library to not map this database into memory. 1027 */ 1028 public void setNoMMap(final boolean noMMap) { 1029 this.noMMap = noMMap; 1030 } 1031 1032 /** 1033Return true if the library is configured to not map this database into 1034 memory. 1035<p> 1036This method may be called at any time during the life of the application. 1037<p> 1038@return 1039True if the library is configured to not map this database into 1040 memory. 1041 */ 1042 public boolean getNoMMap() { 1043 return noMMap; 1044 } 1045 1046 /** 1047 Set the size of the pages used to hold items in the database, in bytes. 1048 <p> 1049 The minimum page size is 512 bytes, the maximum page size is 64K bytes, 1050 and the page size must be a power-of-two. If the page size is not 1051 explicitly set, one is selected based on the underlying filesystem I/O 1052 block size. The automatically selected size has a lower limit of 512 1053 bytes and an upper limit of 16K bytes. 1054 <p> 1055 This method configures a database, not only operations performed using 1056the specified {@link com.sleepycat.db.Database Database} handle. 1057 <p> 1058 This method may not be called after the database is opened. 1059If the database already exists when it is opened, 1060the information specified to this method will be ignored. 1061 If creating additional databases in a file, the page size specified must 1062 be consistent with the existing databases in the file or an error will 1063 be returned. 1064 <p> 1065 @param pageSize 1066 The size of the pages used to hold items in the database, in bytes. 1067 */ 1068 public void setPageSize(final int pageSize) { 1069 this.pageSize = pageSize; 1070 } 1071 1072 /** 1073Return the size of the pages used to hold items in the database, in bytes. 1074<p> 1075This method may be called at any time during the life of the application. 1076<p> 1077@return 1078The size of the pages used to hold items in the database, in bytes. 1079 */ 1080 public int getPageSize() { 1081 return pageSize; 1082 } 1083 1084 /** 1085 Set the function to be called if the database environment panics. 1086<p> 1087Errors can occur in the Berkeley DB library where the only solution is 1088to shut down the application and run recovery (for example, if Berkeley 1089DB is unable to allocate heap memory). In such cases, the Berkeley DB 1090methods will throw a {@link com.sleepycat.db.RunRecoveryException RunRecoveryException}. It is often easier 1091to simply exit the application when such errors occur rather than 1092gracefully return up the stack. This method specifies a function to be 1093called when {@link com.sleepycat.db.RunRecoveryException RunRecoveryException} is about to be thrown from a 1094Berkeley DB method. 1095<p> 1096For {@link com.sleepycat.db.Database Database} handles opened inside of database environments, 1097calling this method affects the entire environment and is equivalent to 1098calling {@link com.sleepycat.db.EnvironmentConfig#setPanicHandler EnvironmentConfig.setPanicHandler}. 1099<p> 1100This method may be called at any time during the life of the application. 1101<p> 1102@param panicHandler 1103The function to be called if the database environment panics. 1104 */ 1105 public void setPanicHandler(final PanicHandler panicHandler) { 1106 this.panicHandler = panicHandler; 1107 } 1108 1109 /** 1110Return the function to be called if the database environment panics. 1111<p> 1112This method may be called at any time during the life of the application. 1113<p> 1114@return 1115The function to be called if the database environment panics. 1116 */ 1117 public PanicHandler getPanicHandler() { 1118 return panicHandler; 1119 } 1120 1121 /** 1122 Set the cache priority for pages referenced by the DB handle. 1123 <p> 1124 The priority of a page biases the replacement algorithm to be more or less 1125 likely to discard a page when space is needed in the buffer pool. The bias 1126 is temporary, and pages will eventually be discarded if they are not 1127 referenced again. The priority setting is only advisory, and does not 1128 guarantee pages will be treated in a specific way. 1129 <p> 1130 @param priority 1131 The desired cache priority. 1132 */ 1133 public void setPriority(final CacheFilePriority priority) { 1134 this.priority = priority; 1135 } 1136 1137 /** 1138Return the the cache priority for pages referenced by this handle. 1139<p> 1140This method may be called at any time during the life of the application. 1141<p> 1142@return 1143The the cache priority for pages referenced by this handle. 1144 */ 1145 public CacheFilePriority getPriority() { 1146 return priority; 1147 } 1148 1149 /** 1150 Set the size of the extents used to hold pages in a Queue database, 1151 specified as a number of pages. 1152 <p> 1153 Each extent is created as a separate physical file. If no extent 1154 size is set, the default behavior is to create only a single 1155 underlying database file. 1156 <p> 1157 This method configures a database, not only operations performed using 1158the specified {@link com.sleepycat.db.Database Database} handle. 1159 <p> 1160 This method may not be called after the database is opened. 1161If the database already exists when it is opened, 1162the information specified to this method will be ignored. 1163 <p> 1164 @param queueExtentSize 1165 The number of pages in a Queue database extent. 1166 */ 1167 public void setQueueExtentSize(final int queueExtentSize) { 1168 this.queueExtentSize = queueExtentSize; 1169 } 1170 1171 /** 1172Return the size of the extents used to hold pages in a Queue database, 1173 specified as a number of pages. 1174<p> 1175This method may be called at any time during the life of the application. 1176<p> 1177@return 1178The size of the extents used to hold pages in a Queue database, 1179 specified as a number of pages. 1180 */ 1181 public int getQueueExtentSize() { 1182 return queueExtentSize; 1183 } 1184 1185 /** 1186 Configure {@link com.sleepycat.db.Database#consume Database.consume} to return key/data pairs in 1187 order, always returning the key/data item from the head of the 1188 queue. 1189 <p> 1190 The default behavior of queue databases is optimized for multiple 1191 readers, and does not guarantee that record will be retrieved in the 1192 order they are added to the queue. Specifically, if a writing 1193 thread adds multiple records to an empty queue, reading threads may 1194 skip some of the initial records when the next call to retrieve a 1195 key/data pair returns. 1196 <p> 1197 This flag configures the {@link com.sleepycat.db.Database#consume Database.consume} method to verify 1198 that the record being returned is in fact the head of the queue. 1199 This will increase contention and reduce concurrency when there are 1200 many reading threads. 1201 <p> 1202 Calling this method only affects the specified {@link com.sleepycat.db.Database Database} handle 1203(and any other library handles opened within the scope of that handle). 1204 <p> 1205 @param queueInOrder 1206 If true, configure the {@link com.sleepycat.db.Database#consume Database.consume} method to return 1207 key/data pairs in order, always returning the key/data item from the 1208 head of the queue. 1209 A value of false is illegal to this method, that is, once set, the 1210configuration cannot be cleared. 1211 */ 1212 public void setQueueInOrder(final boolean queueInOrder) { 1213 this.queueInOrder = queueInOrder; 1214 } 1215 1216 /** 1217Return true if the {@link com.sleepycat.db.Database#consume Database.consume} method is configured to return 1218 key/data pairs in order, always returning the key/data item from the 1219 head of the queue. 1220<p> 1221This method may be called at any time during the life of the application. 1222<p> 1223@return 1224True if the {@link com.sleepycat.db.Database#consume Database.consume} method is configured to return 1225 key/data pairs in order, always returning the key/data item from the 1226 head of the queue. 1227 */ 1228 public boolean getQueueInOrder() { 1229 return queueInOrder; 1230 } 1231 1232 /** 1233 Configure the database in read-only mode. 1234 <p> 1235 Any attempt to modify items in the database will fail, regardless 1236 of the actual permissions of any underlying files. 1237 <p> 1238 @param readOnly 1239 If true, configure the database in read-only mode. 1240 */ 1241 public void setReadOnly(final boolean readOnly) { 1242 this.readOnly = readOnly; 1243 } 1244 1245 /** 1246Return true if the database is configured in read-only mode. 1247<p> 1248This method may be called at any time during the life of the application. 1249<p> 1250@return 1251True if the database is configured in read-only mode. 1252 */ 1253 public boolean getReadOnly() { 1254 return readOnly; 1255 } 1256 1257 /** 1258 Configure {@link com.sleepycat.db.Database#append Database.append} to call the function after the 1259 record number has been selected but before the data has been stored 1260 into the database. 1261 <p> 1262 This method configures operations performed using the specified 1263{@link com.sleepycat.db.Database Database} object, not all operations performed on the underlying 1264database. 1265 <p> 1266 This method may not be called after the database is opened. 1267 <p> 1268 @param recnoAppender 1269 The function to call after the record number has been selected but 1270 before the data has been stored into the database. 1271 */ 1272 public void setRecordNumberAppender( 1273 final RecordNumberAppender recnoAppender) { 1274 this.recnoAppender = recnoAppender; 1275 } 1276 1277 /** 1278Return the function to call after the record number has been 1279 selected but before the data has been stored into the database. 1280<p> 1281This method may be called at any time during the life of the application. 1282<p> 1283@return 1284The function to call after the record number has been 1285 selected but before the data has been stored into the database. 1286 */ 1287 public RecordNumberAppender getRecordNumberAppender() { 1288 return recnoAppender; 1289 } 1290 1291 /** 1292 Set the delimiting byte used to mark the end of a record in the backing 1293 source file for the Recno access method. 1294 <p> 1295 This byte is used for variable length records if a backing source 1296 file is specified. If a backing source file is specified and no 1297 delimiting byte was specified, newline characters (that is, ASCII 1298 0x0a) are interpreted as end-of-record markers. 1299 <p> 1300 This method configures a database, not only operations performed using 1301the specified {@link com.sleepycat.db.Database Database} handle. 1302 <p> 1303 This method may not be called after the database is opened. 1304If the database already exists when it is opened, 1305the information specified to this method will be ignored. 1306 <p> 1307 @param recordDelimiter 1308 The delimiting byte used to mark the end of a record in the backing 1309 source file for the Recno access method. 1310 */ 1311 public void setRecordDelimiter(final int recordDelimiter) { 1312 this.recordDelimiter = recordDelimiter; 1313 } 1314 1315 /** 1316Return the delimiting byte used to mark the end of a record in the 1317 backing source file for the Recno access method. 1318<p> 1319This method may be called at any time during the life of the application. 1320<p> 1321@return 1322The delimiting byte used to mark the end of a record in the 1323 backing source file for the Recno access method. 1324 */ 1325 public int getRecordDelimiter() { 1326 return recordDelimiter; 1327 } 1328 1329 /** 1330 Specify the database record length, in bytes. 1331 <p> 1332 For the Queue access method, specify the record length. For the 1333 Queue access method, the record length must be enough smaller than 1334 the database's page size that at least one record plus the database 1335 page's metadata information can fit on each database page. 1336 <p> 1337 For the Recno access method, specify the records are fixed-length, 1338 not byte-delimited, and the record length. 1339 <p> 1340 Any records added to the database that are less than the specified 1341 length are automatically padded (see 1342 {@link com.sleepycat.db.DatabaseConfig#setRecordPad DatabaseConfig.setRecordPad} for more information). 1343 <p> 1344 Any attempt to insert records into the database that are greater 1345 than the specified length will cause the call to fail. 1346 <p> 1347 This method configures a database, not only operations performed using 1348the specified {@link com.sleepycat.db.Database Database} handle. 1349 <p> 1350 This method may not be called after the database is opened. 1351If the database already exists when it is opened, 1352the information specified to this method will be ignored. 1353 <p> 1354 @param recordLength 1355 The database record length, in bytes. 1356 */ 1357 public void setRecordLength(final int recordLength) { 1358 this.recordLength = recordLength; 1359 } 1360 1361 /** 1362Return the database record length, in bytes. 1363<p> 1364This method may be called at any time during the life of the application. 1365<p> 1366@return 1367The database record length, in bytes. 1368 */ 1369 public int getRecordLength() { 1370 return recordLength; 1371 } 1372 1373 /** 1374 Configure the Btree to support retrieval by record number. 1375 <p> 1376 Logical record numbers in Btree databases are mutable in the face of 1377 record insertion or deletion. 1378 <p> 1379 Maintaining record counts within a Btree introduces a serious point 1380 of contention, namely the page locations where the record counts are 1381 stored. In addition, the entire database must be locked during both 1382 insertions and deletions, effectively single-threading the database 1383 for those operations. Configuring a Btree for retrieval by record 1384 number can result in serious performance degradation for some 1385 applications and data sets. 1386 <p> 1387 Retrieval by record number may not be configured for a Btree that also 1388 supports duplicate data items. 1389 <p> 1390 Calling this method affects the database, including all threads of 1391control accessing the database. 1392 <p> 1393 If the database already exists when the database is opened, any database 1394configuration specified by this method 1395must be the same as the existing database or an error 1396will be returned. 1397 <p> 1398 @param btreeRecordNumbers 1399 If true, configure the Btree to support retrieval by record number. 1400 A value of false is illegal to this method, that is, once set, the 1401configuration cannot be cleared. 1402 */ 1403 public void setBtreeRecordNumbers(final boolean btreeRecordNumbers) { 1404 this.btreeRecordNumbers = btreeRecordNumbers; 1405 } 1406 1407 /** 1408Return true if the Btree is configured to support retrieval by record number. 1409<p> 1410This method may be called at any time during the life of the application. 1411<p> 1412@return 1413True if the Btree is configured to support retrieval by record number. 1414 */ 1415 public boolean getBtreeRecordNumbers() { 1416 return btreeRecordNumbers; 1417 } 1418 1419 /** 1420 Set the padding character for short, fixed-length records for the Queue 1421 and Recno access methods. 1422 <p> 1423 If no pad character is specified, "space" characters (that is, ASCII 1424 0x20) are used for padding. 1425 <p> 1426 This method configures a database, not only operations performed using 1427the specified {@link com.sleepycat.db.Database Database} handle. 1428 <p> 1429 This method may not be called after the database is opened. 1430If the database already exists when it is opened, 1431the information specified to this method will be ignored. 1432 <p> 1433 @param recordPad 1434 The padding character for short, fixed-length records for the Queue 1435 and Recno access methods. 1436 */ 1437 public void setRecordPad(final int recordPad) { 1438 this.recordPad = recordPad; 1439 } 1440 1441 /** 1442Return the padding character for short, fixed-length records for the 1443 Queue and Recno access methods. 1444<p> 1445This method may be called at any time during the life of the application. 1446<p> 1447@return 1448The padding character for short, fixed-length records for the 1449 Queue and Recno access methods. 1450 */ 1451 public int getRecordPad() { 1452 return recordPad; 1453 } 1454 1455 /** 1456 Set the underlying source file for the Recno access method. 1457 <p> 1458 The purpose of the source file is to provide fast access and 1459 modification to databases that are normally stored as flat text 1460 files. 1461 <p> 1462 The recordSource parameter specifies an underlying flat text 1463 database file that is read to initialize a transient record number 1464 index. In the case of variable length records, the records are 1465 separated, as specified by the 1466 {@link com.sleepycat.db.DatabaseConfig#setRecordDelimiter DatabaseConfig.setRecordDelimiter} method. For example, 1467 standard UNIX byte stream files can be interpreted as a sequence of 1468 variable length records separated by newline characters (that is, ASCII 1469 0x0a). 1470 <p> 1471 In addition, when cached data would normally be written back to the 1472 underlying database file (for example, the {@link com.sleepycat.db.Database#close Database.close} 1473 or {@link com.sleepycat.db.Database#sync Database.sync} methods are called), the in-memory copy 1474 of the database will be written back to the source file. 1475 <p> 1476 By default, the backing source file is read lazily; that is, records 1477 are not read from the file until they are requested by the application. 1478 <b> 1479 If multiple processes (not threads) are accessing a Recno database 1480 concurrently, and are either inserting or deleting records, the backing 1481 source file must be read in its entirety before more than a single 1482 process accesses the database, and only that process should specify 1483 the backing source file as part of opening the database. See the 1484 {@link com.sleepycat.db.DatabaseConfig#setSnapshot DatabaseConfig.setSnapshot} method for more information. 1485 </b> 1486 <p> 1487 <b> 1488 Reading and writing the backing source file cannot be 1489 transaction-protected because it involves filesystem operations that 1490 are not part of the {@link com.sleepycat.db.Database Database} transaction methodology. For 1491 this reason, if a temporary database is used to hold the records, 1492 it is possible to lose the contents of the source file, for example, 1493 if the system crashes at the right instant. If a file is used to 1494 hold the database, normal database recovery on that file can be used 1495 to prevent information loss, although it is still possible that the 1496 contents of the source file will be lost if the system crashes. 1497 </b> 1498 <p> 1499 The source file must already exist (but may be zero-length) when 1500 the database is opened. 1501 <p> 1502 It is not an error to specify a read-only source file when creating 1503 a database, nor is it an error to modify the resulting database. 1504 However, any attempt to write the changes to the backing source file 1505 using either the {@link com.sleepycat.db.Database#sync Database.sync} or {@link com.sleepycat.db.Database#close Database.close} 1506 methods will fail, of course. Specify the noSync argument to the 1507 {@link com.sleepycat.db.Database#close Database.close} method to stop it from attempting to write 1508 the changes to the backing file; instead, they will be silently 1509 discarded. 1510 <p> 1511 For all of the previous reasons, the source file is generally used 1512 to specify databases that are read-only for Berkeley DB 1513 applications; and that are either generated on the fly by software 1514 tools or modified using a different mechanism -- for example, a text 1515 editor. 1516 <p> 1517 This method configures operations performed using the specified 1518{@link com.sleepycat.db.Database Database} object, not all operations performed on the underlying 1519database. 1520 <p> 1521 This method may not be called after the database is opened. 1522If the database already exists when it is opened, 1523the information specified to this method must be the same as that 1524historically used to create the database or corruption can occur. 1525 <p> 1526 @param recordSource 1527 The name of an underlying flat text database file that is read to 1528 initialize a transient record number index. In the case of variable 1529 length records, the records are separated, as specified by the 1530 {@link com.sleepycat.db.DatabaseConfig#setRecordDelimiter DatabaseConfig.setRecordDelimiter} method. For example, 1531 standard UNIX byte stream files can be interpreted as a sequence of 1532 variable length records separated by newline characters (that is, ASCII 1533 0x0a). 1534 */ 1535 public void setRecordSource(final java.io.File recordSource) { 1536 this.recordSource = recordSource; 1537 } 1538 1539 /** 1540Return the name of an underlying flat text database file that is 1541 read to initialize a transient record number index. 1542<p> 1543This method may be called at any time during the life of the application. 1544<p> 1545@return 1546The name of an underlying flat text database file that is 1547 read to initialize a transient record number index. 1548 */ 1549 public java.io.File getRecordSource() { 1550 return recordSource; 1551 } 1552 1553 /** 1554 Configure the logical record numbers to be mutable, and change as 1555 records are added to and deleted from the database. 1556 <p> 1557 For example, the deletion of record number 4 causes records numbered 1558 5 and greater to be renumbered downward by one. If a cursor was 1559 positioned to record number 4 before the deletion, it will refer to 1560 the new record number 4, if any such record exists, after the 1561 deletion. If a cursor was positioned after record number 4 before 1562 the deletion, it will be shifted downward one logical record, 1563 continuing to refer to the same record as it did before. 1564 <p> 1565 Creating new records will cause the creation of multiple records if 1566 the record number is more than one greater than the largest record 1567 currently in the database. For example, creating record 28, when 1568 record 25 was previously the last record in the database, will 1569 create records 26 and 27 as well as 28. Attempts to retrieve 1570 records that were created in this manner will result in an error 1571 return of {@link com.sleepycat.db.OperationStatus#KEYEMPTY OperationStatus.KEYEMPTY}. 1572 <p> 1573 If a created record is not at the end of the database, all records 1574 following the new record will be automatically renumbered upward by one. 1575 For example, the creation of a new record numbered 8 causes records 1576 numbered 8 and greater to be renumbered upward by one. If a cursor was 1577 positioned to record number 8 or greater before the insertion, it will 1578 be shifted upward one logical record, continuing to refer to the same 1579 record as it did before. 1580 <p> 1581 For these reasons, concurrent access to a Recno database configured 1582 with mutable record numbers may be largely meaningless, although it 1583 is supported. 1584 <p> 1585 Calling this method affects the database, including all threads of 1586control accessing the database. 1587 <p> 1588 If the database already exists when the database is opened, any database 1589configuration specified by this method 1590must be the same as the existing database or an error 1591will be returned. 1592 <p> 1593 @param renumbering 1594 If true, configure the logical record numbers to be mutable, and 1595 change as records are added to and deleted from the database. 1596 A value of false is illegal to this method, that is, once set, the 1597configuration cannot be cleared. 1598 */ 1599 public void setRenumbering(final boolean renumbering) { 1600 this.renumbering = renumbering; 1601 } 1602 1603 /** 1604Return true if the logical record numbers are mutable, and change as 1605 records are added to and deleted from the database. 1606<p> 1607This method may be called at any time during the life of the application. 1608<p> 1609@return 1610True if the logical record numbers are mutable, and change as 1611 records are added to and deleted from the database. 1612 */ 1613 public boolean getRenumbering() { 1614 return renumbering; 1615 } 1616 1617 /** 1618 Configure the Btree to not do reverse splits. 1619 <p> 1620 As pages are emptied in a database, the Btree implementation 1621 attempts to coalesce empty pages into higher-level pages in order 1622 to keep the database as small as possible and minimize search time. 1623 This can hurt performance in applications with cyclical data 1624 demands; that is, applications where the database grows and shrinks 1625 repeatedly. For example, because Berkeley DB does page-level locking, 1626 the maximum level of concurrency in a database of two pages is far 1627 smaller than that in a database of 100 pages, so a database that has 1628 shrunk to a minimal size can cause severe deadlocking when a new 1629 cycle of data insertion begins. 1630 <p> 1631 Calling this method only affects the specified {@link com.sleepycat.db.Database Database} handle 1632(and any other library handles opened within the scope of that handle). 1633 <p> 1634 @param reverseSplitOff 1635 If true, configure the Btree to not do reverse splits. 1636 A value of false is illegal to this method, that is, once set, the 1637configuration cannot be cleared. 1638 */ 1639 public void setReverseSplitOff(final boolean reverseSplitOff) { 1640 this.reverseSplitOff = reverseSplitOff; 1641 } 1642 1643 /** 1644Return true if the Btree has been configured to not do reverse splits. 1645<p> 1646This method may be called at any time during the life of the application. 1647<p> 1648@return 1649True if the Btree has been configured to not do reverse splits. 1650 */ 1651 public boolean getReverseSplitOff() { 1652 return reverseSplitOff; 1653 } 1654 1655 /** 1656 Configure the database to support sorted, duplicate data items. 1657 <p> 1658 Insertion when the key of the key/data pair being inserted already 1659 exists in the database will be successful. The ordering of 1660 duplicates in the database is determined by the duplicate comparison 1661 function. 1662 <p> 1663 If the application does not specify a duplicate data item comparison 1664 function, a default lexical comparison will be used. 1665 <p> 1666 If a primary database is to be associated with one or more secondary 1667 databases, it may not be configured for duplicates. 1668 <p> 1669 A Btree that supports duplicate data items cannot also be configured 1670 for retrieval by record number. 1671 <p> 1672 Calling this method affects the database, including all threads of 1673control accessing the database. 1674 <p> 1675 If the database already exists when the database is opened, any database 1676configuration specified by this method 1677must be the same as the existing database or an error 1678will be returned. 1679 <p> 1680 @param sortedDuplicates 1681 If true, configure the database to support duplicate data items. 1682 A value of false is illegal to this method, that is, once set, the 1683configuration cannot be cleared. 1684 */ 1685 public void setSortedDuplicates(final boolean sortedDuplicates) { 1686 this.sortedDuplicates = sortedDuplicates; 1687 } 1688 1689 /** 1690Return true if the database is configured to support sorted duplicate data 1691 items. 1692<p> 1693This method may be called at any time during the life of the application. 1694<p> 1695@return 1696True if the database is configured to support sorted duplicate data 1697 items. 1698 */ 1699 public boolean getSortedDuplicates() { 1700 return sortedDuplicates; 1701 } 1702 1703 /** 1704 Configure the database to support unsorted duplicate data items. 1705 <p> 1706 Insertion when the key of the key/data pair being inserted already 1707 exists in the database will be successful. The ordering of 1708 duplicates in the database is determined by the order of insertion, 1709 unless the ordering is otherwise specified by use of a database 1710 cursor operation. 1711 <p> 1712 If a primary database is to be associated with one or more secondary 1713 databases, it may not be configured for duplicates. 1714 <p> 1715 Sorted duplicates are preferred to unsorted duplicates for 1716 performance reasons. Unsorted duplicates should only be used by 1717 applications wanting to order duplicate data items manually. 1718 <p> 1719 Calling this method affects the database, including all threads of 1720control accessing the database. 1721 <p> 1722 If the database already exists when the database is opened, any database 1723configuration specified by this method 1724must be the same as the existing database or an error 1725will be returned. 1726 <p> 1727 @param unsortedDuplicates 1728 If true, configure the database to support unsorted duplicate data items. 1729 A value of false is illegal to this method, that is, once set, the 1730configuration cannot be cleared. 1731 */ 1732 public void setUnsortedDuplicates(final boolean unsortedDuplicates) { 1733 this.unsortedDuplicates = unsortedDuplicates; 1734 } 1735 1736 /** 1737Return true if the database is configured to support duplicate data items. 1738<p> 1739This method may be called at any time during the life of the application. 1740<p> 1741@return 1742True if the database is configured to support duplicate data items. 1743 */ 1744 public boolean getUnsortedDuplicates() { 1745 return unsortedDuplicates; 1746 } 1747 1748 /** 1749 Specify that any specified backing source file be read in its entirety 1750 when the database is opened. 1751 <p> 1752 If this flag is not specified, the backing source file may be read 1753 lazily. 1754 <p> 1755 Calling this method only affects the specified {@link com.sleepycat.db.Database Database} handle 1756(and any other library handles opened within the scope of that handle). 1757 <p> 1758 @param snapshot 1759 If true, any specified backing source file will be read in its entirety 1760 when the database is opened. 1761 A value of false is illegal to this method, that is, once set, the 1762configuration cannot be cleared. 1763 */ 1764 public void setSnapshot(final boolean snapshot) { 1765 this.snapshot = snapshot; 1766 } 1767 1768 /** 1769Return true if the any specified backing source file will be read in its 1770 entirety when the database is opened. 1771<p> 1772This method may be called at any time during the life of the application. 1773<p> 1774@return 1775True if the any specified backing source file will be read in its 1776 entirety when the database is opened. 1777 */ 1778 public boolean getSnapshot() { 1779 return snapshot; 1780 } 1781 1782 /** 1783Return true if the database open is enclosed within a transaction. 1784<p> 1785This method may be called at any time during the life of the application. 1786<p> 1787@return 1788True if the database open is enclosed within a transaction. 1789 */ 1790 public boolean getTransactional() { 1791 return transactional; 1792 } 1793 1794 /** 1795 Enclose the database open within a transaction. 1796 <p> 1797 If the call succeeds, the open operation will be recoverable. If 1798 the call fails, no database will have been created. 1799 <p> 1800 All future operations on this database, which are not explicitly 1801 enclosed in a transaction by the application, will be enclosed in 1802 in a transaction within the library. 1803 <p> 1804 @param transactional 1805 If true, enclose the database open within a transaction. 1806 */ 1807 public void setTransactional(final boolean transactional) { 1808 this.transactional = transactional; 1809 } 1810 1811 /** 1812 Configure the database environment to not write log records for this 1813 database. 1814 <p> 1815 This means that updates of this database exhibit the ACI (atomicity, 1816 consistency, and isolation) properties, but not D (durability); that 1817 is, database integrity will be maintained, but if the application 1818 or system fails, integrity will not persist. The database file must 1819 be verified and/or restored from backup after a failure. In order 1820 to ensure integrity after application shut down, the database 1821 must be flushed to disk before the database handles are closed, 1822 or all 1823 database changes must be flushed from the database environment cache 1824 using {@link com.sleepycat.db.Environment#checkpoint Environment.checkpoint}. 1825 <p> 1826 All database handles for a single physical file must call this method, 1827 including database handles for different databases in a physical file. 1828 <p> 1829 Calling this method only affects the specified {@link com.sleepycat.db.Database Database} handle 1830(and any other library handles opened within the scope of that handle). 1831 <p> 1832 @param transactionNotDurable 1833 If true, configure the database environment to not write log records 1834 for this database. 1835 A value of false is illegal to this method, that is, once set, the 1836configuration cannot be cleared. 1837 */ 1838 public void setTransactionNotDurable(final boolean transactionNotDurable) { 1839 this.transactionNotDurable = transactionNotDurable; 1840 } 1841 1842 /** 1843Return true if the database environment is configured to not write log 1844 records for this database. 1845<p> 1846This method may be called at any time during the life of the application. 1847<p> 1848@return 1849True if the database environment is configured to not write log 1850 records for this database. 1851 */ 1852 public boolean getTransactionNotDurable() { 1853 return transactionNotDurable; 1854 } 1855 1856 /** 1857 Configure the database to be physically truncated by truncating the 1858 underlying file, discarding all previous databases it might have 1859 held. 1860 <p> 1861 Underlying filesystem primitives are used to implement this 1862 configuration. For this reason, it is applicable only to a physical 1863 file and cannot be used to discard databases within a file. 1864 <p> 1865 This configuration option cannot be lock or transaction-protected, and 1866 it is an error to specify it in a locking or transaction-protected 1867 database environment. 1868 <p> 1869 @param truncate 1870 If true, configure the database to be physically truncated by truncating 1871 the underlying file, discarding all previous databases it might have 1872 held. 1873 */ 1874 public void setTruncate(final boolean truncate) { 1875 this.truncate = truncate; 1876 } 1877 1878 /** 1879Return true if the database has been configured to be physically truncated 1880 by truncating the underlying file, discarding all previous databases 1881 it might have held. 1882<p> 1883This method may be called at any time during the life of the application. 1884<p> 1885@return 1886True if the database has been configured to be physically truncated 1887 by truncating the underlying file, discarding all previous databases 1888 it might have held. 1889 */ 1890 public boolean getTruncate() { 1891 return truncate; 1892 } 1893 1894 /** 1895 Configure the type of the database. 1896 <p> 1897 If they type is DB_UNKNOWN, the database must already exist. 1898 <p> 1899 @param type 1900 The type of the database. 1901 */ 1902 public void setType(final DatabaseType type) { 1903 this.type = type; 1904 } 1905 1906 /** 1907 Return the type of the database. 1908 <p> 1909 This method may be used to determine the type of the database after 1910 opening it. 1911 <p> 1912 This method may not be called before the 1913database has been opened. 1914 <p> 1915 @return 1916 The type of the database. 1917 */ 1918 public DatabaseType getType() { 1919 return type; 1920 } 1921 1922 /** 1923 Configure the database to be accessed via applications running under 1924 an X/Open conformant Transaction Manager. 1925 <p> 1926 The database will be opened in the environment specified by the 1927 OPENINFO parameter of the GROUPS section of the ubbconfig file. 1928 <p> 1929 @param xaCreate 1930 If true, configure the database to be accessed via applications 1931 running under an X/Open conformant Transaction Manager. 1932 */ 1933 public void setXACreate(final boolean xaCreate) { 1934 this.xaCreate = xaCreate; 1935 } 1936 1937 /** 1938Return true if the database has been configured to be accessed via applications 1939 running under an X/Open conformant Transaction Manager. 1940<p> 1941This method may be called at any time during the life of the application. 1942<p> 1943@return 1944True if the database has been configured to be accessed via applications 1945 running under an X/Open conformant Transaction Manager. 1946 */ 1947 public boolean getXACreate() { 1948 return xaCreate; 1949 } 1950 1951 /* package */ 1952 Db createDatabase(final DbEnv dbenv) 1953 throws DatabaseException { 1954 1955 int createFlags = 0; 1956 1957 createFlags |= xaCreate ? DbConstants.DB_XA_CREATE : 0; 1958 return new Db(dbenv, createFlags); 1959 } 1960 1961 /* package */ 1962 Db openDatabase(final DbEnv dbenv, 1963 final DbTxn txn, 1964 final String fileName, 1965 final String databaseName) 1966 throws DatabaseException, java.io.FileNotFoundException { 1967 1968 final Db db = createDatabase(dbenv); 1969 // The DB_THREAD flag is inherited from the environment 1970 // (defaulting to ON if no environment handle is supplied). 1971 boolean threaded = (dbenv == null || 1972 (dbenv.get_open_flags() & DbConstants.DB_THREAD) != 0); 1973 1974 int openFlags = 0; 1975 openFlags |= allowCreate ? DbConstants.DB_CREATE : 0; 1976 openFlags |= readUncommitted ? DbConstants.DB_READ_UNCOMMITTED : 0; 1977 openFlags |= exclusiveCreate ? DbConstants.DB_EXCL : 0; 1978 openFlags |= multiversion ? DbConstants.DB_MULTIVERSION : 0; 1979 openFlags |= noMMap ? DbConstants.DB_NOMMAP : 0; 1980 openFlags |= readOnly ? DbConstants.DB_RDONLY : 0; 1981 openFlags |= threaded ? DbConstants.DB_THREAD : 0; 1982 openFlags |= truncate ? DbConstants.DB_TRUNCATE : 0; 1983 1984 if (transactional && txn == null) 1985 openFlags |= DbConstants.DB_AUTO_COMMIT; 1986 1987 boolean succeeded = false; 1988 try { 1989 configureDatabase(db, DEFAULT); 1990 db.open(txn, fileName, databaseName, type.getId(), openFlags, mode); 1991 succeeded = true; 1992 return db; 1993 } finally { 1994 if (!succeeded) 1995 try { 1996 db.close(0); 1997 } catch (Throwable t) { 1998 // Ignore it -- an exception is already in flight. 1999 } 2000 } 2001 } 2002 2003 /* package */ 2004 void configureDatabase(final Db db, final DatabaseConfig oldConfig) 2005 throws DatabaseException { 2006 2007 int dbFlags = 0; 2008 dbFlags |= checksum ? DbConstants.DB_CHKSUM : 0; 2009 dbFlags |= btreeRecordNumbers ? DbConstants.DB_RECNUM : 0; 2010 dbFlags |= queueInOrder ? DbConstants.DB_INORDER : 0; 2011 dbFlags |= renumbering ? DbConstants.DB_RENUMBER : 0; 2012 dbFlags |= reverseSplitOff ? DbConstants.DB_REVSPLITOFF : 0; 2013 dbFlags |= sortedDuplicates ? DbConstants.DB_DUPSORT : 0; 2014 dbFlags |= snapshot ? DbConstants.DB_SNAPSHOT : 0; 2015 dbFlags |= unsortedDuplicates ? DbConstants.DB_DUP : 0; 2016 dbFlags |= transactionNotDurable ? DbConstants.DB_TXN_NOT_DURABLE : 0; 2017 if (!db.getPrivateDbEnv()) 2018 dbFlags |= (password != null) ? DbConstants.DB_ENCRYPT : 0; 2019 2020 if (dbFlags != 0) 2021 db.set_flags(dbFlags); 2022 2023 if (btMinKey != oldConfig.btMinKey) 2024 db.set_bt_minkey(btMinKey); 2025 if (byteOrder != oldConfig.byteOrder) 2026 db.set_lorder(byteOrder); 2027 if ((cacheSize != oldConfig.cacheSize || 2028 cacheCount != oldConfig.cacheCount) && db.getPrivateDbEnv()) 2029 db.set_cachesize(cacheSize, cacheCount); 2030 if (errorStream != oldConfig.errorStream) 2031 db.set_error_stream(errorStream); 2032 if (errorPrefix != oldConfig.errorPrefix) 2033 db.set_errpfx(errorPrefix); 2034 if (hashFillFactor != oldConfig.hashFillFactor) 2035 db.set_h_ffactor(hashFillFactor); 2036 if (hashNumElements != oldConfig.hashNumElements) 2037 db.set_h_nelem(hashNumElements); 2038 if (messageStream != oldConfig.messageStream) 2039 db.set_message_stream(messageStream); 2040 if (pageSize != oldConfig.pageSize) 2041 db.set_pagesize(pageSize); 2042 if (password != oldConfig.password && db.getPrivateDbEnv()) 2043 db.set_encrypt(password, DbConstants.DB_ENCRYPT_AES); 2044 if (priority != oldConfig.priority) 2045 db.set_priority(priority.getFlag()); 2046 if (queueExtentSize != oldConfig.queueExtentSize) 2047 db.set_q_extentsize(queueExtentSize); 2048 if (recordDelimiter != oldConfig.recordDelimiter) 2049 db.set_re_delim(recordDelimiter); 2050 if (recordLength != oldConfig.recordLength) 2051 db.set_re_len(recordLength); 2052 if (recordPad != oldConfig.recordPad) 2053 db.set_re_pad(recordPad); 2054 if (recordSource != oldConfig.recordSource) 2055 db.set_re_source( 2056 (recordSource == null) ? null : recordSource.toString()); 2057 2058 if (btreeComparator != oldConfig.btreeComparator) 2059 db.set_bt_compare(btreeComparator); 2060 if (btreePrefixCalculator != oldConfig.btreePrefixCalculator) 2061 db.set_bt_prefix(btreePrefixCalculator); 2062 if (duplicateComparator != oldConfig.duplicateComparator) 2063 db.set_dup_compare(duplicateComparator); 2064 if (feedbackHandler != oldConfig.feedbackHandler) 2065 db.set_feedback(feedbackHandler); 2066 if (errorHandler != oldConfig.errorHandler) 2067 db.set_errcall(errorHandler); 2068 if (hashComparator != oldConfig.hashComparator) 2069 db.set_h_compare(hashComparator); 2070 if (hasher != oldConfig.hasher) 2071 db.set_h_hash(hasher); 2072 if (messageHandler != oldConfig.messageHandler) 2073 db.set_msgcall(messageHandler); 2074 if (recnoAppender != oldConfig.recnoAppender) 2075 db.set_append_recno(recnoAppender); 2076 if (panicHandler != oldConfig.panicHandler) 2077 db.set_paniccall(panicHandler); 2078 } 2079 2080 /* package */ 2081 DatabaseConfig(final Db db) 2082 throws DatabaseException { 2083 2084 type = DatabaseType.fromInt(db.get_type()); 2085 2086 final int openFlags = db.get_open_flags(); 2087 allowCreate = (openFlags & DbConstants.DB_CREATE) != 0; 2088 readUncommitted = (openFlags & DbConstants.DB_READ_UNCOMMITTED) != 0; 2089 exclusiveCreate = (openFlags & DbConstants.DB_EXCL) != 0; 2090 multiversion = (openFlags & DbConstants.DB_MULTIVERSION) != 0; 2091 noMMap = (openFlags & DbConstants.DB_NOMMAP) != 0; 2092 readOnly = (openFlags & DbConstants.DB_RDONLY) != 0; 2093 truncate = (openFlags & DbConstants.DB_TRUNCATE) != 0; 2094 2095 final int dbFlags = db.get_flags(); 2096 checksum = (dbFlags & DbConstants.DB_CHKSUM) != 0; 2097 btreeRecordNumbers = (dbFlags & DbConstants.DB_RECNUM) != 0; 2098 queueInOrder = (dbFlags & DbConstants.DB_INORDER) != 0; 2099 renumbering = (dbFlags & DbConstants.DB_RENUMBER) != 0; 2100 reverseSplitOff = (dbFlags & DbConstants.DB_REVSPLITOFF) != 0; 2101 sortedDuplicates = (dbFlags & DbConstants.DB_DUPSORT) != 0; 2102 snapshot = (dbFlags & DbConstants.DB_SNAPSHOT) != 0; 2103 unsortedDuplicates = (dbFlags & DbConstants.DB_DUP) != 0; 2104 transactionNotDurable = (dbFlags & DbConstants.DB_TXN_NOT_DURABLE) != 0; 2105 2106 if (type == DatabaseType.BTREE) { 2107 btMinKey = db.get_bt_minkey(); 2108 } 2109 byteOrder = db.get_lorder(); 2110 // Call get_cachesize* on the DbEnv to avoid this error: 2111 // DB->get_cachesize: method not permitted in shared environment 2112 cacheSize = db.get_env().get_cachesize(); 2113 cacheCount = db.get_env().get_cachesize_ncache(); 2114 errorStream = db.get_error_stream(); 2115 errorPrefix = db.get_errpfx(); 2116 if (type == DatabaseType.HASH) { 2117 hashFillFactor = db.get_h_ffactor(); 2118 hashNumElements = db.get_h_nelem(); 2119 } 2120 messageStream = db.get_message_stream(); 2121 // Not available by design 2122 password = ((dbFlags & DbConstants.DB_ENCRYPT) != 0) ? "" : null; 2123 priority = CacheFilePriority.fromFlag(db.get_priority()); 2124 if (type == DatabaseType.QUEUE) { 2125 queueExtentSize = db.get_q_extentsize(); 2126 } 2127 if (type == DatabaseType.QUEUE || type == DatabaseType.RECNO) { 2128 recordLength = db.get_re_len(); 2129 recordPad = db.get_re_pad(); 2130 } 2131 if (type == DatabaseType.RECNO) { 2132 recordDelimiter = db.get_re_delim(); 2133 recordSource = (db.get_re_source() == null) ? null : 2134 new java.io.File(db.get_re_source()); 2135 } 2136 transactional = db.get_transactional(); 2137 2138 btreeComparator = db.get_bt_compare(); 2139 btreePrefixCalculator = db.get_bt_prefix(); 2140 duplicateComparator = db.get_dup_compare(); 2141 feedbackHandler = db.get_feedback(); 2142 errorHandler = db.get_errcall(); 2143 hashComparator = db.get_h_compare(); 2144 hasher = db.get_h_hash(); 2145 messageHandler = db.get_msgcall(); 2146 recnoAppender = db.get_append_recno(); 2147 panicHandler = db.get_paniccall(); 2148 } 2149} 2150