List of usage examples for java.util BitSet BitSet
public BitSet()
From source file:org.restcomm.app.qoslib.Utils.QosInfo.java
private void setWifi(WifiInfo wifiInfo, WifiConfiguration wifiConfig) { if (wifiInfo == null || wifiConfig == null) return;//ww w . j ava2s . c o m String macid = wifiInfo.getBSSID(); if (macid == null) return; String[] bytes = macid.split(":"); long bssid = 0; for (int i = 0; i < 6; i++) { if (i < bytes.length) { long v = hexval(bytes[i]); bssid = bssid + (v << ((5 - i) * 8)); } } WifiID = bssid; if (wifiConfig != null) { int bits = 0; for (int i = 0; i < 4; i++) { if (wifiConfig.allowedKeyManagement.get(i)) bits += 1 << i; } BitSet bs = new BitSet(); //bs.set(WifiConfiguration.KeyMgmt.NONE); //if (wifiConfig.allowedKeyManagement..allowedAuthAlgorithms.intersects(bs)) WifiSec = bits; } int freq = getWifiFrequency(wifiInfo); if (freq != -1) WifiFreq = freq; int sig = wifiInfo.getRssi(); WifiSig = sig; }
From source file:org.onosproject.teyang.utils.topology.NodeConverter.java
private static TeNode yang2TeSubsystemNodeAugment(Te yangNodeAugTe, TeNodeId teNodeId, Network yangNetwork, Networks yangNetworks, Node yangNode, Map<KeyId, TerminationPoint> teTps) { NodeId yangNodeId = yangNode.nodeId(); NetworkId yangNetworkId = yangNetwork.networkId(); long teNodeIdLong = Ip4Address.valueOf(teNodeId.dottedQuad().string()).toInt(); TeTopologyKey underlayTopologyIdId = null; // FIXME: yang has a list of supporting nodes, but TeNode only has one // supportTeNodeId. How ro retrieve providerId, clientId, topologyId, teNodeId? TeNodeKey supportTeNodeId = null;/*from w w w . j av a 2 s . co m*/ // supportTeNodeId = new TeNodeKey(providerId, clientId, topologyId, teNodeId) // yangSupportNodes.get(0). TeNodeKey sourceTeNodeId = null; //ignore CommonNodeData teData = null; Map<Long, ConnectivityMatrix> connMatrices = null; Map<Long, org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttps = null; List<Long> teLinkIds = Lists.newArrayList(); List<Long> teTpIds = Lists.newArrayList(); // ********************************************** to find teLinkIds // teLinkIds should be supposed to get from YANG Link and TP data. // For now, assuming each teTp is sourcing a TE link . if (MapUtils.isNotEmpty(teTps)) { for (Map.Entry<KeyId, TerminationPoint> entry : teTps.entrySet()) { if (entry.getValue().teTpId() != null) { teTpIds.add(entry.getValue().teTpId()); teLinkIds.add(entry.getValue().teTpId()); } } } // ********************************************** to find teTpIds // if (yangNode.yangAugmentedInfoMap() != null // && !yangNode.yangAugmentedInfoMap().isEmpty()) { // // AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode // .yangAugmentedInfo(AugmentedNdNode.class); // // if (yangTpNodeAugment.terminationPoint() != null) { // for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology // .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint // yangTpnode : yangTpNodeAugment.terminationPoint()) { // teTpIds.add(Long.valueOf(yangTpnode.tpId().uri().string())); // } // } // } // ********************************************** Config ynodeAugCfg = yangNodeAugTe.config(); if (ynodeAugCfg != null) { TeNodeAttributes teNodeAttr = ynodeAugCfg.teNodeAttributes(); if (teNodeAttr != null) { if (teNodeAttr.underlayTopology() != null) { underlayTopologyIdId = yang2TeSubsystemNodeUnderlayTopology(teNodeAttr.underlayTopology(), yangNetworks); } BitSet flags = new BitSet(); if (teNodeAttr.isAbstract()) { flags.set(TeNode.BIT_ABSTRACT); } teData = new CommonNodeData(null, // teNodeAttr.name().string(), EnumConverter.yang2TeSubsystemAdminStatus(teNodeAttr.adminStatus()), EnumConverter.yang2TeSubsystemOpStatus(yangNodeAugTe.state().operStatus()), flags); // if (teNodeAttr.connectivityMatrix() != null) { if (teNodeAttr.connectivityMatrices() != null) { connMatrices = yang2TeSubsystemNodeConnectivityMatrix(yangNetworkId.uri().toString(), yangNodeId.uri().toString(), teNodeAttr.connectivityMatrices()); } } } if (yangNodeAugTe.tunnelTerminationPoint() != null) { ttps = yang2TeSubsystemTtp(yangNodeAugTe.tunnelTerminationPoint(), yangNode, yangNetworks); } TeNode teNode = new DefaultTeNode(teNodeIdLong, underlayTopologyIdId, supportTeNodeId, sourceTeNodeId, teData, connMatrices, teLinkIds, ttps, teTpIds); return teNode; }
From source file:org.apache.openjpa.kernel.StateManagerImpl.java
public void setDelayed(int field, boolean delay) { if (_delayed == null) { _delayed = new BitSet(); }/* w ww. j a v a2 s .co m*/ if (delay) { _delayed.set(field); } else { _delayed.clear(field); } }
From source file:org.apache.openjpa.kernel.StateManagerImpl.java
/** * Loads a delayed access field.//from w ww . j a v a 2s. c o m * @param field */ public void loadDelayedField(int field) { if (!isDelayed(field)) { return; } try { beforeRead(field); } catch (RuntimeException re) { throw translate(re); } lock(); try { boolean active = _broker.isActive(); int lockLevel = calculateLockLevel(active, false, null); BitSet fields = new BitSet(); fields.set(field); if (!_broker.getStoreManager().load(this, fields, _broker.getFetchConfiguration(), lockLevel, null)) { throw new ObjectNotFoundException(_loc.get("del-instance", _meta.getDescribedType(), _oid)) .setFailedObject(getManagedInstance()); } // Cleared the delayed bit _delayed.clear(field); obtainLocks(active, false, lockLevel, null, null); } catch (RuntimeException re) { throw translate(re); } finally { unlock(); } }
From source file:org.jahia.services.search.facets.SimpleJahiaJcrFacets.java
private OpenBitSet getDocIdSet(Query query, final String locale) { OpenBitSet docIds = null;/*from ww w . j a va 2 s .c o m*/ try { final BitSet bitset = new BitSet(); searcher.search(query, new AbstractHitCollector() { @Override public void collect(int docId, float scorer) { if (locale != null) { try { int docMainDocId = getMainDocIdForTranslations( searcher.getIndexReader().document(docId, TRANSLATION_FIELDS), locale); if (docMainDocId != -1) { bitset.set(docMainDocId); } } catch (Exception e) { logger.warn("Error getting index document while faceting", e); } } bitset.set(docId); } @Override public boolean acceptsDocsOutOfOrder() { return true; } }); docIds = new OpenBitSetDISI(new DocIdBitSet(bitset).iterator(), bitset.size()); } catch (IOException e) { logger.debug("Can't retrive bitset from hits", e); } return docIds; }
From source file:org.jahia.services.search.facets.SimpleJahiaJcrFacets.java
OpenBitSet getPositiveDocSet(Query q, final String locale) throws IOException { OpenBitSet answer;//from w w w .j a v a 2s .com // if (filterCache != null) { // answer = filterCache.get(q); // if (answer!=null) return answer; // } final BitSet bitset = new BitSet(); searcher.search(q, new AbstractHitCollector() { @Override public void collect(int docId, float scorer) { if (locale != null) { try { int docMainDocId = getMainDocIdForTranslations( searcher.getIndexReader().document(docId, TRANSLATION_FIELDS), locale); if (docMainDocId != -1) { bitset.set(docMainDocId); } } catch (Exception e) { logger.warn("Error getting index document while faceting", e); } } bitset.set(docId); } @Override public boolean acceptsDocsOutOfOrder() { return true; } }); answer = new OpenBitSetDISI(new DocIdBitSet(bitset).iterator(), bitset.size()); // answer = getDocSetNC(q,null); // if (filterCache != null) filterCache.put(q,answer); return answer; }
From source file:mondrian.olap.Util.java
/** * Creates a bitset with bits from {@code fromIndex} (inclusive) to * specified {@code toIndex} (exclusive) set to {@code true}. * * <p>For example, {@code bitSetBetween(0, 3)} returns a bit set with bits * {0, 1, 2} set./*from w w w. ja v a 2s.c om*/ * * @param fromIndex Index of the first bit to be set. * @param toIndex Index after the last bit to be set. * @return Bit set */ public static BitSet bitSetBetween(int fromIndex, int toIndex) { final BitSet bitSet = new BitSet(); if (toIndex > fromIndex) { // Avoid http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6222207 // "BitSet internal invariants may be violated" bitSet.set(fromIndex, toIndex); } return bitSet; }
From source file:org.roaringbitmap.TestRoaringBitmap.java
@Test public void flipTest1() { final RoaringBitmap rb = new RoaringBitmap(); rb.flip(100000, 200000); // in-place on empty bitmap final int rbcard = rb.getCardinality(); Assert.assertEquals(100000, rbcard); final BitSet bs = new BitSet(); for (int i = 100000; i < 200000; ++i) bs.set(i);/*from w ww .j a va 2 s. c om*/ Assert.assertTrue(equals(bs, rb)); }
From source file:org.roaringbitmap.TestRoaringBitmap.java
@Test public void flipTest1A() { final RoaringBitmap rb = new RoaringBitmap(); final RoaringBitmap rb1 = RoaringBitmap.flip(rb, 100000, 200000); final int rbcard = rb1.getCardinality(); Assert.assertEquals(100000, rbcard); Assert.assertEquals(0, rb.getCardinality()); final BitSet bs = new BitSet(); Assert.assertTrue(equals(bs, rb)); // still empty? for (int i = 100000; i < 200000; ++i) bs.set(i);/* w w w.j a va 2s . c om*/ Assert.assertTrue(equals(bs, rb1)); }
From source file:org.roaringbitmap.TestRoaringBitmap.java
@Test public void flipTest2() { final RoaringBitmap rb = new RoaringBitmap(); rb.flip(100000, 100000);// ww w. j av a2s .c o m final int rbcard = rb.getCardinality(); Assert.assertEquals(0, rbcard); final BitSet bs = new BitSet(); Assert.assertTrue(equals(bs, rb)); }