public Chunk(World par1World, int par2, int par3) {
    this.storageArrays = new ExtendedBlockStorage[16];
    this.blockBiomeArray = new byte[256];
    this.precipitationHeightMap = new int[256];
    this.updateSkylightColumns = new boolean[256];
    this.isGapLightingUpdated = false;
    this.chunkTileEntityMap = new HashMap();
    this.isTerrainPopulated = false;
    this.isModified = false;
    this.hasEntities = false;
    this.lastSaveTime = 0L;
    this.sendUpdates = false;
    this.field_82912_p = 0;
    this.queuedLightChecks = 4096;
    this.field_76653_p = false;
    this.entityLists = new List[16];
    this.worldObj = par1World;
    this.xPosition = par2;
    this.zPosition = par3;
    this.heightMap = new int[256];

    for (int var4 = 0; var4 < this.entityLists.length; ++var4) {
      this.entityLists[var4] = new ArrayList();
    }

    Arrays.fill(this.precipitationHeightMap, -999);
    Arrays.fill(this.blockBiomeArray, (byte) -1);
  }
Example #2
0
 // Check if OK should be enabled
 // Called on:
 //      -- change in text field
 //      -- change in check box selection
 //      -- change in team combo selection
 // Required:
 //      -- userName
 //      -- at least one check box
 //      -- password, if this is an Add, but not if Edit
 // Not required: TBD: ???
 //      -- First and Last Name
 //      -- Team
 private void checkOkSetEnabled() {
   char[] pchars = password.getPassword();
   char[] cchars = confirmPassword.getPassword();
   if (!userName.getText().equals("")
       && (unitizeCheckBox.isSelected()
           || uqcCheckBox.isSelected()
           || codingCheckBox.isSelected()
           || codingqcCheckBox.isSelected()
           || listingCheckBox.isSelected()
           || tallyCheckBox.isSelected()
           || qaCheckBox.isSelected()
           || tlCheckBox.isSelected()
           || adminCheckBox.isSelected())
       && (usersId != 0 || pchars.length != 0)
       && (pchars.length == 0 || cchars.length != 0)) {
     okButton.setEnabled(true);
   } else {
     okButton.setEnabled(false);
   }
   if (pchars.length == 0) {
     confirmPassword.setEditable(false);
   } else {
     confirmPassword.setEditable(true);
   }
   Arrays.fill(pchars, '#');
   Arrays.fill(cchars, '#');
 }
Example #3
0
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    int cases = 1;
    while (true) {
      st = new StringTokenizer(in.readLine());
      n = Integer.parseInt(st.nextToken());
      m = Integer.parseInt(st.nextToken());
      if (n == 0 && m == 0) break;
      a = new int[n];
      b = new int[m];
      dp = new int[n + 1][m + 1];
      st = new StringTokenizer(in.readLine());
      for (int i = 0; i < n; i++) {
        a[i] = Integer.parseInt(st.nextToken());
        Arrays.fill(dp[i], -1);
      }
      Arrays.fill(dp[n], -1);
      st = new StringTokenizer(in.readLine());
      for (int i = 0; i < m; i++) b[i] = Integer.parseInt(st.nextToken());

      System.out.println("Twin Towers #" + cases);
      System.out.println("Number of Tiles : " + LCS(0, 0));
      System.out.println();
      cases++;
    }
    in.close();
    System.exit(0);
  }
  private void init() {

    this.entries = new HashMap<>(numTicks);
    clear();

    //        Log.v(TAG, "after clear");

    // two for loops to reorder (since angle 0 - 90)
    this.tickAngle = new float[numTicks];
    this.tickSpace = new float[numTicks];
    Arrays.fill(tickAngle, 0.f);
    Arrays.fill(tickSpace, 0.f);
    float bumpBottom = 0;
    int intermedTicks = numTicks / 12;
    for (int ticks = 0; ticks < numTicks; ticks++) {

      //            Log.v(TAG, "at tick " + ticks);

      if (ticks < numTicks / 4) {
        tickAngle[ticks] = (ticks * tickLength + space) + 270.f;
      } else {
        tickAngle[ticks] = (ticks * tickLength + space) - 90.f;
      }

      if (ticks == numTicks / 2 - intermedTicks && numTicks <= numTicks / 2) {
        bumpBottom += 3;
      }
      tickSpace[ticks] = spaceTillBorder + bumpBottom;
    }
  }
