Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15000/src/java/com/bigdata/isolation Modified Files: IsolatableFusedView.java IsolatedBTree.java IIsolatableIndex.java UnisolatedBTree.java Added Files: UnisolatedIndexSegment.java Log Message: Updated the UML model and added a ZIP containing an HTML presentation of the model. Working on partitioned index support. --- NEW FILE: UnisolatedIndexSegment.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Mar 7, 2007 */ package com.bigdata.isolation; import com.bigdata.isolation.UnisolatedBTree.DeletedEntryFilter; import com.bigdata.objndx.AbstractBTree; import com.bigdata.objndx.BatchContains; import com.bigdata.objndx.BatchLookup; import com.bigdata.objndx.IEntryIterator; import com.bigdata.objndx.IndexSegment; import com.bigdata.objndx.IndexSegmentExtensionMetadata; import com.bigdata.objndx.IndexSegmentFileStore; /** * <p> * A scalable read-only B+-Tree mapping variable length unsigned byte[] keys to * byte[] values that is capable of being isolated by a transaction (it * maintains version counters) and supports deletion markers. Application data * are transparently encapsulated in {@link IValue} objects which keep track of * version counters (in support of transactions) and deletion markers (in * support of both transactions and partitioned indices). Users of this class * will only see application values, not {@link IValue} objects. * </p> * * @see UnisolatedBTree, which provides a mutable implementation with a similar * contract. * * @todo This class should either share code or tests cases with * {@link UnisolatedBTree} (I just copied over the logic for non-mutation * operations). There are no direct tests of this class at this time. * * @todo define extension that stores the index name and uuid for the named * index to which the segment belongs (add method to {@link AbstractBTree} * to allow subclassing {@link IndexSegmentExtensionMetadata}). * * @todo add a boolean flag to mark index segments that are the final result of * a compacting merge. This will make it possible to reconstruct from the * file system which index segments are part of the consistent state for a * given restart time. * * @todo consider caching the first/last key in support of both correct * rejection of queries directed to the wrong index segment and managing * the metadataMap for a distributed index. * * @todo examine the format of the uuid. can we use part of it as the unique * basis for one up identifiers within a parition? * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class UnisolatedIndexSegment extends IndexSegment implements IIsolatableIndex { /** * */ public UnisolatedIndexSegment(IndexSegmentFileStore store) { super(store); } // /** // * This method breaks isolation to return the {@link Value} for a key. // * It is used by {@link IsolatedBTree#validate(UnisolatedBTree)} to test // * version counters when a key already exists in the global scope. // * // * @todo make protected and refactor tests so that we do not need public // * access to this method. there should be tests in this package // * that examine the specific version counters that are assigned // * such that we do not need to expose this method as public. // */ // final public Value getValue(byte[] key) { // // return (Value) super.lookup(key); // // } /** * True iff the key does not exist or if it exists but is marked as * {@link IValue#isDeleted()}. * * @param key * The search key. * * @return True iff there is an non-deleted entry for the search key. */ public boolean contains(byte[] key) { if (key == null) throw new IllegalArgumentException(); Value value = (Value) super.lookup(key); if (value == null || value.deleted) return false; return true; } /** * Return the {@link IValue#getValue()} associated with the key or * <code>null</code> if the key is not found or if the key was found * by the entry is flagged as {@link IValue#isDeleted()}. * * @param key * The search key. * * @return The application value stored under that search key (may be * null) or null if the key was not found or if they entry was * marked as deleted. */ public Object lookup(Object key) { if (key == null) throw new IllegalArgumentException(); Value value = (Value) super.lookup(key); if (value == null || value.deleted) return null; return value.datum; } /** * Overriden to return <code>null</code> if the entry at that index is * deleted. */ public Object valueAt(int index) { Value value = (Value) super.valueAt(index); if (value == null || value.deleted) return null; return value.datum; } /** * This method will include deleted entries in the key range in the * returned count. */ public int rangeCount(byte[] fromKey, byte[] toKey) { return super.rangeCount(fromKey, toKey); } /** * Visits only the non-deleted entries in the key range. */ public IEntryIterator rangeIterator(byte[] fromKey, byte[] toKey) { return root.rangeIterator(fromKey, toKey, DeletedEntryFilter.INSTANCE); } public IEntryIterator entryIterator() { return root.rangeIterator(null, null, DeletedEntryFilter.INSTANCE); } public void contains(BatchContains op) { op.apply(this); } public void lookup(BatchLookup op) { op.apply(this); } } Index: UnisolatedBTree.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/UnisolatedBTree.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** UnisolatedBTree.java 21 Feb 2007 20:17:22 -0000 1.7 --- UnisolatedBTree.java 8 Mar 2007 18:14:06 -0000 1.8 *************** *** 57,60 **** --- 57,61 ---- import com.bigdata.objndx.IEntryIterator; import com.bigdata.objndx.ISimpleBTree; + import com.bigdata.objndx.IndexSegment; import com.bigdata.objndx.EntryIterator.EntryFilter; import com.bigdata.rawstore.IRawStore; *************** *** 82,112 **** * * @see IsolatedBTree, a {@link BTree} that has been isolated by a transaction. ! * * The following is an ad-hoc summary of the behavior of some methods exposed by * this class: ! <pre> ! ! contains() - done. ! insert() - done. ! remove() - done. ! lookup() - done. ! ! addAll() - ok as implemented. values will be wrapped in {@link IValue} objects ! as they are inserted. if the source is also an {@link UnisolatedBTree} then the ! application values will be inserted into this tree, not the {@link IValue} objects. ! ! indexOf() - ok as implemented (counts deleted entries). ! keyAt() - ok as implemented, but will return keys for deleted entries. ! valueAt() - overriden to return null for a deleted entry. ! ! rangeCount - ok as implemented (counts deleted entries). ! rangeIterator - must filter out deleted entries. ! ! entryIterator() - only non-deleted entries. ! ! IBatchBTree - all methods are overriden to use {@link IBatchOp#apply(ISimpleBTree)} ! so that they will correctly apply the semantics of the {@link UnisolatedBTree}. ! ! </pre> */ public class UnisolatedBTree extends BTree implements IIsolatableIndex { --- 83,120 ---- * * @see IsolatedBTree, a {@link BTree} that has been isolated by a transaction. ! * ! * @see UnisolatedIndexSegment, a read-only {@link IndexSegment} suitable for ! * storing data from an {@link UnisolatedBTree}. ! * * The following is an ad-hoc summary of the behavior of some methods exposed by * this class: ! * ! * <pre> ! * ! * contains() - done. ! * insert() - done. ! * remove() - done. ! * lookup() - done. ! * ! * addAll() - ok as implemented. values will be wrapped in {@link IValue} objects ! * as they are inserted. if the source is also an {@link UnisolatedBTree} then the ! * application values will be inserted into this tree, not the {@link IValue} objects. ! * ! * indexOf() - ok as implemented (counts deleted entries). ! * keyAt() - ok as implemented, but will return keys for deleted entries. ! * valueAt() - overriden to return null for a deleted entry. ! * ! * rangeCount - ok as implemented (counts deleted entries). ! * rangeIterator - must filter out deleted entries. ! * ! * entryIterator() - only non-deleted entries. ! * ! * IBatchBTree - all methods are overriden to use {@link IBatchOp#apply(ISimpleBTree)} ! * so that they will correctly apply the semantics of the {@link UnisolatedBTree}. ! * ! * </pre> ! * ! * @todo Any changes to the non-mutation operations on this class MUST also be ! * reflected in {@link UnisolatedIndexSegment}. */ public class UnisolatedBTree extends BTree implements IIsolatableIndex { *************** *** 257,263 **** /** ! * This method breaks isolatation to return the {@link Value} for a key. It ! * is used by {@link IsolatedBTree#validate(UnisolatedBTree)} to test ! * version counters when a key already exists in the global scope. * * @todo make protected and refactor tests so that we do not need public --- 265,271 ---- /** ! * This method breaks isolation to return the {@link Value} for a key. It is ! * used by {@link IsolatedBTree#validate(UnisolatedBTree)} to test version ! * counters when a key already exists in the global scope. * * @todo make protected and refactor tests so that we do not need public *************** *** 437,441 **** /** ! * A filter that hides deleted entries. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> --- 445,450 ---- /** ! * A filter that hides deleted entries and resolves {@link Value}s to the ! * corresponding application datum. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> Index: IsolatableFusedView.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/IsolatableFusedView.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IsolatableFusedView.java 6 Mar 2007 20:38:05 -0000 1.2 --- IsolatableFusedView.java 8 Mar 2007 18:14:06 -0000 1.3 *************** *** 50,54 **** import com.bigdata.objndx.AbstractBTree; import com.bigdata.objndx.FusedView; - import com.bigdata.scaleup.PartitionedJournal.IViewMetadata; /** --- 50,53 ---- Index: IIsolatableIndex.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/IIsolatableIndex.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IIsolatableIndex.java 13 Feb 2007 23:01:02 -0000 1.1 --- IIsolatableIndex.java 8 Mar 2007 18:14:06 -0000 1.2 *************** *** 61,71 **** /** * <p> ! * Interface for transactional isolation of an index. ! * </p> ! * <p> ! * This is a marker interface for an index that supports deletion markers and ! * transactions. Both unisolated and isolated indicies MUST use this interface ! * in order to support transactions since version counters MUST be maintained in ! * the unisolated indices as well as the isolated indices. * </p> * <p> --- 61,70 ---- /** * <p> ! * This is a marker interface for an index that can be isolated by a ! * transaction. Implementations of this interface understand and maintain both ! * version counters and deletion markers and constrain application data to ! * variable length byte[]s. Both unisolated and isolated indicies MUST use this ! * interface in order to support transactions since version counters MUST be ! * maintained in the unisolated indices as well as the isolated indices. * </p> * <p> *************** *** 168,172 **** * should it be silently ignored? * - * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ --- 167,170 ---- Index: IsolatedBTree.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/IsolatedBTree.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IsolatedBTree.java 19 Feb 2007 19:00:20 -0000 1.6 --- IsolatedBTree.java 8 Mar 2007 18:14:06 -0000 1.7 *************** *** 119,124 **** * class. */ ! public class IsolatedBTree extends UnisolatedBTree implements IIsolatableIndex, ! IIsolatedIndex { /** --- 119,123 ---- * class. */ ! public class IsolatedBTree extends UnisolatedBTree implements IIsolatedIndex { /** |