java.util.BitSet Java Examples

The following examples show how to use java.util.BitSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: floodlight_with_topoguard   Author: xuraylei   File: PutRequestMessage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, PutRequestMessage struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  struct.header.write(oprot);
  oprot.writeString(struct.storeName);
  oprot.writeBinary(struct.key);
  BitSet optionals = new BitSet();
  if (struct.isSetVersionedValue()) {
    optionals.set(0);
  }
  if (struct.isSetValue()) {
    optionals.set(1);
  }
  oprot.writeBitSet(optionals, 2);
  if (struct.isSetVersionedValue()) {
    struct.versionedValue.write(oprot);
  }
  if (struct.isSetValue()) {
    oprot.writeBinary(struct.value);
  }
}
 
Example #2
Source Project: constellation   Author: constellation-app   File: SelectionRowFilter.java    License: Apache License 2.0 6 votes vote down vote up
SelectionRowFilter(final Graph graph, final GraphElementType et) {
    selected = new BitSet();
    final ReadableGraph rg = graph.getReadableGraph();
    try {
        final boolean isVertex = et == GraphElementType.VERTEX;
        final int count = isVertex ? rg.getVertexCount() : rg.getTransactionCount();
        final int selectedId = rg.getAttribute(et, (isVertex ? VisualConcept.VertexAttribute.SELECTED : VisualConcept.TransactionAttribute.SELECTED).getName());
        for (int position = 0; position < count; position++) {
            final int id = isVertex ? rg.getVertex(position) : rg.getTransaction(position);

            final boolean isSelected = rg.getBooleanValue(selectedId, id);
            if (isSelected) {
                selected.set(position);
            }
        }
    } finally {
        rg.release();
    }
}
 
Example #3
Source Project: galaxy-sdk-java   Author: XiaoMi   File: MetricService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void write(libthrift091.protocol.TProtocol prot, queryConsumerGroup_result struct) throws libthrift091.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetSuccess()) {
    optionals.set(0);
  }
  if (struct.isSetE()) {
    optionals.set(1);
  }
  oprot.writeBitSet(optionals, 2);
  if (struct.isSetSuccess()) {
    struct.success.write(oprot);
  }
  if (struct.isSetE()) {
    struct.e.write(oprot);
  }
}
 
Example #4
Source Project: hollow   Author: Netflix   File: TransitiveSetTraverser.java    License: Apache License 2.0 6 votes vote down vote up
private static void addTransitiveMatches(HollowReadStateEngine stateEngine, HollowMapTypeReadState typeState, Map<String, BitSet> matches) {
    HollowMapSchema schema = typeState.getSchema();
    BitSet matchingOrdinals = getOrCreateBitSet(matches, schema.getName(), typeState.maxOrdinal());

    HollowTypeReadState keyTypeState = stateEngine.getTypeState(schema.getKeyType());
    HollowTypeReadState valueTypeState = stateEngine.getTypeState(schema.getValueType());

    BitSet keyOrdinals = getOrCreateBitSet(matches, schema.getKeyType(), keyTypeState.maxOrdinal());
    BitSet valueOrdinals = getOrCreateBitSet(matches, schema.getValueType(), valueTypeState.maxOrdinal());

    int ordinal = matchingOrdinals.nextSetBit(0);
    while(ordinal != -1) {
        HollowMapEntryOrdinalIterator iter = typeState.ordinalIterator(ordinal);
        while(iter.next()) {
            keyOrdinals.set(iter.getKey());
            valueOrdinals.set(iter.getValue());
        }

        ordinal = matchingOrdinals.nextSetBit(ordinal + 1);
    }
}
 
Example #5
Source Project: phoenix   Author: cloudera-labs   File: PhoenixPreparedStatement.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ResultSetMetaData getMetaData() throws SQLException {
    if (statement.getOperation().isMutation()) {
        return null;
    }
    int paramCount = statement.getBindCount();
    List<Object> params = this.getParameters();
    BitSet unsetParams = new BitSet(statement.getBindCount());
    for (int i = 0; i < paramCount; i++) {
        if ( params.get(i) == BindManager.UNBOUND_PARAMETER) {
            unsetParams.set(i);
            params.set(i, null);
        }
    }
    try {
        // Just compile top level query without optimizing to get ResultSetMetaData
        QueryPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE);
        return new PhoenixResultSetMetaData(this.getConnection(), plan.getProjector());
    } finally {
        int lastSetBit = 0;
        while ((lastSetBit = unsetParams.nextSetBit(lastSetBit)) != -1) {
            params.set(lastSetBit, BindManager.UNBOUND_PARAMETER);
            lastSetBit++;
        }
    }
}
 
