Tabnine Logo
ImmutableBytesWritable$Comparator.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.hadoop.hbase.io.ImmutableBytesWritable$Comparator
constructor

Best Java code snippets using org.apache.hadoop.hbase.io.ImmutableBytesWritable$Comparator.<init> (Showing top 15 results out of 315)

origin: apache/hbase

private void doComparisonsOnRaw(ImmutableBytesWritable a,
                ImmutableBytesWritable b,
                int expectedSignum)
 throws IOException {
 ImmutableBytesWritable.Comparator comparator =
  new ImmutableBytesWritable.Comparator();
 ByteArrayOutputStream baosA = new ByteArrayOutputStream();
 ByteArrayOutputStream baosB = new ByteArrayOutputStream();
 a.write(new DataOutputStream(baosA));
 b.write(new DataOutputStream(baosB));
 assertEquals(
  "Comparing " + a + " and " + b + " as raw",
  signum(comparator.compare(baosA.toByteArray(), 0, baosA.size(),
               baosB.toByteArray(), 0, baosB.size())),
  expectedSignum);
 assertEquals(
  "Comparing " + a + " and " + b + " as raw (inverse)",
  -signum(comparator.compare(baosB.toByteArray(), 0, baosB.size(),
                baosA.toByteArray(), 0, baosA.size())),
  expectedSignum);
}
origin: apache/phoenix

  private List<ImmutableBytesWritable> sortKeys() {
    // This will throw InsufficientMemoryException if necessary
    memoryChunk.resize(memoryChunk.getSize() + SizedUtil.sizeOfArrayList(hash.size()));

    keyList = new ArrayList<ImmutableBytesWritable>(hash.size());
    keyList.addAll(hash.keySet());
    Comparator<ImmutableBytesWritable> comp = new ImmutableBytesWritable.Comparator();
    if (orderBy == OrderBy.REV_ROW_KEY_ORDER_BY) {
      comp = Collections.reverseOrder(comp);
    }
    Collections.sort(keyList, comp);
    return keyList;
  }
}
origin: forcedotcom/phoenix

/**
 * Builds a comparator from the list of columns in ORDER BY clause.
 * @param orderByExpressions the columns in ORDER BY clause.
 * @return the comparator built from the list of columns in ORDER BY clause.
 */
// ImmutableBytesWritable.Comparator doesn't implement generics
@SuppressWarnings("unchecked")
private static Comparator<ResultEntry> buildComparator(List<OrderByExpression> orderByExpressions) {
  Ordering<ResultEntry> ordering = null;
  int pos = 0;
  for (OrderByExpression col : orderByExpressions) {
    Ordering<ImmutableBytesWritable> o = Ordering.from(new ImmutableBytesWritable.Comparator());
    if(!col.isAscending()) o = o.reverse();
    o = col.isNullsLast() ? o.nullsLast() : o.nullsFirst();
    Ordering<ResultEntry> entryOrdering = o.onResultOf(new NthKey(pos++));
    ordering = ordering == null ? entryOrdering : ordering.compound(entryOrdering);
  }
  return ordering;
}
origin: com.aliyun.phoenix/ali-phoenix-core

/**
 * Builds a comparator from the list of columns in ORDER BY clause.
 * @param orderByExpressions the columns in ORDER BY clause.
 * @return the comparator built from the list of columns in ORDER BY clause.
 */
// ImmutableBytesWritable.Comparator doesn't implement generics
@SuppressWarnings("unchecked")
private static Comparator<ResultEntry> buildComparator(List<OrderByExpression> orderByExpressions) {
  Ordering<ResultEntry> ordering = null;
  int pos = 0;
  for (OrderByExpression col : orderByExpressions) {
    Expression e = col.getExpression();
    Comparator<ImmutableBytesWritable> comparator = 
        e.getSortOrder() == SortOrder.DESC && !e.getDataType().isFixedWidth() 
        ? buildDescVarLengthComparator() 
        : new ImmutableBytesWritable.Comparator();
    Ordering<ImmutableBytesWritable> o = Ordering.from(comparator);
    if(!col.isAscending()) o = o.reverse();
    o = col.isNullsLast() ? o.nullsLast() : o.nullsFirst();
    Ordering<ResultEntry> entryOrdering = o.onResultOf(new NthKey(pos++));
    ordering = ordering == null ? entryOrdering : ordering.compound(entryOrdering);
  }
  return ordering;
}
origin: org.apache.phoenix/phoenix-core

