Пример #1
1
  @Test
  public void test_2GB_over() throws IOException {
    Assume.assumeTrue(CC.FULL_TEST);

    byte[] data = new byte[51111];
    int dataHash = Arrays.hashCode(data);

    Set<Long> recids = new TreeSet<Long>();

    for (int i = 0; i < 1e5; i++) {
      long recid = engine.recordPut(data, Serializer.BYTE_ARRAY_SERIALIZER);
      recids.add(recid);

      //            if(i%10000==0){
      //            System.out.println(recid);
      //            for(Long l:recids){
      //                byte[] b = engine.recordGet(l, Serializer.BYTE_ARRAY_SERIALIZER);
      //                int hash = Arrays.hashCode(b);
      //                assertEquals(l,dataHash, hash);
      //            }
      //            }

    }

    engine.commit();

    for (Long l : recids) {
      byte[] b = engine.recordGet(l, Serializer.BYTE_ARRAY_SERIALIZER);
      int hash = Arrays.hashCode(b);
      assertEquals(dataHash, hash);
    }
  }
Пример #2
1
  @Override
  public int hashCode() {
    int result = (ObjectUtils.isNotNull(url) ? url.hashCode() : 0);
    result = 31 * result + method.hashCode();
    result = 31 * result + (ObjectUtils.isNotNull(post) ? post.hashCode() : 0);
    result =
        31 * result
            + (ObjectUtils.isNotNull(fileBytes) && fileBytes.length != 0
                ? Arrays.hashCode(fileBytes)
                : 0);
    result = 31 * result + headers.hashCode();
    result = 31 * result + query.hashCode();

    return result;
  }
Пример #3
0
 @Override
 public int hashCode() {
   int result = (a ? 1 : 0);
   result = 31 * result + b;
   result = 31 * result + Arrays.hashCode(c);
   result = 31 * result + Arrays.hashCode(d);
   result = 31 * result + e.hashCode();
   result = 31 * result + f.hashCode();
   return result;
 }
 @Override
 public int hashCode() {
   int result = 17;
   result = 31 * result + id.hashCode();
   result = 31 * result + Arrays.hashCode(teams);
   return result;
 }
Пример #5
0
 public int doHashCode() {
   int result = name != null ? name.hashCode() : 0;
   result = 31 * result + (operator != null ? operator.hashCode() : 0);
   result = 31 * result + (value != null ? value.hashCode() : 0);
   result = 31 * result + (values != null ? Arrays.hashCode(values) : 0);
   return result;
 }
Пример #6
0
  @Override
  public int hashCode() {
    int hash = 3;

    hash = 67 * hash + Arrays.hashCode(this._bytes);
    return hash;
  }
 // Breakout calculation of the termArrays hashcode
 private int termArraysHashCode() {
   int hashCode = 1;
   for (final Term[] termArray : termArrays) {
     hashCode = 31 * hashCode + (termArray == null ? 0 : Arrays.hashCode(termArray));
   }
   return hashCode;
 }
 public int hashCode() {
   int result;
   result = methodSignature.hashCode();
   result = 31 * result + methodName.hashCode();
   result = 31 * result + Arrays.hashCode(paramFlags);
   result = 31 * result + (returnFlag ? 1 : 0);
   return result;
 }
Пример #9
0
 public int hashCode() {
   int result = (this.mechanism != null) ? this.mechanism.hashCode() : 0;
   result = 31 * result + this.userName.hashCode();
   result = 31 * result + this.source.hashCode();
   result = 31 * result + ((this.password != null) ? Arrays.hashCode(this.password) : 0);
   result = 31 * result + this.mechanismProperties.hashCode();
   return result;
 }
  public int hashCode() {
    // stolen from GPIndividual.  It's a decent algorithm.
    int hash = this.getClass().hashCode();

    hash = (hash << 1 | hash >>> 31) ^ Arrays.hashCode(genome);

    return hash;
  }
