當前位置: 首頁>>代碼示例>>Java>>正文


Java UnsignedBytes.lexicographicalComparator方法代碼示例

本文整理匯總了Java中com.google.common.primitives.UnsignedBytes.lexicographicalComparator方法的典型用法代碼示例。如果您正苦於以下問題:Java UnsignedBytes.lexicographicalComparator方法的具體用法?Java UnsignedBytes.lexicographicalComparator怎麽用?Java UnsignedBytes.lexicographicalComparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.UnsignedBytes的用法示例。


在下文中一共展示了UnsignedBytes.lexicographicalComparator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openClosedBackwardTestWithGuava

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Test
public void openClosedBackwardTestWithGuava() {
  final Comparator<byte[]> guava = UnsignedBytes.lexicographicalComparator();
  final Comparator<ByteBuffer> comparator = (bb1, bb2) -> {
    final byte[] array1 = new byte[bb1.remaining()];
    final byte[] array2 = new byte[bb2.remaining()];
    bb1.mark();
    bb2.mark();
    bb1.get(array1);
    bb2.get(array2);
    bb1.reset();
    bb2.reset();
    return guava.compare(array1, array2);
  };
  verify(openClosedBackward(bb(7), bb(2)), comparator, 6, 4, 2);
  verify(openClosedBackward(bb(8), bb(4)), comparator, 6, 4);
}
 
開發者ID:lmdbjava,項目名稱:lmdbjava,代碼行數:18,代碼來源:CursorIteratorTest.java

示例2: createIndexes

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
protected void createIndexes(DB database)
{
	//HEIGHT INDEX
	Tuple2Comparator<Integer, byte[]> comparator = new Fun.Tuple2Comparator<Integer, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
	NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("blocks_index_height")
			.comparator(comparator)
			.makeOrGet();
	
	NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("blocks_index_height_descending")
			.comparator(new ReverseComparator(comparator))
			.makeOrGet();
	
	createIndex(HEIGHT_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Integer, byte[], Block>() {
	   	@Override
	    public Integer run(byte[] key, Block value) {
	   		return value.getHeight();
	    }
	});
}
 
開發者ID:razakal,項目名稱:Qora,代碼行數:21,代碼來源:BlockMap.java

示例3: createIndexes

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
	//TIMESTAMP INDEX
	Tuple2Comparator<Long, byte[]> comparator = new Fun.Tuple2Comparator<Long, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
	NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("transactions_index_timestamp")
			.comparator(comparator)
			.makeOrGet();
			
	NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("transactions_index_timestamp_descending")
			.comparator(new ReverseComparator(comparator))
			.makeOrGet();
			
	createIndex(TIMESTAMP_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Long, byte[], Transaction>() {
	   	@Override
	    public Long run(byte[] key, Transaction value) {
	   		return value.getTimestamp();
	    }
	});
}
 
開發者ID:razakal,項目名稱:Qora,代碼行數:21,代碼來源:TransactionMap.java

