Пример #1
0
  public int doNestedTermConjunctions(
      IndexSearcher s, int termsInIndex, int maxOuterClauses, int maxClauses, int iter)
      throws IOException {
    int ret = 0;
    long nMatches = 0;
    for (int i = 0; i < iter; i++) {
      int oClauses = r.nextInt(maxOuterClauses - 1) + 2;
      BooleanQuery oq = new BooleanQuery();
      for (int o = 0; o < oClauses; o++) {

        int nClauses = r.nextInt(maxClauses - 1) + 2; // min 2 clauses
        BooleanQuery bq = new BooleanQuery();
        BitSet termflag = new BitSet(termsInIndex);
        for (int j = 0; j < nClauses; j++) {
          int tnum;
          // don't pick same clause twice
          tnum = r.nextInt(termsInIndex);
          if (termflag.get(tnum)) tnum = termflag.nextClearBit(tnum);
          if (tnum < 0 || tnum >= 25) tnum = termflag.nextClearBit(0);
          termflag.set(tnum);
          Query tq = new TermQuery(terms[tnum]);
          bq.add(tq, BooleanClause.Occur.MUST);
        } // inner

        oq.add(bq, BooleanClause.Occur.MUST);
      } // outer

      CountingHitCollector hc = new CountingHitCollector();
      s.search(oq, hc);
      nMatches += hc.getCount();
      ret += hc.getSum();
    }
    System.out.println("Average number of matches=" + (nMatches / iter));
    return ret;
  }
  private void assignConnectorPolicy(ActivityCluster ac, Map<ActivityId, ActivityPlan> taskMap) {
    Map<ConnectorDescriptorId, IConnectorPolicy> cPolicyMap =
        new HashMap<ConnectorDescriptorId, IConnectorPolicy>();
    Set<ActivityId> activities = ac.getActivityMap().keySet();
    BitSet targetBitmap = new BitSet();
    for (ActivityId a1 : activities) {
      Task[] ac1TaskStates = taskMap.get(a1).getTasks();
      int nProducers = ac1TaskStates.length;
      List<IConnectorDescriptor> outputConns = ac.getActivityOutputMap().get(a1);
      if (outputConns != null) {
        for (IConnectorDescriptor c : outputConns) {
          ConnectorDescriptorId cdId = c.getConnectorId();
          ActivityId a2 = ac.getConsumerActivity(cdId);
          Task[] ac2TaskStates = taskMap.get(a2).getTasks();
          int nConsumers = ac2TaskStates.length;

          int[] fanouts = new int[nProducers];
          if (c.allProducersToAllConsumers()) {
            for (int i = 0; i < nProducers; ++i) {
              fanouts[i] = nConsumers;
            }
          } else {
            for (int i = 0; i < nProducers; ++i) {
              c.indicateTargetPartitions(nProducers, nConsumers, i, targetBitmap);
              fanouts[i] = targetBitmap.cardinality();
            }
          }
          IConnectorPolicy cp = assignConnectorPolicy(ac, c, nProducers, nConsumers, fanouts);
          cPolicyMap.put(cdId, cp);
        }
      }
    }
    scheduler.getJobRun().getConnectorPolicyMap().putAll(cPolicyMap);
  }
Пример #3
0
 @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);
       }
     }
   }
 }
 @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);
       }
     }
   }
 }
Пример #5
0
 private void buildSCC() {
   digraph.removeNode(n2);
   digraph.removeNode(n2 + 1);
   digraph.addNode(n2);
   digraph.addNode(n2 + 1);
   // TODO CHECK THIS PART
   for (int i = 0; i < n; i++) {
     if (free.get(i)) {
       digraph.addArc(n2, i);
     } else {
       digraph.addArc(i, n2);
     }
   }
   for (int i = n; i < n2; i++) {
     if (free.get(i)) {
       digraph.addArc(i, n2 + 1);
     } else {
       digraph.addArc(n2 + 1, i);
     }
   }
   SCCfinder.findAllSCC();
   nodeSCC = SCCfinder.getNodesSCC();
   digraph.removeNode(n2);
   digraph.removeNode(n2 + 1);
 }
