library/src/main/java/com/kdgregory/aws/utils/kinesis/KinesisWriter.java
/**
     *  Attempts to add a record to the current batch. Returns true if able to do so,
     *  false if adding the record would exceed Amazon's batch size.
     */
Attempts to add a record to the current batch. Returns true if able to do so,
false if adding the record would exceed Amazon's batch size.
Attempts to add a record to the current batch . Returns true if able to do so false if adding the record would exceed Amazon ' s batch size .
public boolean addRecord(String partitionKey, byte[] data)
    {
        if (unsentRecords.size() >= MAX_RECORDS_PER_REQUEST)
            return false;
        if ((partitionKey == null) || partitionKey.isEmpty())
        {
            partitionKey = String.format("%08x", partitionKeyRandomizer.nextInt());
        }
        int partitionKeySize = CommonUtils.toUTF8(partitionKey).length;
        int dataSize = data.length;
        if (partitionKeySize + dataSize > MAX_RECORD_SIZE)
            return false;
        if (partitionKeySize + dataSize + unsentRecordsSize > MAX_REQUEST_SIZE)
            return false;
        unsentRecordsSize += partitionKeySize + dataSize;
        unsentRecords.add(new PutRecordsRequestEntry()
                           .withPartitionKey(partitionKey)
                           .withData(ByteBuffer.wrap(data)));
        return true;
    }
public boolean addRecord ( String partitionKey , byte [ ] data ) { if ( unsentRecords . size ( ) >= MAX_RECORDS_PER_REQUEST ) return false ; if ( ( partitionKey == null ) || partitionKey . isEmpty ( ) ) { partitionKey = String . format ( "%08x" , partitionKeyRandomizer . nextInt ( ) ) ; } int partitionKeySize = CommonUtils . toUTF8 ( partitionKey ) . length ; int dataSize = data . length ; if ( partitionKeySize + dataSize > MAX_RECORD_SIZE ) return false ; if ( partitionKeySize + dataSize + unsentRecordsSize > MAX_REQUEST_SIZE ) return false ; unsentRecordsSize += partitionKeySize + dataSize ; unsentRecords . add ( new PutRecordsRequestEntry ( ) . withPartitionKey ( partitionKey ) . withData ( ByteBuffer . wrap ( data ) ) ) ; return true ; }
Attempts to add a record to the current batch.
Attempts to add a record to the current batch .