Java Code Examples for java.util.BitSet#get()

The following examples show how to use java.util.BitSet#get() . 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: GetUserInfoResponse.java    From galaxy-sdk-java with Apache License 2.0 6 votes vote down vote up
@Override
public void read(libthrift091.protocol.TProtocol prot, GetUserInfoResponse struct) throws libthrift091.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.developerId = iprot.readString();
  struct.setDeveloperIdIsSet(true);
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
    struct.userName = iprot.readString();
    struct.setUserNameIsSet(true);
  }
  if (incoming.get(1)) {
    struct.email = iprot.readString();
    struct.setEmailIsSet(true);
  }
  if (incoming.get(2)) {
    struct.sms = iprot.readString();
    struct.setSmsIsSet(true);
  }
}
 
Example 2
Source File: StreamSpec.java    From galaxy-sdk-java with Apache License 2.0 6 votes vote down vote up
@Override
public void read(libthrift091.protocol.TProtocol prot, StreamSpec struct) throws libthrift091.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
    struct.enableStream = iprot.readBool();
    struct.setEnableStreamIsSet(true);
  }
  if (incoming.get(1)) {
    struct.viewType = com.xiaomi.infra.galaxy.sds.thrift.StreamViewType.findByValue(iprot.readI32());
    struct.setViewTypeIsSet(true);
  }
  if (incoming.get(2)) {
    {
      libthrift091.protocol.TList _list109 = new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, iprot.readI32());
      struct.attributes = new ArrayList<String>(_list109.size);
      String _elem110;
      for (int _i111 = 0; _i111 < _list109.size; ++_i111)
      {
        _elem110 = iprot.readString();
        struct.attributes.add(_elem110);
      }
    }
    struct.setAttributesIsSet(true);
  }
}
 
Example 3
Source File: BlobChunk.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, BlobChunk struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.chunk = iprot.readBinary();
  struct.setChunkIsSet(true);
  struct.last = iprot.readBool();
  struct.setLastIsSet(true);
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
    struct.lobId = iprot.readI32();
    struct.setLobIdIsSet(true);
  }
  if (incoming.get(1)) {
    struct.offset = iprot.readI64();
    struct.setOffsetIsSet(true);
  }
  if (incoming.get(2)) {
    struct.totalLength = iprot.readI64();
    struct.setTotalLengthIsSet(true);
  }
}
 
Example 4
Source File: FetchResponse.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, FetchResponse struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  {
    org.apache.thrift.protocol.TList _list67 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
    struct.results = new ArrayList<QidResponse>(_list67.size);
    QidResponse _elem68;
    for (int _i69 = 0; _i69 < _list67.size; ++_i69)
    {
      _elem68 = new QidResponse();
      _elem68.read(iprot);
      struct.results.add(_elem68);
    }
  }
  struct.setResultsIsSet(true);
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.code = iprot.readI32();
    struct.setCodeIsSet(true);
  }
}
 
Example 5
Source File: TestGF256Algebra.java    From archistar-smc with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testPow() {
    System.err.println("Testing pow correspondence with mult");
    BitSet bits = new BitSet(SIZE);
    for (int a = 0; a < SIZE; ++a) {
        int prod = UNITY;
        for (int p = 0; p < SIZE; ++p) {
            int r = gf256.pow(a, p);
            if (r != prod)
                fail(String.format("pow and mult disagree: %d^%d -> %d or %d",
                        a, p, r, prod));
            if (bits.get(r))
                break;
            bits.set(r);
            prod = gf256.mult(prod, a);
        }
        bits.clear();
    }
}
 
Example 6
Source File: ChangeSelectionPlugin.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final BitSet elementBitSet = (BitSet) parameters.getParameters().get(ELEMENT_BIT_SET_PARAMETER_ID).getObjectValue();
    final GraphElementType elementType = (GraphElementType) ((ElementTypeParameterValue) parameters.getSingleChoice(ELEMENT_TYPE_PARAMETER_ID)).getObjectValue();
    final SelectionMode selectionMode = (SelectionMode) parameters.getParameters().get(SELECTION_MODE_PARAMETER_ID).getObjectValue();

    final int selectedAttribute = graph.getAttribute(elementType, "selected");
    if (selectedAttribute == Graph.NOT_FOUND) {
        return;
    }

    final int elementCount = elementType.getElementCount(graph);
    for (int elementPosition = 0; elementPosition < elementCount; elementPosition++) {
        final int elementId = elementType.getElement(graph, elementPosition);
        final boolean currentlySelected = graph.getBooleanValue(selectedAttribute, elementId);
        final boolean newSelected = elementBitSet.get(elementId);
        graph.setBooleanValue(selectedAttribute, elementId, selectionMode.calculateSelection(currentlySelected, newSelected));
    }
}
 
