ObjectStore Java API User Guide
Chapter 13

Tools Reference

This chapter provides reference information for the following tools:

osgc: Collecting Garbage in Databases

osjbrowsedb: Browsing a Database

osjcfp: Running the Postprocessor

osjcgen: Generating Peer Classes

osjcheckdb: Checking References in a Database

osjshowdb: Displaying Information About a Database

osjuphsh: Upgrading String Hash Codes in Databases

osjversion: Obtaining ObjectStore Version Information

osgc: Collecting Garbage in Databases

The command line utility for collecting garbage is osgc. Invoke this tool with the following format:

osgc [ options] database_name

For example, execution of

osgc db
is the same as calling the Database.GC() method on the db database. You can specify the following options:

Option Description
-seg segment_id Collects garbage from only the specified segment. By default, the osgc utility operates on the entire database.
-retries number Indicates the number of times the tool tries to resume the sweep phase of garbage collection after it waits for a lock. The default is 10. This is identical to the COM.odi.gc.retries property.
-retryInterval interval Indicates the number of milliseconds the sweep operation waits between sweep attempts for a concurrency conflict to be resolved before it tries to resume the sweep. The default is 1000. This is identical to the COM.odi.gc.retryInterval property.
-lockTimeOut interval Indicates the number of milliseconds the sweep operation waits for a lock conflict to be resolved. If it is not resolved in the specified length of time, the tool aborts the current transaction and starts a new transaction. ObjectStore rounds this value up to the nearest second. The default is 1000. This is identical to the COM.odi.gc.lockTimeOut property.
-transactionPriority n Specifies the transaction priority associated with transactions started by the tool. The Server uses this specification when it must determine which transaction must be the victim in a deadlock. This number is intentionally low so that the garbage collection transaction is the deadlock victim of choice. The default is 0. This is identical to the COM.odi.gc.transactionPriority property.
-displayGarbage level Displays information about the candidates for garbage collection instead of actually destroying the candidates. The level you specify determines the amount of information the tool displays. 1 lists the number of objects per segment that would be destroyed. 2 is not currently supported. 3 lists the location of each GC candidate. 4 lists the roots of garbage graphs. Level 4 can require intensive computations.
-statistics Displays statistics for the garbage collection operation. This includes the total number of reachable objects and the total number of garbage objects.

The name of the garbage collection utility is osgc and not osjgc because this tool works on databases created with the C++ interface to ObjectStore, as well as databases created with the Java interface to ObjectStore.

See also Running osgc on C++ Databases or Segments.

osjbrowsedb: Browsing a Database

This release includes a beta version of a database browser. For information about how to use the browser, see the browser.htm file in the doc directory of your ObjectStore installation directory.

osjcfp: Running the Postprocessor

To make classes persistence-capable, compile the source files and then run the postprocessor on the resulting class files. You must run the postprocessor on all class files in a batch at the same time. The postprocessor can accept a command line that intersperses file names, options, and input file specifications. Complete information about the postprocessor is in Chapter 8, Automatically Generating Persistence-Capable Classes.

The command format is

osjcfp -dest destination_dir file_name [ file_name...] [ options]

The following table describes the options you can specify.