Example #5
0
  @Test
  public void WAL_replay_mixed() {
    e = openEngine();
    e.structuralLock.lock();

    for (int i = 0; i < 3; i++) {
      long v = e.composeIndexVal(100 + i, e.round16Up(10000) + i * 16, true, true, true);
      e.walPutLong(0xF0000 + i * 8, v);
      byte[] d = new byte[9];
      Arrays.fill(d, (byte) i);
      e.putDataSingleWithoutLink(-1, e.round16Up(100000) + 64 + i * 16, d, 0, d.length);
    }
    e.commit();
    e.structuralLock.lock();
    e.commitLock.lock();
    e.replayWAL();

    for (int i = 0; i < 3; i++) {
      long v = e.composeIndexVal(100 + i, e.round16Up(10000) + i * 16, true, true, true);
      assertEquals(v, e.vol.getLong(0xF0000 + i * 8));

      byte[] d = new byte[9];
      Arrays.fill(d, (byte) i);
      byte[] d2 = new byte[9];

      e.vol.getData(e.round16Up(100000) + 64 + i * 16, d2, 0, d2.length);
      assertTrue(Serializer.BYTE_ARRAY.equals(d, d2));
    }
  }
Example #6
0
  public void digestData() throws IOException, PKCS11Exception {
    byte[] buffer = new byte[1024];
    byte[] helpBuffer, testDigest;
    int bytesRead;

    System.out.println("Digest Data");
    myPKCS11Module_.C_DigestInit(session_, digestMechanism_);
    try {
      messageDigest_ = MessageDigest.getInstance("SHA-1");
    } catch (Exception e) {
      System.out.println(e);
    }
    InputStream dataInput = new FileInputStream(file_);
    while ((bytesRead = dataInput.read(buffer, 0, buffer.length)) >= 0) {
      helpBuffer =
          new byte[bytesRead]; // we need a buffer that only holds what to send for digesting
      System.arraycopy(buffer, 0, helpBuffer, 0, bytesRead);
      myPKCS11Module_.C_DigestUpdate(session_, helpBuffer);
      messageDigest_.update(helpBuffer);
      Arrays.fill(helpBuffer, (byte) 0);
    }
    Arrays.fill(buffer, (byte) 0);
    digest_ = myPKCS11Module_.C_DigestFinal(session_);
    testDigest = messageDigest_.digest();
    System.out.println("PKCS11digest:" + Functions.toHexString(digest_));
    System.out.println("TestDigest  :" + Functions.toHexString(testDigest));
    System.out.println("FINISHED\n");
  }
 /** {@inheritDoc} */
 @Override
 public void clear() {
   super.clear();
   Arrays.fill(_set, 0, _set.length, no_entry_key);
   Arrays.fill(_states, 0, _states.length, FREE);
   Arrays.fill(_values, 0, _values.length, null);
 }
 float[] getBackwardDiagonal(
     final int x0,
     final int y0,
     final int x1,
     final int y1,
     final int xMax,
     final int yMax,
     final float[][][] matrix) {
   final float[] diagonal =
       new float[matrix.length == 0 ? 1000 : 5 * matrix[0].length * this.stateNumber];
   int j = y0, k = 0;
   if (y0 + 1 < yMax) {
     System.arraycopy(matrix[x0][y0 + 1], 0, diagonal, k, this.stateNumber);
   } else {
     Arrays.fill(diagonal, k, k + this.stateNumber, Float.NEGATIVE_INFINITY);
   }
   k += this.stateNumber;
   for (int i = x0; i <= x1; i++) {
     System.arraycopy(matrix[i][j], 0, diagonal, k, this.stateNumber);
     k += this.stateNumber;
     if (i + 1 < xMax) {
       System.arraycopy(matrix[i + 1][j], 0, diagonal, k, this.stateNumber);
     } else {
       Arrays.fill(diagonal, k, k + this.stateNumber, Float.NEGATIVE_INFINITY);
     }
     k += this.stateNumber;
     j--;
   }
   return diagonal;
 }