Пример #6
0
  /**
   * Returns an exact copy of the game. This may be used for forward searches such as minimax. The
   * copying is relatively efficient.
   *
   * @return the game
   */
  public Game copy() {
    Game copy = new Game();

    copy.seed = seed;
    copy.rnd = new Random(seed);
    copy.laberintoActua = laberintoActua;
    copy.pills = (BitSet) pills.clone();
    copy.powerPills = (BitSet) powerPills.clone();
    copy.indiceDeLaberinto = indiceDeLaberinto;
    copy.cuentaElLvl = cuentaElLvl;
    copy.tiempoLvlActual = tiempoLvlActual;
    copy.tiempoTotal = tiempoTotal;
    copy.score = score;
    copy.fastamasComerMultiplicador = fastamasComerMultiplicador;
    copy.juegoTerminado = juegoTerminado;
    copy.timeOfLastGlobalReversal = timeOfLastGlobalReversal;
    copy.pacmanFueComido = pacmanFueComido;
    copy.pastillaFueComida = pastillaFueComida;
    copy.pildoraPoderFueComida = pildoraPoderFueComida;
    copy.pacman = pacman.copy();

    copy.fantasmaComido = new EnumMap<GHOST, Boolean>(GHOST.class);
    copy.fantasmas = new EnumMap<GHOST, Ghost>(GHOST.class);

    for (GHOST ghostType : GHOST.values()) {
      copy.fantasmas.put(ghostType, fantasmas.get(ghostType).copy());
      copy.fantasmaComido.put(ghostType, fantasmaComido.get(ghostType));
    }

    return copy;
  }
Пример #7
0
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, LineageCommand struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   BitSet incoming = iprot.readBitSet(2);
   if (incoming.get(0)) {
     struct.commandType = tachyon.thrift.CommandType.findByValue(iprot.readI32());
     struct.setCommandTypeIsSet(true);
   }
   if (incoming.get(1)) {
     {
       org.apache.thrift.protocol.TList _list13 =
           new org.apache.thrift.protocol.TList(
               org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
       struct.checkpointFiles = new ArrayList<CheckpointFile>(_list13.size);
       CheckpointFile _elem14;
       for (int _i15 = 0; _i15 < _list13.size; ++_i15) {
         _elem14 = new CheckpointFile();
         _elem14.read(iprot);
         struct.checkpointFiles.add(_elem14);
       }
     }
     struct.setCheckpointFilesIsSet(true);
   }
 }
Пример #8
0
 public zziz zzgX() {
   int i = 0;
   int ai[] = null;
   if (zzGu != null) {
     int ai1[] = new int[zzGu.cardinality()];
     int j = zzGu.nextSetBit(0);
     do {
       ai = ai1;
       if (j < 0) {
         break;
       }
       ai1[i] = j;
       j = zzGu.nextSetBit(j + 1);
       i++;
     } while (true);
   }
   return new zziz(
       mName,
       zzGo,
       zzGp,
       zzGq,
       zzGr,
       zzGs,
       (zzit[]) zzGt.toArray(new zzit[zzGt.size()]),
       ai,
       zzGv);
 }
Пример #9
0
  @Override
  public void visitCode(Code obj) {
    Method m = getMethod();
    if (m.getReturnType() == Type.VOID) {
      return;
    }

    stack.resetForMethodEntry(this);
    ifBlocks.clear();
    activeUnconditional = null;

    CodeException[] ces = obj.getExceptionTable();
    if (CollectionUtils.isEmpty(ces)) {
      catchPCs = null;
    } else {
      catchPCs = new BitSet();
      for (CodeException ce : ces) {
        catchPCs.set(ce.getHandlerPC());
      }
    }
    gotoBranchPCs.clear();
    casePositions.clear();
    lookingForResetOp = false;

    try {
      super.visitCode(obj);
    } catch (StopOpcodeParsingException e) {
      // reported an issue, so get out
    }
  }