Option Description
@ input_file Causes the contents of the named input file to replace this argument in the command line. The postprocessor does this before any other argument processing. You can specify this option multiple times on one command line to include multiple files. You cannot nest this option. That is, the postprocessor does not expand this argument if it appears in an input file.
{ -a | -arraydims }
num_array_dimensions
Specifies the maximum number of dimensions that ObjectStore allows for persistent arrays of objects whose classes are annotated during this execution of the postprocessor. If you do not specify this option, the default is three dimensions.
{ -cis | -classinfosuffix } suffix_string Specifies the suffix that the postprocessor adds to the name of the ClassInfo subclass that the postprocessor generates for each class it makes persistence-capable. By default, the suffix is ClassInfo. This is useful when you need to limit the number of characters in file names. For all batches in an application, you must specify the same suffix if you do not use the default.
{ -cpath | -classpath }
class_path
Specifies the path by which to locate class files for postprocessing. If you specify this option, ObjectStore uses it in place of the CLASSPATH environment variable. The -classpath option does not affect the class path used for the execution of the postprocessor.
{ -cc | -copyclass } Copies classes to the destination directory without annotating them. This option applies to class names, .class files, .jar files, and .zip files that you specify on the command line after the -copyclass option and before the next -persistcapable or -persistaware option or the end of the command line. This option is useful when you want nonpersistent classes or classes that have already been annotated to be in the same directory as persistence-capable or persistence-aware classes being created. If you specify the -persistaware or -persistcapable option for any file for which you also specify the -copyclass option, the postprocessor ignores the -copyclass option for that file. If you specify the -translatepackage option and the copyclass option, the postprocessor modifies the class to accommodate the new package name.
{ -d | -dest } destination_dir This option is required. The postprocessor uses the directory you specify for destination_dir as the root for locating the annotated files. The postprocessor places each class file it operates on in the package-appropriate subdirectory of the destination directory, as though the destination directory were in your class path. If the destination directory specification would cause the postprocessor to overwrite an original file, and you did not specify the -inplace option, the postprocessor reports an error and terminates without producing any output.
{ -f | -force } Forces the postprocessor to overwrite existing annotated .class and ClassInfo files.
-hashcode class_name Causes the postprocessor to add a persistent hashCode() method to the specified class. You typically use this option with the -nodefaulthashcode option. If you specify this option for a class for which you explicitly defined a hashCode() method, the postprocessor reports an error.
-includesummary
inc_class_name
Instructs the postprocessor to include the specified summary in the new summary it creates. It does not matter whether or not the postprocessor is also annotating any classes. Replace inc_class_name with the name of a file generated by a previous execution of the postprocessor with the -summary option. You must know the name of the generated file. If you did not postprocess the library yourself, you must get the name of the generated class from the library vendor. When you specify the -includesummary option, you must also specify the -summary option.