Example #6
Source Project: galaxy-sdk-java   Author: XiaoMi   File: Record.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void read(libthrift091.protocol.TProtocol prot, Record struct) throws libthrift091.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
    struct.data = iprot.readBinary();
    struct.setDataIsSet(true);
  }
  if (incoming.get(1)) {
    struct.checksum = iprot.readI32();
    struct.setChecksumIsSet(true);
  }
  if (incoming.get(2)) {
    struct.eof = iprot.readBool();
    struct.setEofIsSet(true);
  }
}
 
Example #7
Source Project: Panako   Author: JorenSix   File: RafsCliTest.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private static List<BitSetWithID> extractPackedPrints(File f,int fileIndex){		
	final int sampleRate = Config.getInt(Key.RAFS_SAMPLE_RATE);//2250Hz Nyquist frequency
	final int size = Config.getInt(Key.RAFS_FFT_SIZE);
	final int overlap =  size - Config.getInt(Key.RAFS_FFT_STEP_SIZE); 
	String file = f.getAbsolutePath();
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	RafsExtractor ex = new RafsExtractor(file, true);
	RafsPacker packer = new RafsPacker(ex,true);
	//String baseName = f.getName();
	d.setZeroPadFirstBuffer(true);
	d.addAudioProcessor(ex);
	d.addAudioProcessor(packer);
	d.run();
	List<BitSetWithID> prints = new ArrayList<>();
	
	for (Map.Entry<Float, BitSet> frameEntry : packer.packedFingerprints.entrySet()) {
		int offset = (int) (frameEntry.getKey() * 1000);
		prints.add(new BitSetWithID(fileIndex * (1L<<32)  + offset, frameEntry.getValue()));
	}
	return prints;		
}
 
Example #8
Source Project: ignite   Author: apache   File: GridPartitionStateMap.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates map copy.
 * @param from Source map.
 * @param onlyActive Retains only active partitions.
 */
public GridPartitionStateMap(GridPartitionStateMap from, boolean onlyActive) {
    size = from.size();

    states = (BitSet)from.states.clone();

    if (onlyActive) {
        int part = 0;

        int maxPart = states.size() / BITS;

        while (part < maxPart) {
            GridDhtPartitionState state = from.state(part);

            if (state != null && !state.active())
                remove(part);

            part++;
        }
    }
}
 
Example #9
Source Project: kylin   Author: apache   File: GeneticAlgorithm.java    License: Apache License 2.0 6 votes vote down vote up
protected Population initRandomPopulation(BitsChromosomeHelper helper) {
    List<Chromosome> chromosomeList = Lists.newArrayListWithCapacity(populationSize);

    while (chromosomeList.size() < populationSize) {
        BitSet bitSetForSelection = new BitSet(helper.getLength());

        //Initialize selection genes
        double totalSpace = 0;
        while (totalSpace < helper.spaceLimit) {
            int j = org.apache.commons.math3.genetics.GeneticAlgorithm.getRandomGenerator()
                    .nextInt(helper.getLength());
            if (!bitSetForSelection.get(j)) {
                totalSpace += helper.getCuboidSizeByBitIndex(j);
                bitSetForSelection.set(j);
            }
        }

        Chromosome chromosome = new BitsChromosome(bitSetForSelection, benefitPolicy.getInstance(), helper);
        chromosomeList.add(chromosome);
    }
    return new ElitisticListPopulation(chromosomeList, maxPopulationSize, 0.8);
}
 
Example #10
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ConcurrentSkipListSetTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Subsets of subsets subdivide correctly
 */
