@ -278,15 +278,6 @@ public class MemoryRecords extends AbstractRecords {
@@ -278,15 +278,6 @@ public class MemoryRecords extends AbstractRecords {
return new MemoryRecords ( buffer ) ;
}
public static MemoryRecordsBuilder builder ( ByteBuffer buffer ,
CompressionType compressionType ,
TimestampType timestampType ,
int writeLimit ) {
return new MemoryRecordsBuilder ( buffer , RecordBatch . CURRENT_MAGIC_VALUE , compressionType , timestampType , 0L ,
System . currentTimeMillis ( ) , RecordBatch . NO_PRODUCER_ID , RecordBatch . NO_PRODUCER_EPOCH , RecordBatch . NO_SEQUENCE , false ,
RecordBatch . UNKNOWN_PARTITION_LEADER_EPOCH , writeLimit ) ;
}
public static MemoryRecordsBuilder builder ( ByteBuffer buffer ,
CompressionType compressionType ,
TimestampType timestampType ,
@ -299,7 +290,10 @@ public class MemoryRecords extends AbstractRecords {
@@ -299,7 +290,10 @@ public class MemoryRecords extends AbstractRecords {
CompressionType compressionType ,
TimestampType timestampType ,
long baseOffset ) {
return builder ( buffer , magic , compressionType , timestampType , baseOffset , System . currentTimeMillis ( ) ) ;
long logAppendTime = RecordBatch . NO_TIMESTAMP ;
if ( timestampType = = TimestampType . LOG_APPEND_TIME )
logAppendTime = System . currentTimeMillis ( ) ;
return builder ( buffer , magic , compressionType , timestampType , baseOffset , logAppendTime ) ;
}
public static MemoryRecordsBuilder builder ( ByteBuffer buffer ,
@ -323,7 +317,7 @@ public class MemoryRecords extends AbstractRecords {
@@ -323,7 +317,7 @@ public class MemoryRecords extends AbstractRecords {
int baseSequence ) {
return new MemoryRecordsBuilder ( buffer , magic , compressionType , timestampType , baseOffset ,
logAppendTime , pid , epoch , baseSequence , false , RecordBatch . UNKNOWN_PARTITION_LEADER_EPOCH ,
buffer . capacity ( ) ) ;
buffer . remaining ( ) ) ;
}
public static MemoryRecords withRecords ( CompressionType compressionType , SimpleRecord . . . records ) {
@ -357,8 +351,11 @@ public class MemoryRecords extends AbstractRecords {
@@ -357,8 +351,11 @@ public class MemoryRecords extends AbstractRecords {
return MemoryRecords . EMPTY ;
int sizeEstimate = AbstractRecords . estimateSizeInBytes ( magic , compressionType , Arrays . asList ( records ) ) ;
ByteBuffer buffer = ByteBuffer . allocate ( sizeEstimate ) ;
long logAppendTime = RecordBatch . NO_TIMESTAMP ;
if ( timestampType = = TimestampType . LOG_APPEND_TIME )
logAppendTime = System . currentTimeMillis ( ) ;
MemoryRecordsBuilder builder = builder ( buffer , magic , compressionType , timestampType , initialOffset ,
System . currentTimeMillis ( ) , pid , epoch , baseSequence ) ;
logAppendTime , pid , epoch , baseSequence ) ;
for ( SimpleRecord record : records )
builder . append ( record ) ;
return builder . build ( ) ;