Example #9
0
 public void clear()
 {
   this.size = 0;
   Arrays.fill(this.hashTableKToV, null);
   Arrays.fill(this.hashTableVToK, null);
   this.modCount = (1 + this.modCount);
 }
Example #10
0
  public void reset(byte[] addresses) {
    nextNearSlot = 0;
    Arrays.fill(near, 0);
    Arrays.fill(same, 0);

    addressStream = new ByteBufferSeekableStream(addresses, true);
  }
Example #11
0
 /**
  * Construct an instance of the algorithm.
  *
  * @param costMatrix the cost matrix, where matrix[i][j] holds the cost of assigning worker i to
  *     job j, for all i, j. The cost matrix must not be irregular in the sense that all rows must
  *     be the same length.
  */
 public HungarianAlgorithm(double[][] costMatrix) {
   this.dim = Math.max(costMatrix.length, costMatrix[0].length);
   this.rows = costMatrix.length;
   this.cols = costMatrix[0].length;
   this.costMatrix = new double[this.dim][this.dim];
   for (int w = 0; w < this.dim; w++) {
     if (w < costMatrix.length) {
       if (costMatrix[w].length != this.cols) {
         throw new IllegalArgumentException("Irregular cost matrix");
       }
       this.costMatrix[w] = Arrays.copyOf(costMatrix[w], this.dim);
     } else {
       this.costMatrix[w] = new double[this.dim];
     }
   }
   this.labelByWorker = new double[this.dim];
   this.labelByJob = new double[this.dim];
   this.minSlackWorkerByJob = new int[this.dim];
   this.minSlackValueByJob = new double[this.dim];
   this.committedWorkers = new boolean[this.dim];
   this.parentWorkerByCommittedJob = new int[this.dim];
   this.matchJobByWorker = new int[this.dim];
   Arrays.fill(this.matchJobByWorker, -1);
   this.matchWorkerByJob = new int[this.dim];
   Arrays.fill(this.matchWorkerByJob, -1);
 }
  private void init() {
    this.birdsFlock = new Bird[this.numOfObjects];
    this.bestSolutions = new double[this.dimensions];
    this.bestFitness = Double.MAX_VALUE;
    Random rnd = new Random();

    for (int bird = 0; bird < this.numOfObjects; bird++) {
      double[] randomPositions = new double[this.dimensions];
      double[] randomVelocities = new double[this.dimensions];
      Arrays.fill(randomPositions, 0.0);
      Arrays.fill(randomVelocities, 0.0);

      for (int i = 0; i < this.dimensions; i++) {
        randomPositions[i] =
            (this.MAX_POSITION - this.MIN_POSITION) * rnd.nextDouble() + this.MIN_POSITION;
        randomVelocities[i] =
            (this.MAX_POSITION * 0.1 - this.MIN_POSITION * 0.1) * rnd.nextDouble()
                + this.MIN_POSITION;
      }

      double fitness = this.costFunction.apply(randomPositions);

      this.birdsFlock[bird] =
          new Bird(randomPositions, randomVelocities, randomPositions, fitness, fitness);

      if (this.birdsFlock[bird].currentFitness < this.bestFitness) {
        this.bestFitness = this.birdsFlock[bird].currentFitness;

        for (int i = 0; i < this.dimensions; i++) {
          this.bestSolutions[i] = this.birdsFlock[bird].position[i];
        }
      }
    }
  }
Example #13
0
 protected static void poll() {
   Arrays.fill(instance.mouseButtonUp, false);
   Arrays.fill(instance.mouseButtonDown, false);
   Arrays.fill(instance.keysDown, false);
   Arrays.fill(instance.keysUp, false);
   glfwPollEvents();
 }
  static double[] similarity(LatentDirichletAllocation lda0, LatentDirichletAllocation lda1) {

    int numTopics = lda0.numTopics();

    int numPairs = numTopics * (numTopics - 1);
    @SuppressWarnings({"unchecked", "rawtypes"}) // ok given use w. erasure
    ScoredObject<int[]>[] pairs = (ScoredObject<int[]>[]) new ScoredObject[numPairs];
    int pos = 0;
    for (int i = 0; i < numTopics; ++i) {
      for (int j = 0; j < numTopics; ++j) {
        if (i == j) continue;
        double divergence =
            Statistics.symmetrizedKlDivergence(
                lda0.wordProbabilities(i), lda1.wordProbabilities(j));
        pairs[pos++] = new ScoredObject<int[]>(new int[] {i, j}, divergence);
      }
    }
    Arrays.sort(pairs, ScoredObject.comparator());
    boolean[] taken0 = new boolean[numTopics];
    Arrays.fill(taken0, false);
    boolean[] taken1 = new boolean[numTopics];
    Arrays.fill(taken1, false);
    double[] scores = new double[numTopics];
    int scorePos = 0;
    for (pos = 0; pos < numPairs && scorePos < numTopics; ++pos) {
      int[] pair = pairs[pos].getObject();
      if (!taken0[pair[0]] && !taken1[pair[1]]) {
        taken0[pair[0]] = true;
        taken1[pair[1]] = true;
        scores[scorePos++] = pairs[pos].score();
      }
    }
    return scores;
  }