public void testRecursiveSubSets() throws Exception {
    int setSize = expensiveTests ? 1000 : 100;
    Class cl = ConcurrentSkipListSet.class;

    NavigableSet<Integer> set = newSet(cl);
    BitSet bs = new BitSet(setSize);

    populate(set, setSize, bs);
    check(set,                 0, setSize - 1, true, bs);
    check(set.descendingSet(), 0, setSize - 1, false, bs);

    mutateSet(set, 0, setSize - 1, bs);
    check(set,                 0, setSize - 1, true, bs);
    check(set.descendingSet(), 0, setSize - 1, false, bs);

    bashSubSet(set.subSet(0, true, setSize, false),
               0, setSize - 1, true, bs);
}
 
Example #11
Source Project: spotbugs   Author: spotbugs   File: FindDeadLocalStores.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * If feature is enabled, suppress warnings where there is at least one live
 * store on the line where the warning would be reported.
 *
 * @param accumulator
 *            BugAccumulator containing warnings for method
 * @param liveStoreSourceLineSet
 *            bitset of lines where at least one live store was seen
 */
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) {
    if (!SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE) {
        return;
    }

    // Eliminate any accumulated warnings for instructions
    // that (due to inlining) *can* be live stores.
    entryLoop: for (Iterator<? extends BugInstance> i = accumulator.uniqueBugs().iterator(); i.hasNext();) {

        for (SourceLineAnnotation annotation : accumulator.locations(i.next())) {
            if (liveStoreSourceLineSet.get(annotation.getStartLine())) {
                // This instruction can be a live store; don't report
                // it as a warning.
                i.remove();
                continue entryLoop;
            }
        }
    }
}
 
Example #12
Source Project: incubator-sentry   Author: apache   File: TListSentryPrivilegesByAuthResponse.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TListSentryPrivilegesByAuthResponse struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  struct.status.write(oprot);
  BitSet optionals = new BitSet();
  if (struct.isSetPrivilegesMapByAuth()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetPrivilegesMapByAuth()) {
    {
      oprot.writeI32(struct.privilegesMapByAuth.size());
      for (Map.Entry<TSentryAuthorizable, TSentryPrivilegeMap> _iter127 : struct.privilegesMapByAuth.entrySet())
      {
        _iter127.getKey().write(oprot);
        _iter127.getValue().write(oprot);
      }
    }
  }
}
 
Example #13
Source Project: Bats   Author: lealone   File: BitSets.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns an iterable over the bits in a bitmap that are set to '1'.
 *
 * <p>This allows you to iterate over a bit set using a 'foreach' construct.
 * For instance:
 *
 * <blockquote><code>
 * BitSet bitSet;<br>
 * for (int i : Util.toIter(bitSet)) {<br>
 * &nbsp;&nbsp;print(i);<br>
 * }</code></blockquote>
 *
 * @param bitSet Bit set
 * @return Iterable
 */
public static Iterable<Integer> toIter(final BitSet bitSet) {
  return () -> new Iterator<Integer>() {
    int i = bitSet.nextSetBit(0);

    public boolean hasNext() {
      return i >= 0;
    }

    public Integer next() {
      int prev = i;
      i = bitSet.nextSetBit(i + 1);
      return prev;
    }

    public void remove() {
      throw new UnsupportedOperationException();
    }
  };
}
 
Example #14
Source Project: ZjDroid   Author: halfkiss   File: PostInstructionRegisterInfoMethodItem.java    License: Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #15
Source Project: flink   Author: apache   File: FlinkAggregateJoinTransposeRule.java    License: Apache License 2.0 6 votes vote down vote up
private static void populateEquivalences(Map<Integer, BitSet> equivalence,
		RexNode predicate) {
	switch (predicate.getKind()) {
		case EQUALS:
			RexCall call = (RexCall) predicate;
			final List<RexNode> operands = call.getOperands();
			if (operands.get(0) instanceof RexInputRef) {
				final RexInputRef ref0 = (RexInputRef) operands.get(0);
				if (operands.get(1) instanceof RexInputRef) {
					final RexInputRef ref1 = (RexInputRef) operands.get(1);
					populateEquivalence(equivalence, ref0.getIndex(), ref1.getIndex());
					populateEquivalence(equivalence, ref1.getIndex(), ref0.getIndex());
				}
			}
	}
}
 
