congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Table.computeRow
Code IndexAdd Tabnine to your IDE (free)

How to use
computeRow
method
in
org.jgroups.util.Table

Best Java code snippets using org.jgroups.util.Table.computeRow (Showing top 18 results out of 315)

origin: wildfly/wildfly

/**
 * Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly. The
 * capacity of the matrix should be size * resize_factor. Caller must hold the lock.
 */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void _compact() {
  // This is the range we need to copy into the new matrix (including from and to)
  int from=computeRow(low), to=computeRow(hr);
  int range=to - from +1;  // e.g. from=3, to=5, new_size has to be [3 .. 5] (=3)
  int new_size=(int)Math.max( (double)range * resize_factor, (double) range +1 );
  new_size=Math.max(new_size, num_rows); // don't fall below the initial size defined
  if(new_size < matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, from, new_matrix, 0, range);
    matrix=new_matrix;
    offset+=from * elements_per_row;
    num_compactions++;
  }
}
origin: wildfly/wildfly

/**
 * Returns an element at seqno
 * @param seqno
 * @return
 */
public T get(long seqno) {
  lock.lock();
  try {
    if(seqno - low <= 0 || seqno - hr > 0)
      return null;
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

/**
 * To be used only for testing; doesn't do any index or sanity checks
 * @param seqno
 * @return
 */
public T _get(long seqno) {
  lock.lock();
  try {
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

/** Moves rows down the matrix, by removing purged rows. If resizing to accommodate seqno is still needed, computes
 * a new size. Then either moves existing rows down, or copies them into a new array (if resizing took place).
 * The lock must be held by the caller of resize(). */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void resize(long seqno) {
  int num_rows_to_purge=computeRow(low);
  int row_index=computeRow(seqno) - num_rows_to_purge;
  if(row_index < 0)
    return;
  int new_size=Math.max(row_index +1, matrix.length);
  if(new_size > matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, num_rows_to_purge, new_matrix, 0, matrix.length - num_rows_to_purge);
    matrix=new_matrix;
    num_resizes++;
  }
  else if(num_rows_to_purge > 0) {
    move(num_rows_to_purge);
  }
  offset+=(num_rows_to_purge * elements_per_row);
}
origin: wildfly/wildfly

/** Removes the next non-null element and nulls the index if nullify=true */
public T remove(boolean nullify) {
  lock.lock();
  try {
    int row_index=computeRow(hd+1);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(hd+1);
    if(index < 0)
      return null;
    T existing_element=row[index];
    if(existing_element != null) {
      hd++;
      size=Math.max(size-1, 0); // cannot be < 0 (well that would be a bug, but let's have this 2nd line of defense !)
      if(nullify) {
        row[index]=null;
        if(hd - low > 0)
          low=hd;
      }
    }
    return existing_element;
  }
  finally {
    lock.unlock();
  }
}
origin: wildfly/wildfly

int start_row=computeRow(low), end_row=computeRow(seqno);
if(start_row < 0) start_row=0;
if(end_row < 0)
origin: wildfly/wildfly

  return false;
int row_index=computeRow(seqno);
if(check_if_resize_needed && row_index >= matrix.length) {
  resize(seqno);
  row_index=computeRow(seqno);
origin: wildfly/wildfly

lock.lock();
try {
  if(highest_seqno != -1 && computeRow(highest_seqno) >= matrix.length)
    resize(highest_seqno);
origin: wildfly/wildfly

/**
 * Iterates over the matrix with range [from .. to] (including from and to), and calls
 * {@link Visitor#visit(long,Object,int,int)}. If the visit() method returns false, the iteration is terminated.
 * <p/>
 * This method must be called with the lock held
 * @param from The starting seqno
 * @param to The ending seqno, the range is [from .. to] including from and to
 * @param visitor An instance of Visitor
 */
@GuardedBy("lock")
public void forEach(long from, long to, Visitor<T> visitor) {
  if(from - to > 0) // same as if(from > to), but prevents long overflow
    return;
  int row=computeRow(from), column=computeIndex(from);
  int distance=(int)(to - from +1);
  T[] current_row=row+1 > matrix.length? null : matrix[row];
  for(int i=0; i < distance; i++) {
    T element=current_row == null? null : current_row[column];
    if(!visitor.visit(from, element, row, column))
      break;
    from++;
    if(++column >= elements_per_row) {
      column=0;
      row++;
      current_row=row+1 > matrix.length? null : matrix[row];
    }
  }
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly. The
 * capacity of the matrix should be size * resize_factor. Caller must hold the lock.
 */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void _compact() {
  // This is the range we need to copy into the new matrix (including from and to)
  int from=computeRow(low), to=computeRow(hr);
  int range=to - from +1;  // e.g. from=3, to=5, new_size has to be [3 .. 5] (=3)
  int new_size=(int)Math.max( (double)range * resize_factor, (double) range +1 );
  new_size=Math.max(new_size, num_rows); // don't fall below the initial size defined
  if(new_size < matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, from, new_matrix, 0, range);
    matrix=new_matrix;
    offset+=from * elements_per_row;
    num_compactions++;
  }
}
origin: org.jboss.eap/wildfly-client-all

/**
 * To be used only for testing; doesn't do any index or sanity checks
 * @param seqno
 * @return
 */
public T _get(long seqno) {
  lock.lock();
  try {
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
origin: org.jboss.eap/wildfly-client-all

/** Moves rows down the matrix, by removing purged rows. If resizing to accommodate seqno is still needed, computes
 * a new size. Then either moves existing rows down, or copies them into a new array (if resizing took place).
 * The lock must be held by the caller of resize(). */
@SuppressWarnings("unchecked")
@GuardedBy("lock")
protected void resize(long seqno) {
  int num_rows_to_purge=computeRow(low);
  int row_index=computeRow(seqno) - num_rows_to_purge;
  if(row_index < 0)
    return;
  int new_size=Math.max(row_index +1, matrix.length);
  if(new_size > matrix.length) {
    T[][] new_matrix=(T[][])new Object[new_size][];
    System.arraycopy(matrix, num_rows_to_purge, new_matrix, 0, matrix.length - num_rows_to_purge);
    matrix=new_matrix;
    num_resizes++;
  }
  else if(num_rows_to_purge > 0) {
    move(num_rows_to_purge);
  }
  offset+=(num_rows_to_purge * elements_per_row);
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Returns an element at seqno
 * @param seqno
 * @return
 */
public T get(long seqno) {
  lock.lock();
  try {
    if(seqno - low <= 0 || seqno - hr > 0)
      return null;
    int row_index=computeRow(seqno);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(seqno);
    return index >= 0? row[index] : null;
  }
  finally {
    lock.unlock();
  }
}
origin: org.jboss.eap/wildfly-client-all

/** Removes the next non-null element and nulls the index if nullify=true */
public T remove(boolean nullify) {
  lock.lock();
  try {
    int row_index=computeRow(hd+1);
    if(row_index < 0 || row_index >= matrix.length)
      return null;
    T[] row=matrix[row_index];
    if(row == null)
      return null;
    int index=computeIndex(hd+1);
    if(index < 0)
      return null;
    T existing_element=row[index];
    if(existing_element != null) {
      hd++;
      size=Math.max(size-1, 0); // cannot be < 0 (well that would be a bug, but let's have this 2nd line of defense !)
      if(nullify) {
        row[index]=null;
        if(hd - low > 0)
          low=hd;
      }
    }
    return existing_element;
  }
  finally {
    lock.unlock();
  }
}
origin: org.jboss.eap/wildfly-client-all

int start_row=computeRow(low), end_row=computeRow(seqno);
if(start_row < 0) start_row=0;
if(end_row < 0)
origin: org.jboss.eap/wildfly-client-all

  return false;
int row_index=computeRow(seqno);
if(check_if_resize_needed && row_index >= matrix.length) {
  resize(seqno);
  row_index=computeRow(seqno);
origin: org.jboss.eap/wildfly-client-all

lock.lock();
try {
  if(highest_seqno != -1 && computeRow(highest_seqno) >= matrix.length)
    resize(highest_seqno);
origin: org.jboss.eap/wildfly-client-all

/**
 * Iterates over the matrix with range [from .. to] (including from and to), and calls
 * {@link Visitor#visit(long,Object,int,int)}. If the visit() method returns false, the iteration is terminated.
 * <p/>
 * This method must be called with the lock held
 * @param from The starting seqno
 * @param to The ending seqno, the range is [from .. to] including from and to
 * @param visitor An instance of Visitor
 */
@GuardedBy("lock")
public void forEach(long from, long to, Visitor<T> visitor) {
  if(from - to > 0) // same as if(from > to), but prevents long overflow
    return;
  int row=computeRow(from), column=computeIndex(from);
  int distance=(int)(to - from +1);
  T[] current_row=row+1 > matrix.length? null : matrix[row];
  for(int i=0; i < distance; i++) {
    T element=current_row == null? null : current_row[column];
    if(!visitor.visit(from, element, row, column))
      break;
    from++;
    if(++column >= elements_per_row) {
      column=0;
      row++;
      current_row=row+1 > matrix.length? null : matrix[row];
    }
  }
}
org.jgroups.utilTablecomputeRow

Javadoc

Computes and returns the row index for seqno. The caller must hold the lock.

Popular methods of Table

  • add
    Adds elements from the list to the table
  • <init>
  • _add
  • _compact
    Moves the contents of matrix down by the number of purged rows and resizes the matrix accordingly. T
  • capacity
    Returns the total capacity in the matrix
  • compact
  • computeIndex
    Computes and returns the index within a row for seqno
  • computeSize
    Iterate from low to hr and add up non-null values. Caller must hold the lock.
  • findHighestSeqno
  • forEach
    Iterates over the matrix with range [from .. to] (including from and to), and calls Visitor#visit(lo
  • get
    Returns an element at seqno
  • getAdders
  • get,
  • getAdders,
  • getDigest,
  • getHighestDeliverable,
  • getHighestDelivered,
  • getHighestReceived,
  • getLow,
  • getMissing,
  • getNumCompactions

Popular in Java

  • Making http requests using okhttp
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now