{ -index | -indexablefield } field Marks a field as indexable for a peer (COM.odi.coll) collection. This option applies only to the field that immediately follows it. You must specify a fully qualified field, for example, COM.odi.demo.people.name. You can specify this option multiple times. This option does not apply to utility (COModi.util) collections. This option is useful because it allows a query to run faster. The postprocessor does not actually add the index. You can add a persistent index with a call to the API at run time. When the index is present, queries that use the specified field are faster. Suppose you declare a field to be indexable and then you change the value of that field. Performance is slightly slower than if the field were not indexable. This is true for any object of the class, whether or not the object is in a collection. Now suppose an object with an indexable field is in a collection and the collection has an index on the indexable field. If you change the value of the field, performance is slightly slower than when the object is not in a collection. The extra time is needed to update the index. It is possible for an object to belong to many collections. Each collection can have an index on a particular field. If you change the value of that field, ObjectStore must update each index and the performance penalty is greater. If a class has any indexable fields, every instance of the class is larger by three 32-bit words in the database.
-inplace Causes the postprocessor to annotate standalone files (files that are not in .zip files or .jar files) in place rather than writing the annotated file in the destination directory. When the postprocessor annotates a class in place, it overwrites the original class files with the annotated class files, and writes the ClassInfo subclass to the same directory as the persistence-capable class. If a class originates in a .zip file or .jar file, the postprocessor writes the annotated class and its corresponding ClassInfo subclass to the destination directory. Do not use this option when you are doing iterative development. During development, a separate output directory avoid errors and supports debugging. When you specify the -inplace option, you must still specify a destination directory, but the postprocessor ignores it.
{ -it | -ignoretransient } field_name Instructs the postprocessor to ignore the transient attribute of the specified field and treat the field as a persistence-capable field. You must specify a fully qualified field name. The field is treated as persistence-capable only for the purposes of postprocessing. This option is useful when a persistence-capable class you are defining inherits from a class that includes a transient field. If you do not specify this option for a transient field, the postprocessor ignores the field, which can cause problems if you want to use the field.
-modifyjava Allows the postprocessor to modify classes in standard Java packages. The default is that the postprocessor does not modify standard Java classes.
{ -naf | -noannotatefield } qualified_field_name Prevents access to the specified field from causing fetch() and dirty() calls on the containing object. This is useful for transient fields when you access them outside a transaction. Normally, access to a transient field causes fetch() or dirty() to be called to allow the postInitializeContents() and preFlushContents() methods to convert between persistent and transient state.
-noarrayopt Disables optimization of fetch() and dirty() calls for array objects in looping constructs. This causes osjcfp to insert the calls to fetch() or dirty() in every iteration rather than only in the first loop iteration.
{-nodefaulthashcode
| -ndhc }
Prevents the postprocessor from automatically adding a hashCode() method to a class, except for classes for which you explicitly specify the -hashcode option. If you specify this option, it is your responsibility to ensure that there is a suitable hashCode() method for classes that are used as keys in persistent hash tables.
-noinitializeropt Disables optimization of fetch() and dirty() calls in constructors. Specify this option when you want the postprocessor to perform full annotation of constructors. Full annotation means that if the object becomes persistent during constructor execution, modifications to the object are correctly handled. By default, the postprocessor does not fully annotate constructors to handle changes in the newly constructed object. Typically, this is the desired behavior. If your application inserts objects into ObjectStore collections during construction of the objects being inserted, you must specify the -noinitializeropt option. Doing so avoids errors in the handling of modifications to the newly constructed objects.
-noopt Disables the three optimizations that are disabled by the --noarrayopt, -noinitializeropt, and -nothisopt options. The -noopt option is a shortcut you can use when you want to specify all three options. You might want to specify this option when the optimizations are preventing the postprocessor from inserting required fetch() and dirty() calls in your classes.
-nothisopt Disables optimization of fetch() and dirty() calls for access to fields relative to this in nonstatic member methods. This causes osjcfp to insert a fetch() or dirty() call for each access to a field in this.
-nowrite Performs process and error checking but does not actually annotate class files. This option allows a test run of the postprocessor. You use it to determine whether or not all specified classes are accessible, whether or not additional options are needed, and if you specify -v (verbose) you can see where the resulting files would be located.
-optimizeclassinfo | -oci Prevents the postprocessor from generating xxxClassInfo.java files for public and abstract classes. This reduces the disk footprint and application startup times, since there are fewer classes to load when the application starts. When the postprocessor does not create a ClassInfo class, it uses the Java reflection API instead. Some of the reflection API is subject to security and access constraints that are enforced to varying degrees depending on the version of the JDK and the platform. In other words, you can use the -optimizeclassinfo option if the Java environment in which you intend to run the application does not restrict the use of the reflection API.
{ -pa | -persistaware } Causes subsequent .class files, .jar files, and .zip files on the command line to be persistence-aware. This means that instances of the classes can operate on persistent objects but cannot be persistent. The postprocessor annotates persistence-aware classes so that there are calls to ObjectStore.fetch() and ObjectStore.dirty() where needed during operations on potentially persistent objects and arrays that might be used by the persistence-aware class. This option applies to class names, .class files, .jar files, and .zip files that you specify on the command line after the -persistaware option and before the next -persistcapable or -copyclass option or the end of the command line. In other words, the -persistcapable option or the -copyclass option alters this mode. The -pc option is in effect by default.
{ -pc | -persistcapable } Causes subsequent .class files, .jar files, and .zip files on the command line to be persistence-capable. This option applies to class names, .class files, .jar files, and .zip files that you specify on the command line after the -persistcapable option and before the next -persistaware or -copyclass option or the end of the command line. The -pa (persistence-aware) option or the -copyclass option alters this mode. The -pc option is in effect by default.
{ -q | -quiet } Causes the postprocessor to refrain from displaying warnings. A warning message provides information about something that the postprocessor recognizes as a possible problem, but cannot confirm as actually being a problem. This option cancels a previous -verbose option, if you specified one.
{ -qc | -quietclass }
class_name
Causes the postprocessor to refrain from displaying warnings for the specified class. A warning message provides information about something that the postprocessor recognizes as a possible problem, but cannot confirm as actually being a problem. This option applies only to the name that immediately follows it. Specify a fully qualified class name. If the postprocessor is renaming the class, it does not matter whether you specify the old name or the new name. If you specify -verbose in the same command, this option takes precedence for the specified class.
{ -qf | -quietfield }
member_name
Causes the postprocessor to refrain from displaying warnings for the specified class field. A warning message provides information about something that the postprocessor recognizes as a possible problem, but cannot confirm as actually being a problem. This option applies only to the name that immediately follows it. Specify a fully qualified class field name. If the postprocessor is renaming the class, it does not matter whether you specify the old name or the new name. If you specify -verbose in the same command, this option takes precedence for the specified class field.
-summary gen_class_name Causes the postprocessor to generate a class with the name gen_class_name. This generated class extends the COM.odi.PersistentTypeSummary class. The gen_class_name.getPersistentClasses() method returns a list of the classes that were made persistence-capable in this execution of the postprocessor. The generated class has a no-argument constructor that passes arrays to the PersistentTypeSummary class constructor. To identify persistence-capable classes in libraries and include them in this summary, specify the -includesummary option.