Пример #10
0
 @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);
   }
 }
Пример #11
0
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, TGetOperationStatusResp struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   struct.status = new TStatus();
   struct.status.read(iprot);
   struct.setStatusIsSet(true);
   BitSet incoming = iprot.readBitSet(4);
   if (incoming.get(0)) {
     struct.operationState =
         org.apache.hive.service.cli.thrift.TOperationState.findByValue(iprot.readI32());
     struct.setOperationStateIsSet(true);
   }
   if (incoming.get(1)) {
     struct.sqlState = iprot.readString();
     struct.setSqlStateIsSet(true);
   }
   if (incoming.get(2)) {
     struct.errorCode = iprot.readI32();
     struct.setErrorCodeIsSet(true);
   }
   if (incoming.get(3)) {
     struct.errorMessage = iprot.readString();
     struct.setErrorMessageIsSet(true);
   }
 }
Пример #12
0
 @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, 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);
   }
 }
Пример #14
0
 public BitSet randBitSet(int sz, int numBitsToSet) {
   BitSet set = new BitSet(sz);
   for (int i = 0; i < numBitsToSet; i++) {
     set.set(r.nextInt(sz));
   }
   return set;
 }
Пример #15
0
 /**
  * Faster removal of components from a entity.
  *
  * @param type the type of component to remove from this entity
  * @return this EntityEdit for chaining
  */
 public EntityEdit remove(ComponentType type) {
   if (componentBits.get(type.getIndex())) {
     world.getComponentManager().removeComponent(entity, type);
     componentBits.clear(type.getIndex());
   }
   return this;
 }
  /**
   * Updates the interal bitset from <code>iterator</code>. This will set <code>validMask</code> to
   * true if <code>iterator</code> is non-null.
   */
  private void updateMask(AttributedCharacterIterator iterator) {
    if (iterator != null) {
      validMask = true;
      this.iterator = iterator;

      // Update the literal mask
      if (literalMask == null) {
        literalMask = new BitSet();
      } else {
        for (int counter = literalMask.length() - 1; counter >= 0; counter--) {
          literalMask.clear(counter);
        }
      }

      iterator.first();
      while (iterator.current() != CharacterIterator.DONE) {
        Map attributes = iterator.getAttributes();
        boolean set = isLiteral(attributes);
        int start = iterator.getIndex();
        int end = iterator.getRunLimit();

        while (start < end) {
          if (set) {
            literalMask.set(start);
          } else {
            literalMask.clear(start);
          }
          start++;
        }
        iterator.setIndex(start);
      }
    }
  }
Пример #17
0
 @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);
   }
 }
Пример #18
0
 @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());
       }
     }
   }
 }
Пример #19
0
 @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);
   }
 }
Пример #20
0
  private void testConsistency() {
    // test if there's an entry for every set bit in availabilityMap
    for (int i = availabilityMap.nextSetBit(0); i >= 0; i = availabilityMap.nextSetBit(i + 1)) {
      if (iBlockRegistry.getRaw(i) == null
          && iItemRegistry.getRaw(i) == null
          && !blockedIds.contains(i)) {
        throw new IllegalStateException(
            String.format("availabilityMap references empty entries for id %d.", i));
      }
    }

    for (int pass = 0; pass < 2; pass++) {
      boolean isBlock = pass == 0;
      String type = isBlock ? "block" : "item";
      FMLControlledNamespacedRegistry<?> registry = isBlock ? iBlockRegistry : iItemRegistry;
      registry.validateContent(
          (isBlock ? MAX_BLOCK_ID : MAX_ITEM_ID),
          type,
          availabilityMap,
          blockedIds,
          iBlockRegistry);
    }

    FMLLog.fine("Registry consistency check successful");
  }