示例4: testEqualsPerformance

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Test
public void testEqualsPerformance() {
    boolean testEnabled = false;

    if (testEnabled) {
        final int ITERATIONS = 10000000;
        long start1 = System.currentTimeMillis();
        for (int i = 0; i < ITERATIONS; i++) {
            Comparator<byte[]> comparator = UnsignedBytes
                    .lexicographicalComparator();

            comparator.compare(wrapper1.getData(),
                    wrapper2.getData());
        }
        System.out.println(System.currentTimeMillis() - start1 + "ms");

        long start2 = System.currentTimeMillis();
        for (int i = 0; i < ITERATIONS; i++) {
            Arrays.equals(wrapper1.getData(), wrapper2.getData());
        }
        System.out.println(System.currentTimeMillis() - start2 + "ms");

        long start3 = System.currentTimeMillis();
        for (int i = 0; i < ITERATIONS; i++) {
            FastByteComparisons.compareTo(wrapper1.getData(), 0, wrapper1.getData().length, wrapper2.getData(), 0, wrapper1.getData().length);
        }
        System.out.println(System.currentTimeMillis() - start3 + "ms");
    }
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:30,代碼來源:ByteArrayWrapperTest.java

示例5: getTxChanges

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Override
public Collection<byte[]> getTxChanges() {
  if (conflictLevel == TxConstants.ConflictDetection.NONE) {
    return Collections.emptyList();
  }

  Collection<byte[]> txChanges = new TreeSet<byte[]>(UnsignedBytes.lexicographicalComparator());
  for (Set<ActionChange> changeSet : changeSets.values()) {
    for (ActionChange change : changeSet) {
      txChanges.add(getChangeKey(change.getRow(), change.getFamily(), change.getQualifier()));
    }
  }
  return txChanges;
}
 
開發者ID:apache,項目名稱:incubator-tephra,代碼行數:15,代碼來源:AbstractTransactionAwareTable.java

示例6: startTx

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Override
public void startTx(Transaction tx) {
  this.tx = tx;
  if (inProgressChanges == null) {
    inProgressChanges = new TreeSet<>(UnsignedBytes.lexicographicalComparator());
    for (long inProgressTx : tx.getInProgress()) {
      inProgressChanges.add(Bytes.concat(fenceId, Longs.toByteArray(inProgressTx)));
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-tephra,代碼行數:11,代碼來源:WriteFence.java

示例7: CostEstimator

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
protected CostEstimator(Schema schema, Properties properties, KeyCreator keyCreator,
                        CostModelFactory modelFactory) {
    this.schema = schema;
    this.properties = properties;
    model = modelFactory.newCostModel(schema, this);
    key = keyCreator.createKey();
    keyPTarget = new PersistitKeyValueTarget(getClass().getSimpleName());
    bytesComparator = UnsignedBytes.lexicographicalComparator();
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:10,代碼來源:CostEstimator.java

示例8: TransactionDatabase

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
public TransactionDatabase(TransactionDatabase parent)
{
	this.parent = parent;
    
    //OPEN MAP
    this.transactionMap = new TreeMap<byte[], byte[]>(UnsignedBytes.lexicographicalComparator());
}
 
開發者ID:razakal,項目名稱:Qora,代碼行數:8,代碼來源:TransactionDatabase.java

示例9: createRedeemScript

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
/**
 * Creates redeem script with given public keys and threshold. Given public keys will be placed in
 * redeem script in the lexicographical sorting order.
 */
public static Script createRedeemScript(int threshold, List<byte[]> pubkeys) {
    pubkeys = new ArrayList<byte[]>(pubkeys);
    final Comparator comparator = UnsignedBytes.lexicographicalComparator();
    Collections.sort(pubkeys, new Comparator<byte[]>() {
        @Override
        public int compare(byte[] k1, byte[] k2) {
            return comparator.compare(k1, k2);
        }
    });

    return ScriptBuilder.createMultiSigOutputScript(threshold, pubkeys);
}
 
開發者ID:bither,項目名稱:bitherj,代碼行數:17,代碼來源:ScriptBuilder.java

示例10: testEqualsPerformance

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Test
public void testEqualsPerformance() {
	boolean testEnabled = false;
	
	if(testEnabled) {
		final int ITERATIONS = 10000000;
		long start1 = System.currentTimeMillis();
		for (int i = 0; i < ITERATIONS; i++) {
			Comparator<byte[]> comparator = UnsignedBytes
					.lexicographicalComparator();

			comparator.compare(wrapper1.getData(),
					wrapper2.getData());
		}
		System.out.println(System.currentTimeMillis() - start1 + "ms");
		
		long start2 = System.currentTimeMillis();
		for (int i = 0; i < ITERATIONS; i++) {
			Arrays.equals(wrapper1.getData(), wrapper2.getData());
		}
		System.out.println(System.currentTimeMillis() - start2 + "ms");
		
		long start3 = System.currentTimeMillis();
		for (int i = 0; i < ITERATIONS; i++) {
			FastByteComparisons.compareTo(wrapper1.getData(), 0, wrapper1.getData().length, wrapper2.getData(), 0, wrapper1.getData().length);
		}
		System.out.println(System.currentTimeMillis() - start3 + "ms");
	}
}
 
開發者ID:ethereumj,項目名稱:ethereumj,代碼行數:30,代碼來源:ByteArrayWrapperTest.java

示例11: TestFieldIndex

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
public TestFieldIndex(int numFields, MiruBitmaps<RoaringBitmap, RoaringBitmap> bitmaps) {
    indexes = new NavigableMap[numFields];
    this.bitmaps = bitmaps;
    for (int i = 0; i < numFields; i++) {
        Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator();
        indexes[i] = new ConcurrentSkipListMap<>((o1, o2) -> {
            return comparator.compare(o1.getBytes(), o2.getBytes());
        });
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:11,代碼來源:LuceneBackedQueryParserTest.java

示例12: LongLexicoderTest

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
public LongLexicoderTest() {
	super(
			Lexicoders.LONG,
			Long.MIN_VALUE,
			Long.MAX_VALUE,
			new Long[] {
				-10l,
				Long.MIN_VALUE,
				2678l,
				Long.MAX_VALUE,
				0l
			},
			UnsignedBytes.lexicographicalComparator());
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:15,代碼來源:LongLexicoderTest.java

示例13: IntegerLexicoderTest

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
public IntegerLexicoderTest() {
	super(
			Lexicoders.INT,
			Integer.MIN_VALUE,
			Integer.MAX_VALUE,
			new Integer[] {
				-10,
				Integer.MIN_VALUE,
				2678,
				Integer.MAX_VALUE,
				0
			},
			UnsignedBytes.lexicographicalComparator());
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:15,代碼來源:IntegerLexicoderTest.java

示例14: MapStore

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
public MapStore(String name){
  this.map = new ConcurrentSkipListMap<>(UnsignedBytes.lexicographicalComparator());
  this.name = name;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:5,代碼來源:MapStore.java

示例15: compare

import com.google.common.primitives.UnsignedBytes; //導入方法依賴的package包/類
@Override
public int compare(final byte[] o1, final byte[] o2) {
  final Comparator<byte[]> c = UnsignedBytes.lexicographicalComparator();
  return c.compare(o1, o2);
}
 
開發者ID:lmdbjava,項目名稱:lmdbjava,代碼行數:6,代碼來源:ComparatorTest.java


注:本文中的com.google.common.primitives.UnsignedBytes.lexicographicalComparator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。