Example 7
Source File: CronSequenceGenerator.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void setMonths(BitSet bits, String value) {
	int max = 12;
	value = replaceOrdinals(value, "FOO,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC");
	BitSet months = new BitSet(13);
	// Months start with 1 in Cron and 0 in Calendar, so push the values first into a longer bit set
	setNumberHits(months, value, 1, max + 1);
	// ... and then rotate it to the front of the months
	for (int i = 1; i <= max; i++) {
		if (months.get(i)) {
			bits.set(i - 1);
		}
	}
}
 
Example 8
Source File: HollowCombinerExcludePrimaryKeysCopyDirector.java    From hollow with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldCopy(HollowTypeReadState typeState, int ordinal) {
    BitSet bitSet = excludedOrdinals.get(typeState);
    if(bitSet != null && bitSet.get(ordinal))
        return false;
    return baseDirector.shouldCopy(typeState, ordinal);
}
 
Example 9
Source File: ProducerService.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, sendAsync_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = new Result();
    struct.success.read(iprot);
    struct.setSuccessIsSet(true);
  }
}
 
Example 10
Source File: CHDTest.java    From minperf with Apache License 2.0 5 votes vote down vote up
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 11
Source File: DistributedRPCInvocations.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, failRequest_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.aze = new AuthorizationException();
    struct.aze.read(iprot);
    struct.set_aze_isSet(true);
  }
}
 
Example 12
Source File: SentryHDFSService.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, get_all_authz_updates_from_args struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(2);
  if (incoming.get(0)) {
    struct.permSeqNum = iprot.readI64();
    struct.setPermSeqNumIsSet(true);
  }
  if (incoming.get(1)) {
    struct.pathSeqNum = iprot.readI64();
    struct.setPathSeqNumIsSet(true);
  }
}
 
Example 13
Source File: Scribe.java    From incubator-retired-htrace with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, Log_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = ResultCode.findByValue(iprot.readI32());
    struct.setSuccessIsSet(true);
  }
}
 
Example 14
Source File: SettableBlobMeta.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, SettableBlobMeta struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.replication_factor = iprot.readI32();
    struct.set_replication_factor_isSet(true);
  }
}
 
Example 15
Source File: MessageService.java    From galaxy-sdk-java with Apache License 2.0 5 votes vote down vote up
@Override
public void read(libthrift091.protocol.TProtocol prot, getScheduleInfo_result struct) throws libthrift091.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(2);
  if (incoming.get(0)) {
    struct.success = new GetScheduleInfoResponse();
    struct.success.read(iprot);
    struct.setSuccessIsSet(true);
  }
  if (incoming.get(1)) {
    struct.e = new com.xiaomi.infra.galaxy.talos.thrift.GalaxyTalosException();
    struct.e.read(iprot);
    struct.setEIsSet(true);
  }
}
 
Example 16
Source File: TDssService.java    From light_drtc with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, addMqinfoToAdminQu_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = iprot.readI32();
    struct.setSuccessIsSet(true);
  }
}
 
Example 17
Source File: TDssService.java    From light_drtc with Apache License 2.0 5 votes vote down vote up
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, batchStats_result struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    struct.success = iprot.readI32();
    struct.setSuccessIsSet(true);
  }
}
 
Example 18
Source File: DefaultTreeSelectionModel.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Used to test if a particular set of <code>TreePath</code>s can
 * be added. This will return true if <code>paths</code> is null (or
 * empty), or this object has no RowMapper, or nothing is currently selected,
 * or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
 * adding the paths to the current selection still results in a
 * contiguous set of <code>TreePath</code>s.
 */