Example #15
0
 public void solve(int testNumber, FastScanner in, FastPrinter out) {
   long n = in.nextLong();
   int c = in.nextInt();
   int m = in.nextInt();
   int[][] a = new int[c][c];
   for (int[] d : a) {
     Arrays.fill(d, 1);
   }
   for (int i = 0; i < m; i++) {
     int x = in.nextInt() - 1;
     int y = in.nextInt() - 1;
     a[x][y] = 0;
     a[y][x] = 0;
   }
   Matrix matrix = new Matrix(a);
   final int MOD = 1000000007;
   matrix = Matrix.powMod(matrix, n - 1, MOD);
   int[] ones = new int[c];
   Arrays.fill(ones, 1);
   Matrix x = new Matrix(new int[][] {ones});
   x = x.multiplyMod(matrix, MOD);
   long ans = 0;
   for (int i = 0; i < x.n; i++) {
     for (int j = 0; j < x.m; j++) {
       ans += x.get(i, j);
       ans %= MOD;
     }
   }
   out.println(ans);
 }
  /**
   * Clears cached information saved from the last haplotype, allowing us to start at the beginning
   * of the present haplotype with intitial values of 0.
   *
   * @param fillLength How much of the cache arrays do we need to zero
   */
  private void clearPreviouslyCachedInfo(final int fillLength) {
    Arrays.fill(matchCacheArray, 0, fillLength, 0);
    Arrays.fill(deleteCacheArray, 0, fillLength, 0);
    Arrays.fill(insertCacheArray, 0, fillLength, 0);

    partialSum = 0;
  }
  void init(
      long skipPointer,
      IntIndexInput.Index docBaseIndex,
      IntIndexInput.Index freqBaseIndex,
      IntIndexInput.Index posBaseIndex,
      long payloadBasePointer,
      int df,
      boolean storesPayloads) {

    super.init(skipPointer, df);
    this.currentFieldStoresPayloads = storesPayloads;

    lastPayloadPointer = payloadBasePointer;

    for (int i = 0; i < maxNumberOfSkipLevels; i++) {
      docIndex[i].set(docBaseIndex);
      if (freqIndex != null) {
        freqIndex[i].set(freqBaseIndex);
      }
      if (posBaseIndex != null) {
        posIndex[i].set(posBaseIndex);
      }
    }
    Arrays.fill(payloadPointer, payloadBasePointer);
    Arrays.fill(payloadLength, 0);
  }
 void checkIterationSanity(Queue q) {
   if (rnd.nextBoolean()) return;
   int size = q.size();
   Object[] a = q.toArray();
   Object[] b = new Object[size + 2];
   Arrays.fill(b, Boolean.TRUE);
   Object[] c = q.toArray(b);
   equal(a.length, size);
   check(b == c);
   check(b[size] == null);
   check(b[size + 1] == Boolean.TRUE);
   equal(q.toString(), Arrays.toString(a));
   Integer[] xx = null, yy = null;
   if (size > 0) {
     xx = new Integer[size - 1];
     Arrays.fill(xx, 42);
     yy = ((Queue<Integer>) q).toArray(xx);
     for (Integer zz : xx) equal(42, zz);
   }
   Iterator it = q.iterator();
   for (int i = 0; i < size; i++) {
     check(it.hasNext());
     Object x = it.next();
     check(x == a[i]);
     check(x == b[i]);
     if (xx != null) check(x == yy[i]);
   }
   check(!it.hasNext());
 }
