From: Bryan T. <tho...@us...> - 2007-03-27 14:34:27
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6186/src/java/com/bigdata/isolation Modified Files: UnisolatedIndexSegment.java IsolatedBTree.java UnisolatedBTree.java Log Message: Added indexUUID to AbstractBTree so that each scale-out index may have a unique indentifier. Modified the BTreeMetadata class and derived classes to use Externalizable, to support explicit versioning of the metadata record, and to have private fields since they can not be final with Externalizable. Index: UnisolatedIndexSegment.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/UnisolatedIndexSegment.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UnisolatedIndexSegment.java 15 Mar 2007 16:11:13 -0000 1.2 --- UnisolatedIndexSegment.java 27 Mar 2007 14:34:23 -0000 1.3 *************** *** 75,81 **** * 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 --- 75,82 ---- * operations). There are no direct tests of this class at this time. * ! * @todo define extension that stores the index name for a named index to which ! * the segment belongs (add method to {@link AbstractBTree} to allow ! * subclassing {@link IndexSegmentExtensionMetadata})? (Note that we already ! * store the indexUUID). * * @todo add a boolean flag to mark index segments that are the final result of *************** *** 88,93 **** * 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> --- 89,94 ---- * the metadataMap for a distributed index. * ! * @todo examine the format of the segmentUUID. 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> Index: UnisolatedBTree.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/UnisolatedBTree.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** UnisolatedBTree.java 15 Mar 2007 16:11:13 -0000 1.9 --- UnisolatedBTree.java 27 Mar 2007 14:34:23 -0000 1.10 *************** *** 48,51 **** --- 48,59 ---- package com.bigdata.isolation; + import java.io.Externalizable; + import java.io.IOException; + import java.io.ObjectInput; + import java.io.ObjectOutput; + import java.util.UUID; + + import org.CognitiveWeb.extser.LongPacker; + import com.bigdata.objndx.BTree; import com.bigdata.objndx.BTreeMetadata; *************** *** 162,169 **** * * @param store */ ! public UnisolatedBTree(IRawStore store) { ! this(store, DEFAULT_BRANCHING_FACTOR, null); } --- 170,178 ---- * * @param store + * @param indexUUID */ ! public UnisolatedBTree(IRawStore store, UUID indexUUID) { ! this(store, DEFAULT_BRANCHING_FACTOR, indexUUID, null); } *************** *** 174,182 **** * * @param store * @param conflictResolver */ ! public UnisolatedBTree(IRawStore store, IConflictResolver conflictResolver) { ! this(store, DEFAULT_BRANCHING_FACTOR, conflictResolver); } --- 183,192 ---- * * @param store + * @param indexUUID * @param conflictResolver */ ! public UnisolatedBTree(IRawStore store, UUID indexUUID, IConflictResolver conflictResolver) { ! this(store, DEFAULT_BRANCHING_FACTOR, indexUUID, conflictResolver); } *************** *** 187,194 **** * @param store * @param branchingFactor */ ! public UnisolatedBTree(IRawStore store, int branchingFactor) { ! this(store, branchingFactor, null); } --- 197,205 ---- * @param store * @param branchingFactor + * @param indexUUID */ ! public UnisolatedBTree(IRawStore store, int branchingFactor, UUID indexUUID) { ! this(store, branchingFactor, indexUUID, null); } *************** *** 210,216 **** * transactions (aka serialization orders). */ ! public UnisolatedBTree(IRawStore store, int branchingFactor, IConflictResolver conflictResolver ) { ! super(store, branchingFactor, Value.Serializer.INSTANCE ); this.conflictResolver = conflictResolver; --- 221,228 ---- * transactions (aka serialization orders). */ ! public UnisolatedBTree(IRawStore store, int branchingFactor, ! UUID indexUUID, IConflictResolver conflictResolver) { ! super(store, branchingFactor, indexUUID, Value.Serializer.INSTANCE ); this.conflictResolver = conflictResolver; *************** *** 229,233 **** super(store,metadata); ! this.conflictResolver = ((UnisolatedBTreeMetadata) metadata).conflictResolver; } --- 241,245 ---- super(store,metadata); ! this.conflictResolver = ((UnisolatedBTreeMetadata) metadata).getConflictResolver(); } *************** *** 245,253 **** * @version $Id$ */ ! public static class UnisolatedBTreeMetadata extends BTreeMetadata { private static final long serialVersionUID = -4938674944860230200L; ! public final IConflictResolver conflictResolver; /** --- 257,278 ---- * @version $Id$ */ ! public static class UnisolatedBTreeMetadata extends BTreeMetadata implements Externalizable { private static final long serialVersionUID = -4938674944860230200L; ! private IConflictResolver conflictResolver; ! ! public IConflictResolver getConflictResolver() { ! ! return conflictResolver; ! ! } ! ! /** ! * De-serialization constructor. ! */ ! public UnisolatedBTreeMetadata() { ! ! } /** *************** *** 262,265 **** --- 287,318 ---- } + private static final transient int VERSION0 = 0x0; + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + + super.readExternal(in); + + final int version = (int)LongPacker.unpackLong(in); + + if (version != VERSION0) { + + throw new IOException("Unknown version: version=" + version); + + } + + conflictResolver = (IConflictResolver) in.readObject(); + + } + + public void writeExternal(ObjectOutput out) throws IOException { + + super.writeExternal(out); + + LongPacker.packLong(out,VERSION0); + + out.writeObject(conflictResolver); + + } + } Index: IsolatedBTree.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/isolation/IsolatedBTree.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IsolatedBTree.java 15 Mar 2007 16:11:13 -0000 1.9 --- IsolatedBTree.java 27 Mar 2007 14:34:23 -0000 1.10 *************** *** 139,143 **** public IsolatedBTree(IRawStore store, UnisolatedBTree src) { ! super(store, src.getBranchingFactor(), src.getConflictResolver()); this.src = src; --- 139,144 ---- public IsolatedBTree(IRawStore store, UnisolatedBTree src) { ! super(store, src.getBranchingFactor(), src.getIndexUUID(), src ! .getConflictResolver()); this.src = src; *************** *** 515,518 **** --- 516,520 ---- tmp = new BTree(getStore(), // same store. getBranchingFactor(), // same branching factor + src.getIndexUUID(), // same indexUUID. ByteArrayValueSerializer.INSTANCE // byte[] values. ); |