public class PairLexicoder<A extends Comparable<A>,B extends Comparable<B>> extends org.apache.accumulo.core.client.lexicoder.impl.AbstractLexicoder<org.apache.accumulo.core.util.ComparablePair<A,B>> implements Lexicoder<org.apache.accumulo.core.util.ComparablePair<A,B>>
{ @code StringLexicoder stringEncoder = new StringLexicoder(); ReverseLexicoder<Date> dateEncoder = new ReverseLexicoder<Date>(new DateLexicoder()); PairLexicoder<String,Date> pairLexicoder = new PairLexicoder<String,Date>(stringEncoder, dateEncoder); byte[] pair1 = pairLexicoder.encode(new ComparablePair<String,Date>("com.google", new Date())); byte[] pair2 = pairLexicoder.encode(new ComparablePair<String,Date>("com.google", new Date(System.currentTimeMillis() + 500))); byte[] pair3 = pairLexicoder.encode(new ComparablePair<String,Date>("org.apache", new Date(System.currentTimeMillis() + 1000))); }In the example, pair2 will be sorted before pair1. pair3 will occur last since 'org' is sorted after 'com'. If we just used a
DateLexicoder
instead
of a ReverseLexicoder
, pair1 would have been sorted before pair2.Constructor and Description |
---|
PairLexicoder(Lexicoder<A> firstLexicoder,
Lexicoder<B> secondLexicoder) |
Modifier and Type | Method and Description |
---|---|
org.apache.accumulo.core.util.ComparablePair<A,B> |
decode(byte[] b) |
protected org.apache.accumulo.core.util.ComparablePair<A,B> |
decodeUnchecked(byte[] data,
int offset,
int len)
Decodes a byte array without checking if the offset and len exceed the bounds of the actual array.
|
byte[] |
encode(org.apache.accumulo.core.util.ComparablePair<A,B> data) |
decode
public byte[] encode(org.apache.accumulo.core.util.ComparablePair<A,B> data)
encode
in interface org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder<org.apache.accumulo.core.util.ComparablePair<A extends Comparable<A>,B extends Comparable<B>>>
public org.apache.accumulo.core.util.ComparablePair<A,B> decode(byte[] b)
decode
in interface org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder<org.apache.accumulo.core.util.ComparablePair<A extends Comparable<A>,B extends Comparable<B>>>
decode
in class AbstractEncoder<org.apache.accumulo.core.util.ComparablePair<A extends Comparable<A>,B extends Comparable<B>>>
protected org.apache.accumulo.core.util.ComparablePair<A,B> decodeUnchecked(byte[] data, int offset, int len)
AbstractEncoder
decodeUnchecked
in class AbstractEncoder<org.apache.accumulo.core.util.ComparablePair<A extends Comparable<A>,B extends Comparable<B>>>
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.