Example #19
0
  @Override
  public CanvasSize estimateViewport() {
    if (viewport == null) {
      final int dim = proj.getDimensionality();
      DoubleMinMax minmaxx = new DoubleMinMax();
      DoubleMinMax minmaxy = new DoubleMinMax();

      // Origin
      final double[] vec = new double[dim];
      double[] orig = projectScaledToRender(vec);
      minmaxx.put(orig[0]);
      minmaxy.put(orig[1]);
      // Diagonal point
      Arrays.fill(vec, 1.);
      double[] diag = projectScaledToRender(vec);
      minmaxx.put(diag[0]);
      minmaxy.put(diag[1]);
      // Axis end points
      for (int d = 0; d < dim; d++) {
        Arrays.fill(vec, 0.);
        vec[d] = 1.;
        double[] ax = projectScaledToRender(vec);
        minmaxx.put(ax[0]);
        minmaxy.put(ax[1]);
      }
      viewport =
          new CanvasSize(minmaxx.getMin(), minmaxx.getMax(), minmaxy.getMin(), minmaxy.getMax());
    }
    return viewport;
  }
Example #20
0
 public static List<Vertex> compute(Graph graph) {
   List<Vertex> resultList = new LinkedList<Vertex>();
   Vertex[] vertexes = graph.getVertexes();
   List<EdgeFrom>[] edgesTo = graph.getEdgesTo();
   double[] d = new double[vertexes.length];
   Arrays.fill(d, Double.MAX_VALUE);
   d[d.length - 1] = 0;
   int[] path = new int[vertexes.length];
   Arrays.fill(path, -1);
   PriorityQueue<State> que = new PriorityQueue<State>();
   que.add(new State(0, vertexes.length - 1));
   while (!que.isEmpty()) {
     State p = que.poll();
     if (d[p.vertex] < p.cost) continue;
     for (EdgeFrom edgeFrom : edgesTo[p.vertex]) {
       if (d[edgeFrom.from] > d[p.vertex] + edgeFrom.weight) {
         d[edgeFrom.from] = d[p.vertex] + edgeFrom.weight;
         que.add(new State(d[edgeFrom.from], edgeFrom.from));
         path[edgeFrom.from] = p.vertex;
       }
     }
   }
   for (int t = 0; t != -1; t = path[t]) {
     resultList.add(vertexes[t]);
   }
   return resultList;
 }