/**
 * Builds a comparator from the list of columns in ORDER BY clause.
 * @param orderByExpressions the columns in ORDER BY clause.
 * @return the comparator built from the list of columns in ORDER BY clause.
 */
// ImmutableBytesWritable.Comparator doesn't implement generics
@SuppressWarnings("unchecked")
private static Comparator<ResultEntry> buildComparator(List<OrderByExpression> orderByExpressions) {
  Ordering<ResultEntry> ordering = null;
  int pos = 0;
  for (OrderByExpression col : orderByExpressions) {
    Expression e = col.getExpression();
    Comparator<ImmutableBytesWritable> comparator = 
        e.getSortOrder() == SortOrder.DESC && !e.getDataType().isFixedWidth() 
        ? buildDescVarLengthComparator() 
        : new ImmutableBytesWritable.Comparator();
    Ordering<ImmutableBytesWritable> o = Ordering.from(comparator);
    if(!col.isAscending()) o = o.reverse();
    o = col.isNullsLast() ? o.nullsLast() : o.nullsFirst();
    Ordering<ResultEntry> entryOrdering = o.onResultOf(new NthKey(pos++));
    ordering = ordering == null ? entryOrdering : ordering.compound(entryOrdering);
  }
  return ordering;
}
origin: org.apache.hbase/hbase-server

private void doComparisonsOnRaw(ImmutableBytesWritable a,
                ImmutableBytesWritable b,
                int expectedSignum)
 throws IOException {
 ImmutableBytesWritable.Comparator comparator =
  new ImmutableBytesWritable.Comparator();
 ByteArrayOutputStream baosA = new ByteArrayOutputStream();
 ByteArrayOutputStream baosB = new ByteArrayOutputStream();
 a.write(new DataOutputStream(baosA));
 b.write(new DataOutputStream(baosB));
 assertEquals(
  "Comparing " + a + " and " + b + " as raw",
  signum(comparator.compare(baosA.toByteArray(), 0, baosA.size(),
               baosB.toByteArray(), 0, baosB.size())),
  expectedSignum);
 assertEquals(
  "Comparing " + a + " and " + b + " as raw (inverse)",
  -signum(comparator.compare(baosB.toByteArray(), 0, baosB.size(),
                baosA.toByteArray(), 0, baosA.size())),
  expectedSignum);
}
origin: com.aliyun.phoenix/ali-phoenix-core

  private List<ImmutableBytesWritable> sortKeys() {
    // This will throw InsufficientMemoryException if necessary
    memoryChunk.resize(memoryChunk.getSize() + SizedUtil.sizeOfArrayList(hash.size()));

    keyList = new ArrayList<ImmutableBytesWritable>(hash.size());
    keyList.addAll(hash.keySet());
    Comparator<ImmutableBytesWritable> comp = new ImmutableBytesWritable.Comparator();
    if (orderBy == OrderBy.REV_ROW_KEY_ORDER_BY) {
      comp = Collections.reverseOrder(comp);
    }
    Collections.sort(keyList, comp);
    return keyList;
  }
}
origin: com.aliyun.phoenix/ali-phoenix-core

private static Comparator<ImmutableBytesWritable> buildDescVarLengthComparator() {
  return new Comparator<ImmutableBytesWritable>() {
    @Override
    public int compare(ImmutableBytesWritable o1, ImmutableBytesWritable o2) {
      return DescVarLengthFastByteComparisons.compareTo(
          o1.get(), o1.getOffset(), o1.getLength(),
          o2.get(), o2.getOffset(), o2.getLength());
    }
    
  };
}

origin: org.apache.phoenix/phoenix-core

private static Comparator<ImmutableBytesWritable> buildDescVarLengthComparator() {
  return new Comparator<ImmutableBytesWritable>() {
    @Override
    public int compare(ImmutableBytesWritable o1, ImmutableBytesWritable o2) {
      return DescVarLengthFastByteComparisons.compareTo(
          o1.get(), o1.getOffset(), o1.getLength(),
          o2.get(), o2.getOffset(), o2.getLength());
    }
    
  };
}