Пример #21
0
 /**
  * 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;
 }
Пример #22
0
  @Override
  public void setProperty(String propertyName, Object value, BitSet bsSelected) {

    // if (Logger.debugging) {
    // Logger.debug("Hover.setProperty(" + propertyName + "," + value + ")");
    // }

    if ("target" == propertyName) {
      if (value == null) atomIndex = -1;
      else {
        atomIndex = ((Integer) value).intValue();
      }
      return;
    }

    if ("text" == propertyName) {
      text = (String) value;
      if (text != null && text.length() == 0) text = null;
      return;
    }

    if ("specialLabel" == propertyName) {
      specialLabel = (String) value;
      return;
    }

    if ("atomLabel" == propertyName) {
      String text = (String) value;
      if (text != null && text.length() == 0) text = null;
      int count = viewer.getAtomCount();
      if (atomFormats == null || atomFormats.length < count) atomFormats = new String[count];
      for (int i = bsSelected.nextSetBit(0); i >= 0; i = bsSelected.nextSetBit(i + 1))
        atomFormats[i] = text;
      return;
    }

    if ("xy" == propertyName) {
      xy = (Point3i) value;
      return;
    }

    if ("label" == propertyName) {
      labelFormat = (String) value;
      if (labelFormat != null && labelFormat.length() == 0) labelFormat = null;
      return;
    }

    if (propertyName == "deleteModelAtoms") {
      if (atomFormats != null) {
        int firstAtomDeleted = ((int[]) ((Object[]) value)[2])[1];
        int nAtomsDeleted = ((int[]) ((Object[]) value)[2])[2];
        atomFormats =
            (String[]) ArrayUtil.deleteElements(atomFormats, firstAtomDeleted, nAtomsDeleted);
      }
      atomIndex = -1;
      return;
    }

    super.setProperty(propertyName, value, null);
  }
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, StorageResourceDescription struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   struct.storageResourceId = iprot.readString();
   struct.setStorageResourceIdIsSet(true);
   struct.hostName = iprot.readString();
   struct.setHostNameIsSet(true);
   BitSet incoming = iprot.readBitSet(3);
   if (incoming.get(0)) {
     struct.storageResourceDescription = iprot.readString();
     struct.setStorageResourceDescriptionIsSet(true);
   }
   if (incoming.get(1)) {
     struct.enabled = iprot.readBool();
     struct.setEnabledIsSet(true);
   }
   if (incoming.get(2)) {
     {
       org.apache.thrift.protocol.TList _list5 =
           new org.apache.thrift.protocol.TList(
               org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
       struct.dataMovementInterfaces =
           new ArrayList<org.apache.airavata.model.data.movement.DataMovementInterface>(
               _list5.size);
       org.apache.airavata.model.data.movement.DataMovementInterface _elem6;
       for (int _i7 = 0; _i7 < _list5.size; ++_i7) {
         _elem6 = new org.apache.airavata.model.data.movement.DataMovementInterface();
         _elem6.read(iprot);
         struct.dataMovementInterfaces.add(_elem6);
       }
     }
     struct.setDataMovementInterfacesIsSet(true);
   }
 }
Пример #24
0
 @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);
   }
 }
Пример #25
0
 @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();
   }
 }
Пример #26
0
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, SelectQuery struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   BitSet incoming = iprot.readBitSet(2);
   if (incoming.get(0)) {
     {
       org.apache.thrift.protocol.TList _list21 =
           new org.apache.thrift.protocol.TList(
               org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
       struct.operations = new ArrayList<SelectOperation>(_list21.size);
       for (int _i22 = 0; _i22 < _list21.size; ++_i22) {
         SelectOperation _elem23; // required
         _elem23 = new SelectOperation();
         _elem23.read(iprot);
         struct.operations.add(_elem23);
       }
     }
     struct.setOperationsIsSet(true);
   }
   if (incoming.get(1)) {
     struct.page = new Page();
     struct.page.read(iprot);
     struct.setPageIsSet(true);
   }
 }
Пример #27
0
 void computeIn(LinkedList<Vertex> worklist) {
   int i;
   BitSet old;
   BitSet ne;
   Vertex v;
   ListIterator<Vertex> iter;
   iter = succ.listIterator();
   while (iter.hasNext()) {
     v = iter.next();
     out.or(v.in);
   }
   old = in;
   in = new BitSet();
   in.or(out);
   in.andNot(def);
   in.or(use);
   if (!in.equals(old)) {
     iter = pred.listIterator();
     while (iter.hasNext()) {
       v = iter.next();
       if (!v.listed) {
         worklist.addLast(v);
         v.listed = true;
       }
     }
   }
 }
Пример #28
0
  public static String encodeURI(String url, String env) throws UnsupportedEncodingException {
    BitSet urlsafe = new BitSet();
    // alpha characters
    for (int i = 'a'; i <= 'z'; i++) {
      urlsafe.set(i);
    }
    for (int i = 'A'; i <= 'Z'; i++) {
      urlsafe.set(i);
    }
    // numeric characters
    for (int i = '0'; i <= '9'; i++) {
      urlsafe.set(i);
    }
    // special chars
    urlsafe.set('-');
    urlsafe.set('_');
    urlsafe.set('.');
    urlsafe.set('*');
    // blank to be replaced with +
    urlsafe.set(' ');
    urlsafe.set(':');
    urlsafe.set('/');
    urlsafe.set('=');
    urlsafe.set('#');
    urlsafe.set('?');
    urlsafe.set('&');
    urlsafe.set('%');

    return new String(URLCodec.encodeUrl(urlsafe, url.getBytes(env)));
  }
Пример #29
0
 /**
  * @param ev
  * @param alphabet
  * @param bs
  * @param sup
  * @param seqDB
  * @param posDB
  * @param sInd
  * @param eInd
  */
 protected void verifyContentGeneralAcceptance(
     Event ev,
     Vector<Element> alphabet,
     BitSet bs,
     long[] sup,
     Vector<Integer>[] seqDB,
     Vector<Integer>[] posDB,
     int sInd,
     int eInd) {
   ItemSet set = ev.getSet();
   for (int i = 0; i < set.size(); i++) {
     Element el = set.elementAt(i);
     int found = alphabet.indexOf(el);
     if (-1 != found) {
       // If current sequence did not contribute to the support of
       // this element yet, increment its support
       if (!bs.get(found)) {
         sup[found]++;
         bs.set(found);
       }
       // In any case, add another object to projecyed db
       seqDB[found].addElement(new Integer(sInd));
       posDB[found].addElement(new Integer(eInd));
     }
   }
 }
Пример #30
0
  public int doNestedConjunctions(int iter, int maxOuterClauses, int maxClauses)
      throws IOException {
    int ret = 0;
    long nMatches = 0;

    for (int i = 0; i < iter; i++) {
      int oClauses = r.nextInt(maxOuterClauses - 1) + 2;
      BooleanQuery oq = new BooleanQuery();
      BitSet result = null;

      for (int o = 0; o < oClauses; o++) {

        int nClauses = r.nextInt(maxClauses - 1) + 2; // min 2 clauses
        BooleanQuery bq = new BooleanQuery();
        for (int j = 0; j < nClauses; j++) {
          result = addClause(bq, result);
        }

        oq.add(bq, BooleanClause.Occur.MUST);
      } // outer

      CountingHitCollector hc =
          validate ? new MatchingHitCollector(result) : new CountingHitCollector();
      s.search(oq, hc);
      nMatches += hc.getCount();
      ret += hc.getSum();
      if (validate) assertEquals(result.cardinality(), hc.getCount());
      // System.out.println(hc.getCount());
    }
    System.out.println("Average number of matches=" + (nMatches / iter));
    return ret;
  }