Пример #11
0
  private static int testHash() {
    int errors = 0;

    Object[] data = new String[] {"perfect", "ham", "THC"};

    errors += ((Objects.hash((Object[]) null) == 0) ? 0 : 1);

    errors += (Objects.hash("perfect", "ham", "THC") == Arrays.hashCode(data)) ? 0 : 1;

    return errors;
  }
 private MethodInvocationKey(
     Class<?> lookupClass, String methodName, Class<?>[] parameterTypes) {
   this.lookupClass = new SoftReference<Class<?>>(lookupClass);
   this.methodName = methodName;
   this.parameterTypes = new SoftReference<Class<?>[]>(parameterTypes);
   // hashcode will always be used, so we precompute it in order to make sure we
   // won't compute it multiple times during comparisons
   int result = lookupClass != null ? lookupClass.hashCode() : 0;
   result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
   result = 31 * result + Arrays.hashCode(parameterTypes);
   this.hashCode = result;
 }
Пример #13
0
  @Test
  public void test_store_reopen_over_2GB() {
    Assume.assumeTrue(CC.FULL_TEST);

    byte[] data = new byte[11111];
    final long max = Volume.BUF_SIZE * 2L / data.length;
    final int hash = Arrays.hashCode(data);

    List<Long> recids = new ArrayList<Long>();

    for (int i = 0; i < max; i++) {
      long recid = engine.recordPut(data, Serializer.BYTE_ARRAY_SERIALIZER);
      recids.add(recid);
    }

    reopenStore();

    for (long recid : recids) {
      byte[] b = engine.recordGet(recid, Serializer.BYTE_ARRAY_SERIALIZER);
      assertEquals(hash, Arrays.hashCode(b));
    }
  }
Пример #14
0
 @Override
 public int hashCode() {
   int result = id != null ? id.hashCode() : 0;
   result = 31 * result + (ssn != null ? ssn.hashCode() : 0);
   result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
   result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
   result = 31 * result + (frequentFlyerMiles != null ? frequentFlyerMiles.hashCode() : 0);
   result = 31 * result + (picture != null ? Arrays.hashCode(picture) : 0);
   result = 31 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
   result = 31 * result + age;
   result = 31 * result + (lastFlight != null ? lastFlight.hashCode() : 0);
   result = 31 * result + (passengerType != null ? passengerType.hashCode() : 0);
   result = 31 * result + (preferences != null ? preferences.hashCode() : 0);
   result = 31 * result + (cards != null ? cards.hashCode() : 0);
   result = 31 * result + (address != null ? address.hashCode() : 0);
   result = 31 * result + (tickets != null ? tickets.hashCode() : 0);
   return result;
 }