protected boolean canPathsBeAdded(TreePath[] paths) {
    if(paths == null || paths.length == 0 || rowMapper == null ||
       selection == null || selectionMode ==
       TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
        return true;
    else {
        BitSet                       bitSet = new BitSet();
        DefaultListSelectionModel    lModel = listSelectionModel;
        int                          anIndex;
        int                          counter;
        int                          min = lModel.getMinSelectionIndex();
        int                          max = lModel.getMaxSelectionIndex();
        TreePath[]                   tempPath = new TreePath[1];

        if(min != -1) {
            for(counter = min; counter <= max; counter++) {
                if(lModel.isSelectedIndex(counter))
                    bitSet.set(counter);
            }
        }
        else {
            tempPath[0] = paths[0];
            min = max = rowMapper.getRowsForPaths(tempPath)[0];
        }
        for(counter = paths.length - 1; counter >= 0; counter--) {
            if(paths[counter] != null) {
                tempPath[0] = paths[counter];
                int[]   rows = rowMapper.getRowsForPaths(tempPath);
                if (rows == null) {
                    return false;
                }
                anIndex = rows[0];
                min = Math.min(anIndex, min);
                max = Math.max(anIndex, max);
                if(anIndex == -1)
                    return false;
                bitSet.set(anIndex);
            }
        }
        for(counter = min; counter <= max; counter++)
            if(!bitSet.get(counter))
                return false;
    }
    return true;
}
 
Example 19
Source File: CommonNeighboursPlugin.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final boolean includeConnectionsIn = parameters.getBooleanValue(INCLUDE_CONNECTIONS_IN_PARAMETER_ID);
    final boolean includeConnectionsOut = parameters.getBooleanValue(INCLUDE_CONNECTIONS_OUT_PARAMETER_ID);
    final boolean treatUndirectedBidirectional = parameters.getBooleanValue(TREAT_UNDIRECTED_BIDIRECTIONAL_PARAMETER_ID);
    final int minCommonFeatures = parameters.getParameters().get(MINIMUM_COMMON_FEATURES_PARAMETER_ID).getIntegerValue();
    final boolean selectedOnly = parameters.getBooleanValue(SELECTED_ONLY_PARAMETER_ID);
    final boolean community = parameters.getBooleanValue(COMMUNITY_PARAMETER_ID);

    final int vertexSelectedAttributeId = VisualConcept.VertexAttribute.SELECTED.get(graph);

    // map each vertex to its neighbour count
    final int vertexCount = graph.getVertexCount();
    final BitSet[] neighbours = new BitSet[vertexCount];
    final BitSet update = new BitSet(vertexCount);
    final BitSet selected = new BitSet(vertexCount);
    for (int vertexPosition = 0; vertexPosition < vertexCount; vertexPosition++) {
        final int vertexId = graph.getVertex(vertexPosition);
        neighbours[vertexPosition] = new BitSet(vertexCount);
        for (int vertexNeighbourPosition = 0; vertexNeighbourPosition < graph.getVertexNeighbourCount(vertexId); vertexNeighbourPosition++) {
            final int neighbourId = graph.getVertexNeighbour(vertexId, vertexNeighbourPosition);
            final int neighbourPosition = graph.getVertexPosition(neighbourId);

            if (vertexPosition == neighbourPosition) {
                continue;
            }

            final int linkId = graph.getLink(vertexId, neighbourId);
            for (int linkEdgePosition = 0; linkEdgePosition < graph.getLinkEdgeCount(linkId); linkEdgePosition++) {
                final int edgeId = graph.getLinkEdge(linkId, linkEdgePosition);
                final int edgeDirection = graph.getEdgeDirection(edgeId);
                final boolean isRequestedDirection = (treatUndirectedBidirectional && edgeDirection == GraphConstants.UNDIRECTED
                        || includeConnectionsIn && graph.getEdgeDestinationVertex(edgeId) == neighbourId
                        || includeConnectionsOut && graph.getEdgeSourceVertex(edgeId) == neighbourId);
                if (isRequestedDirection) {
                    if (!SimilarityUtilities.checkEdgeTypes(graph, edgeId)) {
                        continue;
                    }
                    neighbours[vertexPosition].set(neighbourPosition, true);
                    update.set(vertexPosition, true);
                }
            }
        }
        final boolean vertexSelected = graph.getBooleanValue(vertexSelectedAttributeId, vertexId);
        selected.set(vertexPosition, vertexSelected);
    }

    // calculate common neighbours for every pair of vertices on the graph
    final Map<Tuple<Integer, Integer>, Float> commonNeighbourScores = new HashMap<>();
    for (int vertexOnePosition = update.nextSetBit(0); vertexOnePosition >= 0; vertexOnePosition = update.nextSetBit(vertexOnePosition + 1)) {
        for (int vertexTwoPosition = update.nextSetBit(0); vertexTwoPosition >= 0; vertexTwoPosition = update.nextSetBit(vertexTwoPosition + 1)) {
            if (!selectedOnly || (selected.get(vertexOnePosition) || selected.get(vertexTwoPosition))) {
                if (vertexOnePosition >= vertexTwoPosition) {
                    continue;
                }

                final BitSet intersection = (BitSet) neighbours[vertexOnePosition].clone();
                intersection.and(neighbours[vertexTwoPosition]);
                intersection.set(vertexOnePosition, false);
                intersection.set(vertexTwoPosition, false);

                if (intersection.cardinality() < minCommonFeatures) {
                    continue;
                }

                final int vertexOneId = graph.getVertex(vertexOnePosition);
                final int vertexTwoId = graph.getVertex(vertexTwoPosition);

                float commonNeighbours = (float) intersection.cardinality();
                if (community && (selected.get(vertexOnePosition) && selected.get(vertexTwoPosition))) {
                    commonNeighbours += 1;
                }
                commonNeighbourScores.put(Tuple.create(vertexOneId, vertexTwoId), commonNeighbours);
            }
        }
    }

    // update the graph with common neighbours values
    SimilarityUtilities.addScoresToGraph(graph, commonNeighbourScores, COMMON_NEIGHBOURS_ATTRIBUTE);

    // complete with schema
    PluginExecution.withPlugin(VisualSchemaPluginRegistry.COMPLETE_SCHEMA).executeNow(graph);
}
 
