Berkeley DB Tree Size

Hi,
I am using berkeley DB to store large number of keys/values. I set the database type to BTREE i.e. for example DbConfig.setType(DatabaseType.BTREE);
Please I want to ask if the speed of retrieving key/value from berkeley database defined above depends on the key/value size. in other words, if the value size for example was 2MB then over the time it increased to 4MB does this affects the performance of retrieving...? if yes then please tell me how to overcome this problem?
Best regards,
Ahmad.

Hi Ahmad,
Is this a hypothetical question, or did you experience any problems with retrieving records?
Will you use transactions in your application? What release of Berkeley DB are you using and what API?
How many separate processes does your application have? How many threads of control in each process? What is the number of threads of control which will simultaneously retrieve records from the database?
Is the database configured to support record numbers?
Is the database configured for duplicate data items?
What do the keys look like?
How the data is retrieved (using partial retrieval, cursors, etc.)? How are the keys sorted? What is the cache size?
Related docs:
Retrieving Btree records by logical record number: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/bt_recnum.html
Retrieving records: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am/get.html
Retrieving records with a cursor: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am/curget.html
Retrieving records in bulk: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_misc/get_bulk.html
Partial record storage and retrieval: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_misc/partial.html
Retrieved key/data permanence for C/C++: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_misc/perm.html
Access method tuning (there is a paragraph for large key/data items): http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_misc/tune.html
The page size implicitly sets the size of an overflow record. Overflow records are key or data items that are too large to fit on a normal database page because of their size, and are therefore stored in overflow pages. Overflow pages are pages that exist outside of the normal database structure. For this reason, there is often a significant performance penalty associated with retrieving or modifying overflow records.
Usually, having large records should make the cache too hot, since a significant part of the cache will have to be flushed in order to retrieve a new data item. I think that if you want to test this, you'll have to do it in a multi-threaded program.
Also, performance will be better if all of the pages that make up a large record are contiguous, and that happens by default if the records are inserted in order.
Bogdan Coman