Example #21
0
 /**
  * Update the row means and column means.
  *
  * @param mat Data matrix
  * @param all Flag, to update all
  * @return overall mean
  */
 protected double updateRowAndColumnMeans(final double[][] mat, boolean all) {
   final int mode = all ? CellVisitor.ALL : CellVisitor.SELECTED;
   Arrays.fill(rowM, 0.);
   Arrays.fill(colM, 0.);
   allM = 0.;
   visitAll(mat, mode, MEANVISITOR);
   visitColumn(
       mat,
       0,
       mode,
       new CellVisitor() {
         @Override
         public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
           rowM[row] /= colcard;
           return false;
         }
       });
   visitRow(
       mat,
       0,
       mode,
       new CellVisitor() {
         @Override
         public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
           colM[col] /= rowcard;
           return false;
         }
       });
   allM /= colcard * rowcard;
   return allM;
 }
 protected static int inplaceor(int[] bitmap, IteratingRLW32 i) {
   int pos = 0;
   int s;
   while ((s = i.size()) > 0) {
     if (pos + s < bitmap.length) {
       final int L = i.getRunningLength();
       if (i.getRunningBit()) java.util.Arrays.fill(bitmap, pos, pos + L, ~0);
       pos += L;
       final int LR = i.getNumberOfLiteralWords();
       for (int k = 0; k < LR; ++k) bitmap[pos++] |= i.getLiteralWordAt(k);
       if (!i.next()) {
         return pos;
       }
     } else {
       int howmany = bitmap.length - pos;
       int l = i.getRunningLength();
       if (pos + l > bitmap.length) {
         if (i.getRunningBit()) {
           java.util.Arrays.fill(bitmap, pos, bitmap.length, ~0);
         }
         i.discardFirstWords(howmany);
         return bitmap.length;
       }
       if (i.getRunningBit()) java.util.Arrays.fill(bitmap, pos, pos + l, ~0);
       pos += l;
       for (int k = 0; pos < bitmap.length; ++k) bitmap[pos++] |= i.getLiteralWordAt(k);
       i.discardFirstWords(howmany);
       return pos;
     }
   }
   return pos;
 }
  private void locateViews() {

    mCellsPos.clear();
    mCells.clear();

    int count_y = mCellsCountY;
    int count_x = mCellsCountX;

    for (int j = 0; j < count_y; j++) {
      for (int i = 0; i < count_x; i++) {
        View child = getViewFromAdapter(i, j);
        // int type = getViewTypeFromAdapter(calcIndex2(i, j));
        if (child == null) continue;

        mCells.put(calcIndex2(i, j), child);
        mCellsPos.put(child, calcIndex2(i, j));
      }
    }

    if (mCellsWidth == null || mCellsWidth.length != mCellsCountX) {
      mCellsWidth = new int[mCellsCountX];
    }
    if (mCellsHeight == null || mCellsHeight.length != mCellsCountY) {
      mCellsHeight = new int[mCellsCountY];
    }

    Arrays.fill(mCellsWidth, 0);
    Arrays.fill(mCellsHeight, 0);
  }
  protected KeyPeg[] getAnswer(CodePeg[] codePegs) {
    KeyPeg[] keyPegs = new KeyPeg[Peg.LINE_SIZE];
    Arrays.fill(keyPegs, KeyPeg.WRONG);
    int keyPegsIndex = 0;

    // Check positions.
    boolean[] positionUsed = new boolean[Peg.LINE_SIZE];
    Arrays.fill(positionUsed, false);

    for (int i = 0; i < Peg.LINE_SIZE; i++) {
      if (codePegs[i] == this.secretCode[i]) {
        positionUsed[i] = true;
        keyPegs[keyPegsIndex++] = KeyPeg.CORRECT;
      }
    }

    // Checking colors.
    for (int i = 0; i < Peg.LINE_SIZE; i++) {
      if (!positionUsed[i]) {
        for (int j = 0; j < Peg.LINE_SIZE; j++) {
          if (codePegs[i] == this.secretCode[j] && !positionUsed[j]) {
            positionUsed[j] = true;
            keyPegs[keyPegsIndex++] = KeyPeg.COLOR;
          }
        }
      }
    }

    return keyPegs;
  }
Example #25
0
 public final void initConstants(int size) {
   constants = new IRubyObject[size];
   constantTargetHashes = new int[size];
   constantGenerations = new int[size];
   Arrays.fill(constantGenerations, -1);
   Arrays.fill(constantTargetHashes, -1);
 }
Example #26
0
  private void ensureCapacity() throws IOException {
    if (offset >= BLOCK_SIZE) {
      // get the next block
      if (blockCount >= usedBlocks.length) {
        int[] blocks = new int[blockCount * 2];
        System.arraycopy(usedBlocks, 0, blocks, 0, usedBlocks.length);
        Arrays.fill(blocks, usedBlocks.length, blocks.length, -1);
        usedBlocks = blocks;
      }

      int nextBlockId = usedBlocks[blockCount];
      if (nextBlockId == -1) {
        nextBlockId = file.allocBlock();
        usedBlocks[blockCount] = nextBlockId;
      }

      // flush the current block into the disk
      if (blockId != -1) {
        BTreeUtils.integerToBytes(nextBlockId, bytes);
        file.writeBlock(blockId, bytes);
      }

      blockId = nextBlockId;
      blockCount++;

      Arrays.fill(bytes, (byte) 0);

      offset = 4;
    }
  }
    public FloatValueCollapse(
        int maxDoc,
        String field,
        int nullPolicy,
        int[] ords,
        boolean max,
        boolean needsScores,
        IntIntOpenHashMap boostDocs,
        SortedDocValues values)
        throws IOException {
      super(maxDoc, field, nullPolicy, max, needsScores, boostDocs, values);
      this.ords = ords;
      this.ordVals = new float[ords.length];
      Arrays.fill(ords, -1);

      if (max) {
        comp = new MaxFloatComp();
        Arrays.fill(ordVals, -Float.MAX_VALUE);
      } else {
        this.nullVal = Float.MAX_VALUE;
        comp = new MinFloatComp();
        Arrays.fill(ordVals, Float.MAX_VALUE);
      }

      if (needsScores) {
        this.scores = new float[ords.length];
        if (nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) {
          nullScores = new FloatArrayList();
        }
      }
    }
