plainblack.com
Username Password
search
Bookmark and Share

Lineage

Lineage is the way assets relate themselves to each other. Lineage determines where assets reside in the asset tree, and how they are positioned relative to their siblings.

Each asset has a rank, which is a 6 digit number, left padded by zeros. The lineage of the each asset its rank appended to its parent's lineage.

 

 

The lineage of the “Our History” page in this example is “000001000002000002”. Knowing this little piece of information we can infer all kinds of other information. We know that this asset is the third generation: three sets of six digits. Also, our parent's lineage is “000001000002”: just subtract our rank from our lineage. And our grandparent's lineage is “000001”: by subtracting six digits from our parent's lineage.

If you want to see this, run the following command from the MySQL command line:

 

select assetId, className, lineage from asset order by lineage

 

Why is this important? For a number of reasons:

  • You can use it to troubleshoot performance problems, especially those related to navigation.

  • You can use it to write SQL that you might need for reports or troubleshooting.

  • You can use it to fix problems on your site.

 

Navigation Performance

Navigation performance certainly has to do with how your navigation is configured, but it can also have a lot to do with how your asset tree is built. For example, building a tree right off the root of the system isn't usually a good idea. The Import Node is also right off the root, and depending upon how your navigation is configured, that can mean serious performance problems because your navigation may also be reading the import node's data, which it of course will never need.