Similar Messages

  • Question of Berkeley DB "cache size"

    quote:
    Set the size of the shared memory buffer pool, that is, the size of the cache.
    The cache should be the size of the normal working data set of the application, with some small amount of additional memory for unusual situations. (Note: the working set is not the same as the number of pages accessed simultaneously, and is usually much larger.)
    The default cache size is 256KB, and may not be specified as less than 20KB. Any cache size less than 500MB is automatically increased by 25% to account for buffer pool overhead; cache sizes larger than 500MB are used as specified. The current maximum size of a single cache is 4GB. (All sizes are in powers-of-two, that is, 256KB is 2^18 not 256,000.)
    The database environment's cache size may also be set using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_cachesize", one or more whitespace characters, and the cache size specified in three parts: the gigabytes of cache, the additional bytes of cache, and the number of caches, also separated by whitespace characters. For example, "set_cachesize 2 524288000 3" would create a 2.5GB logical cache, split between three physical caches. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.
    This method configures a database environment, including all threads of control accessing the database environment, not only the operations performed using a specified Environment handle.
    This method may not be called after the environment has been opened. If joining an existing database environment, any information specified to this method will be ignored.
    This method may be called at any time during the life of the application.
    Parameters:
    cacheSize The size of the shared memory buffer pool, that is, the size of the cache.
    The question:
    When I have a host, the memory total is 16G.
    I don't know what mean of this document.
    How many max cache size can be set ?
    4G? 16G?
    or cacheCount (4)* 4G = 16G?
    My Email: [email protected]

    What version of Berkeley DB are you using?
    I'm a little confused about what you are quoting. Most of your quote seems to be from DB_ENV->set_cachesize(), but set_cachesize does not have a parameter named cacheSize. The parameters for set_cachesize are gbytes, bytes and ncache.
    You use set_cachesize to specify the logical cache that you can optionally split into more than one physical region. The maximum size of the logical cache is 4GB and there is only one logical cache. You specify the total size of the logical cache with the gbytes and bytes parameters. If you set ncache to a value greater than 1, you split this logical cache into separate physical regions. So, for example, if you specify (gbytes=2, bytes=0, ncache=1) you will have a logical cache of 2GB that internally is split into 2 separate physical regions of 1GB each.
    You can read more about the memory pool cache in the Reference Guide sections "Selecting a cache size" and "Configuring the memory pool".
    If you have other Berkeley DB questions that are not specific to replication, you should direct them to the general Berkeley DB forum where you will have the benefit of a wider set of Berkeley DB experts:
    Berkeley DB
    Paula Bingham
    Oracle

  • Tree size for TreeByNesting UI Element

    Hi
    I have table and a Tree embedded in it.
    I have mapped a value Attribute to the table property  for no of rows to visible.
    When the User Expands a Tree node I am trying to use onActionLoad Children to find out no of children and try to set the same to the value Attribute.
    But there is no event getting generated when user Collapses the tree Node to determine the size of the Table.
    please let me know in case we can achive the same by other means.
    Thank you
    Regards
    Krishna Kanth

    hai krishna,
               Say A-parent B-parent
                a1,a2,a3 -- b1,b2,b3 are children
        the children will be available in a table in backend.just loop the table and get the children under parent A and load them under A |||ly do it for parent B.Please give ur requirement in detail.
    Regards
    Sharanya.R

  • Tree size of expanded items

    Hello,
    I have a MasterColumn to represent a tree-like hierarchy in a table
    and I wonder how I can retrieve the total number of expanded lines of the
    tree at runtime, ie retrieving the number "n" that is displayed in the
    table footer "Row x of n"
    Thanks and best regards,
    Laurent

    Laurent,
    Check my post /people/valery.silaev/blog/2005/06/20/master-of-columns-part-ii
    Copy from there method sizeOf(<nodeElement>);
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Tree Size Limitation Error

    Hi, i have the problem that when i fill a tree box with over 5000 entries, the entries over a spezified number are showed completely gray, that means there is a border where the whole box is turning in gray and you can't read anything. Turning back with scroll panel i can read the entries again.
    I have the Labview Version 7.1, but i don't think the version has anything to do with it. Maybe someone knows the reason?

    Hi Alicona,
    normally you are only limited by the limits of your operating system. In the case of 32bit-OS's you are able to have 2^31-1 entries.
    I don't know what is going wrong on your side, so it would be the best if you could send me a little example that shows your wrong behavior.
    National Instruments
    District Sales Manager

  • Tree size, change width

    HI,
    I have created a layout page. It consists of 2 colons (narrow-wide). I want to change the narrow (left side) to a smaller width. Does anyone know how to?
    I have tried the menu:
    System Administration -> System Configuration -> Knowledge Management -> Content Management -> User Interface -> Settings -> Resource Render Settings -> CustomerTreeResourceRender
    and set the width size to 70px, but this doesn't make any changes on my page.
    Any hints?
    Kr,
    hilde

    Hi Hilde,
    As far as I understand you want to modify a page layout to have different proportions.
    The way to do this is to create a portal component which has a new layout (you could in theory overwrite SAP standard for narrow-wide, but this is not recommended).
    See http://help.sap.com/saphelp_nw04s/helpdata/en/42/efe25b0d301aa2e10000000a422035/frameset.htm
    Suggest you just use the narrowWide.jsp (see C:\usr\sap\<sid>\JC00\j2ee\cluster\server0\src\irj\servlet_jsp\irj\root\WEB-INF\portal\portalapps\com.sap.portal.layouts.default\jsp )as a starting point and just change the proportions in your own code.
    narrowWide.jsp:
    <%@ taglib uri="prt:taglib:com.sap.portal.reserved.layout.TagLibHtmlb" prefix="hbj" %>
    <%@ taglib uri="prt:taglib:com.sap.portal.reserved.layout.TagLibLayout" prefix="lyt" %>
    <lyt:template>
        <hbj:content id="myContext" >
            <hbj:page title="Portal Page">
                <hbj:gridLayout   id="GridLayout1"  width="100%" cellSpacing="2">
                    <hbj:gridLayoutCell rowIndex="1" columnIndex="1" width="30%" verticalAlignment="top">
                        <lyt:container id="column1" />
                    </hbj:gridLayoutCell>
                    <hbj:gridLayoutCell rowIndex="1" columnIndex="2" width="70%" verticalAlignment="top">
                        <lyt:container id="column2" />
                    </hbj:gridLayoutCell>
                </hbj:gridLayout>
            </hbj:page>
        </hbj:content>
    </lyt:template>
    Regards
    Dagfinn
    PS afterwards you of course has to assign the new layout to your page

  • Why only gets one node when select many nodes of tree in DWCS4 on Mac OS

    I use tag <mm:treecontrol> to create tree in DWCS4 on Mac OS.
    When I select many nodes in tree, but I only get one node by method: selectedNodes.
    codes of created tree as following:
    <mm:treecontrol name='tree' size='20' multiple noheaders>
         <mm:treecolumn state='hidden'>
              <mm:treenode value='A' state='expanded'></mm:treenode>
              <mm:treenode value='B' state='expanded'></mm:treenode>
              <mm:treenode value='C' state='expanded'></mm:treenode>
    </mm:treecontrol>
    Who can  tell me reasons?
    Thanks!
    comments: if don't use tag <mm:treecolumn>, tree will not show on Mac OS.

    Hi macbig,
    I finally got to look at my sister's computer. The HDD "Repair Disk" found missing threads, missing directory records, etc. and ended with:
    Error: Disk Utility can't repair this disk. Back up as many of your files as possible, reformat the disk, and restore your backed-
    up files.
    Then, I tried "Verify Disk" and it found invalid volume file count and ended with:
    The volume Macintosh HD was found corrupted and needs to be repaired.
    Error: This disk needs to be repaired. Click Repair Disk
    I guess running Apple Hardware Test is not going to happen. :/
    I've ordered online a new 2.5 disk, make a Maverick boot USB, and start from scratch. Do you have any other suggestions?
    As for the corrupted old hard drive, do you have any suggestions of how to get out the data somehow?
    Thank you so much!

  • Folder Size in Explorer, Windows 7

    Dear Readers:
    I would like to know if Windows 7 includes the option to view Folder Size in the Explorer window interface (an option similar to viewing [file] Size)?  I have attempted to use various software to do this in Windows Vista such as Tree Size Professional but the help files say that Windows Vista does not allow viewing of Folder Sizes in Explorer.
    Sincerely,
    penciline

    For those who like to roll their own,  this VB Script code will work with Windows 7 and show a simple list with folders and sizes from a cmd prompt.  You can specify the depth.  It's very fast.  Run with no parameters for instructions.
    ' ====================================================================
    ' DirSize7.vbs
    ' Used to display dir sizes in Windows 7 or XP.
    ' To Use:  cscript DirSize7.vbs C:\temp 4
    '     Where:
    '       First parm  = The dir to start with (default = script dir)
    '       Second parm = number of child dirs to display (default = 4)
    ' 2010/7/20 - Tom Woodgerd - Upgraded from DirSizeXP.  Added code to handle folders with no access.
    ' ====================================================================
    option explicit         ' Require declaration of variables.
    Dim arrArgs
    Dim strTopDir
    Dim numDepth
    Dim iii
    Dim strEOL
    Dim strTab
    Dim ws
    Dim fso
    Dim strFolder
    Dim arrFolderCollection1
    Dim arrFolderCollection2
    Dim arrFolderCollection3
    Dim arrFolderCollection4
    Dim strDisp
    Dim strF1
    Dim strF2
    Dim strF3
    Dim strF4
    Dim strRootFolder
    Dim int_strF1Size
    Set ws = WScript.CreateObject ("Wscript.Shell")
    strEOL = chr(10) & chr(13)
    strTab = chr(9)
    Set fso = CreateObject("Scripting.FileSystemObject")
    ' ---------------  Get command line arguments.
    Set arrArgs = WScript.Arguments
    ' --------- Get folder from command line or if none, the script dir.
    If arrArgs.Count > 0 Then
      strTopDir = arrArgs(0)
    Else
      strTopDir = fso.GetParentFolderName(Wscript.ScriptFullName)
    End If
    ' --------- Get depth from command line or default = 4.
    If arrArgs.Count > 1 Then
      numDepth = arrArgs(1)
      If numDepth > 4 Then
        numDepth = 4
      End If
    Else
      numDepth = 4
    End if
    If arrArgs.Count > 0 Then
      WScript.Echo "====================================================================++======"
      WScript.Echo "DirSize7:          Starting From: " & strTopDir & "    Depth = " & numDepth
      WScript.Echo ""
      WScript.Echo "=========================================================(Ver 7/20/2010)===="
    Else
      WScript.Echo "======================================================================++===="
      WScript.Echo "DirSize7:          Starting From: " & strTopDir & "    Depth = " & numDepth
      WScript.Echo ""
      WScript.Echo "     Useage: cscript dirsize7.vbs D:\temp 3"
      WScript.Echo "     Where:"
      WScript.Echo "       Starting Directory = D:\temp"
      WScript.Echo "       Deepest folder to display = 3 (up to 4 max)"
      WScript.Echo ""
      WScript.Echo "==========================================================(Ver 7/20/2010)==="
    End If
    ' --------- Main Loop ---------------------------------------------
    Set strFolder = fso.GetFolder(strTopDir)
    If Not strFolder.IsRootFolder then
      int_strF1Size = 0
      On Error Resume Next
      int_strF1Size = strFolder.size
      If int_strF1Size = 0 then       '--- See if we have access.
        WScript.Echo "----No Access---- "  & strFolder
        WScript.quit
      Else
        WScript.Echo f_AddCommas(strFolder.size), " "& strFolder
      end if
    End If
    Set arrFolderCollection1 = strFolder.SubFolders
    For Each strF1 in arrFolderCollection1
      int_strF1Size = 0
      On Error Resume Next
      int_strF1Size = strF1.size
      If int_strF1Size = 0 then       '--- See if we have access.
        WScript.Echo " ----No Access---- "  & strF1
      Else
        WScript.Echo f_AddCommas(strF1.size), " "& chr(28)&" "& strF1
        If numDepth >= 2 Then '----------------------------- Start of 2nd level
          Set strFolder = fso.GetFolder(strF1)
          Set arrFolderCollection2 = strFolder.SubFolders
          For Each strF2 in arrFolderCollection2
            WScript.Echo f_AddCommas(strF2.size), "  "& chr(28)&" "& strF2
            If numDepth >= 3 Then '----------------------- Start of 3rd level
              Set strFolder = fso.GetFolder(strF2)
              Set arrFolderCollection3 = strFolder.SubFolders
              For Each strF3 in arrFolderCollection3
                WScript.Echo f_AddCommas(strF3.size), "   "& chr(28)&" "&  strF3
                  If numDepth >= 4 Then '----------------- Start of 4th level
                    Set strFolder = fso.GetFolder(strF3)
                    Set arrFolderCollection4 = strFolder.SubFolders
                    For Each strF4 in arrFolderCollection4
                      WScript.Echo f_AddCommas(strF4.size), "    "& chr(28)&" "&  strF4
                    Next
                  End If '--------------------------------- End of 4th level
                Next
            End If '----------------------------------- End of 3rd level
          Next
        End If ' ---------------------------------- End of 2nd Level
      End if
    Next
    ' -------------------------- Format a numeric string with commas
    Function f_AddCommas(parmStr)
      Dim strTemp
      ' ---- Drop the ".00"
      strTemp = left(formatcurrency(parmStr), Instr(formatcurrency(parmStr), ".")-1 )
      strTemp = mid(strTemp,2)  ' Drop the $
      f_AddCommas = space(15-len(strTemp)) & strTemp
    End Function

  • ALV tree using Objects

    Hi,
    I am making an ALV tree using objects and the code is crashing due to an error in the Screen 100 ( which I am using ). I tried to implement the example provided at http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm but that is not working.
    Can anyone please tell me a working example or a brief tutorial so that I can correct the logical errors in my code.
    Thanks,
    Gaurav

    Hi,
    Check whether u have uncommented the PAI and PBO modules.
    Try this one.
    REPORT ZZZTEST_3
           NO STANDARD PAGE HEADING
           MESSAGE-ID zcs_cs_001.
    1/ Report Name: ZZZ_ALV_TREE_DEMO
    The definition and implementation of the event reciever class
    include <icon>.
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    class lcl_event_receiver definition deferred.
    data :
         Alv Containers
         tree definition
           o_tree type ref to cl_gui_simple_tree,
         Event Handler
           o_eventreceiver     type ref to lcl_event_receiver,
           o_dockingcontainer TYPE REF TO cl_gui_docking_container.
    data :
        node structures for tree building
          i_nodes type table of abdemonode, " node table def create bespoke
          w_nodes like line of i_nodes,     " work area
          i_tree_event type cntl_simple_events, " Itab for Tree Events
          w_tree_event type cntl_simple_event.   " Work area for Tree Events
    data:
           v_ratio1            type i,     "docking container screen area
    container screen area
           v_action(12)        type c.
    Internal Tables Used for Object ALV Display.
    data:
          i_toolbar           type table of stb_button,  "Tool bar for Grid1
          i_exclude1          type ui_functions,
          i_exclude2          type ui_functions,
          i_groups            type lvc_t_sgrp,  " Group Definitions
          i_selected_rows     type lvc_t_row.   " Select row type
    constants: c_x(1)    type c value 'X',             "Checked
               c_a(1)    type c value 'A'.             "All Layouts
          CLASS lcl_event_receiver DEFINITION
    class lcl_event_receiver definition.
      event receiver definitions for ALV actions
      public section.
        class-methods:
    Status bar
           handle_user_command
            for event user_command of cl_gui_alv_grid
                importing e_ucomm,
    Tree Actions
          handle_node_double_click
            for event node_double_click of cl_gui_simple_tree
            importing node_key,
    Row Double click for dirll down.
           handle_double_click
             for event double_click of cl_gui_alv_grid
                importing e_row
                          e_column
                          es_row_no.
    endclass.
    Implementation
    Every event handler that is specified below should also be set after
    the object has been created.  This is done in the PBO processing.
    with the following command
    SET HANDLER oEventreceiver->handle_toolbar FOR o_Alvgrid.
    class lcl_event_receiver implementation.
      method handle_user_command.
    In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
      endmethod.
    *&      Method handle_double_click
    This method is called when the user double clicks on a line to drill
    down.
    The following are exported from the ALV
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_double_click.
    The double click drill down processing should be
    coded in the form below.
      endmethod.
    *&      Method handle_node_double_click
    This method handles the node double click event of the tree
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_node_double_click.
       perform f9903_handle_node_double_click using node_key.
      endmethod.
    endclass.
    INITIALIZATION
    INITIALIZATION.
    PERFORM f050_initialize_values.
    FORM f050_initialize_values.
      v_ratio1 = 30.  "tree size
    ENDFORM.                    "  f050_initialize_values
    START-OF-SELECTION
    START-OF-SELECTION.
    END-OF-SELECTION
    END-OF-SELECTION.
      CALL SCREEN 9001.
    *Data Selection
    FORM f9000_objects_create USING    value(pobject)
                                 pparent
                                 value(pratio)
                                 value(prows)
                                 value(pcolumns).
      CASE pobject.
        WHEN  'o_dockingcontainer'.
          IF o_dockingcontainer IS INITIAL.
            CREATE OBJECT o_dockingcontainer
              EXPORTING
               side                        = v_dock_side1
                ratio                       = pratio  "amount of screen
              EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5
                others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
          WHEN 'o_tree'.
          IF o_tree IS INITIAL.
            CREATE OBJECT o_tree
             EXPORTING
            LIFETIME                    =
               parent                      = pparent
            SHELLSTYLE                  =
               node_selection_mode         = o_tree->node_sel_mode_single
            HIDE_SELECTION              =
              name                        = 'Transactions'
             EXCEPTIONS
               lifetime_error              = 1
               cntl_system_error           = 2
               create_error                = 3
                failed                     = 4
               illegal_node_selection_mode = 5
               others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
        WHEN 'o_eventreceiver'.
          IF o_eventreceiver IS INITIAL.
            CREATE OBJECT o_eventreceiver.
            PERFORM f9800_error_handle USING text-e08.
          ENDIF.
        WHEN OTHERS.
       do nothing
      ENDCASE.
    ENDFORM.                    " f9000_objects_create
    *&      Form  f9100_create_tree
          Create the Tree
         -->P_O_TREE  tree data
    FORM f9100_create_tree USING p_o_tree TYPE REF TO cl_gui_simple_tree.
      REFRESH: i_nodes.
      CLEAR: w_nodes.
    Header Tree Folder
      w_nodes-node_key = 'ROOT'.
      w_nodes-isfolder = c_x.
      w_nodes-expander = c_x.
      w_nodes-text = 'Transactions'.
      APPEND w_nodes TO i_nodes.
    Adding Root Nodes for the tree.
    Key:
    NODE_KEY, RELATKEY, RELATSHIP, HIDDEN, DISABLED, ISFOLDER, N_IMAGE,
    EXP_IMAGE, STYLE, LAST_HITEM, NO_BRANCH, EXPANDER, DRAGDROPID, TEXT
      PERFORM f9101_node_list USING: '1' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Sales Orders'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VA01' '1' '' '' '' '' '@[email protected]' '' '' '' '' ''
                              '' 'Create Sales Orders',
                            Document Details
                              'VA02' '1' '' '' '' '' '@[email protected]' '' '' '' '' ''
                               '' 'Change Sales Orders'.
      PERFORM f9101_node_list USING: '2' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Deliveries'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VL01' '2' '' '' '' '' '@[email protected]' '' '' '' '' ''
                              '' 'Create Outbound Delivery',
                            Document Details
                              'VL02' '2' '' '' '' '' '@[email protected]' '' '' '' '' ''
                              '' 'Change Outbound Delivery'.
    add the nodes to the tree object,
      PERFORM f9102_add_treenodes TABLES i_nodes
                                 USING 'ABDEMONODE'  "node definition
                                        p_o_tree.       "tree declaration
    enabling event handlers for the tree
      PERFORM f9103_tree_event_handle USING p_o_tree.
    ENDFORM.                    " f9100_create_tree
    *&      Form  f9101_node_list
          Adding Nodes in a TREE
    FORM f9101_node_list USING    value(pnodekey)
                                 value(prelatkey)
                                 value(prelatship)
                                 value(phidden)
                                 value(pdisabled)
                                 value(pisfolder)
                                 value(pimage)
                                 value(pexpimage)
                                 value(pstyle)
                                 value(plastitem)
                                 value(pnobranch)
                                 value(pexpander)
                                 value(pdragdropid)
                                 value(ptext).
      w_nodes-node_key   = pnodekey.
      w_nodes-relatkey   = prelatkey.
      w_nodes-relatship  = prelatship. "Natural number
      w_nodes-hidden     = phidden.
      w_nodes-disabled   = pdisabled.
      w_nodes-isfolder   = pisfolder.
      w_nodes-n_image    =  pimage.  "Icons / embedded bitmap
      w_nodes-exp_image  = pexpimage. "Icons / embedded bitmap
      w_nodes-style      = pstyle.
      w_nodes-last_hitem = plastitem. "Tree Control: Column Name / Item
      "Name
      w_nodes-no_branch  = pnobranch.
      w_nodes-expander   = pexpander.
      w_nodes-dragdropid = pdragdropid.
      w_nodes-text       = ptext.
      APPEND w_nodes TO i_nodes.
    ENDFORM.                    " f9101_node_list
    *&      Form  f9102_add_treenodes
          Adding the Nodes to the Tree
         -->PI_NODES  Table containg the Nodes
         -->PTABLE    Name of the Table structure name
         -->PO_TREE   tree object
    FORM f9102_add_treenodes TABLES pi_nodes TYPE STANDARD TABLE
                            USING  value(ptable)
                                   po_tree TYPE REF TO cl_gui_simple_tree.
      CALL METHOD po_tree->add_nodes
        EXPORTING
          table_structure_name           = ptable    "may need to change
          node_table                     = pi_nodes[]
        EXCEPTIONS
          error_in_node_table            = 1
          failed                         = 2
          dp_error                       = 3
          table_structure_name_not_found = 4
          OTHERS                         = 5
      PERFORM f9800_error_handle USING text-e10.
    ENDFORM.                    " f9102_add_treenodes
    *&      Form  f9103_tree_event_handle
          Event Handling for Tree.
         -->P_P_O_TREE  text
    FORM f9103_tree_event_handle USING
                                p_o_tree TYPE REF TO cl_gui_simple_tree.
      w_tree_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
      w_tree_event-appl_event = ' '. " process PAI if event occurs
      APPEND w_tree_event TO i_tree_event.
      CALL METHOD p_o_tree->set_registered_events
          EXPORTING
            events = i_tree_event
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
      IF sy-subrc <> 0.
       MESSAGE A000.
      ENDIF.
      IF o_eventreceiver IS INITIAL.
        CREATE OBJECT o_eventreceiver.
      ENDIF.
      SET HANDLER o_eventreceiver->handle_node_double_click FOR p_o_tree.
    ENDFORM.                    " f9103_tree_event_handle
         -->P_IEXCLUDE  text
         -->P_1150   text
    FORM f9200_exclude_functions USING   pexclude LIKE i_exclude1
                                   value(pfunction).
      DATA: l_exclude TYPE ui_func.
      l_exclude = pfunction.
      APPEND l_exclude TO pexclude.
    ENDFORM.                    " f9200_exclude_functions
    *&      Form  f9903_handle_node_double_click
          This form is used to handle the double click event for the tree
         -->P_NODE_KEY  Node clicked.
    FORM f9903_handle_node_double_click USING  p_node_key.
      CASE p_node_key.
        WHEN 'VA01'.
         SUBMIT ZZZ_TEST AND RETURN.
         CALL TRANSACTION 'VA01'. " and skip first screen.
        WHEN 'VA02'.
          CALL TRANSACTION 'VA02'. " and skip first screen.
        WHEN 'VL01'.
          CALL TRANSACTION 'VL01'. " and skip first screen.
        WHEN 'VL02'.
          CALL TRANSACTION 'VL02'. " and skip first screen.
        WHEN OTHERS.
        do nothning.
      ENDCASE.
    ENDFORM.                    " f9903_handle_node_double_click
    *&      Form  f9700_free_objects
    This form handles the freeing of the following objects
    ALV
    Docking Container
         -->P_O_ALVGRID  text
         -->P_0020   text
         -->P_0021   text
    FORM f9700_free_objects USING pobject
                        value(ptype)
                        value(ptext).
    Need to type the field symbol or it does not work
      CASE ptype.
        WHEN 'DOCKING'.
          DATA: l_odock TYPE REF TO cl_gui_docking_container.
          l_odock = pobject.
          IF NOT ( l_odock IS INITIAL ).
            CALL METHOD l_odock->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, l_odock.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN 'TREE'.
          DATA: l_otree TYPE REF TO cl_gui_simple_tree.
          l_otree = pobject.
          IF NOT ( l_otree IS INITIAL ).
            CALL METHOD l_otree->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error  = 2
                OTHERS            = 3.
            CLEAR: pobject, l_otree.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN OTHERS.
       do something.
      ENDCASE.
    ENDFORM.                    " f9700_free_objects
    *&      Form  f9800_error_handle
          Handles Errors
         -->P_PTEXT  text
    FORM f9800_error_handle USING    value(ptext).
      IF sy-subrc NE 0.
    add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e01
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    ENDFORM.                    " f9800_error_handle
    *PBO & PAI Modules
    *&      Module  STATUS_9001  OUTPUT
          text
    module status_9001 output.
    Set the Status Bar
      set pf-status 'Z_STATUS'.
    Set the Title
      set titlebar 'Z_TITLE'.
      perform f9000_objects_create using:
                create docking container
                  'o_dockingcontainer' '' v_ratio1 '' '',
                create a tree
                  'o_tree' o_dockingcontainer '' '' '',
                Create the event reciever
                  'o_eventreceiver' '' '' '' ''.
    Create the Tree View.
      perform f9100_create_tree using o_tree.
    endmodule.                 " STATUS_9001  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
          text
    module user_command_9001 input.
      case sy-ucomm.
        when 'EXIT' or  'CANC'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-E05,
                        o_eventreceiver 'EVENT' text-e09.
    leave program.
          leave.    " to SCREEN 0.
        when 'BACK'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-e05,
                        o_eventreceiver 'EVENT' text-E09.
          set screen '0'.
          leave screen.
        when others.
      endcase.
    endmodule.                 " USER_COMMAND_9001  INPUT
    Get back to me if u have any queries. Give me ur mail id, i will send one more sample code for ALV tree. This sample program will display only Tree not grid u can add ALV grid too.
    Thanks & Regards,
    Judith.

  • Sorted tree HW problem

    hi, i was wondering if someone could give me tips or pointer or even the solution :). all help is appreciated
    if you know of a tutorial besides the basic java one that would be gr8 too
    (2) Write a class named my_SortedTree with three methods.
    (i) Given a sequence of numbers (total number of numbers will be the full tree size 2n-1), sort them in an increasing order.
    (ii) Store the sorted sequence in a full binary tree so that use the �in order� traverse algorithm can print them in an increasing order. Note that your tree MUST be a full tree.
    For example, given �14 23 13 18 11 26 16� as input, your program should sort them first, so that the sequence is �11 13 14 16 18 23 26�, then insert those seven numbers into tree structure one by one, it should be 1623181311 1426
    (iii) Use the level-order traverse algorithm to print all of them.

    hi, i was wondering if someone could give me tips or
    pointer or even the solution :). all help is
    appreciated
    if you know of a tutorial besides the basic java one
    that would be gr8 too
    (2) Write a class named my_SortedTree with three
    methods.
    (i) Given a sequence of numbers (total number of
    numbers will be the full tree size 2n-1), sort them
    in an increasing order.
    (ii) Store the sorted sequence in a full binary tree
    so that use the �in order� traverse algorithm can
    print them in an increasing order. Note that your
    tree MUST be a full tree.
    For example, given �14 23 13 18 11 26 16� as input,
    your program should sort them first, so that the
    sequence is �11 13 14 16 18 23 26�, then insert those
    seven numbers into tree structure one by one, it
    should be 1623181311 1426
    (iii) Use the level-order traverse algorithm to print
    all of them.
    Here is a link to a pretty good tutorial example of ADT's in Java.
    It covers stacks, queues, Binary Search Trees, and much more...
    IMHO I would work through some of the examples and even diagram each step in the areas that are tough to visualize.
    JJ

  • Problem with tokenized  input from command line

    I am trying to take an input from the command line, parse it to tokens and perform whatever operation is needed depending on the name of the token, on a binary tree of stacks for example, if i type 1 2 1 3 printLevelOrder, then the root of the tree should have 3, 2,1 in the stack, the left child should have 1 and the right child should be empty. and then a level order print of the tree should be performed.
    however what is happening when i run this code is the numbers are being put into the right stacks of the tree, but any commands such as printLevelOrder or PrintPopRoot are entering the code that is for placing numbers onto the stack instead of executing that command and skipping past this piece of code.
    so my question is, why is the if statement if (word =="printLevelOrder") not being executed when thats whats in the word ?
    example input and output shown below code fragment.
              try {
                  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                 String line = "";
                 while (line != "***") {
                      System.out.print("> prompt ");
                      line = in.readLine();
                      StringTokenizer tokenizer = new StringTokenizer(line," ");
                      String word = new String();
                      while (tokenizer.hasMoreTokens()) {
                             word = tokenizer.nextToken();
                             boolean notCommand = true;
                             if (word =="printLevelOrder") {
                                  theTree.printLevelOrder();
                                  System.out.println("(word ==printLevelOrder)");
                                  notCommand=false;
                             if (word == "printPopLevelOrder") {
                                  theTree.printPopLevelOrder();
                                  notCommand=false;
                             if (word == "printPopInorder") {
                                  theTree.printPopInorder();
                                  notCommand=false;
                             if (word == "printPopPreorder") {
                                  theTree.printPopPreorder();
                                  notCommand=false;
                             if (word == "printPopRoot") {
                                  theTree.printPopRoot();
                                  notCommand=false;
                             if (word == "***") {
                                  notCommand=false;
                             if (notCommand == true) {
                                  System.out.println("(notCommand == true)");
                                  boolean notPlaced = true;
                                  int v = 1;
                                  while ((notPlaced==true) && (v < theTree.size())) {
                                       if (theTree.element(v).isEmpty()) {
                                            theTree.element(v).push(Integer.valueOf(word));
                                            System.out.println("Inserting"+word);
                                            System.out.println("in empty stack at location: "+v);
                                            notPlaced=false;
                                       if (notPlaced==true) {
                                            if (  Integer.valueOf(word) >= Integer.valueOf( theTree.element(v).top().toString() )  ) {
                                                 theTree.element(v).push(Integer.valueOf(word));
                                                 System.out.println("Inserting"+word);
                                                 System.out.println("in stack at location: "+v);
                                                 notPlaced=false;
                                       v++;
              }valid inputs: int value, printLevelOrder, printPopLevelOrder, printPopInorder, p
    rintPopPreorder, printPopRoot, *** to quit
    prompt 1 3 2 4 2 printLevelOrder(notCommand == true)
    Inserting1
    in empty stack at location: 1
    (notCommand == true)
    Inserting3
    in stack at location: 1
    (notCommand == true)
    Inserting2
    in empty stack at location: 2
    (notCommand == true)
    Inserting4
    in stack at location: 1
    (notCommand == true)
    Inserting2
    in stack at location: 2
    (notCommand == true)
    Exception in thread "main" java.lang.NumberFormatException: For input string: "printLevelOrder"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:447)
    at java.lang.Integer.valueOf(Integer.java:553)
    at TreeStack.main(TreeStack.java:73)
    Press any key to continue . . .

    lol aww, shame that you forgot to do that. i had 10 / 10 for mine, and seing as the deadline is now well and trully over,
    here is the entire source for anybody who was following the discussion or whatever and wanted to experiment.
    additional files needed >
    http://users.cs.cf.ac.uk/Paul.Rosin/CM0212/Stack.java
    http://users.cs.cf.ac.uk/Paul.Rosin/CM0212/ArrayStack.java
    http://users.cs.cf.ac.uk/Paul.Rosin/CM0212/StackEmptyException.java
    http://users.cs.cf.ac.uk/Paul.Rosin/CM0212/StackFullException.java
    /*TreeStack.java - reads command line input of values and assigns them to stacks in a  binary tree and performs
    operations on the ADT. valid inputs: <int>,   printLevelOrder,   printPopLevelOrder,
    printPopInorder,   printPopPreOrder,   printPopRoot.         Terminates on invalid input.
    Written by George St. Clair.
    S/N:0208456         22/11/2005
    import java.util.Vector;
    import java.io.*;
    import java.util.StringTokenizer;
    public class TreeStack {
         private final int TREE_CAPACITY = 7 + 1;
         private final int STACK_CAPACITY = 10;
         Vector tree = new Vector(TREE_CAPACITY) ;
         //collect input from command line, add values to stacks at nodes of the teee
         //and perform required operations on the treestack
         public static void main (String [] args) {
              //create a tree of stacks
              TreeStack theTree = new TreeStack ();
              try {
                   //collect standard input
                  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                 String line = "";
                 while (line != null) {
                        System.out.print("");
                      line = in.readLine();
                      //tokenise input
                      StringTokenizer tokenizer = new StringTokenizer(line," ");
                      String word = new String();
                      while (tokenizer.hasMoreTokens()) {
                             //assign word to the token
                             word = tokenizer.nextToken();
                             boolean notCommand = true;
                             //perform operation on treestack depending on what word is
                             if (word.equals("printLevelOrder"))  {
                                  System.out.println("printLevelOrder");
                                  theTree.printLevelOrder();
                                  notCommand=false;
                             if (word.equals("printPopLevelOrder"))  {
                                  System.out.println("printPopLevelOrder");
                                  theTree.printPopLevelOrder();
                                  notCommand=false;
                             if (word.equals("printPopInorder"))  {
                                  System.out.println("printPopInorder");
                                  theTree.printPopInorder();
                                  notCommand=false;
                             if (word.equals("printPopPreorder"))  {
                                  System.out.println("printPopPreorder");
                                  theTree.printPopPreorder();
                                  notCommand=false;
                             if (word.equals("printPopRoot"))  {
                                  System.out.println("printPopRoot");
                                  theTree.printPopRoot();
                                  notCommand=false;
                             //if word was not a command it must be a number
                             if (notCommand == true) {
                                  boolean notPlaced = true;
                                  int v = 1;
                                  //starting at the root, find suitable place for number
                                  while ((notPlaced==true) && (v < theTree.size())) {
                                       //if the stack at v is empty, number goes here
                                       if (theTree.element(v).isEmpty()) {
                                            theTree.element(v).push(Integer.valueOf(word));
                                            System.out.println("inserting: "+word);
                                            System.out.println("in empty stack at location: "+(v-1));
                                            notPlaced=false;
                                       //if the stack is not empty
                                       if (notPlaced==true) {
                                            //if the value on the top of the stack is smaller than number, number goes onto the stack
                                            if (  Integer.valueOf(word) > Integer.valueOf( theTree.element(v).top().toString() )  ) {
                                                 theTree.element(v).push(Integer.valueOf(word));
                                                 System.out.println("inserting: "+word);
                                                 System.out.println("in stack at location: "+(v-1));
                                                 notPlaced=false;
                                       //if that node was no good, check the next one for suitability
                                       v++;
              catch (Exception e) {
                   //occurs when user inputs something that is neither a command, or a number, or upon EOF, or stack is full
         public TreeStack () {
              //create the TreeStack ADT by adding stacks in the vector, note vector 0 is instantiated but not used.
              for (int i = 1;i<=TREE_CAPACITY;i++)
                   tree.add(new ArrayStack(STACK_CAPACITY));
         public int size() {
              //return the size of the tree +1 (as 0 is not used)
              return tree.size();
         public ArrayStack element (int v) {
              //return the ArrayStack at v
              return (ArrayStack)tree.get(v);
         public int leftChild (int v ) {
              //return left child of v
              return v*2;
         public int rightChild (int v ) {
              //return the right child of v
              return v*2+1;
         public boolean children (int v ) {
              //search for children of v and return true if one exists
              for (int i =v;i<size();i++) {
                   if (i/2==v ) {
                         //left child found at i
                         return true;
                   if ((i-1)/2==v ) {
                        //right child found at i
                        return true;
              //no children found
              return false;
         public boolean isInternal (int v ) {
              //test whether node v is internal (has children)
              if (children (v)== true) {
                   //has children
                   return true;
              return false;
         //print the top value in each stack encountered on a level-order traversal of tree
         public void printLevelOrder() {
              //for every node of tree v
              for (int v = 1;v<size();v++) {
                   if (!element(v).isEmpty() ) {
                        //print the top value in stack v
                        System.out.println(" "+element(v).top());
                   else {
                        //stack at v is empty
                        System.out.println(" -");
         //pop off and print the top value in each stack encountered on a level-order traversal of tree
         public void printPopLevelOrder () {
              //pop off and print the top value in stack v
              for (int v = 1;v<size();v++) {
              //for each node of tree v
                   if (!element(v).isEmpty() ) {
                        //if v isnt empty print the top value in stack v
                        System.out.println(" "+element(v).top());
                        //pop the top value in the stack at v
                        element(v).pop();
                   else {
                        //stack at v is empty
                        System.out.println(" -");
         //pop off and print the top value in each stack encountered on an in-order traversal of tree
         public void printPopInorder () {
              printPopInorder (1);
         public void printPopInorder (int v) {
              boolean isInternal = false;
              if (isInternal (v)) {
                   //use a boolean for isInternal to save on running the method twice
                   isInternal = true;
                   //recursively search left subtree
                   printPopInorder (leftChild(v));
              //pop off and print the top value at v
              if (element(v).isEmpty() ) {
                   //stack at v is empty
                   System.out.println(" -");
              else {
                   //if v isnt empty print the top value in stack v then pop
                   System.out.println(" "+element(v).top());
                   element(v).pop();
              if (isInternal ) {
                   //recursively search right subtree
                   printPopInorder (rightChild(v));
         //pop off and print the top value in each stack encountered on an pre-order traversal of tree
         public void printPopPreorder() {
              printPopPreorder(1);
         public void printPopPreorder(int v) {
              //pop off and print the top value at v
              if (!element(v).isEmpty() ) {
                   //if v isnt empty print the top value in stack v then pop
                   System.out.println(" "+element(v).top());
                   element(v).pop();
              else {
                   //stack at v is empty
                   System.out.println(" -");
              if (isInternal (v)) {
                   //recursively search left and right subtrees
                   printPopPreorder (leftChild(v));
                   printPopPreorder (rightChild(v));
         //pop off and print all values from the stack at the root
         public void printPopRoot (){
              //while the root stack has values left
              while (!element(1).isEmpty()) {
                   //print, then pop
                   System.out.println(" "+element(1).top());
                   element(1).pop();
    }

  • JTree sizing question...

    Hello:
    I have a JTree for which each cell contains a button. I have written a renderer that renders the button, and I realize that I have to do some special stuff to capture a click on the button. My question is unrelated to all of that.
    The problem is that over time, the labels on my buttons change (and may become longer (wider)), but the tree size does not change. In fact, when I update the button label and the tree is re-rendered the rendering of the button gets "chopped off". I've put the tree in a scroll pane, but this doesn't help - the right side of some of the buttons get cut off to the original tree size. I've tried lots of different variations on setPreferredSize, calling repaint, etc, and am not having any luck. I've put together a demonstration of this behavior in a smallish application that I'm posting here, where I create a 2 node tree with buttons that read "Hi", then I change the button labels to "Goodbye" and re-render. You'll see that the button's are cut off about halfway through the button.
    In case its important - I'm running java version 1.5.0_07 on a 32-bit Linux box.
    Any help would be greatly appreciated. Thanks in advance!
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    public class JTreeQuestion
      public static void main(String [] args)
        JTreeFrame f = new JTreeFrame();
        f.pack();
        f.setLocation(30, 30);
        //Draws buttons with "Hi" (short string)
        f.setVisible(true);
        ButtonNode.updateString("Goodbye");
        //Draws buttons with longer string, buttons get "cut off"
        f.repaint();
    class JTreeFrame extends JFrame
      JTree tree;
      JScrollPane treeView;
      public JTreeFrame()
        super("My Tree");
        DefaultMutableTreeNode root;
        root = new DefaultMutableTreeNode(new ButtonNode());
        root.add(new DefaultMutableTreeNode(new ButtonNode()));
        tree = new JTree(root);
        tree.setCellRenderer(new ButtonNodeRenderer());
        treeView = new JScrollPane(tree);
        add(treeView);
    class ButtonNode
      public static String str = "Hi";
      public static void updateString(String inStr)
      { str = inStr; }
      String getStr()
      { return str; }
    class ButtonNodeRenderer extends DefaultTreeCellRenderer
      public Component getTreeCellRendererComponent(JTree tree,
                              Object value, boolean sel, boolean expanded,
                              boolean leaf, int row, boolean hasFocus)
        Box theBox = new Box(BoxLayout.X_AXIS);
        super.getTreeCellRendererComponent(tree, value, sel, expanded,
                                           leaf, row, hasFocus);
        DefaultMutableTreeNode jtreeNode = (DefaultMutableTreeNode)value;
        theBox.add(new JButton(((ButtonNode)jtreeNode.getUserObject()).getStr()));
        return (theBox);
    }

    For those who are interested. The DefaultTreeModel has a method named nodeChanged() that tells the tree model that a specific node has changed, and the model re-interprets the cell causing its sizse to change as necessary, so that the full button is rendered now.
    Basically what I did was instead of calling repain, I call a method that I wrote that loops through all the tree nodes, indicates they have changed, then repaint's, and it all works out. My trees are relatively small, so this is fine, but if others face the same problem, you'll probably want to selectively indicate which nodes have changed so the tree model doesn't have to do more work than necessary.

  • Fatal region error detected; run  Recovery

    I try include 2600 documents 1,06 GB and I have the message (Fatal region error detected; run Recovery ). I executed db_recover.exe to try resolve the problem without sucess. I did this test in 3 differents computers and I had the same problem. I am use a free version , I am studyng berkeley db xml and need test performance with a big collection of document xml. Why am I have problem if berkeley db xml is able to support terabyte in size.

    This message indicates that you are probably setting your Berkeley DB cache size too large. MapViewOfFile is the Windows API used to map the cache file. It will fail if Windows cannot find enough contiguous VM for the mapping.
    Regards,
    George
    I have about 30 documents ~10MB and I get this all
    the time.
    MapViewOfFile: Not enough storage is available to
    process this command.
    PANIC: Not enough space
    com.sleepycat.db.RunRecoveryException:
    DB_RUNRECOVERY: Fatal error, run database recovery:
    DB_RUNRECOVERY: Fatal error, run database recovery
    at
    t
    com.sleepycat.db.internal.db_javaJNI.DbEnv_open(Native
    Method)
    at
    t
    com.sleepycat.db.internal.DbEnv.open(DbEnv.java:262)
    at
    t
    com.sleepycat.db.EnvironmentConfig.openEnvironment(Env
    ironmentConfig.java:908)
    at
    t
    com.sleepycat.db.Environment.<init>(Environment.java:3
    0
    This is under WinXP with BDXML 2.3.10.

  • Serious lock problem - transaction has active cursors

    Hi,
    i use BDB C via the Java-API (4.6.21, developing with WindowsXP). Currently i am having serious problems with LOCK_NOT_GRANTED_EXCEPTIONS.
    My application is a queue implementation. One push objects into the database, another one reads them and a third one deletes entries with an outdated TTL (time-to-live). All of these processes are done by multiple dedicated threads what leads to highly concurrent situations.
    The TTL cleaning uses a tx-cursor which deletes entries that are too old. The inserter simply uses put(). The reader uses a cursor too, which starts with a pointer (via getSearchKey) or at the beginning of the database (if no start could be found, the pointer is then outdated as it was deleted by TTL cleaning run).
    The isolation level is at READ_COMMITTED. Sometimes i use RMW locks for reading and updating status information.
    So i implemented a lock detection which retries at least the inserts if a lock fails. The reads can fail and report their exceptions to the outside world. This seems to work fine. Sometimes i get some LOCK_NOT_GRANTED_EXCEPTIONS and the recovery should work. But it works only sometimes.
    BDB-C complains with "transaction has active cursors" (see txn.c - line 1186). All subsequent calls to rollback or commit or any other method of BDB-C handles fails then with a RunRecoveryException. I am absolutely sure, i have no open cursors, as i close them implicitly before tx.commit() or tx.abort(). I wrote a reference counter to ensure that and it shows always a count of 0 open cursors as expected.
    The whole process is of course quite heavy stress for the DB - i am actually read, write, delete and checkpoint the db at the same position at the same time.
    I am tending to introduce MVCC to avoid those locking issues. As i understood concurrent updates of the same db page with multiversion transactions may also cause DeadLockExceptions. Can i use RMW locks to avoid concurrent updates on the same pages with MVCC?
    Some hints?
    TIA
    Dirk

    Hi,
    I have created a patch for Berkeley DB 4.6.21, which outputs information about all cursor open and close operations. This should help you see which cursor is not being closed.
    If you apply the patch below to your Berkeley DB tree, and rebuild.
    Then add setVerbose(VerboseConfig.CURSOR, true), to your EnvironmentConfig initialization.
    It will send log messages to the output stream configured via EnvironmentConfig.setMessageStream(). The default is System.out.
    There will likely be a lot of output.
    Please let me know if this helps you resolve the problem. Otherwise, ask more questions ;)
    Regards,
    Alex Gorrod
    diff -rc db-4.6.21.orig/build_windows/db.h db-4.6.21/build_windows/db.h
    *** db-4.6.21.orig/build_windows/db.h     Fri Sep 28 01:32:08 2007
    --- db-4.6.21/build_windows/db.h     Mon May 12 17:29:52 2008
    *** 60,66 ****
      #define     DB_VERSION_MAJOR     4
      #define     DB_VERSION_MINOR     6
      #define     DB_VERSION_PATCH     21
    ! #define     DB_VERSION_STRING     "Berkeley DB 4.6.21: (September 27, 2007)"
    --- 60,66 ----
      #define     DB_VERSION_MAJOR     4
      #define     DB_VERSION_MINOR     6
      #define     DB_VERSION_PATCH     21
    ! #define     DB_VERSION_STRING     "Berkeley DB 4.6.21: (May 12, 2008)"
    *** 2133,2138 ****
    --- 2133,2139 ----
      #define     DB_VERB_REGISTER     0x0010     /* Dump waits-for table. */
      #define     DB_VERB_REPLICATION     0x0020     /* Replication information. */
      #define     DB_VERB_WAITSFOR     0x0040     /* Dump waits-for table. */
    + #define     DB_VERB_CURSOR          0x0080     /* Cursor open/close information. */
           u_int32_t      verbose;     /* Verbose output. */
           void          app_private;     / Application-private handle. */
    diff -rc db-4.6.21.orig/db/db_am.c db-4.6.21/db/db_am.c
    *** db-4.6.21.orig/db/db_am.c     Thu Jun 14 04:21:30 2007
    --- db-4.6.21/db/db_am.c     Mon May 12 17:32:08 2008
    *** 283,288 ****
    --- 283,291 ----
           TAILQ_INSERT_TAIL(&dbp->active_queue, dbc, links);
           F_SET(dbc, DBC_ACTIVE);
           MUTEX_UNLOCK(dbenv, dbp->mutex);
    +      if (FLD_ISSET(dbenv->verbose, DB_VERB_CURSOR))
    +           __db_msg(dbenv,
    +               "Cursor (%p) opened, associated txn: %p", dbc, dbc->txn);
           *dbcp = dbc;
           return (0);
    diff -rc db-4.6.21.orig/db/db_cam.c db-4.6.21/db/db_cam.c
    *** db-4.6.21.orig/db/db_cam.c     Tue Jun  5 21:46:24 2007
    --- db-4.6.21/db/db_cam.c     Mon May 12 17:32:25 2008
    *** 71,76 ****
    --- 71,79 ----
           opd = cp->opd;
           ret = 0;
    +      if (FLD_ISSET(dbenv->verbose, DB_VERB_CURSOR))
    +           __db_msg(dbenv,
    +               "Cursor (%p) closed, associated txn: %p", dbc, dbc->txn);
            * Remove the cursor(s) from the active queue.  We may be closing two
            * cursors at once here, a top-level one and a lower-level, off-page
    diff -rc db-4.6.21.orig/dbinc/db.in db-4.6.21/dbinc/db.in
    *** db-4.6.21.orig/dbinc/db.in     Fri Jun 29 00:23:35 2007
    --- db-4.6.21/dbinc/db.in     Mon May 12 17:23:20 2008
    *** 2106,2111 ****
    --- 2106,2112 ----
      #define     DB_VERB_REGISTER     0x0010     /* Dump waits-for table. */
      #define     DB_VERB_REPLICATION     0x0020     /* Replication information. */
      #define     DB_VERB_WAITSFOR     0x0040     /* Dump waits-for table. */
    + #define     DB_VERB_CURSOR          0x0080     /* Cursor open/close information. */
           u_int32_t      verbose;     /* Verbose output. */
           void          app_private;     / Application-private handle. */
    diff -rc db-4.6.21.orig/dist/pubdef.in db-4.6.21/dist/pubdef.in
    *** db-4.6.21.orig/dist/pubdef.in     Fri Jul  6 10:22:52 2007
    --- db-4.6.21/dist/pubdef.in     Mon May 12 17:21:48 2008
    *** 432,437 ****
    --- 432,438 ----
      DB_USERCOPY_SETDATA          * I N
      DB_USE_ENVIRON               D I J
      DB_USE_ENVIRON_ROOT          D I J
    + DB_VERB_CURSOR               D I J
      DB_VERB_DEADLOCK          D I J
      DB_VERB_FILEOPS               D I J
      DB_VERB_FILEOPS_ALL          D I J
    diff -rc db-4.6.21.orig/env/env_method.c db-4.6.21/env/env_method.c
    *** db-4.6.21.orig/env/env_method.c     Fri May 18 01:15:11 2007
    --- db-4.6.21/env/env_method.c     Mon May 12 17:28:57 2008
    *** 1070,1075 ****
    --- 1070,1076 ----
           int *onoffp;
           switch (which) {
    +      case DB_VERB_CURSOR:
           case DB_VERB_DEADLOCK:
           case DB_VERB_FILEOPS:
           case DB_VERB_FILEOPS_ALL:
    *** 1098,1103 ****
    --- 1099,1105 ----
           int on;
           switch (which) {
    +      case DB_VERB_CURSOR:
           case DB_VERB_DEADLOCK:
           case DB_VERB_FILEOPS:
           case DB_VERB_FILEOPS_ALL:
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/EnvironmentConfig.java db-4.6.21/java/src/com/sleepycat/db/EnvironmentConfig.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/EnvironmentConfig.java     Fri Jul  6 10:22:54 2007
    --- db-4.6.21/java/src/com/sleepycat/db/EnvironmentConfig.java     Mon May 12 17:25:22 2008
    *** 114,119 ****
    --- 114,120 ----
          private boolean yieldCPU = false;
          /* Verbose Flags */
    +     private boolean verboseCursor = false;
          private boolean verboseDeadlock = false;
          private boolean verboseFileops = false;
          private boolean verboseFileopsAll = false;
    *** 846,851 ****
    --- 847,855 ----
          public void setVerbose(final VerboseConfig flag, boolean enable) {
              int iflag = flag.getInternalFlag();
              switch (iflag) {
    +         case DbConstants.DB_VERB_CURSOR:
    +             verboseCursor = enable;
    +             break;
              case DbConstants.DB_VERB_DEADLOCK:
                  verboseDeadlock = enable;
                  break;
    *** 876,881 ****
    --- 880,887 ----
          public boolean getVerbose(final VerboseConfig flag) {
              int iflag = flag.getInternalFlag();
              switch (iflag) {
    +         case DbConstants.DB_VERB_CURSOR:
    +             return verboseCursor;
              case DbConstants.DB_VERB_DEADLOCK:
                  return verboseDeadlock;
              case DbConstants.DB_VERB_FILEOPS:
    *** 1151,1156 ****
    --- 1157,1167 ----
                  dbenv.set_flags(offFlags, false);
              /* Verbose flags */
    +         if (verboseCursor && !oldConfig.verboseCursor)
    +             dbenv.set_verbose(DbConstants.DB_VERB_CURSOR, true);
    +         if (!verboseCursor && oldConfig.verboseCursor)
    +             dbenv.set_verbose(DbConstants.DB_VERB_CURSOR, false);
    +
              if (verboseDeadlock && !oldConfig.verboseDeadlock)
                  dbenv.set_verbose(DbConstants.DB_VERB_DEADLOCK, true);
              if (!verboseDeadlock && oldConfig.verboseDeadlock)
    *** 1342,1347 ****
    --- 1353,1359 ----
              yieldCPU = ((envFlags & DbConstants.DB_YIELDCPU) != 0);
              /* Verbose flags */
    +         verboseCursor = dbenv.get_verbose(DbConstants.DB_VERB_CURSOR);
              verboseDeadlock = dbenv.get_verbose(DbConstants.DB_VERB_DEADLOCK);
              verboseFileops = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS);
              verboseFileopsAll = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS_ALL);
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/VerboseConfig.java db-4.6.21/java/src/com/sleepycat/db/VerboseConfig.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/VerboseConfig.java     Fri Jul  6 10:22:54 2007
    --- db-4.6.21/java/src/com/sleepycat/db/VerboseConfig.java     Mon May 12 17:28:07 2008
    *** 12,17 ****
    --- 12,19 ----
      import com.sleepycat.db.internal.DbEnv;
      public final class VerboseConfig {
    +     public static final VerboseConfig CURSOR =
    +         new VerboseConfig("CURSOR", DbConstants.DB_VERB_CURSOR);
          public static final VerboseConfig DEADLOCK =
              new VerboseConfig("DEADLOCK", DbConstants.DB_VERB_DEADLOCK);
          public static final VerboseConfig FILEOPS =
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/internal/DbConstants.java db-4.6.21/java/src/com/sleepycat/db/internal/DbConstants.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/internal/DbConstants.java     Fri Sep 28 01:32:07 2007
    --- db-4.6.21/java/src/com/sleepycat/db/internal/DbConstants.java     Mon May 12 17:29:17 2008
    *** 194,199 ****
    --- 194,200 ----
          int DB_UPGRADE = 0x0000001;
          int DB_USE_ENVIRON = 0x0004000;
          int DB_USE_ENVIRON_ROOT = 0x0008000;
    +     int DB_VERB_CURSOR = 0x0080;
          int DB_VERB_DEADLOCK = 0x0001;
          int DB_VERB_FILEOPS = 0x0002;
          int DB_VERB_FILEOPS_ALL = 0x0004;

  • DiskWarrior Drive Recovery - How long & still successful?

    I attempted to backup a friend's MacBook 120 Gig drive with Carbon Copy Cloner on Saturday (this machine is running latest version of Tiger). I was booted from the internal drive and cloning to an external USB drive. In the process the machine became unresponsive to any keyboard input or mouse clicks (the mouse continued tracking while this was going on).
    Thinking that I was doing a read only activity on the internal drive, I powered the MacBook down with the power key. When I started it back up it seemed to reboot multiple times or some other activity that causes multiple startup chimes. (I was not sitting in front of the computer, only heard the chimes).
    After quite a lot of time (multiple minutes) the computer came to a gray screen with a blinking ? folder.
    I then booted the machine from a Firewire drive that I have set up for emergency purposes (Leopard 10.5.4). The internal disk would not mount so I ran a Disk Verify with Disk Utility. It complained about incorrect B-Tree size, or something wrong with the Catalog / B-Tree and indicated the drive could not be repaired. I then ran fsck_hfs with no options and got a message indicating that the B-Tree was at fault.
    I considered running fsck_hfs and forcing it to rebuild the catalog, but decided that I wasn't comfortable with that approach.
    I purchased DiskWarrior 4.1 and installed it on the external drive & it has been running since Sunday morning on step 5 "Locating Directory Data". Since then I have heard disk activity (sometimes a bit noisy with intermittent clicks, sometimes normal drive access sounds). The "Speed reduced by disk malfunction" count has been steadily increasing since Sunday. It is currently at 22,217.
    I've read many forum posts about DiskWarrior running for days, and if this count is representing bad blocks, then 22K out of 233 million is a believeable number.
    Has anyone run DiskWarrior this long and ended up recovering data, or am I waiting for a lost cause to end?
    My intent is to copy whatever data is recovered off to an external drive and have this thing taken in for a new hard drive under warranty.
    Anyone that has an extended DiskWarrior run that ended successfully, I would love to hear from you!

    Update: I let it run for 8 days, and called Alsoft Tech Support for some advice. It appears that although the count of "Speed reduced by..." was increasing with a pretty regular pattern, DiskWarrior was trying to reread the same 7 or 8K blocks over and over. You can scan through the system log to see what block numbers are receiving read errors. In this case the errors varied from about block number 18000 up to block 25000. In effect it was just looping over and over on those blocks.
    Alsoft did suggest taking steps to cool the drive since that seems to help in some cases. I ended up Cancelling the Rebuild, and I'm expecting Apple will replace the drive as faulty.

Maybe you are looking for

  • Can not paste in iCal

    I am new to iCal...I opened up iCal and double clicked on a time to paste an entry...it was a medium length URL...when I right clicked on the space to paste the URL...it did not show any choices like paste...I tried right clicking a few more times an

  • Need to Learn ABAP OO and Workflow concepts.

    Hello Mates, I am just a 2 weeks old in Sap - ABAP, I was working on MS-.NET. But somehow ABAP is attracting me more than any other  language, I did certification as well. But somehow I am not able to understand the ABAP OO concepts inregards to work

  • Ipod mini: used to be on mac - now pc?!?!?!  please help!

    hey- My old mac crashed, and all of my music files are in my ipod mini. I've decided to use a pc for all of my music needs. I've tried to run the updater.... but it only gives me the restore option. It says that it's because my ipod's not formatted t

  • ME31K :  BAPI_AGREEMENT_MAINTAIN

    Hi i am trying to create the contract using BAPI  :  BAPI_AGREEMENT_MAINTAIN . BUT i am getting an error : "Please enter material number or account assignment category" i am passing the following  parameters   wa_contract_header-vendor = '300005' .  

  • Handling Change of IT with multiple records in P&F

    Good Morning all, Has anyone done this yet? What is the approach to change an infotype with multiple records using P&F; For example IT0021, Subtype 2 (Child). I'm assuming that we will need to display all the records in a tbale first in the Form. The