Tabnine Logo
ImmutableBytesWritable$Comparator
Code IndexAdd Tabnine to your IDE (free)

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

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

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: 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: 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: 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: 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

Javadoc

A Comparator optimized for ImmutableBytesWritable.

Most used methods

  • <init>
    constructor
  • compare

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • setScale (BigDecimal)
  • setRequestProperty (URLConnection)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top plugins for Android Studio
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