예제 #1
0
  /*
   * Put the separator function of a Bucket buck
   * into the BucketTree beyond the current
   * active_bucket.
   */
  private void insert(Bucket buck) {
    int i, index;
    Bucket b;

    if (buck.separator == null) return;

    for (i = active_bucket; i < bucket_tree.length; i++) {
      // Get the index for current Bucket's variable.
      index = bucket_tree[i].variable.get_index();
      // If separator contains a variable in the current Bucket, then join buckets.
      if (buck.separator.memberOf(index)) {
        // Add separator to bucket.
        bucket_tree[i].discrete_functions.addElement(buck.separator);
        // Update the non_conditioning variables.
        // Go through the non-conditioning variables in the inserted Bucket.
        for (Enumeration e = buck.non_conditioning_variables.elements(); e.hasMoreElements(); )
          bucket_tree[i].non_conditioning_variables.addElement(e.nextElement());
        // Take the inserted Bucket variable out by making it CONDITIONING:
        // Must take the variable out as it has been eliminated already.
        bucket_tree[i].non_conditioning_variables.removeElement(buck.variable);
        // Mark parent/child relationship.
        buck.child = bucket_tree[i];
        bucket_tree[i].parents.addElement(buck);
        return;
      }
    }
  }
예제 #2
0
파일: MessageFile.java 프로젝트: imace/zava
  /**
   * Create a cursor reading data from timestamp onwards. If timestamp is before the first message
   * then the cursor reads starting at the first message. If timestamp is past the last message then
   * the cursor will return false until more messages appear in the file.
   */
  @SuppressWarnings("StatementWithEmptyBody")
  public MessageCursor cursorByTimestamp(long timestamp) throws IOException {
    int i = findBucketByTimestamp(timestamp);
    if (i < 0) return new Cursor(firstMessageId);

    // the first message with timestamp >= the time we are looking for may be in a previous bucket
    // because
    // the bucket timestamp resolution is only ms so go back until we get a change in time .. that
    // way we
    // are sure to find it
    Bucket b = getBucket(i);
    for (; b.getTimestamp() == timestamp && i > 0; b = getBucket(--i)) ;

    Cursor c = new Cursor(getBucket(i).getFirstMessageId());
    for (; c.next(); ) { // skip messages until we get one >= timestamp
      if (c.getTimestamp() >= timestamp) {
        c.unget();
        break;
      }
    }
    return c;
  }