origin: org.apache.hbase/hbase-server

private void doComparisonsOnObjects(ImmutableBytesWritable a,
                  ImmutableBytesWritable b,
                  int expectedSignum) {
 ImmutableBytesWritable.Comparator comparator =
  new ImmutableBytesWritable.Comparator();
 assertEquals(
  "Comparing " + a + " and " + b + " as objects",
  signum(comparator.compare(a, b)), expectedSignum);
 assertEquals(
  "Comparing " + a + " and " + b + " as objects (inverse)",
  -signum(comparator.compare(b, a)), expectedSignum);
}
origin: org.apache.hbase/hbase-server

public void testSpecificCompare() {
 ImmutableBytesWritable ibw1 = new ImmutableBytesWritable(new byte[]{0x0f});
 ImmutableBytesWritable ibw2 = new ImmutableBytesWritable(new byte[]{0x00, 0x00});
 ImmutableBytesWritable.Comparator c = new ImmutableBytesWritable.Comparator();
 assertFalse("ibw1 < ibw2", c.compare( ibw1, ibw2 ) < 0 );
}
origin: apache/phoenix

/**
 * Builds a comparator from the list of columns in ORDER BY clause.
 * @param orderByExpressions the columns in ORDER BY clause.
 * @return the comparator built from the list of columns in ORDER BY clause.
 */
// ImmutableBytesWritable.Comparator doesn't implement generics
@SuppressWarnings("unchecked")
private static Comparator<ResultEntry> buildComparator(List<OrderByExpression> orderByExpressions) {
  Ordering<ResultEntry> ordering = null;
  int pos = 0;
  for (OrderByExpression col : orderByExpressions) {
    Expression e = col.getExpression();
    Comparator<ImmutableBytesWritable> comparator = 
        e.getSortOrder() == SortOrder.DESC && !e.getDataType().isFixedWidth() 
        ? buildDescVarLengthComparator() 
        : new ImmutableBytesWritable.Comparator();
    Ordering<ImmutableBytesWritable> o = Ordering.from(comparator);
    if(!col.isAscending()) o = o.reverse();
    o = col.isNullsLast() ? o.nullsLast() : o.nullsFirst();
    Ordering<ResultEntry> entryOrdering = o.onResultOf(new NthKey(pos++));
    ordering = ordering == null ? entryOrdering : ordering.compound(entryOrdering);
  }
  return ordering;
}
origin: apache/phoenix

private static Comparator<ImmutableBytesWritable> buildDescVarLengthComparator() {
  return new Comparator<ImmutableBytesWritable>() {
    @Override
    public int compare(ImmutableBytesWritable o1, ImmutableBytesWritable o2) {
      return DescVarLengthFastByteComparisons.compareTo(
          o1.get(), o1.getOffset(), o1.getLength(),
          o2.get(), o2.getOffset(), o2.getLength());
    }
    
  };
}

origin: apache/hbase

public void testSpecificCompare() {
 ImmutableBytesWritable ibw1 = new ImmutableBytesWritable(new byte[]{0x0f});
 ImmutableBytesWritable ibw2 = new ImmutableBytesWritable(new byte[]{0x00, 0x00});
 ImmutableBytesWritable.Comparator c = new ImmutableBytesWritable.Comparator();
 assertFalse("ibw1 < ibw2", c.compare( ibw1, ibw2 ) < 0 );
}
origin: apache/hbase

private void doComparisonsOnObjects(ImmutableBytesWritable a,
                  ImmutableBytesWritable b,
                  int expectedSignum) {
 ImmutableBytesWritable.Comparator comparator =
  new ImmutableBytesWritable.Comparator();
 assertEquals(
  "Comparing " + a + " and " + b + " as objects",
  signum(comparator.compare(a, b)), expectedSignum);
 assertEquals(
  "Comparing " + a + " and " + b + " as objects (inverse)",
  -signum(comparator.compare(b, a)), expectedSignum);
}
org.apache.hadoop.hbase.ioImmutableBytesWritable$Comparator<init>

Javadoc

constructor

Popular methods of ImmutableBytesWritable$Comparator

  • compare

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • setContentView (Activity)
  • findViewById (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • From CI to AI: The AI layer in your organization
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