Example #28
0
  /**
   * 对报文进行采用MD5进行hmac签名
   *
   * @param aValue - 字符�?
   * @param aKey - 密钥
   * @param encoding - 字符串编码方�?
   * @return - 签名结果,hex字符�?
   */
  public static String hmacSign(String aValue, String aKey, String encoding) {
    byte k_ipad[] = new byte[64];
    byte k_opad[] = new byte[64];
    byte keyb[];
    byte value[];
    try {
      keyb = aKey.getBytes(encoding);
      value = aValue.getBytes(encoding);
    } catch (UnsupportedEncodingException e) {
      keyb = aKey.getBytes();
      value = aValue.getBytes();
    }
    Arrays.fill(k_ipad, keyb.length, 64, (byte) 54);
    Arrays.fill(k_opad, keyb.length, 64, (byte) 92);
    for (int i = 0; i < keyb.length; i++) {
      k_ipad[i] = (byte) (keyb[i] ^ 0x36);
      k_opad[i] = (byte) (keyb[i] ^ 0x5c);
    }

    MessageDigest md = null;
    try {
      md = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
      return null;
    }
    md.update(k_ipad);
    md.update(value);
    byte dg[] = md.digest();
    md.reset();
    md.update(k_opad);
    md.update(dg, 0, 16);
    dg = md.digest();
    return ConvertUtils.toHex(dg);
  }
Example #29
0
  /*
   * encrypt magic String 64 times in ECB
   */
  private byte[] encryptMagicString() {
    int[] text = {
      MAGIC_STRING[0],
      MAGIC_STRING[1],
      MAGIC_STRING[2],
      MAGIC_STRING[3],
      MAGIC_STRING[4],
      MAGIC_STRING[5]
    };
    for (int i = 0; i < 64; i++) {
      for (int j = 0; j < MAGIC_STRING_LENGTH; j += 2) {
        int left = text[j];
        int right = text[j + 1];

        left ^= P[0];
        for (int k = 1; k < ROUNDS; k += 2) {
          right ^= F(left) ^ P[k];
          left ^= F(right) ^ P[k + 1];
        }
        right ^= P[ROUNDS + 1];
        // swap values:
        text[j] = right;
        text[j + 1] = left;
      }
    }
    byte[] result = new byte[24]; // holds 192 bit key
    intToBigEndian(text, result, 0);
    Arrays.fill(text, 0);
    Arrays.fill(P, 0);
    Arrays.fill(S, 0);

    return result;
  }
Example #30
0
  /**
   * Constructor
   *
   * @param executor
   */
  public AbstractTransaction(HStoreSite hstore_site) {
    this.hstore_site = hstore_site;
    int numPartitions = hstore_site.getCatalogContext().numberOfPartitions;

    this.released = new boolean[numPartitions];
    this.prepared = new boolean[numPartitions];
    this.finished = new boolean[numPartitions];
    this.round_state = new RoundState[numPartitions];
    this.round_ctr = new int[numPartitions];
    this.exec_readOnly = new boolean[numPartitions];
    this.exec_queueWork = new boolean[numPartitions];
    this.exec_eeWork = new boolean[numPartitions];

    this.exec_firstUndoToken = new long[numPartitions];
    this.exec_lastUndoToken = new long[numPartitions];
    this.exec_noUndoBuffer = new boolean[numPartitions];

    this.init_task = new InitializeTxnMessage(this);

    this.readTables = new boolean[numPartitions][];
    this.writeTables = new boolean[numPartitions][];

    Arrays.fill(this.exec_firstUndoToken, HStoreConstants.NULL_UNDO_LOGGING_TOKEN);
    Arrays.fill(this.exec_lastUndoToken, HStoreConstants.NULL_UNDO_LOGGING_TOKEN);
    Arrays.fill(this.exec_readOnly, true);
    Arrays.fill(this.exec_queueWork, false);
    Arrays.fill(this.exec_eeWork, false);
  }