java/KinesisAggregator/src/main/java/com/amazonaws/kinesis/agg/AggRecord.java [485:596]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		BigInteger hashKey = BigInteger.ZERO;

		this.md5.reset();
		byte[] pkDigest = this.md5.digest(partitionKey.getBytes(StandardCharsets.UTF_8));

		for (int i = 0; i < this.md5.getDigestLength(); i++) {
			BigInteger p = new BigInteger(String.valueOf((int) pkDigest[i] & 0xFF)); // convert
																						// to
																						// unsigned
																						// integer
			BigInteger shifted = p.shiftLeft((16 - i - 1) * 8);
			hashKey = hashKey.add(shifted);
		}

		return hashKey.toString(10);
	}

	/**
	 * A class for tracking unique partition keys or explicit hash keys for an
	 * aggregated Kinesis record. Also assists in keeping track of indexes for their
	 * locations in the protobuf tables.
	 */
	private class KeySet {
		/** The list of unique keys in this keyset. */
		private List<String> keys;
		/** A lookup mapping of key to index in protobuf table. */
		private Map<String, Long> lookup;

		/**
		 * Create a new empty keyset.
		 */
		public KeySet() {
			this.keys = new LinkedList<>();
			this.lookup = new TreeMap<>();
		}

		/**
		 * If the input key were added to this KeySet, determine what its resulting
		 * index would be.
		 * 
		 * @param s The input string to potentially add to the KeySet
		 * 
		 * @return The table index that this string would occupy if it were added to
		 *         this KeySet.
		 */
		public Long getPotentialIndex(String s) {
			Long it = this.lookup.get(s);
			if (it != null) {
				return it;
			}

			return Long.valueOf(this.keys.size());
		}

		/**
		 * Add a new key to this keyset.
		 * 
		 * @param s The key to add to the keyset.
		 * 
		 * @return A pair of <boolean,long>. The boolean is true if this key is not
		 *         already in this keyset, false otherwise. The long indicates the index
		 *         of the key.
		 */
		public ExistenceIndexPair add(String s) {
			Long it = this.lookup.get(s);
			if (it != null) {
				return new ExistenceIndexPair(false, it);
			}

			if (!this.lookup.containsKey(s)) {
				this.lookup.put(s, Long.valueOf(this.keys.size()));
			}

			this.keys.add(s);
			return new ExistenceIndexPair(true, Long.valueOf(this.keys.size() - 1));
		}

		/**
		 * @return True if this keyset contains the input key, false otherwise.
		 */
		public boolean contains(String s) {
			return s != null && this.lookup.containsKey(s);
		}

		/**
		 * Clear all the contents of this keyset.
		 */
		public void clear() {
			this.keys.clear();
			this.lookup.clear();
		}
	};

	/**
	 * A helper class for use with the KeySet that indicates whether or not a key
	 * exists in the KeySet and what its saved index would be.
	 */
	private class ExistenceIndexPair {
		private Boolean first;
		private Long second;

		public ExistenceIndexPair(Boolean first, Long second) {
			this.first = first;
			this.second = second;
		}

		public Boolean getFirst() {
			return this.first;
		}

		public Long getSecond() {
			return this.second;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



java/KinesisAggregatorV2/src/main/java/com/amazonaws/kinesis/agg/AggRecord.java [479:590]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		BigInteger hashKey = BigInteger.ZERO;

		this.md5.reset();
		byte[] pkDigest = this.md5.digest(partitionKey.getBytes(StandardCharsets.UTF_8));

		for (int i = 0; i < this.md5.getDigestLength(); i++) {
			BigInteger p = new BigInteger(String.valueOf((int) pkDigest[i] & 0xFF)); // convert
																						// to
																						// unsigned
																						// integer
			BigInteger shifted = p.shiftLeft((16 - i - 1) * 8);
			hashKey = hashKey.add(shifted);
		}

		return hashKey.toString(10);
	}

	/**
	 * A class for tracking unique partition keys or explicit hash keys for an
	 * aggregated Kinesis record. Also assists in keeping track of indexes for their
	 * locations in the protobuf tables.
	 */
	private class KeySet {
		/** The list of unique keys in this keyset. */
		private List<String> keys;
		/** A lookup mapping of key to index in protobuf table. */
		private Map<String, Long> lookup;

		/**
		 * Create a new empty keyset.
		 */
		public KeySet() {
			this.keys = new LinkedList<>();
			this.lookup = new TreeMap<>();
		}

		/**
		 * If the input key were added to this KeySet, determine what its resulting
		 * index would be.
		 * 
		 * @param s The input string to potentially add to the KeySet
		 * 
		 * @return The table index that this string would occupy if it were added to
		 *         this KeySet.
		 */
		public Long getPotentialIndex(String s) {
			Long it = this.lookup.get(s);
			if (it != null) {
				return it;
			}

			return Long.valueOf(this.keys.size());
		}

		/**
		 * Add a new key to this keyset.
		 * 
		 * @param s The key to add to the keyset.
		 * 
		 * @return A pair of <boolean,long>. The boolean is true if this key is not
		 *         already in this keyset, false otherwise. The long indicates the index
		 *         of the key.
		 */
		public ExistenceIndexPair add(String s) {
			Long it = this.lookup.get(s);
			if (it != null) {
				return new ExistenceIndexPair(false, it);
			}

			if (!this.lookup.containsKey(s)) {
				this.lookup.put(s, Long.valueOf(this.keys.size()));
			}

			this.keys.add(s);
			return new ExistenceIndexPair(true, Long.valueOf(this.keys.size() - 1));
		}

		/**
		 * @return True if this keyset contains the input key, false otherwise.
		 */
		public boolean contains(String s) {
			return s != null && this.lookup.containsKey(s);
		}

		/**
		 * Clear all the contents of this keyset.
		 */
		public void clear() {
			this.keys.clear();
			this.lookup.clear();
		}
	};

	/**
	 * A helper class for use with the KeySet that indicates whether or not a key
	 * exists in the KeySet and what its saved index would be.
	 */
	private class ExistenceIndexPair {
		private Boolean first;
		private Long second;

		public ExistenceIndexPair(Boolean first, Long second) {
			this.first = first;
			this.second = second;
		}

		public Boolean getFirst() {
			return this.first;
		}

		public Long getSecond() {
			return this.second;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