Пример #15
0
  @Override
  public int hashCode() {
    int result = 1;

    result = 31 * result + (this.int1 == null ? 0 : this.int1.hashCode());
    result = 31 * result + (this.tinyint1 == null ? 0 : this.tinyint1.hashCode());
    result = 31 * result + (this.smallint1 == null ? 0 : this.smallint1.hashCode());
    result = 31 * result + (this.bigint1 == null ? 0 : this.bigint1.hashCode());
    result = 31 * result + (this.boolean1 == null ? 0 : this.boolean1.hashCode());
    result = 31 * result + (this.double1 == null ? 0 : this.double1.hashCode());
    result = 31 * result + (this.string1 == null ? 0 : this.string1.hashCode());
    result = 31 * result + (this.record == null ? 0 : this.record.hashCode());
    result = 31 * result + (this.list1 == null ? 0 : this.list1.hashCode());
    result = 31 * result + (this.map1 == null ? 0 : this.map1.hashCode());
    result = 31 * result + (this.enum1 == null ? 0 : this.enum1.hashCode());
    result = 31 * result + (this.nullableint == null ? 0 : this.nullableint.hashCode());
    result = 31 * result + (this.bytes1 == null ? 0 : Arrays.hashCode(this.bytes1));
    result = 31 * result + (this.container1 == null ? 0 : this.container1.hashCode());
    result = 31 * result + (this.innerSample == null ? 0 : this.innerSample.hashCode());

    return result;
  }
  /** @throws Exception If failed. */
  public void testCompact() throws Exception {
    File file = new File(UUID.randomUUID().toString());

    X.println("file: " + file.getPath());

    FileSwapSpaceSpi.SwapFile f = new FileSwapSpaceSpi.SwapFile(file, 8);

    Random rnd = new Random();

    ArrayList<FileSwapSpaceSpi.SwapValue> arr = new ArrayList<>();

    int size = 0;

    for (int a = 0; a < 100; a++) {
      FileSwapSpaceSpi.SwapValue[] vals = new FileSwapSpaceSpi.SwapValue[1 + rnd.nextInt(10)];

      int size0 = 0;

      for (int i = 0; i < vals.length; i++) {
        byte[] bytes = new byte[1 + rnd.nextInt(49)];

        rnd.nextBytes(bytes);

        size0 += bytes.length;

        vals[i] = new FileSwapSpaceSpi.SwapValue(bytes);

        arr.add(vals[i]);
      }

      f.write(new FileSwapSpaceSpi.SwapValues(vals, size0), 1);

      size += size0;

      assertEquals(f.length(), size);
      assertEquals(file.length(), size);
    }

    int i = 0;

    for (FileSwapSpaceSpi.SwapValue val : arr) assertEquals(val.idx(), ++i);

    i = 0;

    for (int cnt = arr.size() / 2; i < cnt; i++) {

      FileSwapSpaceSpi.SwapValue v = arr.remove(rnd.nextInt(arr.size()));

      assertTrue(f.tryRemove(v.idx(), v));
    }

    int hash0 = 0;

    for (FileSwapSpaceSpi.SwapValue val : arr) hash0 += Arrays.hashCode(val.readValue(f.readCh));

    ArrayList<T2<ByteBuffer, ArrayDeque<FileSwapSpaceSpi.SwapValue>>> bufs = new ArrayList();

    for (; ; ) {
      ArrayDeque<FileSwapSpaceSpi.SwapValue> que = new ArrayDeque<>();

      ByteBuffer buf = f.compact(que, 1024);

      if (buf == null) break;

      bufs.add(new T2(buf, que));
    }

    f.delete();

    int hash1 = 0;

    for (FileSwapSpaceSpi.SwapValue val : arr) hash1 += Arrays.hashCode(val.value(null));

    assertEquals(hash0, hash1);

    File file0 = new File(UUID.randomUUID().toString());

    FileSwapSpaceSpi.SwapFile f0 = new FileSwapSpaceSpi.SwapFile(file0, 8);

    for (T2<ByteBuffer, ArrayDeque<FileSwapSpaceSpi.SwapValue>> t : bufs)
      f0.write(t.get2(), t.get1(), 1);

    int hash2 = 0;

    for (FileSwapSpaceSpi.SwapValue val : arr) hash2 += Arrays.hashCode(val.readValue(f0.readCh));

    assertEquals(hash2, hash1);
  }
 @Override
 public int hashCode() {
   int result = values != null ? Arrays.hashCode(values) : 0;
   result = 31 * result + (canBeOred ? 1 : 0);
   return result;
 }
Пример #18
0
 @Override
 public int hashCode() {
   return value.ordinal() + Arrays.hashCode(ids);
 }
Пример #19
0
 @Override
 public int hashCode() {
   return Arrays.hashCode(delta);
 }
Пример #20
0
 public int hashCode() {
   return Arrays.hashCode(canonicalizeBSONObject(this).encode());
 }
Пример #21
0
 /** {@inheritDoc} */
 @Override
 public int hashCode() {
   return Arrays.hashCode(vals);
 }
 public int hashCode() {
   int result = files.hashCode();
   result = 31 * result + Arrays.hashCode(combinedHash);
   return result;
 }
Пример #23
0
 @Override
 public int hashCode() {
   return Arrays.hashCode(matrix);
 }
Пример #24
0
 // override Object
 public int hashCode() {
   return Arrays.hashCode(originTable.getQualifiedName()) + iOriginColumn + (isDerived ? 313 : 0);
 }
 @Override
 public int hashCode() {
   return Arrays.hashCode(attributes);
 }
Пример #26
0
 public int hashCode() {
   return (toBeResolved.hashCode() << 16 + Arrays.hashCode(params));
 }
