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 File: TListSentryPrivilegesByAuthResponse.java From incubator-sentry with Apache License 2.0 | 6 votes |
@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 #2
Source File: TransitiveSetTraverser.java From hollow with Apache License 2.0 | 6 votes |
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 #3
Source File: MetricService.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
@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 File: PhoenixPreparedStatement.java From phoenix with Apache License 2.0 | 6 votes |
@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 #5
Source File: ConcurrentSkipListMapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 #6
Source File: SelectionRowFilter.java From constellation with Apache License 2.0 | 6 votes |
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 #7
Source File: BlockProcessor.java From Box with Apache License 2.0 | 6 votes |
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 #8
Source File: PositionListIndex.java From metanome-algorithms with Apache License 2.0 | 6 votes |
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 #9
Source File: JavaVMemServiceImpl.java From mnemonic with Apache License 2.0 | 6 votes |
@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 #10
Source File: TotalBill.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
@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 #11
Source File: Record.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
@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 #12
Source File: GridPartitionStateMap.java From ignite with Apache License 2.0 | 6 votes |
/** * 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 #13
Source File: BitSetStreamTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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 #14
Source File: GeneticAlgorithm.java From kylin with Apache License 2.0 | 6 votes |
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 #15
Source File: ConcurrentSkipListSetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 #16
Source File: FlinkAggregateJoinTransposeRule.java From flink with Apache License 2.0 | 6 votes |
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 #17
Source File: FindDeadLocalStores.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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 #18
Source File: PostInstructionRegisterInfoMethodItem.java From ZjDroid with Apache License 2.0 | 6 votes |
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 #19
Source File: BitSets.java From Bats with Apache License 2.0 | 6 votes |
/** * 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> * 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 #20
Source File: RafsCliTest.java From Panako with GNU Affero General Public License v3.0 | 6 votes |
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 #21
Source File: PutRequestMessage.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
@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 #22
Source File: FastTopicMatcher.java From ballerina-message-broker with Apache License 2.0 | 5 votes |
/** * Add columns for all the constituent tables corresponding to a specific subscription pattern. * * @param constituents constituent list of the subscription pattern. */ private void addColumns(String[] constituents) { int colNum = subscribedTopicList.size() - 1; for (int tableIndex = 0; tableIndex < constituentTables.size(); tableIndex++) { Map<String, BitSet> table = constituentTables.get(tableIndex); String constituent; if (tableIndex < constituents.length) { constituent = constituents[tableIndex]; } else { constituent = constituents[constituents.length - 1]; if (!MULTIPLE_WORD_WILDCARD.equals(constituent)) { constituent = NULL_CONSTITUENT; } } for (Map.Entry<String, BitSet> entry : table.entrySet()) { if (entry.getKey().equals(NULL_CONSTITUENT)) { if (MULTIPLE_WORD_WILDCARD.equals(constituent) || NULL_CONSTITUENT.equals(constituent)) { entry.getValue().set(colNum); } } else { if (entry.getKey().equals(constituent) || MULTIPLE_WORD_WILDCARD.equals(constituent) || SINGLE_WORD_WILDCARD.equals(constituent)) { entry.getValue().set(colNum); } } } } }
Example #23
Source File: CHDTest.java From minperf with Apache License 2.0 | 5 votes |
private static <T> void verify(CHD<T> eval, Set<T> set) { BitSet known = new BitSet(); for (T x : set) { int index = eval.evaluate(x); if (index > set.size() || index < 0) { Assert.fail("wrong entry: " + x + " " + index); } if (known.get(index)) { eval.evaluate(x); Assert.fail("duplicate entry: " + x + " " + index); } known.set(index); } }
Example #24
Source File: BitSetsTest.java From calcite with Apache License 2.0 | 5 votes |
/** * Tests the method * {@link org.apache.calcite.util.BitSets#toList(java.util.BitSet)}. */ @Test void testToListBitSet() { BitSet bitSet = new BitSet(10); assertEquals(BitSets.toList(bitSet), Collections.<Integer>emptyList()); bitSet.set(5); assertEquals(BitSets.toList(bitSet), Arrays.asList(5)); bitSet.set(3); assertEquals(BitSets.toList(bitSet), Arrays.asList(3, 5)); }
Example #25
Source File: ReactionContainer.java From ReactionDecoder with GNU Lesser General Public License v3.0 | 5 votes |
/** * * @param prodMap * @throws java.io.IOException * @throws Exception */ public synchronized void putAllProduct(TreeMap<Integer, IAtomContainer> prodMap) throws IOException, Exception { pAtomContainerMap.putAll(prodMap); for (Map.Entry<Integer, IAtomContainer> map : prodMap.entrySet()) { BitSet fp = fpr.getFingerprint(map.getValue()); setFingerPrintofProduct(map.getKey(), fp); } }
Example #26
Source File: ImmutableBitSet.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private ImmutableBitSet(BitSet set, boolean needClone) { if (needClone) { this.set = (BitSet) set.clone(); } else { this.set = set; } this.arr = new int[set.cardinality()]; int j = 0; for (int i = set.nextSetBit(0); i >= 0; i = set.nextSetBit(i + 1)) { arr[j++] = i; } }
Example #27
Source File: GlyphView.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
JustificationInfo(int start, int end, int leadingSpaces, int contentSpaces, int trailingSpaces, boolean hasTab, BitSet spaceMap) { this.start = start; this.end = end; this.leadingSpaces = leadingSpaces; this.contentSpaces = contentSpaces; this.trailingSpaces = trailingSpaces; this.hasTab = hasTab; this.spaceMap = spaceMap; }
Example #28
Source File: JSRInlinerAdapter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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 #29
Source File: GlyphView.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
JustificationInfo(int start, int end, int leadingSpaces, int contentSpaces, int trailingSpaces, boolean hasTab, BitSet spaceMap) { this.start = start; this.end = end; this.leadingSpaces = leadingSpaces; this.contentSpaces = contentSpaces; this.trailingSpaces = trailingSpaces; this.hasTab = hasTab; this.spaceMap = spaceMap; }
Example #30
Source File: HeapDataOutputStream.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public final void markForReuse() { if (this.canReuseChunks) { this.nonReusableChunks = new BitSet(); } else { throw new IllegalArgumentException("cannot reuse wrapped buffers"); } }