1 21 package com.db4o.inside.ix; 22 23 import com.db4o.foundation.*; 24 25 28 public abstract class IxPatch extends IxTree { 29 30 int _parentID; 31 32 Object _value; 33 34 private Queue4 _queue; 36 IxPatch(IndexTransaction a_ft, int a_parentID, Object a_value) { 37 super(a_ft); 38 _parentID = a_parentID; 39 _value = a_value; 40 } 41 42 public Tree add(final Tree a_new) { 43 int cmp = compare(a_new); 44 if (cmp == 0) { 45 IxPatch patch = (IxPatch) a_new; 46 cmp = _parentID - patch._parentID; 47 48 if (cmp == 0) { 49 50 Queue4 queue = _queue; 51 52 if (queue == null) { 53 queue = new Queue4(); 54 queue.add(this); 55 } 56 57 queue.add(patch); 58 patch._queue = queue; 59 patch._subsequent = _subsequent; 60 patch._preceding = _preceding; 61 patch.calculateSize(); 62 return patch; 63 } 64 } 65 return add(a_new, cmp); 66 } 67 68 public int compare(Tree a_to) { 69 Indexable4 handler = _fieldTransaction.i_index._handler; 70 return handler.compareTo(handler.comparableObject(trans(), _value)); 71 } 72 73 public boolean hasQueue() { 74 return _queue != null; 75 } 76 77 public Queue4 detachQueue() { 78 Queue4 queue = _queue; 79 this._queue = null; 80 return queue; 81 } 82 83 protected Tree shallowCloneInternal(Tree tree) { 84 IxPatch patch=(IxPatch)super.shallowCloneInternal(tree); 85 patch._parentID=_parentID; 86 patch._value=_value; 87 patch._queue=_queue; 88 return patch; 89 } 90 } 91 | Popular Tags |