{ -tf | -transientfield } qualified_field_name Causes the postprocessor to treat the specified field as though it has a transient modifier, even if it does not. This is typically useful when a field should not be stored in a database, but it must be available for object serialization.

{ -tp | -translatepackage } orig_pkg_name
new_pkg_name
Renames classes that belong to orig_pkg_name so that they belong to new_pkg_name. The original .class files remain in the original location and the postprocessor does not annotate them. For example, suppose the postprocessor makes a class named a.b.C persistent with -tp a.b a.b.x. The persistent class has the name a.b.x.C. A package specification of "." implies the default unnamed package. For example, the option -tp . persist causes the unpackaged class name C to be renamed persist.C. orig_pkg_name must exactly match the package name of the class being annotated. For example, for a file named a.c.D, a specification of -tp a a.b does not translate the package name. The package of a.c.D is a.c, not a. The postprocessor changes the package name of all classes in the original package that it can locate through the CLASSPATH environment variable or, if it is specified, the -classpath option.
{ -v | -verbose } Causes the postprocessor to write descriptions of its actions to standard output. This option cancels a previous -quiet option, if you specified one.

You can specify any number of class names, .class files, .jar files, or .zip files on the command line. The postprocessor recognizes files as follows:

File Name Recognized As
name.class Explicit file name for a class file.
name.zip Explicit file name for a class .zip file. The postprocessor processes all .class files in the .zip file according to the persistence mode that is in effect when the postprocessor encounters the name of the .zip file. The postprocessor places each file from the .zip file in the package-relative subdirectory of the destination directory. A .zip file allows the postprocessor to process multiple files without the specification of each one on the command line. Also, you can simply specify a .zip file. You do not need to unzip the file before processing the .class files.
name.jar Explicit file name for a class .jar file. The postprocessor treats the file the same way that it treats a .zip file.
name Qualified class name delimited by ".". The postprocessor uses the CLASSPATH environment variable or the specification for the -classpath option to locate the .class file, which can be in a .zip file or .jar file.

Because the postprocessor recognizes name.class as well as name, you can run a command such as

osjcfp -dest osjcfpout *.class
You do not need to derive qualified class names from the file paths.

osjcgen: Generating Peer Classes

To map C++ classes to Java peer classes, run the peer generator tool (osjcgen).

Additional information about the peer class generator is in the book Developing ObjectStore Java Applications That Access C++.

Description of Command Line Format

The command line format appears below. It shows the different components in the command line on different lines only for clarity.

osjcgen -package  destination_package 
-native_interface interface_type
-schema mapping_schema_database
-classdir target_dir -libdir target_dir [ options] class_list

-package
destination_package
Identifies the package in which the peer generator creates peer classes. Required.
-native_inteface
native_interface
Specifies the virtual machine interface for which the tool should generate C++ glue code. Specify jni for the Sun VM or ms_raw for the Microsoft VM.
-schema
mapping_schema_database
Identifies the mapping schema database from which the tool extracts type definitions. Required. You must have specified the -store_member_functions (-smf) and -store_function_parameters (-sfp) options when you ran ossg to create this schema. If you did not, the tool cannot define peer methods. These options cause additional information to be stored in the schema database. osjcgen needs this information to correctly process member functions. The mapping schema database you specify is not the application schema database that the application uses. If the C++ code for which you want to define peer classes does not define methods, you need not specify the -smf and -sfp options when you run ossg.
-classdir target_dir Specifies the directory relative to which the tool writes the peer classes and other generated Java files. For example, if the specified destination_package is MyPkg and the specified target_dir is MyDir, the tool creates the peer classes in MyDir/MyPkg. The directory you specify must exist. If the directory you specify does not contain a subdirectory with the name of the package, the tool creates this subdirectory. Required.
-libdir target_dir Specifies the directory in which the tool creates the C++ files. In the directory you specify, the tool creates a directory that has the name you specify for destination_package. The tool places the C++ files in this package subdirectory of the directory you specify with the -libdir option. The directory you specify must exist. Required.
options Any of the options described in the next table. Optional.
class_list Lists the names of the classes and structs for which you want the tool to generate peer classes. The tool places each peer class in the specified destination package. You can intersperse class name specifications with the options described in the next table. Required. Do not specify enums. If a peer method accepts or returns an enum, the tool automatically generates the peer class for the enum.