Example #16
Source Project: openjdk-8   Author: bpupadhyaya   File: BitSetStreamTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testRandomStream() {
    final int size = 1024 * 1024;
    final int[] seeds = {
            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
            43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    final byte[] bytes = new byte[size];
    for (int seed : seeds) {
        final Random random = new Random(seed);
        random.nextBytes(bytes);
        final BitSet bitSet = BitSet.valueOf(bytes);
        final int cardinality = bitSet.cardinality();
        final IntStream stream = bitSet.stream();
        final int[] array = stream.toArray();
        assertEquals(array.length, cardinality);
        int nextSetBit = -1;
        for (int i=0; i < cardinality; i++) {
            nextSetBit = bitSet.nextSetBit(nextSetBit + 1);
            assertEquals(array[i], nextSetBit);
        }
    }
}
 
Example #17
Source Project: galaxy-sdk-java   Author: XiaoMi   File: TotalBill.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void read(libthrift091.protocol.TProtocol prot, TotalBill struct) throws libthrift091.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(2);
  if (incoming.get(0)) {
    struct.totalCost = iprot.readDouble();
    struct.setTotalCostIsSet(true);
  }
  if (incoming.get(1)) {
    {
      libthrift091.protocol.TList _list5 = new libthrift091.protocol.TList(libthrift091.protocol.TType.STRUCT, iprot.readI32());
      struct.billList = new ArrayList<BillItem>(_list5.size);
      BillItem _elem6;
      for (int _i7 = 0; _i7 < _list5.size; ++_i7)
      {
        _elem6 = new BillItem();
        _elem6.read(iprot);
        struct.billList.add(_elem6);
      }
    }
    struct.setBillListIsSet(true);
  }
}
 
Example #18
Source Project: mnemonic   Author: apache   File: JavaVMemServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void destroyByteBuffer(long id, ByteBuffer bytebuf, ReclaimContext rctx) {
  MemoryInfo mi = this.getMemPools().get((int)id);
  FileChannel channel = mi.getFileChannel();
  int startIdx, requiredblocks;
  long handler, baseAddr;
  try {
    handler = getByteBufferHandler(id, bytebuf);
    for (int blockIdx = 0; blockIdx < mi.getByteBufferBlocksList().size(); blockIdx++) {
      BufferBlockInfo bufferBlock = mi.getByteBufferBlocksList().get(blockIdx);
      if (bufferBlock.getChunkSizeMap().containsKey(handler)) {
        BitSet chunksMap = bufferBlock.getBufferBlockChunksMap();
        baseAddr = bufferBlock.getBufferBlockBaseAddress();
        startIdx = (int)Math.floor((double)((handler - baseAddr) / CHUNK_BLOCK_SIZE));
        requiredblocks = (int)Math.ceil((double)bytebuf.capacity() / CHUNK_BLOCK_SIZE);
        markFree(chunksMap, startIdx, requiredblocks);
        bufferBlock.getChunkSizeMap().remove(handler);
        break;
      }
    }
  } catch (Exception e) {
  }
}
 
Example #19
Source Project: metanome-algorithms   Author: HPI-Information-Systems   File: PositionListIndex.java    License: Apache License 2.0 6 votes vote down vote up
protected ClusterIdentifier buildClusterIdentifier(int recordId, int[][] invertedPlis, BitSet lhs, int lhsSize) { 
	int[] cluster = new int[lhsSize];
	
	int index = 0;
	for (int lhsAttr = lhs.nextSetBit(0); lhsAttr >= 0; lhsAttr = lhs.nextSetBit(lhsAttr + 1)) {
		int clusterId = invertedPlis[lhsAttr][recordId];
		
		if (clusterId < 0)
			return null;
		
		cluster[index] = clusterId;
		index++;
	}
	
	return new ClusterIdentifier(cluster);
}
 