Пример #27
0
 @Override
 public int hashCode() {
   return Arrays.hashCode(board);
 }
 // returns an ID for each test result
 private int getTestId(ITestResult result) {
   int id = result.getTestClass().getName().hashCode();
   id = 31 * id + result.getMethod().getMethodName().hashCode();
   id = 31 * id + (result.getParameters() != null ? Arrays.hashCode(result.getParameters()) : 0);
   return id;
 }
Пример #29
0
  /** constructs Engine using current settings */
  public Engine makeEngine() {

    final boolean readOnly = propsGetBool(Keys.readOnly);
    final File file = props.containsKey(Keys.file) ? new File(props.getProperty(Keys.file)) : null;
    final String volume = props.getProperty(Keys.volume);
    final String store = props.getProperty(Keys.store);

    if (readOnly && file == null)
      throw new UnsupportedOperationException("Can not open in-memory DB in read-only mode.");

    if (readOnly && !file.exists() && !Keys.store_append.equals(store)) {
      throw new UnsupportedOperationException("Can not open non-existing file in read-only mode.");
    }

    if (propsGetLong(Keys.sizeLimit, 0) > 0 && Keys.store_append.equals(store))
      throw new UnsupportedOperationException("Append-Only store does not support Size Limit");

    extendArgumentCheck();

    Engine engine;

    if (!Keys.store_append.equals(store)) {
      Volume.Factory folFac = extendStoreVolumeFactory();

      engine =
          propsGetBool(Keys.transactionDisable)
              ? extendStoreDirect(folFac)
              : extendStoreWAL(folFac);

    } else {
      if (Keys.volume_heap.equals(volume) || Keys.volume_offheap.equals(volume))
        throw new UnsupportedOperationException(
            "Append Storage format is not supported with in-memory dbs");
      engine = extendStoreAppend();
    }

    engine = extendWrapStore(engine);

    if (propsGetBool(Keys.asyncWrite) && !readOnly) {
      engine = extendAsyncWriteEngine(engine);
    }

    final String cache = props.getProperty(Keys.cache, CC.DEFAULT_CACHE);

    if (Keys.cache_disable.equals(cache)) {
      // do not wrap engine in cache
    } else if (Keys.cache_hashTable.equals(cache)) {
      engine = extendCacheHashTable(engine);
    } else if (Keys.cache_hardRef.equals(cache)) {
      engine = extendCacheHardRef(engine);
    } else if (Keys.cache_weakRef.equals(cache)) {
      engine = extendCacheWeakRef(engine);
    } else if (Keys.cache_softRef.equals(cache)) {
      engine = extendCacheSoftRef(engine);
    } else if (Keys.cache_lru.equals(cache)) {
      engine = extendCacheLRU(engine);
    } else {
      throw new IllegalArgumentException("unknown cache type: " + cache);
    }

    engine = extendWrapCache(engine);

    if (propsGetBool(Keys.snapshots)) engine = extendSnapshotEngine(engine);

    engine = extendWrapSnapshotEngine(engine);

    if (readOnly) engine = new ReadOnlyEngine(engine);

    if (propsGetBool(Keys.closeOnJvmShutdown)) {
      engine = new EngineWrapper.CloseOnJVMShutdown(engine);
    }

    // try to read one record from DB, to make sure encryption and compression are correctly set.
    Fun.Tuple2<Integer, byte[]> check = null;
    try {
      check = (Fun.Tuple2<Integer, byte[]>) engine.get(Engine.CHECK_RECORD, Serializer.BASIC);
      if (check != null) {
        if (check.a.intValue() != Arrays.hashCode(check.b))
          throw new RuntimeException("invalid checksum");
      }
    } catch (Throwable e) {
      throw new IllegalArgumentException(
          "Error while opening store. Make sure you have right password, compression or encryption is well configured.",
          e);
    }
    if (check == null && !engine.isReadOnly()) {
      // new db, so insert testing record
      byte[] b = new byte[127];
      new Random().nextBytes(b);
      check = Fun.t2(Arrays.hashCode(b), b);
      engine.update(Engine.CHECK_RECORD, check, Serializer.BASIC);
      engine.commit();
    }

    return engine;
  }
 @Override
 public int hashCode() {
   return Arrays.hashCode(teammates);
 }