Description of Additional Options

The following table describes the additional options you can specify on the osjcgen command line. These options can precede, follow, or be interspersed with the required osjcgen options.

-boolean typedef_name Indicates that the specified typedef name identifies a boolean data type. You can specify this option multiple times.
-classpath class_path Instructs the tool to use the class_path you specify rather than the setting for the CLASSPATH environment variable. When you specify this option, it affects only the lookup of classes by the peer generator tool. It has no effect on the execution of the peer generator tool itself.
-full Turns off the -leaf option. The tool generates complete peer classes for types specified subsequently. The -full option is in effect by default.
-import package Specifies a package name in which to look for a peer class before creating it. For example, suppose you want to generate a peer class for the C++ class X. The tool looks in the package specified with the -import option for a Java version of X. If such a version is found, the tool does not generate a new peer class for X. The application can use the existing peer class. You can specify this option multiple times.
@ input_file You can use the @ input_file option to specify a file that contains arguments for the peer generator tool. The tool inserts the contents of the specified file in the command line before it begins to execute the command line. You can specify this option multiple times. An input file cannot itself include the @ input_file option. If it does, the tool treats it as the name of a class, which is not found.

-leaf Instructs the tool to generate a minimal definition for the peer classes of types specified after this option and before any -full option. When the tool generates a leaf peer class, the application cannot access C++ data or function members or any C++ base classes. The tool defines the Java peer class to inherit directly from CPlusPlus. It does not copy the inheritance structure from the C++ class. This option is useful when you want to prune a type graph to reduce the size of the interface code.
-map C++_name
Java_peer_name
Allows you to specify the name of the Java peer class that you want to identify a particular C++ class. When you specify this option, you need not rely on the default name mapping rules. This option is particularly useful for naming template classes. You can specify the -map option as many times as you need to. Follow each specification with 1 The name of a C++ class. You must also specify the name of the C++ class in the list of classes for which you want to generate peer classes.

2 The name of the Java peer class that you want to represent the C++ class. This can be a fully qualified class name or an unqualified class name. If it is unqualified, the peer generator tool places the Java peer class in the package you specify on the command line.

-map_existing
C++_name
Java_peer_name
Allows you to specify the name of an existing Java peer class that you want to identify a particular C++ class. This option is the same as the -map option, except that the Java peer class already exists or will exist. Consequently, the peer generator tool does not generate any peer code for the Java peer type. In a separate run of the peer generator tool, or manually, you must create the Java peer type. See the documentation for -map for additional details.
-nosynchronize Turns off automatic synchronization of peer methods. If you specify this option, your application is responsible for ensuring that only one thread at a time per session is accessing ObjectStore. Failure to prevent concurrent access to OSJI and peer method entry points can cause OSJI to fail.
-oldtemplates Causes the peer generator to map some C++ characters to Java equivalents used in previous releases of ObjectStore. In Developing ObjectStore Java Applications That Access C++, Chapter 2, Rules for Template Name Flattening shows which C++ characters are invalid in Java and which Java equivalents they are mapped to.
-synchronize Turns on automatic synchronization of peer methods. This is the default.
-suppress package. class. method Suppresses generation of the specified peer method. You should not need to specify this option frequently. However, if generated code for a particular method causes a problem for the compiler, this option allows you to prevent generation of that code. You must specify the package name, the class name, and the method name. Use this option in the following manner: 1 Run osjcgen without specifying this option.

2 Try to compile the generated code.

A particular peer method causes a problem.

3 Run osjcgen again and specify the same classes, but suppress generation of the peer method that causes the problem.

4 Determine how to work around the lack of the suppressed peer method.

If it is not possible to work around the method that is causing the problem, you must redefine the C++ method into a form that does not cause a problem when it is mapped to a peer method.



Example of Running the Peer Generator Tool

The following example generates a Java peer class for the CPerson class. If it does not already exist, the tool creates the MyPkg subdirectory in the MyDir directory. The tool puts the Java peer class in the MyPkg package/subdirectory. The mapping schema database that the tool uses to generate the peer class is CPerson.jadb. The tool places the generated C++ files (and the generated Java files) in the MyDir/MyPkg directory.