Example #20
Source Project: Box   Author: lulululbj   File: BlockProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private static void computeDominators(MethodNode mth) {
	List<BlockNode> basicBlocks = mth.getBasicBlocks();
	int nBlocks = basicBlocks.size();
	for (int i = 0; i < nBlocks; i++) {
		BlockNode block = basicBlocks.get(i);
		block.setId(i);
		block.setDoms(new BitSet(nBlocks));
		block.getDoms().set(0, nBlocks);
	}

	BlockNode entryBlock = mth.getEnterBlock();
	calcDominators(basicBlocks, entryBlock);
	markLoops(mth);

	// clear self dominance
	basicBlocks.forEach(block -> {
		block.getDoms().clear(block.getId());
		if (block.getDoms().isEmpty()) {
			block.setDoms(EMPTY);
		}
	});

	calcImmediateDominators(basicBlocks, entryBlock);
}
 
Example #21
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ConcurrentSkipListMapTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Submaps of submaps subdivide correctly
 */
public void testRecursiveSubMaps() throws Exception {
    int mapSize = expensiveTests ? 1000 : 100;
    Class cl = ConcurrentSkipListMap.class;
    NavigableMap<Integer, Integer> map = newMap(cl);
    bs = new BitSet(mapSize);

    populate(map, mapSize);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    mutateMap(map, 0, mapSize - 1);
    check(map,                 0, mapSize - 1, true);
    check(map.descendingMap(), 0, mapSize - 1, false);

    bashSubMap(map.subMap(0, true, mapSize, false),
               0, mapSize - 1, true);
}
 
Example #22
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: JSRInlinerAdapter.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detects a JSR instruction and sets a flag to indicate we will need to do
 * inlining.
 */
@Override
public void visitJumpInsn(final int opcode, final Label lbl) {
    super.visitJumpInsn(opcode, lbl);
    LabelNode ln = ((JumpInsnNode) instructions.getLast()).label;
    if (opcode == JSR && !subroutineHeads.containsKey(ln)) {
        subroutineHeads.put(ln, new BitSet());
    }
}
 
Example #23
Source Project: DDMQ   Author: didi   File: ConsumerService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, fetch_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = new FetchResponse();
    struct.success.read(iprot);
    struct.setSuccessIsSet(true);
  }
}
 
Example #24
Source Project: octo-rpc   Author: Meituan-Dianping   File: ApiVersion2.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, send_args struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(2);
  if (incoming.get(0)) {
    struct.message = iprot.readString();
    struct.setMessageIsSet(true);
  }
  if (incoming.get(1)) {
    struct.param = iprot.readString();
    struct.setParamIsSet(true);
  }
}
 
Example #25
Source Project: constellation   Author: constellation-app   File: AbstractInclusionGraph.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Transfer connections from wg to inclusionGraph by creating a transaction
 * for each link.
 *
 * @param wg Original graph.
 * @param inclusionGraph Target graph.
 * @param vertices Original vertex ids of interest.
 */
private void addTransactionsFromLinks(final GraphWriteMethods wg, final GraphWriteMethods inclusionGraph, final BitSet vertices) {
    final int linkCount = wg.getLinkCount();
    for (int position = 0; position < linkCount; position++) {
        final int linkId = wg.getLink(position);

        int lo = wg.getLinkLowVertex(linkId);
        int hi = wg.getLinkHighVertex(linkId);

        if (vertices.get(lo) && vertices.get(hi)) {
            inclusionGraph.addTransaction(lo, hi, false);
        }
    }
}
 
Example #26
Source Project: constellation   Author: constellation-app   File: SCollection.java    License: Apache License 2.0 5 votes vote down vote up
private SCollection filterVertices(final Object callback) throws ScriptException {
    final ScriptContext context = engine.getContext();
    context.setAttribute("__func", callback, ScriptContext.ENGINE_SCOPE);

    final BitSet vertices = new BitSet();
    for (int vxId = elementIds.nextSetBit(0); vxId >= 0; vxId = elementIds.nextSetBit(vxId + 1)) {
        context.setAttribute("__p1", new SVertex(readableGraph, vxId), ScriptContext.ENGINE_SCOPE);
        final Object b = engine.eval("__func(__p1)");
        if ((Boolean) b) {
            vertices.set(vxId);
        }
    }

    return new SCollection(engine, readableGraph, GraphElementType.VERTEX, vertices);
}
 
