public boolean addUserRecord()

in java/KinesisAggregatorV2/src/main/java/com/amazonaws/kinesis/agg/AggRecord.java [317:365]


	public boolean addUserRecord(String partitionKey, String explicitHashKey, byte[] data) {
		// set the explicit hash key for the message to the partition key -
		// required for encoding
		explicitHashKey = explicitHashKey != null ? explicitHashKey : createExplicitHashKey(partitionKey);

		// validate values from the provided message
		validatePartitionKey(partitionKey);
		validateExplicitHashKey(explicitHashKey);
		validateData(data);

		// Validate new record size won't overflow max size for a
		// PutRecordRequest
		int sizeOfNewRecord = calculateRecordSize(partitionKey, explicitHashKey, data);
		if (getSizeBytes() + sizeOfNewRecord > MAX_BYTES_PER_RECORD) {
			return false;
		} else if (sizeOfNewRecord > MAX_BYTES_PER_RECORD) {
			throw new IllegalArgumentException(
					"Input record (PK=" + partitionKey + ", EHK=" + explicitHashKey + ", SizeBytes=" + sizeOfNewRecord
							+ ") is larger than the maximum size before Aggregation encoding of "
							+ (MAX_BYTES_PER_RECORD - AGGREGATION_OVERHEAD_BYTES) + " bytes");
		}

		Record.Builder newRecord = Record.newBuilder()
				.setData(data != null ? ByteString.copyFrom(data) : ByteString.EMPTY);

		ExistenceIndexPair pkAddResult = this.partitionKeys.add(partitionKey);
		if (pkAddResult.getFirst().booleanValue()) {
			this.aggregatedRecordBuilder.addPartitionKeyTable(partitionKey);
		}
		newRecord.setPartitionKeyIndex(pkAddResult.getSecond());

		ExistenceIndexPair ehkAddResult = this.explicitHashKeys.add(explicitHashKey);
		if (ehkAddResult.getFirst().booleanValue()) {
			this.aggregatedRecordBuilder.addExplicitHashKeyTable(explicitHashKey);
		}
		newRecord.setExplicitHashKeyIndex(ehkAddResult.getSecond());

		this.aggregatedMessageSizeBytes += sizeOfNewRecord;
		this.aggregatedRecordBuilder.addRecords(newRecord.build());

		// if this is the first record, we use its partition key and hash key
		// for the entire agg record
		if (this.aggregatedRecordBuilder.getRecordsCount() == 1) {
			this.aggPartitionKey = partitionKey;
			this.aggExplicitHashKey = explicitHashKey;
		}

		return true;
	}