osjcgen -package MyPkg
      -native_interface jni
      -schema CPerson.jadb 
      -classdir MyDir 
-      libdir MyDir 
CPerson
If you specify

-libdir SomeOtherDir
the tool places the generated Java files in MyDir/MyPkg and the generated C++ files in SomeOtherDir/MyPkg.

Caution

If the tool generates files that have the same pathnames as your C++ source files, the tool overwrites the C++ source files without warning you. This can happen if you create your C++ source files in the package and directory that you specify with the -package, -classdir, and/or -libdir options to osjcgen.

For example, suppose you have the CPerson.cc C++ file in the /MyDir/MyPkg directory. When you run osjcgen, you specify the following on one line:

osjcgen 
      -package MyPkg 
      -native_inteface jni
      -schema CPerson.jadb 
      -classdir MyDir 
      -libdir MyDir 
CPerson
The peer generator tool generates these files:

/MyDir/MyPkg/CPerson.java
/MyDir/MyPkg/CPersonU.java
/MyDir/MyPkg/CPersonClassInfo.java
/MyDir/MyPkg/CPerson.cc
/MyDir/MyPkg/CPersonU.cc
An explanation of these files appears in Developing ObjectStore Java Applications That Access C++, Chapter 2, Overview of Tool Output. But as you can see, the tool would overwrite your CPerson.cc source file. On Solaris, you can work around this by specifying .CC instead of .cc in the C++ file name. On Windows, you can work around this by specifying .cpp instead of .cc in the C++ file name. Alternatively, you can either specify different directories for -classdir and/or -libdir, or you must not create C++ source files in the Java package subdirectory.

osjcheckdb: Checking References in a Database

The osjcheckdb utility or the Database.check() method checks the references in a database. This tool scans a database and checks that there are no references to destroyed objects. You can fix references to destroyed objects by finding the objects that contain the dangling references and overwriting the invalid references with something else, such as a null value. In addition to finding references to destroyed objects, the tool performs various consistency checks on the database.

If the tool does not find any problems, it does not produce any output.

Check paths

Before you invoke osjcheckdb from the command line, ensure that tools.zip or tools.jar is in your CLASSPATH variable. Also ensure that the distribution bin directory that contains osjcheckdb is in your PATH variable. The format for invoking this tool from the command line is

Command line

osjcheckdb database_name1.odb ...

You can specify one or more databases. Separate multiple specifications with a space. If osjcheckdb cannot check a database that you specify, it displays a message about the inaccessible database and continues to the next database.

Be sure to specify the name of the .odb file of the database.

The tool displays messages about any errors that it finds.

API

The function signature for invoking the API for this tool is

Database.check(java.io.PrintStream)
When ObjectStore executes this method, it operates on the committed contents of the database and on any changes that have been saved as a result of ObjectStore.evict() or ObjectStore.evictAll(). ObjectStore does not operate on any changes that have been made but not committed or evicted.

The method writes any errors it finds to the argument stream. It also returns a Boolean value, which is true if the references are valid and false if there are any bad references.

The osjgcdb tool requires

osjshowdb: Displaying Information About a Database

The osjshowdb utility displays information about one or more databases. This utility is useful when you want to know how many and what types of objects are in a database. You can use this utility to verify the general contents of the database.

This utility displays the following information:

-showObjs option

If you specify the -showObjs option, the osjshowdb utility also displays the following information for each object:

-showData option

Specify the -showData option with osjshowdb to display string values as well as the references an object contains. When you specify the -showData option, it implies the -showObjs option.

Path variables

Before you invoke osjshowdb from the command line, ensure that tools.zip or tools.jar is in your CLASSPATH environment variable. Also ensure that the distribution bin directory that contains osjshowdb is in your PATH variable.

Command line

To execute the osjshowdb utility, use this format:

osjshowdb [-showData] [-showObjs] db1.odb [ db2.odb]...

You can specify one or more databases.

When the utility displays java.lang.String objects, the number of elements is the number of characters in the string. The total bytes indicates the number of bytes that the data occupies on the disk.

There are some internal structures in the database that are not included in the calculations performed by the osjshowdb utility. Consequently, the total number of bytes as indicated in the output from osjshowdb is never equal to the actual size of a segment.