Example 20
Source File: JSRInlinerAdapter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Performs a depth first search walking the normal byte code path starting
 * at <code>index</code>, and adding each instruction encountered into the
 * subroutine <code>sub</code>. After this walk is complete, iterates over
 * the exception handlers to ensure that we also include those byte codes
 * which are reachable through an exception that may be thrown during the
 * execution of the subroutine. Invoked from <code>markSubroutines()</code>.
 *
 * @param sub
 *            the subroutine whose instructions must be computed.
 * @param index
 *            an instruction of this subroutine.
 * @param anyvisited
 *            indexes of the already visited instructions, i.e. marked as
 *            part of this subroutine or any previously computed subroutine.
 */
private void markSubroutineWalk(final BitSet sub, final int index,
        final BitSet anyvisited) {
    if (LOGGING) {
        log("markSubroutineWalk: sub=" + sub + " index=" + index);
    }

    // First find those instructions reachable via normal execution
    markSubroutineWalkDFS(sub, index, anyvisited);

    // Now, make sure we also include any applicable exception handlers
    boolean loop = true;
    while (loop) {
        loop = false;
        for (Iterator<TryCatchBlockNode> it = tryCatchBlocks.iterator(); it
                .hasNext();) {
            TryCatchBlockNode trycatch = it.next();

            if (LOGGING) {
                // TODO use of default toString().
                log("Scanning try/catch " + trycatch);
            }

            // If the handler has already been processed, skip it.
            int handlerindex = instructions.indexOf(trycatch.handler);
            if (sub.get(handlerindex)) {
                continue;
            }

            int startindex = instructions.indexOf(trycatch.start);
            int endindex = instructions.indexOf(trycatch.end);
            int nextbit = sub.nextSetBit(startindex);
            if (nextbit != -1 && nextbit < endindex) {
                if (LOGGING) {
                    log("Adding exception handler: " + startindex + '-'
                            + endindex + " due to " + nextbit + " handler "
                            + handlerindex);
                }
                markSubroutineWalkDFS(sub, handlerindex, anyvisited);
                loop = true;
            }
        }
    }
}