void setExecuted(ThreadInfo ti, Instruction insn) { int idx = ti.getId(); if (covered == null) { covered = new BitSet[idx + 1]; } else if (idx >= covered.length) { BitSet[] a = new BitSet[idx + 1]; System.arraycopy(covered, 0, a, 0, covered.length); covered = a; } if (covered[idx] == null) { covered[idx] = new BitSet(mi.getInstructions().length); } int off = insn.getInstructionIndex(); covered[idx].set(off); if (showBranchCoverage && (insn instanceof IfInstruction)) { if (branchTrue == null) { branchTrue = new BitSet(mi.getInstructions().length); branchFalse = new BitSet(branchTrue.size()); } if (!((IfInstruction) insn).getConditionValue()) { branchTrue.set(off); } else { branchFalse.set(off); } } }
/** * Transition to the next generation by applying the Conway's Game Of Life rule. * * <ol> * <li>Any live cell with fewer than two live neighbours dies, as if caused by under-population. * <li>Any live cell with two or three live neighbours lives on to the next generation. * <li>Any live cell with more than three live neighbours dies, as if by overcrowding. * <li>Any dead cell with exactly three live neighbours becomes a live cell, as if by * reproduction. * </ol> */ public void nextGeneration() { // At each step time, looping all cells in the current generation to apply the rules for (int i = 0; i < vertical; i++) { for (int j = 0; j < horizontal; j++) { byte liveCellNeighbours = countLiveNeighbourCells(i, j); // If the cell is dead and have exactly 3 live cells neighbours becomes a live cell if (!currentGeneration.get(getIndex(i, j))) { if (liveCellNeighbours == 3) { tempGeneration.set(getIndex(i, j)); } } else { // If the cell is live cell // If live cell with fewer than two live neighbours dies // If live cell with more than three live neighbours dies, as if by overcrowding. if (liveCellNeighbours < 2 || liveCellNeighbours > 3) { tempGeneration.clear(getIndex(i, j)); } else { // Otherwise, keep the current state of the cell tempGeneration.set(getIndex(i, j), currentGeneration.get(getIndex(i, j))); } } } } // Swap the next generation to the current generation for the next step time BitSet bs = currentGeneration; currentGeneration = tempGeneration; tempGeneration = bs; }
@Override public void propagate(int evtmask) throws ContradictionException { if (PropagatorEventType.isFullPropagation(evtmask)) { if (n2 < n + vars[n].getLB()) { fails(); // TODO: could be more precise, for explanation purpose } buildDigraph(); } digraph.removeNode(n2); digraph.removeNode(n2 + 1); free.clear(); for (int i = 0; i < n; i++) { if (digraph.getPredOf(i).size() == 0) { free.set(i); } } for (int i = n; i < n2; i++) { if (digraph.getSuccOf(i).size() == 0) { free.set(i); } } int card = repairMatching(); vars[n].updateUpperBound(card, this); if (vars[n].getLB() == card) { filter(); } for (int i = 0; i < idms.length; i++) { idms[i].unfreeze(); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, ResourceJobManager struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.resourceJobManagerId); oprot.writeI32(struct.resourceJobManagerType.getValue()); BitSet optionals = new BitSet(); if (struct.isSetPushMonitoringEndpoint()) { optionals.set(0); } if (struct.isSetJobManagerBinPath()) { optionals.set(1); } if (struct.isSetJobManagerCommands()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetPushMonitoringEndpoint()) { oprot.writeString(struct.pushMonitoringEndpoint); } if (struct.isSetJobManagerBinPath()) { oprot.writeString(struct.jobManagerBinPath); } if (struct.isSetJobManagerCommands()) { { oprot.writeI32(struct.jobManagerCommands.size()); for (Map.Entry<JobManagerCommand, String> _iter5 : struct.jobManagerCommands.entrySet()) { oprot.writeI32(_iter5.getKey().getValue()); oprot.writeString(_iter5.getValue()); } } } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, AppInfoResult struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetDeviceId()) { optionals.set(0); } if (struct.isSetFlowNum()) { optionals.set(1); } if (struct.isSetResult()) { optionals.set(2); } if (struct.isSetAppdatainfo()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetDeviceId()) { oprot.writeI32(struct.deviceId); } if (struct.isSetFlowNum()) { oprot.writeI32(struct.flowNum); } if (struct.isSetResult()) { oprot.writeBool(struct.result); } if (struct.isSetAppdatainfo()) { struct.appdatainfo.write(oprot); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, DeadServer struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetServer()) { optionals.set(0); } if (struct.isSetLastStatus()) { optionals.set(1); } if (struct.isSetStatus()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetServer()) { oprot.writeString(struct.server); } if (struct.isSetLastStatus()) { oprot.writeI64(struct.lastStatus); } if (struct.isSetStatus()) { oprot.writeString(struct.status); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, MemoryUsage struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetMax()) { optionals.set(0); } if (struct.isSetTotal()) { optionals.set(1); } if (struct.isSetFree()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetMax()) { oprot.writeI64(struct.max); } if (struct.isSetTotal()) { oprot.writeI64(struct.total); } if (struct.isSetFree()) { oprot.writeI64(struct.free); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, CqlPreparedResult struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeI32(struct.itemId); oprot.writeI32(struct.count); BitSet optionals = new BitSet(); if (struct.isSetVariable_types()) { optionals.set(0); } if (struct.isSetVariable_names()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetVariable_types()) { { oprot.writeI32(struct.variable_types.size()); for (String _iter210 : struct.variable_types) { oprot.writeString(_iter210); } } } if (struct.isSetVariable_names()) { { oprot.writeI32(struct.variable_names.size()); for (String _iter211 : struct.variable_names) { oprot.writeString(_iter211); } } } }
/** * Prob0 precomputation algorithm. i.e. determine the states of an STPG which, with min/max * probability 0, reach a state in {@code target}, while remaining in those in @{code remain}. * {@code min}=true gives Prob0E, {@code min}=false gives Prob0A. * * @param stpg The STPG * @param remain Remain in these states (optional: null means "all") * @param target Target states * @param min1 Min or max probabilities for player 1 (true=lower bound, false=upper bound) * @param min2 Min or max probabilities for player 2 (true=min, false=max) */ public BitSet prob0(STPG stpg, BitSet remain, BitSet target, boolean min1, boolean min2) { int n, iters; BitSet u, soln, unknown; boolean u_done; long timer; // Start precomputation timer = System.currentTimeMillis(); if (verbosity >= 1) mainLog.println( "Starting Prob0 (" + (min1 ? "min" : "max") + (min2 ? "min" : "max") + ")..."); // Special case: no target states if (target.cardinality() == 0) { soln = new BitSet(stpg.getNumStates()); soln.set(0, stpg.getNumStates()); return soln; } // Initialise vectors n = stpg.getNumStates(); u = new BitSet(n); soln = new BitSet(n); // Determine set of states actually need to perform computation for unknown = new BitSet(); unknown.set(0, n); unknown.andNot(target); if (remain != null) unknown.and(remain); // Fixed point loop iters = 0; u_done = false; // Least fixed point - should start from 0 but we optimise by // starting from 'target', thus bypassing first iteration u.or(target); soln.or(target); while (!u_done) { iters++; // Single step of Prob0 stpg.prob0step(unknown, u, min1, min2, soln); // Check termination u_done = soln.equals(u); // u = soln u.clear(); u.or(soln); } // Negate u.flip(0, n); // Finished precomputation timer = System.currentTimeMillis() - timer; if (verbosity >= 1) { mainLog.print("Prob0 (" + (min1 ? "min" : "max") + (min2 ? "min" : "max") + ")"); mainLog.println(" took " + iters + " iterations and " + timer / 1000.0 + " seconds."); } return u; }
/** Set the bit at i in this SprayPattern to the value b. */ public void set(int i, boolean b) { // Check i if (i < 0 || i >= size) throw new IndexOutOfBoundsException(); // If our bit at i is already b, there is nothing for us to change if (get(i) == b) return; // Otherwise, we know we are going to flip the bit at i // Update our count of how many true bits we'll have after we flip the one at i if (b) ones++; // The bit at i is false, and we're going to set it to true else ones--; // The bit at i is true, and we're going to set it to false // Flipping the bit will make this whole SprayPattern false, or true if (ones == 0 || ones == size) { // Discard our BitSet array = null; // Flipping the bit will leave us with a mixture of true and false bits } else { // If we don't have a BitSet, make one if (array == null) { array = new BitSet(size); // The BitSet starts out all 0s if (!b && ones == size - 1) array.set(0, size); // If all our bits were true, make array all 1s } // Flip the bit at i to the given value array.set(i, b); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, QueryFListResult struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetResult()) { optionals.set(0); } if (struct.isSetFiles()) { optionals.set(1); } if (struct.isSetSpare()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetResult()) { struct.result.write(oprot); } if (struct.isSetFiles()) { { oprot.writeI32(struct.files.size()); for (FileInfo _iter4 : struct.files) { _iter4.write(oprot); } } } if (struct.isSetSpare()) { oprot.writeI32(struct.spare); } }
/** * @return a {@link BitSet} representation of an OR Gate truth table to be passed to the super * constructor. */ private static BitSet createORTruthTable() { BitSet truthTable = new BitSet(); truthTable.set(1); truthTable.set(2); truthTable.set(3); return truthTable; }
private static void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) { List<BlockNode> blocks = mth.getBasicBlocks(); int blocksCount = blocks.size(); BitSet hasPhi = new BitSet(blocksCount); BitSet processed = new BitSet(blocksCount); Deque<BlockNode> workList = new LinkedList<BlockNode>(); BitSet assignBlocks = la.getAssignBlocks(regNum); for (int id = assignBlocks.nextSetBit(0); id >= 0; id = assignBlocks.nextSetBit(id + 1)) { processed.set(id); workList.add(blocks.get(id)); } while (!workList.isEmpty()) { BlockNode block = workList.pop(); BitSet domFrontier = block.getDomFrontier(); for (int id = domFrontier.nextSetBit(0); id >= 0; id = domFrontier.nextSetBit(id + 1)) { if (!hasPhi.get(id) && la.isLive(id, regNum)) { BlockNode df = blocks.get(id); addPhi(df, regNum); hasPhi.set(id); if (!processed.get(id)) { processed.set(id); workList.add(df); } } } } }
BitSet getHandlers() { // this algorithm is a bit subtle - we walk through the code until // we hit a forward GOTO (or RETURN). If the insn following the goto is the // beginning of a handler, we mark everything up to the jump address // as a handler block if (handlers == null) { BitSet hs = getHandlerStarts(); Instruction[] code = mi.getInstructions(); BitSet b = new BitSet(code.length); if (!hs.isEmpty()) { for (int i = 0; i < code.length; i++) { Instruction insn = code[i]; if (insn instanceof GOTO) { GOTO gotoInsn = (GOTO) insn; if (!gotoInsn.isBackJump() && hs.get(i + 1)) { // jump around handler int handlerEnd = gotoInsn.getTarget().getInstructionIndex(); for (i++; i < handlerEnd; i++) { b.set(i); } } } else if (insn instanceof ReturnInstruction) { // everything else is handler for (i++; i < code.length; i++) { b.set(i); } } } } handlers = b; } return handlers; }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, ConditionalUpdates struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetConditions()) { optionals.set(0); } if (struct.isSetUpdates()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetConditions()) { { oprot.writeI32(struct.conditions.size()); for (Condition _iter98 : struct.conditions) { _iter98.write(oprot); } } } if (struct.isSetUpdates()) { { oprot.writeI32(struct.updates.size()); for (ColumnUpdate _iter99 : struct.updates) { _iter99.write(oprot); } } } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, RateData struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetUserID()) { optionals.set(0); } if (struct.isSetPostID()) { optionals.set(1); } if (struct.isSetRatingValue()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetUserID()) { oprot.writeI64(struct.userID); } if (struct.isSetPostID()) { oprot.writeI64(struct.postID); } if (struct.isSetRatingValue()) { oprot.writeDouble(struct.ratingValue); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TConfigInfo struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetGroup()) { optionals.set(0); } if (struct.isSetName()) { optionals.set(1); } if (struct.isSetValue()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetGroup()) { oprot.writeString(struct.group); } if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetValue()) { oprot.writeString(struct.value); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, AggregationInfo struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetAggregationType()) { optionals.set(0); } if (struct.isSetAggregationParams()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetAggregationType()) { oprot.writeString(struct.aggregationType); } if (struct.isSetAggregationParams()) { { oprot.writeI32(struct.aggregationParams.size()); for (Map.Entry<String, String> _iter31 : struct.aggregationParams.entrySet()) { oprot.writeString(_iter31.getKey()); oprot.writeString(_iter31.getValue()); } } } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, BankGroupThrift struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetId()) { optionals.set(0); } if (struct.isSetGroupType()) { optionals.set(1); } if (struct.isSetBankId()) { optionals.set(2); } if (struct.isSetBankCode()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetId()) { oprot.writeI32(struct.id); } if (struct.isSetGroupType()) { oprot.writeI32(struct.groupType); } if (struct.isSetBankId()) { oprot.writeI32(struct.bankId); } if (struct.isSetBankCode()) { oprot.writeString(struct.bankCode); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Endpoint struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetIpv4()) { optionals.set(0); } if (struct.isSetPort()) { optionals.set(1); } if (struct.isSetService_name()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetIpv4()) { oprot.writeI32(struct.ipv4); } if (struct.isSetPort()) { oprot.writeI16(struct.port); } if (struct.isSetService_name()) { oprot.writeString(struct.service_name); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TGetOperationStatusResp struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.status.write(oprot); BitSet optionals = new BitSet(); if (struct.isSetOperationState()) { optionals.set(0); } if (struct.isSetSqlState()) { optionals.set(1); } if (struct.isSetErrorCode()) { optionals.set(2); } if (struct.isSetErrorMessage()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetOperationState()) { oprot.writeI32(struct.operationState.getValue()); } if (struct.isSetSqlState()) { oprot.writeString(struct.sqlState); } if (struct.isSetErrorCode()) { oprot.writeI32(struct.errorCode); } if (struct.isSetErrorMessage()) { oprot.writeString(struct.errorMessage); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Role struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetRoleName()) { optionals.set(0); } if (struct.isSetCreateTime()) { optionals.set(1); } if (struct.isSetOwnerName()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetRoleName()) { oprot.writeString(struct.roleName); } if (struct.isSetCreateTime()) { oprot.writeI32(struct.createTime); } if (struct.isSetOwnerName()) { oprot.writeString(struct.ownerName); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Response struct) throws TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetResultType()) { optionals.set(0); } if (struct.isSetResult()) { optionals.set(1); } if (struct.isSetOperationId()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetResultType()) { oprot.writeString(struct.ResultType); } if (struct.isSetResult()) { oprot.writeBinary(struct.Result); } if (struct.isSetOperationId()) { oprot.writeString(struct.OperationId); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Graph struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetNodeType()) { optionals.set(0); } if (struct.isSetRoots()) { optionals.set(1); } if (struct.isSetAdjacencyList()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetNodeType()) { oprot.writeI32(struct.nodeType.getValue()); } if (struct.isSetRoots()) { { oprot.writeI32(struct.roots.size()); for (String _iter16 : struct.roots) { oprot.writeString(_iter16); } } } if (struct.isSetAdjacencyList()) { { oprot.writeI32(struct.adjacencyList.size()); for (Adjacency _iter17 : struct.adjacencyList) { _iter17.write(oprot); } } } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, Result struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetValue()) { optionals.set(0); } if (struct.isSetError()) { optionals.set(1); } if (struct.isSetErrortext()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetValue()) { oprot.writeString(struct.value); } if (struct.isSetError()) { oprot.writeI32(struct.error.getValue()); } if (struct.isSetErrortext()) { oprot.writeString(struct.errortext); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TCommandTransfer struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetApplicationName()) { optionals.set(0); } if (struct.isSetAgentId()) { optionals.set(1); } if (struct.isSetStartTime()) { optionals.set(2); } if (struct.isSetPayload()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetApplicationName()) { oprot.writeString(struct.applicationName); } if (struct.isSetAgentId()) { oprot.writeString(struct.agentId); } if (struct.isSetStartTime()) { oprot.writeI64(struct.startTime); } if (struct.isSetPayload()) { oprot.writeBinary(struct.payload); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, StorageResourceDescription struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.storageResourceId); oprot.writeString(struct.hostName); BitSet optionals = new BitSet(); if (struct.isSetStorageResourceDescription()) { optionals.set(0); } if (struct.isSetEnabled()) { optionals.set(1); } if (struct.isSetDataMovementInterfaces()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetStorageResourceDescription()) { oprot.writeString(struct.storageResourceDescription); } if (struct.isSetEnabled()) { oprot.writeBool(struct.enabled); } if (struct.isSetDataMovementInterfaces()) { { oprot.writeI32(struct.dataMovementInterfaces.size()); for (org.apache.airavata.model.data.movement.DataMovementInterface _iter4 : struct.dataMovementInterfaces) { _iter4.write(oprot); } } } }
private void equivalent(int p1, int p2) { BitSet b = equivalence.get(p1); b.set(p2); b = equivalence.get(p2); b.set(p1); }
@Override protected void verifyContentAcceptance( EventSequence alpha, ItemSet set, Vector<Element> alphabet, int[] sup, ProjectedDB[] projDBs, int indProj, int sInd, int eInd, boolean inParallel, BitSet visited, BitSet accepted) { for (int i = 0; i < set.size(); i++) { Element el = set.elementAt(i); int found = alphabet.indexOf(el); if ((-1 != found)) { if (!visited.get(found)) { visited.set(found); accepted.set(found, isAcceptedByRelaxation(alpha, el, inParallel)); } if (accepted.get(found)) { if (!projDBs[found].contains(sInd)) sup[found]++; projDBs[found].set(sInd, eInd); } } } }
/** Find non-locals variables. Algorithm from Briggs, Cooper, Harvey and Simpson */ public BitSet findNonLocals() { BitSet nonLocals = new BitSet(nbVar); BitSet killed = new BitSet(nbVar); BitSet emptySet = new BitSet(nbVar); for (BasicBlock bb = firstBB; bb != null; bb = bb.getNext()) { // clear killed set killed.and(emptySet); Iterator insts = bb.getInstructions(); while (insts.hasNext()) { QInst inst = (QInst) insts.next(); QOperandBox[] ops = inst.getUses(); for (int i = 0; i < ops.length; ++i) { QOperand op = ops[i].getOperand(); if (op instanceof QVar) { int r = ((QVar) op).getRegister(); if (!killed.get(r)) { nonLocals.set(r); } } } if (inst.defVar()) { QOperand op = inst.getDefined().getOperand(); if (op instanceof QVar) { int r = ((QVar) op).getRegister(); killed.set(r); } } } } return nonLocals; }