API

The API for the osjshowdb utility is Database.show().

When ObjectStore executes this method, it operates on the committed contents of the database and on any changes that have been saved as a result of ObjectStore.evict() or ObjectStore.evictAll(). ObjectStore does not operate on any changes that have been made but not committed or evicted.

Sample output

customers.odb

Here is some sample output from the osjshowdb utility for the customers and problems databases produced by the tracker demo.

osjshowdb -showObjs customers.odb
Name: customers.odb
There are 2 roots:
  Name: _DMA_Database_header   Type: _DMSS_Database_header
  Name: customers   Type: COM.odi.coll.imp.DictPeer_String
Destroyed Objects: 4
Segment: 0
Size: 48128 (47 Kbytes)
      Total
OID      Data Offset      Elements      Bytes      Type
      Count      Tot Size      Type
      (bytes)
Segment: 2
Size: 8192 (8 Kbytes)
       Total
OID      Data Offset      Elements      Bytes      Type
<1|2|256>      256            24        COM.odi.coll.imp.DictPeer_String
<1|2|452>      452      18      32        java.lang.String
<1|2|520>      520      32      396      java.lang.Object[]
<1|2|928>      928            16      COM.odi.util.OSVectorEntry
<1|2|944>      944      1      20      COM.odi.util.OSVectorEntry[]
<1|2|1008>      1008        17      32      java.lang.String
<1|2|1040>      1040            36      COM.odi.demo.tracker.Customer
<1|2|1076>      1076      32      396      java.lang.Object[]
<1|2|1480>      1480            16      COM.odi.util.OSVectorEntry
<1|2|1496>      1496      1      20      COM.odi.util.OSVectorEntry[]
<1|2|1528>      1528      44      60       java.lang.String
<1|2|1588>      1588            36      COM.odi.demo.tracker.Customer
      Count      Tot Size      Type
      (bytes)
      1      24        COM.odi.coll.imp.DictPeer_String
      2      56        COM.odi.demo.tracker.Customer
      2      56        java.lang.String
Segment: 4
Size: 4096 (4 Kbytes)
       Total
OID      Data Offset      Elements      Bytes      Type
      Count      Tot Size      Type
      (bytes)

problems.odb

osjshowdb -showObjs problems.odb
Name: problems.odb
There are 3 roots:
  Name: _DMA_Database_header   Type: _DMSS_Database_header
  Name: problems   Type: COM.odi.coll.imp.DictPeer_String
  Name: reportSegmentId   Type: java.lang.Integer
Segment: 0
Size: 54272 (53 Kbytes)
       Total
OID      Data Offset      Elements      Bytes      Type
      Count      Tot Size      Type
      (bytes)
Segment: 2
Size: 8192 (8 Kbytes)
       Total
OID      Data Offset      Elements      Bytes      Type
<2|2|256>      256            24        COM.odi.coll.imp.DictPeer_String
<2|2|452>      452      18              32        java.lang.String
<2|2|484>      484            36        COM.odi.demo.tracker.Problem
<2|2|520>      520      32             396        java.lang.Object[]
<2|2|928>      928            16        COM.odi.util.OSVectorEntry
<2|2|944>      944      1              20        COM.odi.util.OSVectorEntry[]
<2|2|1008>      1008      17              32        java.lang.String
<2|2|1040>      1040            36        COM.odi.demo.tracker.Problem
<2|2|1076>      1076      32             396       java.lang.Object[]
<2|2|1480>      1480            16        COM.odi.util.OSVectorEntry
<2|2|1588>      1588            36        COM.odi.demo.tracker.Problem
      Count      Tot Size      Type
      (bytes)
      1              24        COM.odi.coll.imp.DictPeer_String
      3             108        COM.odi.demo.tracker.Problem
      2             64        COM.odi.util.OSVector
      2              32        COM.odi.util.OSVectorEntry
      2              40        COM.odi.util.OSVectorEntry[]
      3             124       java.lang.String
Segment: 4
Size: 4608 (5 Kbytes)
      Total
OID      Data Offset      Elements      Bytes      Type
<1|4|1616>      1616            8  java.lang.Integer
      Count      Tot Size      Type
      (bytes)
            1           8          java.lang.Integer
Segment: 6
Size: 9216 (9 Kbytes)
      Total