Example #27
Source Project: jadx   Author: skylot   File: RegionMaker.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private BlockNode searchFallThroughCase(BlockNode successor, BlockNode out, BitSet caseBlocks) {
	BitSet df = successor.getDomFrontier();
	if (df.intersects(caseBlocks)) {
		return getOneIntersectionBlock(out, caseBlocks, df);
	}
	Set<BlockNode> allPathsBlocks = BlockUtils.getAllPathsBlocks(successor, out);
	Map<BlockNode, BitSet> bitSetMap = BlockUtils.calcPartialPostDominance(mth, allPathsBlocks, out);
	BitSet pdoms = bitSetMap.get(successor);
	if (pdoms != null && pdoms.intersects(caseBlocks)) {
		return getOneIntersectionBlock(out, caseBlocks, pdoms);
	}
	return null;
}
 
Example #28
Source Project: astor   Author: SpoonLabs   File: AmbiguateProperties.java    License: GNU General Public License v2.0 5 votes vote down vote up
private BitSet getRelatedTypesOnNonUnion(JSType type) {
  // All of the types we encounter should have been added to the
  // relatedBitsets via computeRelatedTypes.
  if (relatedBitsets.containsKey(type)) {
    return relatedBitsets.get(type);
  } else {
    throw new RuntimeException("Related types should have been computed for"
                               + " type: " + type + " but have not been.");
  }
}
 
Example #29
Source Project: lucene-solr   Author: apache   File: SearchEquivalenceTestBase.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Asserts that the documents returned by <code>q1</code>
 * are a subset of those returned by <code>q2</code>.
 * 
 * Both queries will be filtered by <code>filter</code>
 */
protected void assertSubsetOf(Query q1, Query q2, Query filter) throws Exception {
  QueryUtils.check(q1);
  QueryUtils.check(q2);

  if (filter != null) {
    q1 = new BooleanQuery.Builder()
        .add(q1, Occur.MUST)
        .add(filter, Occur.FILTER)
        .build();
    q2 = new BooleanQuery.Builder()
        .add(q2, Occur.MUST)
        .add(filter, Occur.FILTER)
        .build();
  }
  // we test both INDEXORDER and RELEVANCE because we want to test needsScores=true/false
  for (Sort sort : new Sort[] { Sort.INDEXORDER, Sort.RELEVANCE }) {
    // not efficient, but simple!
    TopDocs td1 = s1.search(q1, reader.maxDoc(), sort);
    TopDocs td2 = s2.search(q2, reader.maxDoc(), sort);
    assertTrue("too many hits: " + td1.totalHits.value + " > " + td2.totalHits.value, td1.totalHits.value <= td2.totalHits.value);
    
    // fill the superset into a bitset
    BitSet bitset = new BitSet();
    for (int i = 0; i < td2.scoreDocs.length; i++) {
      bitset.set(td2.scoreDocs[i].doc);
    }
    
    // check in the subset, that every bit was set by the super
    for (int i = 0; i < td1.scoreDocs.length; i++) {
      assertTrue(bitset.get(td1.scoreDocs[i].doc));
    }
  }
}
 
Example #30
Source Project: gemfirexd-oss   Author: gemxd   File: UpdateResult.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, UpdateResult struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(4);
  if (incoming.get(0)) {
    struct.updateCount = iprot.readI32();
    struct.setUpdateCountIsSet(true);
  }
  if (incoming.get(1)) {
    {
      org.apache.thrift.protocol.TList _list337 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
      struct.batchUpdateCounts = new ArrayList<Integer>(_list337.size);
      for (int _i338 = 0; _i338 < _list337.size; ++_i338)
      {
        int _elem339;
        _elem339 = iprot.readI32();
        struct.batchUpdateCounts.add(_elem339);
      }
    }
    struct.setBatchUpdateCountsIsSet(true);
  }
  if (incoming.get(2)) {
    struct.generatedKeys = new RowSet();
    struct.generatedKeys.read(iprot);
    struct.setGeneratedKeysIsSet(true);
  }
  if (incoming.get(3)) {
    struct.warnings = new GFXDExceptionData();
    struct.warnings.read(iprot);
    struct.setWarningsIsSet(true);
  }
}