When you select “relative to current page” or “relative to root” style navigations, the navigation system will use lineage to determine the start point, and therefore position in the tree matters. If you want to circumvent this all together, you can specify the URL of your start point, and that will give you the highest performing navigation. However, if you want to use dynamically determined start point, then just be certain that your lineage will support you in that decision. Here's how:

  • Put strict limits on your navigation that will not force it to traverse the lineage to places that contain lots of non-displayable assets (import node, collaboration systems, wiki's, etc).

  • Use folders to help structure your lineage so that your starting lineage doesn't have to look at a lot of siblings.

 

SQL and Lineage

One of the great features of the lineage system is that you can get back an entire tree of data with a single simple SQL query. Something that's not possible with a traditional recursive parent child relationship. In the example we provided previously you can request the entire asset tree like this:

 

select assetId, className, lineage from asset order by lineage

 

But you can also get back a portion of a tree. For example, let's say we have an assetId ('XXX'), and we want to get all of the descendants of that child. We first need to find out the lineage of that asset:

 

select lineage from asset where assetId='XXX'

 

Then we can ask the database to give us all the assetIds that have that lineage ('00001000046'):

 

select assetId from asset where lineage like '00001000046%'

 

We can even combine those two queries using a sub select:

 

select assetId from asset where lineage like ( select concat(lineage,'%') from asset where assetId='XXX' )

 

Fixing Lineage

In very rare circumstances lineage can become corrupted. This happens either if a bug was introduced into the system, or if someone was manually tampering with the database. Luckily this is easily corrected using the rebuildLineage.pl utility. Type the following command:

 

cd /data/WebGUI/sbin
perl rebuildLineage.pl --help

Usage: perl rebuildLineage.pl --configfile=<webguiConfig>



This utility will rebuild your WebGUI Lineage Tree. The lineage tree is an

index that is used to make WebGUI run faster. It will also detect and fix

orphan data, and detect cirular relationships in your tree.



WARNING: Use this tool only if you know what you're doing. It should only

be used if somehow your lineage tree has become corrupt (very rare) or if

you have done some massive reorganization of your asset tree and you want

to fill in the gaps between the ranks of your assets. A side effect of

using this utility can be that your assets may no longer be in the same rank

as they once were, which means that they may appear out of order in your

navigation.



--configFile WebGUI config file.



Options:



--help Display this help message and exit.



--quiet Disable output unless there's an error.

 

To fix the lineage, run this command:

 

cd /data/WebGUI/sbin
perl rebuildLineage.pl --config=www.example.com.conf

 

It will output something like this:

 

Starting...OK

Looking for descendant replationships...

Got the relationships.



Looking for orphans...

No orphans found.



Rewriting existing lineage...

Rebuilding lineage...

Asset ID Old Lineage New Lineage

PBasset000000000000001 old___000001 000001

PBasset000000000000002 old___000001000001 000001000001

pbproto000000000000002 old___000001000001000015 000001000001000001

nbSrhXZQuxIjhWFaFPSuVA old___000001000001000018 000001000001000002

PBtmpl0000000000000001 old___000001000001000018000001 000001000001000002000001

PBtmplHelp000000000001 old___000001000001000018000002 000001000001000002000002

TvOZs8U1kRXLtwtmyW75pg old___000001000001000019 000001000001000003

PBtmpl0000000000000103 old___000001000001000019000001 000001000001000003000001

PBtmpl0000000000000084 old___000001000001000019000002 000001000001000003000002

PBtmpl0000000000000002 old___000001000001000019000003 000001000001000003000003

PBtmpl0000000000000115 old___000001000001000019000004 000001000001000003000004

PBtmpl0000000000000123 old___000001000001000019000005 000001000001000003000005

PBtmpl0000000000000129 old___000001000001000019000006 000001000001000003000006

PBtmpl0000000000000207 old___000001000001000019000007 000001000001000003000007

xSmREZO3GNzK3M5PaueOOQ old___000001000001000020 000001000001000004

PBtmpl0000000000000004 old___000001000001000020000001 000001000001000004000001

0bx-xoL8TSXXubFuqKAoVQ old___000001000001000021 000001000001000005

PBtmpl0000000000000005 old___000001000001000021000001 000001000001000005000001

taX2UYkFF21ALpFZY2rhMw old___000001000001000022 000001000001000006

PBtmpl0000000000000006 old___000001000001000022000001 000001000001000006000001

K0q_N885Httqev1VCqUWxg old___000001000001000023 000001000001000007

PBtmpl0000000000000010 old___000001000001000023000001 000001000001000007000001

fq1ZkYhH24R5tb96kuT10Q old___000001000001000024 000001000001000008

PBtmpl0000000000000011 old___000001000001000024000001 000001000001000008000001

oHk7fAFhEEkB7dHzi0QOQA old___000001000001000025 000001000001000009

PBtmpl0000000000000012 old___000001000001000025000001 000001000001000009000001

9M-lrlPQWeeNWfvnDnK_Xg old___000001000001000026 000001000001000010

PBtmpl0000000000000013 old___000001000001000026000001 000001000001000010000001

_gBYAdTcbkiyamnqi2Xskg old___000001000001000027 000001000001000011

PBtmpl0000000000000014 old___000001000001000027000001 000001000001000011000001

GNOAsX98vCsl0JRwfwL-gg old___000001000001000028 000001000001000012

PBtmpl0000000000000066 old___000001000001000028000001 000001000001000012000001

PBtmpl0000000000000080 old___000001000001000028000002 000001000001000012000002

...

68sKwDgf9cGH58-NZcU4lg old___000001000002 000001000002

_iHetEvMQUOoxS-T2CM0sQ old___000001000002000003 000001000002000001

bX5rYxb6tZ9docY6sUhBlw old___000001000002000003000001 000001000002000001000001

Vzv1pWpg_w6R_o-b0rM2qQ old___000001000002000003000002 000001000002000001000002

NK8bqlwVRILJknqeCDPBHg old___000001000002000003000003 000001000002000001000003

8Bb8gu-me2mhL3ljFyiWLg old___000001000002000004 000001000002000002

6QuS-0rosuZTdTv11fobig old___000001000002000004000001 000001000002000002000001

FOvmwGC0GtZo5VTxJIL3OA old___000001000002000004000002 000001000002000002000002

ix1p0AbwKAz8QWB-T-HHfg old___000001000002000004000003 000001000002000002000003

iCYOjohB9SKvAPr6bXElKA old___000001000002000004000004 000001000002000002000004

4Yfz9hqBqM8OYMGuQK8oLw old___000001000002000004000005 000001000002000002000005

Wl8WZ43g2rK5AYr9o4zY7w old___000001000002000004000006 000001000002000002000006

LBuiKzg2mWwmOPS9AgV3bg old___000001000002000004000007 000001000002000002000007

jTNggl7AoVSUc_ZzrvuCmw old___000001000002000004000008 000001000002000002000008

2TqQc4OISddWCZmRY1_m8A old___000001000002000005 000001000002000003

fK-HMSboA3uu0c1KYkYspA old___000001000002000005000001 000001000002000003000001

Swf6L8poXKc7hUaNPkBevw old___000001000002000006 000001000002000004

Szs5eev3OMssmnsyLRZmWA old___000001000002000006000001 000001000002000004000001

x3OFY6OJh_qsXkZfPwug4A old___000001000002000007 000001000002000005

pJd5TLAjfWMVXD6sCRLwUg old___000001000002000007000001 000001000002000005000001

OhdaFLE7sXOzo_SIP2ZUgA old___000001000002000008 000001000002000006

m4YJFaqzultnB_sj1Uq0aw old___000001000002000009 000001000002000007

IWFxZDyGhQ3-SLZhELa3qw old___000001000002000010 000001000002000008

JACIChYiCgzZzcYeyJ-s0w old___000001000002000011 000001000002000009

PBasset000000000000003 old___000001000003 000001000003

tempspace0000000000000 old___000001000004 000001000004

Cleaning up...OK



Don't forget to clear your cache.

 

When it's finished running, clear your cache. Your cache will likely no longer match what's in the database, so not clearing your cache could cause all kinds of corruption.

Keywords: asset database mysql navigation rank sql

Search | Most Popular | Recent Changes | Wiki Home
© 2018 Plain Black Corporation | All Rights Reserved