Examples of BitVector


Examples of lupos.misc.BitVector

      public Bindings next() {
        final Bindings b = itb.next();
        if (b != null) {
          final Iterator<BitVector> ibv = bloomFilters.iterator();
          for (final Variable v : vars) {
            final BitVector bv = ibv.next();
            Literal literal = b.get(v);
            if(literal!=null){
              bv.set((Math.abs(literal.hashCode()) % NUMBEROFBITSFORBLOOMFILTER));
            }
          }
          if (!itb.hasNext()) {
            for (final TriplePattern tp : ctp) {
              // inform triple patterns of bloom filter!
              int i = 0;
              for (final Item item : tp) {
                if (item.isVariable()) {
                  final Iterator<BitVector> ibv2 = bloomFilters
                      .iterator();
                  for (final Variable v : vars) {
                    final BitVector bloomFilter = ibv2
                        .next();
                    if (v.equals(item)) {
                      BitVector[] bfa = tp
                          .getBloomFilters();
                      if (bfa == null) {
                        bfa = new BitVector[3];
                        bfa[i] = bloomFilter;
                      } else {
                        if (bfa[i] != null) {
                          if (!bfa[i]
                              .equals(bloomFilter))
                            for (int j = 0; j < bloomFilter
                                .size(); j++)
                              if (!bloomFilter
                                  .get(j))
                                bfa[i].clear(j);
                        } else
                          bfa[i] = bloomFilter;
                      }
View Full Code Here

Examples of lupos.misc.BitVector

  public Object evaluate(Object[] args) throws TypeErrorException {
    if(args.length==3){
      String value = args[0].toString();
      BigInteger bitVector = Helper.getInteger(args[1]);
      int bitVectorSize = Helper.getInteger(args[2]).intValue();
      BitVector bv = BitVector.getBitVector(bitVector, bitVectorSize);
      if(bv.get(Math.abs(value.hashCode() % bitVectorSize))){
        return Boolean.TRUE;
      } else {
        return Boolean.FALSE;
      }
    } else {
View Full Code Here

Examples of lupos.misc.BitVector

          if(!this.surelyBoundVariablesInServiceCall.contains(variable)){
            result += "((bound("+variable+") && ";
          }
          result +="<http://www.ifis.uni-luebeck.de/functions/BitVectorFilter>("+variable;
          result +=",";
          BitVector bv = new BitVector(FederatedQueryBitVectorJoinNonStandardSPARQL.bitvectorSize);
          while (bindingsIterator.hasNext()) {
            Bindings b = bindingsIterator.next();
            Literal literal = variable.getLiteral(b);
            if(literal!=null){
              oneOrMoreResults=true;
              bv.set(Math.abs(literal.toString().hashCode() % FederatedQueryBitVectorJoinNonStandardSPARQL.bitvectorSize));
            }
          }
          result += bv.getBigInteger().toString()+","+FederatedQueryBitVectorJoinNonStandardSPARQL.bitvectorSize+")";
          if(!this.surelyBoundVariablesInServiceCall.contains(variable)) {
            result += " ))||";
            result += " !bound("+variable+") ";
          }
          if(it.hasNext())
View Full Code Here

Examples of net.agkn.hll.util.BitVector

        // register width 4 (the minimum size)
        { // scoped locally for sanity
            final int regwidth = 4;
            final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL);
            final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/;

            // lower-bounds of the register
            hll.addRaw(0x000000000000001L/*'j'=1*/);
            assertEquals(bitVector.getRegister(1/*'j'*/), 0);

            hll.addRaw(0x0000000000000012L/*'j'=2*/);
            assertEquals(bitVector.getRegister(2/*'j'*/), 1);

            hll.addRaw(0x0000000000000023L/*'j'=3*/);
            assertEquals(bitVector.getRegister(3/*'j'*/), 2);

            hll.addRaw(0x0000000000000044L/*'j'=4*/);
            assertEquals(bitVector.getRegister(4/*'j'*/), 3);

            hll.addRaw(0x0000000000000085L/*'j'=5*/);
            assertEquals(bitVector.getRegister(5/*'j'*/), 4);

            // upper-bounds of the register
            // NOTE:  bear in mind that BitVector itself does ensure that
            //        overflow of a register is prevented
            hll.addRaw(0x0000000000010006L/*'j'=6*/);
            assertEquals(bitVector.getRegister(6/*'j'*/), 13);

            hll.addRaw(0x0000000000020007L/*'j'=7*/);
            assertEquals(bitVector.getRegister(7/*'j'*/), 14);

            hll.addRaw(0x0000000000040008L/*'j'=8*/);
            assertEquals(bitVector.getRegister(8/*'j'*/), 15);

            hll.addRaw(0x0000000000080009L/*'j'=9*/);
            assertEquals(bitVector.getRegister(9/*'j'*/), 15/*overflow*/);

            // sanity checks to ensure that no other bits above the lowest-set
            // bit matters
            // NOTE:  same as case 'j = 6' above
            hll.addRaw(0x000000000003000AL/*'j'=10*/);
            assertEquals(bitVector.getRegister(10/*'j'*/), 13);

            hll.addRaw(0x000000000011000BL/*'j'=11*/);
            assertEquals(bitVector.getRegister(11/*'j'*/), 13);
        }

        // register width 5
        { // scoped locally for sanity
            final int regwidth = 5;
            final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL);
            final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/;

            // lower-bounds of the register
            hll.addRaw(0x0000000000000001L/*'j'=1*/);
            assertEquals(bitVector.getRegister(1/*'j'*/), 0);

            hll.addRaw(0x0000000000000012L/*'j'=2*/);
            assertEquals(bitVector.getRegister(2/*'j'*/), 1);

            hll.addRaw(0x0000000000000023L/*'j'=3*/);
            assertEquals(bitVector.getRegister(3/*'j'*/), 2);

            hll.addRaw(0x0000000000000044L/*'j'=4*/);
            assertEquals(bitVector.getRegister(4/*'j'*/), 3);

            hll.addRaw(0x0000000000000085L/*'j'=5*/);
            assertEquals(bitVector.getRegister(5/*'j'*/), 4);

            // upper-bounds of the register
            // NOTE:  bear in mind that BitVector itself does ensure that
            //        overflow of a register is prevented
            hll.addRaw(0x0000000100000006L/*'j'=6*/);
            assertEquals(bitVector.getRegister(6/*'j'*/), 29);

            hll.addRaw(0x0000000200000007L/*'j'=7*/);
            assertEquals(bitVector.getRegister(7/*'j'*/), 30);

            hll.addRaw(0x0000000400000008L/*'j'=8*/);
            assertEquals(bitVector.getRegister(8/*'j'*/), 31);

            hll.addRaw(0x0000000800000009L/*'j'=9*/);
            assertEquals(bitVector.getRegister(9/*'j'*/), 31/*overflow*/);
        }
    }
View Full Code Here

Examples of net.agkn.hll.util.BitVector

        final int regwidth = 5;
        final int log2m = 4/*16 registers per counter*/;
        final int m = 1 << log2m;

        final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL);
        final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/;
        for(int i=0; i<m; i++)
            bitVector.setRegister(i, i);

        hll.clear();
        for(int i=0; i<m; i++){
            assertEquals(bitVector.getRegister(i), 0L/*default value of register*/);
        }
    }
View Full Code Here

Examples of net.agkn.hll.util.BitVector

    // Assertion Helpers
    /**
     * Asserts that the two HLLs are register-wise equal.
     */
    private static void assertElementsEqual(final HLL hllA, final HLL hllB) {
        final BitVector bitVectorA = (BitVector)getInternalState(hllA, "probabilisticStorage")/*for testing convenience*/;
        final BitVector bitVectorB = (BitVector)getInternalState(hllA, "probabilisticStorage")/*for testing convenience*/;

        final LongIterator iterA = bitVectorA.registerIterator();
        final LongIterator iterB = bitVectorB.registerIterator();

        for(;iterA.hasNext() && iterB.hasNext();) {
            assertEquals(iterA.next(), iterB.next());
        }
        assertFalse(iterA.hasNext());
View Full Code Here

Examples of net.agkn.hll.util.BitVector

                break;
            case SPARSE:
                this.sparseProbabilisticStorage = new Int2ByteOpenHashMap();
                break;
            case FULL:
                this.probabilisticStorage = new BitVector(regwidth, m);
                break;
            default:
                throw new RuntimeException("Unsupported HLL type " + type);
        }
    }
View Full Code Here

Examples of net.wimpi.modbus.util.BitVector

   *
   * @param count the number of response bits as int.
   */
  public void setBitCount(int count) {
    m_BitCount = count;
    m_Discretes = new BitVector(count);
    //set correct length, without counting unitid and fc
    setDataLength(m_Discretes.byteSize() + 1);
  }//setBitCount
View Full Code Here

Examples of net.wimpi.modbusme.util.BitVector

    m_ReadCoilsRequest.setUnitID(unitid);
    m_ReadCoilsRequest.setReference(ref);
    m_ReadCoilsRequest.setBitCount(count);
    m_Transaction.setRequest(m_ReadCoilsRequest);
    m_Transaction.execute();
    BitVector bv = ((ReadCoilsResponse) m_Transaction.getResponse()).getCoils();
    bv.forceSize(count);
    return bv;
  }//readCoils
View Full Code Here

Examples of org.apache.drill.exec.vector.BitVector

    defBuilder
        .setMajorType(typeBuilder.build());
    MaterializedField field = MaterializedField.create(defBuilder.build());

    // Create a new value vector for 1024 integers
    BitVector v = new BitVector(field, allocator);
    BitVector.Mutator m = v.getMutator();
    v.allocateNew(1024);

    // Put and set a few values
    m.set(0, 1);
    m.set(1, 0);
    m.set(100, 0);
    m.set(1022, 1);
    assertEquals(1, v.getAccessor().get(0));
    assertEquals(0, v.getAccessor().get(1));
    assertEquals(0, v.getAccessor().get(100));
    assertEquals(1, v.getAccessor().get(1022));

    // test setting the same value twice
    m.set(0, 1);
    m.set(0, 1);
    m.set(1, 0);
    m.set(1, 0);
    assertEquals(1, v.getAccessor().get(0));
    assertEquals(0, v.getAccessor().get(1));

    // test toggling the values
    m.set(0, 0);
    m.set(1, 1);
    assertEquals(0, v.getAccessor().get(0));
    assertEquals(1, v.getAccessor().get(1));

    // Ensure unallocated space returns 0
    assertEquals(0, v.getAccessor().get(3));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.