private static int processRawHash(long rawHash) { // mix the bits so we don't use the same hash used to distribute between stages return (int) XxHash64.hash(Long.reverse(rawHash)); } }
@Override public Object read(ByteBuffer buff, int tag) { switch (tag) { case TAG_DOUBLE_0: return 0d; case TAG_DOUBLE_1: return 1d; case TAG_DOUBLE_FIXED: return buff.getDouble(); } return Double.longBitsToDouble(Long.reverse(DataUtils .readVarLong(buff))); }
private DefaultChannelId() { data = new byte[MACHINE_ID.length + PROCESS_ID_LEN + SEQUENCE_LEN + TIMESTAMP_LEN + RANDOM_LEN]; int i = 0; // machineId System.arraycopy(MACHINE_ID, 0, data, i, MACHINE_ID.length); i += MACHINE_ID.length; // processId i = writeInt(i, PROCESS_ID); // sequence i = writeInt(i, nextSequence.getAndIncrement()); // timestamp (kind of) i = writeLong(i, Long.reverse(System.nanoTime()) ^ System.currentTimeMillis()); // random int random = PlatformDependent.threadLocalRandom().nextInt(); i = writeInt(i, random); assert i == data.length; hashCode = Arrays.hashCode(data); }
initialSeedUniquifier ^= Long.reverse(System.nanoTime());
private DefaultChannelId() { data = new byte[MACHINE_ID.length + PROCESS_ID_LEN + SEQUENCE_LEN + TIMESTAMP_LEN + RANDOM_LEN]; int i = 0; // machineId System.arraycopy(MACHINE_ID, 0, data, i, MACHINE_ID.length); i += MACHINE_ID.length; // processId i = writeInt(i, PROCESS_ID); // sequence i = writeInt(i, nextSequence.getAndIncrement()); // timestamp (kind of) i = writeLong(i, Long.reverse(System.nanoTime()) ^ System.currentTimeMillis()); // random int random = PlatformDependent.threadLocalRandom().nextInt(); i = writeInt(i, random); assert i == data.length; hashCode = Arrays.hashCode(data); }
int probeThree(double element, int removedIndex) { int nextIndex = (int) Long.reverse(SpreadFunctions.doubleSpreadOne(element)); int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while(true) { nextIndex = this.mask(nextIndex + spreadTwo); double valueAtIndex = this.table[nextIndex]; if (Double.compare(valueAtIndex, element) == 0) { return nextIndex; } if (Double.compare(valueAtIndex, EMPTY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(valueAtIndex, REMOVED) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(double element, int removedIndex) { int nextIndex = (int) Long.reverse(SpreadFunctions.doubleSpreadOne(element)); int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while(true) { nextIndex = this.mask(nextIndex + spreadTwo); double keyAtIndex = this.keys[nextIndex]; if (Double.compare(keyAtIndex, element) == 0) { return nextIndex; } if (Double.compare(keyAtIndex, EMPTY_KEY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
private DefaultChannelId() { data = new byte[MACHINE_ID.length + PROCESS_ID_LEN + SEQUENCE_LEN + TIMESTAMP_LEN + RANDOM_LEN]; int i = 0; // machineId System.arraycopy(MACHINE_ID, 0, data, i, MACHINE_ID.length); i += MACHINE_ID.length; // processId i = writeInt(i, PROCESS_ID); // sequence i = writeInt(i, nextSequence.getAndIncrement()); // timestamp (kind of) i = writeLong(i, Long.reverse(System.nanoTime()) ^ System.currentTimeMillis()); // random int random = PlatformDependent.threadLocalRandom().nextInt(); i = writeInt(i, random); assert i == data.length; hashCode = Arrays.hashCode(data); }
int probeThree(double element, int removedIndex) { int nextIndex = (int) SpreadFunctions.doubleSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while (true) { nextIndex = this.mask(nextIndex + spreadTwo); double keyAtIndex = this.keys[nextIndex]; if (Double.compare(keyAtIndex, element) == 0) { return nextIndex; } if (Double.compare(keyAtIndex, EMPTY_KEY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(double element, int removedIndex) { int nextIndex = (int) SpreadFunctions.doubleSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while (true) { nextIndex = this.mask(nextIndex + spreadTwo); double keyAtIndex = this.keys[nextIndex]; if (Double.compare(keyAtIndex, element) == 0) { return nextIndex; } if (Double.compare(keyAtIndex, EMPTY_KEY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(double element, int removedIndex) { int nextIndex = (int) SpreadFunctions.doubleSpreadOne(element) << 1; int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while(true) { nextIndex = this.mask((nextIndex >> 1) + spreadTwo) << 1; double keyAtIndex = this.keysValues[nextIndex]; if (Double.compare(keyAtIndex, element) == 0) { return nextIndex; } if (Double.compare(keyAtIndex, EMPTY_KEY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(double element, int removedIndex) { int nextIndex = (int) SpreadFunctions.doubleSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.doubleSpreadTwo(element)) | 1; while (true) { nextIndex = this.mask(nextIndex + spreadTwo); double keyAtIndex = this.keys[nextIndex]; if (Double.compare(keyAtIndex, element) == 0) { return nextIndex; } if (Double.compare(keyAtIndex, EMPTY_KEY) == 0) { return removedIndex == -1 ? nextIndex : removedIndex; } if (Double.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1) { removedIndex = nextIndex; } } }
@Signature(@Arg("number")) public static Memory reverse(Environment env, Memory... args) { return LongMemory.valueOf(Long.reverse(args[0].toLong())); }
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case TAG_DOUBLE_0: return ValueDouble.get(0d); case TAG_DOUBLE_1: return ValueDouble.get(1d); case TAG_DOUBLE_FIXED: return ValueDouble.get(buff.getDouble()); } return ValueDouble.get(Double.longBitsToDouble(Long.reverse(DataUtils.readVarLong(buff)))); } };
int probeThree(long element, int removedIndex) { int nextIndex = (int) SpreadFunctions.longSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.longSpreadTwo(element)) | 1; while (true) { nextIndex = this.mask(nextIndex + spreadTwo); long keyAtIndex = this.keys[nextIndex]; if (keyAtIndex == element) { return nextIndex; } if (keyAtIndex == EMPTY_KEY) { return removedIndex == -1 ? nextIndex : removedIndex; } if (keyAtIndex == REMOVED_KEY && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(long element, int removedIndex) { int nextIndex = (int) SpreadFunctions.longSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.longSpreadTwo(element)) | 1; while (true) { nextIndex = this.mask(nextIndex + spreadTwo); long keyAtIndex = this.keys[nextIndex]; if (keyAtIndex == element) { return nextIndex; } if (keyAtIndex == EMPTY_KEY) { return removedIndex == -1 ? nextIndex : removedIndex; } if (keyAtIndex == REMOVED_KEY && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(long element, int removedIndex) { int nextIndex = (int) SpreadFunctions.longSpreadOne(element); int spreadTwo = (int) Long.reverse(SpreadFunctions.longSpreadTwo(element)) | 1; while(true) { nextIndex = this.mask(nextIndex + spreadTwo); long keyAtIndex = this.keys[nextIndex]; if (keyAtIndex == element) { return nextIndex; } if (keyAtIndex == EMPTY_KEY) { return removedIndex == -1 ? nextIndex : removedIndex; } if (keyAtIndex == REMOVED_KEY && removedIndex == -1) { removedIndex = nextIndex; } } }
int probeThree(long element, int removedIndex) { int nextIndex = (int) SpreadFunctions.longSpreadOne(element) << 1; int spreadTwo = (int) Long.reverse(SpreadFunctions.longSpreadTwo(element)) | 1; while(true) { nextIndex = this.mask((nextIndex >> 1) + spreadTwo) << 1; long keyAtIndex = this.keysValues[nextIndex]; if (keyAtIndex == element) { return nextIndex; } if (keyAtIndex == EMPTY_KEY) { return removedIndex == -1 ? nextIndex : removedIndex; } if (keyAtIndex == REMOVED_KEY && removedIndex == -1) { removedIndex = nextIndex; } } }
private void write0(DataBuffer buff, double x) { long d = Double.doubleToLongBits(x); if (d == DOUBLE_ZERO_BITS) { buff.put((byte) TAG_DOUBLE_0); } else if (d == DOUBLE_ONE_BITS) { buff.put((byte) TAG_DOUBLE_1); } else { long value = Long.reverse(d); if (value >= 0 && value <= DataUtils.COMPRESSED_VAR_LONG_MAX) { buff.put((byte) DOUBLE); buff.putVarLong(value); } else { buff.put((byte) TAG_DOUBLE_FIXED); buff.putDouble(x); } } }
@Override public void write(WriteBuffer buff, Object obj) { if (!(obj instanceof Double)) { super.write(buff, obj); return; } double x = (Double) obj; long d = Double.doubleToLongBits(x); if (d == ObjectDataType.DOUBLE_ZERO_BITS) { buff.put((byte) TAG_DOUBLE_0); } else if (d == ObjectDataType.DOUBLE_ONE_BITS) { buff.put((byte) TAG_DOUBLE_1); } else { long value = Long.reverse(d); if (value >= 0 && value <= DataUtils.COMPRESSED_VAR_LONG_MAX) { buff.put((byte) TYPE_DOUBLE); buff.putVarLong(value); } else { buff.put((byte) TAG_DOUBLE_FIXED); buff.putDouble(x); } } }