Package com.google.common.primitives

Examples of com.google.common.primitives.UnsignedLong


  /**
   * Test unsigned longs are encoded and decoded correctly
   */
  @Test
  public void testUnsignedLongs() throws Exception {
    UnsignedLong a = UnsignedLong.valueOf("9767889778372766922");
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());
    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("Num", a);
    Response response = client.call("Arith.Increment", mArgs);
    Assert.assertEquals(a.add(UnsignedLong.ONE), (UnsignedLong) response.getReply());
    client.close();
  }
View Full Code Here


    return (BSONObject) c.get();
  }

  public static class GoRpcBSONCallBack extends BasicBSONCallback {
    public void gotULong(final String name, final long v) {
      final UnsignedLong ulv = UnsignedLong.asUnsigned(v);
      _put(name, ulv);
    }
View Full Code Here

    if (o == null) {
      throw new NullPointerException();
    }

    if (id instanceof UnsignedLong && o.id instanceof UnsignedLong) {
      UnsignedLong thisId = (UnsignedLong) id;
      UnsignedLong otherId = (UnsignedLong) o.id;
      return thisId.compareTo(otherId);
    }

    if (id instanceof String && o.id instanceof String) {
      String thisId = (String) id;
View Full Code Here

    // Check field types and values
    Row row = cursor.next();
    Cell idCell = row.next();
    Assert.assertEquals("id", idCell.getName());
    Assert.assertEquals(UnsignedLong.class, idCell.getType());
    UnsignedLong id = row.getULong(idCell.getName());

    Cell nameCell = row.next();
    Assert.assertEquals("name", nameCell.getName());
    Assert.assertEquals(byte[].class, nameCell.getType());
    Assert.assertTrue(
        Arrays.equals(("name_" + id.toString()).getBytes(), row.getBytes(nameCell.getName())));

    Cell ageCell = row.next();
    Assert.assertEquals("age", ageCell.getName());
    Assert.assertEquals(Integer.class, ageCell.getType());
    Assert.assertEquals(Integer.valueOf(2 * id.intValue()), row.getInt(ageCell.getName()));

    vtgate.close();
  }
View Full Code Here

                .valueOf("14695981039346656037");

        private static final UnsignedLong FNV64_PRIME = UnsignedLong.valueOf("1099511628211");

        public int compare(final String p1, final String p2) {
            UnsignedLong hash1 = fnv(p1);
            UnsignedLong hash2 = fnv(p2);
            return hash1.compareTo(hash2);
        }
View Full Code Here

        }

        private static UnsignedLong fnv(CharSequence chars) {
            final int length = chars.length();

            UnsignedLong hash = FNV64_OFFSET_BASIS;

            for (int i = 0; i < length; i++) {
                char c = chars.charAt(i);
                byte b1 = (byte) (c >> 8);
                byte b2 = (byte) c;
View Full Code Here

        final int bucket = (byteN * maxBuckets) / 256;
        return Integer.valueOf(bucket);
    }

    public UnsignedLong hashCodeLong(String name) {
        UnsignedLong fnv = FNV1a64bitHash.fnv(name);
        return fnv;
    }
View Full Code Here

TOP

Related Classes of com.google.common.primitives.UnsignedLong

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.