From: Bryan T. <tho...@us...> - 2007-12-05 15:11:23
|
Update of /cvsroot/cweb/generic-native/src/java/org/CognitiveWeb/generic/core In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6183/src/java/org/CognitiveWeb/generic/core Modified Files: LinkSetIndex.java AbstractBTree.java Log Message: bigdata-gom is now running. Index: AbstractBTree.java =================================================================== RCS file: /cvsroot/cweb/generic-native/src/java/org/CognitiveWeb/generic/core/AbstractBTree.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractBTree.java 4 Dec 2007 20:30:42 -0000 1.7 --- AbstractBTree.java 5 Dec 2007 15:11:16 -0000 1.8 *************** *** 338,341 **** --- 338,451 ---- } + /** + * <p> + * Helper method returns the internal key for the generic object for this + * index. The internal key is produced from the coerced key and is used to + * break ties when duplicate keys are supported by the index. When + * {@link #getStoreOidOnly()} is true, then the internal form of the key is + * simply the generic object and the comparator will have been choosen to + * extract the current property value from the generic object and perform + * coercion iff the index is not strongly typed. + * </p> + * + * @param indexEverything + * from {@link LinkSetIndex#getIndexEverything()} + * @param duplicateKeys + * from {@link LinkSetIndex#getDuplicateKeys()} + * @param coerce + * When <code>true</code>, the <i>key</i> will be coerced. + * When <code>false</code> the caller is asserting that the + * <i>key</i> is already in its coerced form. + * @param key + * Either the external or coerced form of the key. There are + * several possible sources for the <i>key</i> + * <ol> + * <li>The current value of the {@link #getValuePropertyClass()} + * property value extracted from <i>what</i> during an index + * build operation;</li> + * <li>The pre- or post-modification property value for that + * property as reported by a property change event;</li> + * <li>An application supplied external key that is being used + * to query the index.</li> + * <li>The successor of a <em>coerced</em> application + * supplied key that is being used to bound a key range scan.</li> + * </ol> + * @param what + * The generic object that is being added to, or dropped from, + * the index. The various methods that query the index, e.g., + * {@link #getPoints( Object externalKey )}, specify <i>what + * </i> as <code>null</code>. When duplicate keys are + * supported this results in a {@link ICompositeKey} whose {@link + * ICompositeKey#getObjectIdentity()} returns <code>0L</code>. + * + * @return The internal form of the key used to index <i>what </i>. It will + * be <code>null</code> iff the generic object will NOT be + * included in the index. Otherwise the returned key should be + * suitable for direct comparison with other keys in the index using + * the selected {@link Comparator} -or- the comparison semantics of + * the backend btree if custom comparators are not supported. If + * {@link #getStoreOidOnly()} is <code>true</code> then the + * returned key will be <i>what</i> (the generic object whose + * property value will be indexed). + * + * @see #getDuplicateKeys() + * @see #getIndexEverything() + * @see #getStoreOidOnly() + */ + protected Object getInternalKey(// + final boolean indexEverything,// + final boolean duplicateKeys,// + final boolean coerce,// + final boolean successor,// + /*final*/ Object key,// + final Generic what// + ) { + + if(successor) { + + if( _successor == null) { + + throw new UnsupportedOperationException("special successor semantics"); + + } + + key = _successor.successor(key); + + } + + final Object coercedKey = ( coerce && _coercer != null ? _coercer.coerce(key) : key ); + // final Object coercedKey = ( coerce ? _coercer.coerce(key) : key ); + + if (coercedKey == null && !indexEverything) { + + /* + * Note: Unless we are indexing everything we will drop out keys + * that coerce to [null]. + */ + + return null; + + } + + Object internalKey = coercedKey; + + if (duplicateKeys) { + + /* + * Note: If we are permitting duplicate external keys, then we + * always wrap the coerced key as a composite key. This let's us + * impose a total ordering over the index even when the external + * (and coerced) keys are not unique. + */ + + internalKey = newCompositeKey(coercedKey, (what == null ? 0L : what + .getOID())); + + } + + return internalKey; + + } + //************************************************************ //********************* Externalizable *********************** Index: LinkSetIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native/src/java/org/CognitiveWeb/generic/core/LinkSetIndex.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** LinkSetIndex.java 4 Dec 2007 20:30:42 -0000 1.19 --- LinkSetIndex.java 5 Dec 2007 15:11:16 -0000 1.20 *************** *** 526,529 **** --- 526,533 ---- private boolean m_indexEverything; private boolean m_sortNullsToEnd; + + /** + * @deprecated this feature will be dropped. + */ private boolean m_storeOidOnly; *************** *** 798,801 **** --- 802,807 ---- * property on the generic object, but only the object identifier of the * indexed generic object. + * + * @deprecated this feature will be dropped. */ public boolean getStoreOidOnly() { *************** *** 1449,1453 **** log.debug("what="+gx+", value="+theValue); ! add(getInternalKey(true, theValue, gx), gx); } // synchronized( gx ) --- 1455,1459 ---- log.debug("what="+gx+", value="+theValue); ! add(getInternalKey(true, false/*successor*/,theValue, gx), gx); } // synchronized( gx ) *************** *** 1657,1661 **** log.debug("what="+what+", value="+value); ! drop(getInternalKey(true, value, what), what); what.removePropertyChangeListener(valuePropertyClass, this); --- 1663,1667 ---- log.debug("what="+what+", value="+value); ! drop(getInternalKey(true, false/*successor*/,value, what), what); what.removePropertyChangeListener(valuePropertyClass, this); *************** *** 1783,1787 **** // Add LSM to the index. ! add(getInternalKey(true, what.get(valuePropertyClass), what), what); commitNativeTransaction(counter); --- 1789,1793 ---- // Add LSM to the index. ! add(getInternalKey(true, false/*successor*/,what.get(valuePropertyClass), what), what); commitNativeTransaction(counter); *************** *** 1824,1828 **** // Drop LSM from the index. ! drop(getInternalKey(true, what.get(valuePropertyClass), what), what); // Drop the property change listener. --- 1830,1834 ---- // Drop LSM from the index. ! drop(getInternalKey(true, false/*successor*/,what.get(valuePropertyClass), what), what); // Drop the property change listener. *************** *** 1890,1896 **** * of object for that OID -- it will have to be the glueObject * in GOM for Objectivity and some flyweight OID in GOM for ! * JDBM. */ ! drop(getInternalKey(true, oldValue, source), source); } --- 1896,1902 ---- * of object for that OID -- it will have to be the glueObject * in GOM for Objectivity and some flyweight OID in GOM for ! * JDBM (actually, just drop [storeOidOnly] as a feature). */ ! drop(getInternalKey(true, false/*successor*/,oldValue, source), source); } *************** *** 1908,1912 **** } else { ! add(getInternalKey(true, newValue, source), source); } --- 1914,1918 ---- } else { ! add(getInternalKey(true, false/*successor*/,newValue, source), source); } *************** *** 1934,1938 **** try { ! drop(getInternalKey(true, is, source), source); } --- 1940,1944 ---- try { ! drop(getInternalKey(true, false/*successor*/,is, source), source); } *************** *** 1960,1964 **** try { ! drop(getInternalKey(true, r, source), source); } --- 1966,1970 ---- try { ! drop(getInternalKey(true, false/*successor*/,r, source), source); } *************** *** 2007,2011 **** try { ! add(getInternalKey(true, is, source), source); } --- 2013,2017 ---- try { ! add(getInternalKey(true, false/*successor*/,is, source), source); } *************** *** 2033,2037 **** try { ! add(getInternalKey(true, r, source), source); } --- 2039,2043 ---- try { ! add(getInternalKey(true, false/*successor*/,r, source), source); } *************** *** 2104,2116 **** * included in the index. Otherwise the returned key should be * suitable for direct comparison with other keys in the index using ! * the selected {@link Comparator}.<br> ! * The return value will be an {@link ICompositeKey} iff {@link ! * #getDuplicateKeys()} returns <code>true</code> and ! * {@link #getStoreOidOnly()} returns <code>false</code>. Iff * {@link #getStoreOidOnly()} is <code>true</code> then the ! * returned key will either by <i>what</i> (the generic object ! * whose property value will be indexed) or a simple data type that ! * must be compared to the coerced property value extracted from ! * generic objects in the index. * * @see #getDuplicateKeys() --- 2110,2118 ---- * included in the index. Otherwise the returned key should be * suitable for direct comparison with other keys in the index using ! * the selected {@link Comparator} -or- the comparison semantics of ! * the backend btree if custom comparators are not supported. If * {@link #getStoreOidOnly()} is <code>true</code> then the ! * returned key will be <i>what</i> (the generic object whose ! * property value will be indexed). * * @see #getDuplicateKeys() *************** *** 2118,2170 **** * @see #getStoreOidOnly() */ ! protected Object getInternalKey(final boolean coerce, final Object key, ! final Generic what) { ! ! if( getStoreOidOnly() ) { ! ! if( what == null ) { ! ! return ( coerce ? coerce(key) : key ); ! ! } else { ! ! return what; ! ! } ! ! } ! ! final Object coercedKey = ( coerce ? coerce(key) : key ); ! ! if (coercedKey == null && !getIndexEverything()) { ! ! /* ! * Note: Unless we are indexing everything we will drop out keys ! * that coerce to [null]. ! */ ! ! return null; ! } ! Object internalKey = coercedKey; ! if (getDuplicateKeys()) { ! /* ! * Note: If we are permitting duplicate external keys, then we ! * always wrap the coerced key as a composite key. This let's us ! * impose a total ordering over the index even when the external ! * (and coerced) keys are not unique. ! */ ! internalKey = getBTree().newCompositeKey(coercedKey, ! (what == null ? 0L : what.getOID())); } ! return internalKey; } --- 2120,2152 ---- * @see #getStoreOidOnly() */ + protected Object getInternalKey(// + final boolean coerce,// + final boolean successor,// + final Object key,// + final Generic what// + ) { ! if (getStoreOidOnly()) { ! if (what == null) { ! return (coerce ? coerce(key) : key); ! } else { ! return what; ! } } ! /* ! * delegate to the AbstractBTree so that the behavior may be customized ! * for the backend. ! */ + return getBTree().getInternalKey(m_indexEverything, + m_duplicateKeys, coerce, successor, key, what); + } *************** *** 2175,2181 **** * the constructor. * </p> */ ! ! protected final Object coerce(Object externalKey) { indexed(); --- 2157,2165 ---- * the constructor. * </p> + * + * @deprecated only used when {@link #getStoreOidOnly()} is <code>true</code> + * and that feature is being dropped. */ ! private final Object coerce(Object externalKey) { indexed(); *************** *** 2543,2555 **** ILinkSetIndexIterator itr = (ILinkSetIndexIterator) iterator(); ! Generic g = (Generic) itr.next(); ! return g.get( getValuePropertyClass() ); ! ! // Iterator itr = iterator(); ! // ! // itr.next(); ! // ! // return getExternalKey(((ILinkSetIndexIterator) itr).getInternalKey()); } --- 2527,2541 ---- ILinkSetIndexIterator itr = (ILinkSetIndexIterator) iterator(); ! try { ! Generic g = (Generic) itr.next(); ! ! return g.get(getValuePropertyClass()); ! ! } finally { ! ! itr.close(); ! ! } } *************** *** 2572,2579 **** */ public Iterator iterator() { ! return getBTree().iterator(this,null, // fromKey null, // toKey ! true // resolve Topics. ); } --- 2558,2568 ---- */ public Iterator iterator() { ! ! return getBTree().iterator(this,// ! null, // fromKey null, // toKey ! true // resolve ); + } *************** *** 2595,2605 **** try { ! final Object fromKey = coerce(key); ! final Object toKey = getBTree().getSuccessor().successor(fromKey); itr = getBTree().iterator(this, ! getInternalKey(false/* coerce */, fromKey, null/* what */), ! getInternalKey(false/* coerce */, toKey, null/* what */), true // resolve values. ); --- 2584,2594 ---- try { ! // final Object fromKey = coerce(key); ! // final Object toKey = getBTree().getSuccessor().successor(fromKey); itr = getBTree().iterator(this, ! getInternalKey(true/* coerce */, false/*successor*/,key, null/* what */), ! getInternalKey(true/* coerce */, true/*successor*/,key, null/* what */), true // resolve values. ); *************** *** 2657,2667 **** try { ! Object fromKey = coerce(key); ! Object toKey = getBTree().getSuccessor().successor(fromKey); return getBTree().iterator(this, ! getInternalKey(false/* coerce */, fromKey, null/* what */), ! getInternalKey(false/* coerce */, toKey, null/* what */), true // resolve values. ); --- 2646,2656 ---- try { ! // Object fromKey = coerce(key); ! // Object toKey = getBTree().getSuccessor().successor(fromKey); return getBTree().iterator(this, ! getInternalKey(true/* coerce */, false/*successor*/,key, null/* what */), ! getInternalKey(true/* coerce */, true/*successor*/,key, null/* what */), true // resolve values. ); *************** *** 2711,2721 **** try { ! final Object fromKey = coerce(key); ! final Object toKey = getBTree().getSuccessor().successor(fromKey); Iterator itr = getBTree().iterator(this, ! getInternalKey(false,fromKey, null), ! getInternalKey(false,toKey, null), false // do not resolve values. ); --- 2700,2710 ---- try { ! // final Object fromKey = coerce(key); ! // final Object toKey = getBTree().getSuccessor().successor(fromKey); Iterator itr = getBTree().iterator(this, ! getInternalKey(true/*coerce*/,false/*successor*/,key, null), ! getInternalKey(true/*coerce*/,true/*successor*/,key, null), false // do not resolve values. ); *************** *** 2755,2760 **** return getBTree().iterator(this, ! getInternalKey(true, fromKey, null), ! getInternalKey(true, toKey, null), true // resolve values. ); --- 2744,2749 ---- return getBTree().iterator(this, ! getInternalKey(true, false/*successor*/,fromKey, null), ! getInternalKey(true, false/*successor*/,toKey, null), true // resolve values. ); *************** *** 2790,2795 **** Iterator itr = getBTree().iterator(this, ! getInternalKey(true, fromKey, null), ! getInternalKey(true, toKey, null), false // do not resolve values. ); --- 2779,2784 ---- Iterator itr = getBTree().iterator(this, ! getInternalKey(true, false/*successor*/,fromKey, null), ! getInternalKey(true, false/*successor*/,toKey, null), false // do not resolve values. ); *************** *** 2817,2821 **** return getBTree().iterator(this, null, // fromKey ! getInternalKey(true,toKey, null), // toKey true // resolve values. ); --- 2806,2810 ---- return getBTree().iterator(this, null, // fromKey ! getInternalKey(true,false/*successor*/,toKey, null), // toKey true // resolve values. ); *************** *** 2850,2854 **** Iterator itr = getBTree().iterator(this, null, // fromKey ! getInternalKey(true, toKey, null), // toKey false // do not resolve values. ); --- 2839,2843 ---- Iterator itr = getBTree().iterator(this, null, // fromKey ! getInternalKey(true, false/*successor*/,toKey, null), // toKey false // do not resolve values. ); *************** *** 2875,2879 **** return getBTree().iterator(this, ! getInternalKey(true, fromKey, null), null, // toKey true // resolve values. --- 2864,2868 ---- return getBTree().iterator(this, ! getInternalKey(true, false/*successor*/,fromKey, null), null, // toKey true // resolve values. *************** *** 2908,2912 **** Iterator itr = getBTree().iterator(this, ! getInternalKey(true, fromKey, null), // fromKey null, // toKey false // do not resolve values. --- 2897,2901 ---- Iterator itr = getBTree().iterator(this, ! getInternalKey(true, false/*successor*/,fromKey, null), // fromKey null, // toKey false // do not resolve values. |