1 23 24 30 31 package com.sun.jdo.spi.persistence.support.sqlstore.sql.concurrency; 32 33 import com.sun.jdo.spi.persistence.support.sqlstore.model.FieldDesc; 34 import com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc; 35 import com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.QueryPlan; 36 import com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.UpdateQueryPlan; 37 38 import java.util.ArrayList ; 39 import java.util.BitSet ; 40 41 43 public class ConcurrencyOptVerify extends ConcurrencyCheckDirty { 44 45 49 protected BitSet prepareVerifyGroupMask(UpdateQueryPlan plan) { 50 ArrayList fields; 51 BitSet verifyGroupMask = new BitSet (); 52 int action = plan.getAction(); 53 54 for (int i = 0; i <= 1; i++) { 55 if (i == 0) { 56 fields = plan.getConfig().fields; 57 } else { 58 fields = plan.getConfig().hiddenFields; 59 } 60 61 if (fields == null) { 62 continue; 63 } 64 65 for (int j = 0; j < fields.size(); j++) { 66 FieldDesc f = (FieldDesc) fields.get(j); 67 68 if ((f instanceof LocalFieldDesc) && 69 (f.sqlProperties & FieldDesc.PROP_IN_CONCURRENCY_CHECK) > 0) { 70 71 if (afterImage.getSetMaskBit(f.absoluteID) || 75 ((action == QueryPlan.ACT_DELETE) && 76 beforeImage.getPresenceMaskBit(f.absoluteID))) { 77 if (f.concurrencyGroup != -1) { 78 verifyGroupMask.set(f.concurrencyGroup); 79 } 80 } 81 } 82 } 83 } 84 85 return verifyGroupMask; 86 } 87 88 protected boolean isFieldVerificationRequired(LocalFieldDesc lf, 89 BitSet verifyGroupMask) { 90 boolean fieldVerificationRequired = true; 91 92 if (lf.concurrencyGroup == -1) { 93 if (!afterImage.getSetMaskBit(lf.absoluteID)) { 94 fieldVerificationRequired = false; 95 } 96 } else { 97 if (!verifyGroupMask.get(lf.concurrencyGroup)) { 98 fieldVerificationRequired = false; 99 } 100 } 101 102 return fieldVerificationRequired; 103 } 104 105 public Object clone() { 106 return new ConcurrencyOptVerify(); 107 } 108 } 109 110 111 112 113 114 115 | Popular Tags |