/** * Make a copy of the given bits. */ public static FixedBitSet copyOf(Bits bits) { if (bits instanceof FixedBits) { // restore the original FixedBitSet FixedBits fixedBits = (FixedBits) bits; bits = new FixedBitSet(fixedBits.bits, fixedBits.length); } if (bits instanceof FixedBitSet) { return ((FixedBitSet)bits).clone(); } else { int length = bits.length(); FixedBitSet bitSet = new FixedBitSet(length); bitSet.set(0, length); for (int i = 0; i < length; ++i) { if (bits.get(i) == false) { bitSet.clear(i); } } return bitSet; } }
@Override public MutableBits newLiveDocs(Bits existing) throws IOException { FixedBitSet fbs = (FixedBitSet) existing; return fbs.clone(); }
@Override public MutableBits newLiveDocs(Bits existing) throws IOException { FixedBitSet fbs = (FixedBitSet) existing; return fbs.clone(); }
/** * Returns a new copy of this vector, in dense format. */ @SuppressWarnings("unchecked") public BinaryVector copy() { BinaryVector copy = new BinaryVector(dimension); copy.bitSet = (FixedBitSet) bitSet.clone(); if (!isSparse) copy.votingRecord = (ArrayList<FixedBitSet>) votingRecord.clone(); return copy; }
/** * Faster normalization according to the Binary Spatter Code's "majority" rule */ public synchronized void normalizeBSC() { if (!isSparse) this.bitSet = concludeVote(); votingRecord = new ArrayList<FixedBitSet>(); votingRecord.add((FixedBitSet) bitSet.clone()); totalNumberOfVotes.set(1); tempSet = new FixedBitSet(dimension); minimum = 0; }
/** * Automatically translate elemental vector (no storage capacity) into * semantic vector (storage capacity initialized, this will occupy RAM) */ protected void elementalToSemantic() { if (!isSparse) { logger.warning("Tried to transform an elemental vector which is not in fact elemental." + "This may be a programming error."); return; } votingRecord = new ArrayList<FixedBitSet>(); tempSet = new FixedBitSet(dimension); if (bitSet.cardinality() != 0) this.superposeBitSet(bitSet.clone(), 1); isSparse = false; }
private static FixedBitSet applyANDOnBitSets(final List<FixedBitSet> filtersData) { //Start by cloning the first, as that's giving you the upper bound for the set ids FixedBitSet first = filtersData.get( 0 ); FixedBitSet toreturn = first.clone(); for ( FixedBitSet bits : filtersData ) { toreturn.and( bits ); } return toreturn; }
/** * An attempt at modeling the intersection between two binary vectors, by randomizing the * dimensions that are not common */ public static BinaryVector intersection(BinaryVector vector, BinaryVector vector2) { FixedBitSet intersection = (FixedBitSet) vector.getCoordinates().clone(); FixedBitSet uncommonGround = (FixedBitSet) vector.getCoordinates().clone(); java.util.Random random = new java.util.Random(); random.setSeed((long) 23); //for consistency across experiments //everything different uncommonGround.xor(vector2.getCoordinates()); //to introduce random noise for (int x =0; x < vector.getDimension(); x++) { // if (x == 0) System.err.print(cnt+"/"+ numchanges+".."+"loop..."); double change = random.nextDouble(); if (uncommonGround.get(x) && change > 0.5) { intersection.flip(x); } } BinaryVector intersectionVector = (BinaryVector) VectorFactory.createZeroVector(VectorType.BINARY, vector.getDimension()); intersectionVector.setCoordinates(intersection); return intersectionVector; }
FixedBitSet possiblePositives = (FixedBitSet) votingRecord.get(row_floor).clone(); FixedBitSet definitePositives2 = concludeVote(remainder, row_floor-1);
votingRecord.add((FixedBitSet) bitSet.clone()); totalNumberOfVotes.set(1); tempSet = new FixedBitSet(dimension);
java.util.Random random = new java.util.Random(); random.setSeed((long) 23); //for consistency across experiments FixedBitSet commonGround = (FixedBitSet) vector.clone();
/** * Make a copy of the given bits. */ public static FixedBitSet copyOf(Bits bits) { if (bits instanceof FixedBits) { // restore the original FixedBitSet FixedBits fixedBits = (FixedBits) bits; bits = new FixedBitSet(fixedBits.bits, fixedBits.length); } if (bits instanceof FixedBitSet) { return ((FixedBitSet)bits).clone(); } else { int length = bits.length(); FixedBitSet bitSet = new FixedBitSet(length); bitSet.set(0, length); for (int i = 0; i < length; ++i) { if (bits.get(i) == false) { bitSet.clear(i); } } return bitSet; } }