OID      Data Offset      Elements      Bytes      Type
<1|6|288>      288      38              52        java.lang.String
<1|6|340>      340            20        COM.odi.demo.tracker.Report
<1|6|360>      360      32             396       java.lang.Object[]
<1|6|768>      768            16        COM.odi.util.OSVectorEntry
<1|6|784>      784      1      20        COM.odi.util.OSVectorEntry[]
<1|6|816>      816      100             116        java.lang.String
<1|6|932>      932            20        COM.odi.demo.tracker.Report
<1|6|952>      952      25              40        java.lang.String
<1|6|992>      992            20        COM.odi.demo.tracker.Report
<1|6|1012>      1012      12              28        java.lang.String
<1|6|1040>      1040            20        COM.odi.demo.tracker.Report
<1|6|1092>      1092      78              92        java.lang.String
<1|6|1184>      1184            20        COM.odi.demo.tracker.Report
<1|6|1204>      1204      32             396        java.lang.Object[]
<1|6|1608>      1608            16        COM.odi.util.OSVectorEntry
<1|6|1624>      1624            20        COM.odi.util.OSVectorEntry[]
<1|6|1656>      1656      80              96        java.lang.String
<1|6|1752>      1752             20       COM.odi.demo.tracker.Report
<1|6|1772>      1772      56              72        java.lang.String
<1|6|1844>      1844            20        COM.odi.demo.tracker.Report
<1|6|1864>      1864      76              92        java.lang.String
<1|6|1956>      1956            20      COM.odi.demo.tracker.Report
<1|6|2008>      2008      62              76        java.lang.String
<1|6|2084>      2084            20        COM.odi.demo.tracker.Report
<1|6|2104>      2104      32             396        java.lang.Object[]
<1|6|2512>      2512            16        COM.odi.util.OSVectorEntry
<1|6|2528>      2528      1              20        COM.odi.util.OSVectorEntry[]
<1|6|2560>      2560      109             124       java.lang.String
<1|6|2684>      2684            20        COM.odi.demo.tracker.Report
      Count      Tot Size      Type
      (bytes)
      10             200        COM.odi.demo.tracker.Report
      3              96        COM.odi.util.OSVector
      3              48        COM.odi.util.OSVectorEntry
      3              60        COM.odi.util.OSVectorEntry[]
      3            1188        java.lang.Object[]
      10             788        java.lang.String

osjuphsh: Upgrading String Hash Codes in Databases

The osjuphsh utility is the command line utility for upgrading databases to use the correct String hash code. Invoke this tool with the following format:

osjuphsh [ options] database_name

For example:

osjuphsh db.odb

Execution of this command is the same operation as a call to the COM.odi.Upgrade.upgradeDatabaseStringHash() method on the db.odb database with the upgradeObjects argument set to true and the multipleTransactions argument set to false.

The options you can specify are:

Option Description
-skipobjects Specifies that the database contains no objects that depend on String.hashCode().
-multitrans Specifies that each object should be upgraded in a separate transaction.
-verbose Specifies that verbose information about the upgrade should be displayed. This includes displaying information about databases that do not require upgrading.

osjversion: Obtaining ObjectStore Version Information

You can use the osjversion utility to display the version number and the build date for the version of ObjectStore you are running. This command is in the bin subdirectory of the installation directory. You must include bin in your path to run osjversion. For example:

% osjversion
Java interface Release 3.0 to ObjectStore Release 5.1, 98-09-22 10:07:16 on buildhost

%

This command is useful when you want to ensure that you have the right version in your path.

You can also run the unzip -z command against any ObjectStore .zip file. Doing so allows you to see what version of ObjectStore the .zip file contains. For example:

% unzip -z osji.zip

Archive: osji.zip Java interface 3.0 to ObjectStore Release 5.1.
98-04-22 10:07:56 on buildhost,

Copyright 1996, 1997, 1998 Object Design, Inc. All rights reserved.

%

The osjversion utility checks what is available through the PATH environment variable. To check what is available through the CLASSPATH variable, you can write a program like the following.

import COM.odi.ObjectStore;
class OSVersion {
      public static void main (String[] args) {
            ObjectStore.initialize(null,null);
            System.out.println(ObjectStore.releaseName());
      }
}



[previous] [next]

Copyright © 1998 Object Design, Inc. All rights reserved.

Updated: 10/07/98 08:46:31