当前位置: 首页>>代码示例>>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;未经允许,请勿转载。