test_class.declarator: compression
test_class.modifier: private
test_class.original_string: private CompressionType compression;
test_class.type: CompressionType
test_class.var_name: compression
test_class.file: clients/src/test/java/org/apache/kafka/common/record/MemoryRecordsTest.java
test_class.identifier: MemoryRecordsTest
test_case.body: @Test
      public void testIterator() {
          MemoryRecords recs1 = MemoryRecords.emptyRecords(ByteBuffer.allocate(1024), compression);
          MemoryRecords recs2 = MemoryRecords.emptyRecords(ByteBuffer.allocate(1024), compression);
          List<Record> list = Arrays.asList(new Record(0L, "a".getBytes(), "1".getBytes()),
                                            new Record(0L, "b".getBytes(), "2".getBytes()),
                                            new Record(0L, "c".getBytes(), "3".getBytes()));
          for (int i = 0; i < list.size(); i++) {
              Record r = list.get(i);
              recs1.append(i, r);
              recs2.append(i, 0L, toArray(r.key()), toArray(r.value()));
          }
          recs1.close();
          recs2.close();
  
          for (int iteration = 0; iteration < 2; iteration++) {
              for (MemoryRecords recs : Arrays.asList(recs1, recs2)) {
                  Iterator<LogEntry> iter = recs.iterator();
                  for (int i = 0; i < list.size(); i++) {
                      assertTrue(iter.hasNext());
                      LogEntry entry = iter.next();
                      assertEquals((long) i, entry.offset());
                      assertEquals(list.get(i), entry.record());
                      entry.record().ensureValid();
                  }
                  assertFalse(iter.hasNext());
              }
          }
      }
test_case.class_method_signature: MemoryRecordsTest.testIterator()
test_case.full_signature: @Test public void testIterator()
test_case.identifier: testIterator
test_case.invocations: emptyRecords allocate emptyRecords allocate asList getBytes getBytes getBytes getBytes getBytes getBytes size get append append toArray key toArray value close close asList iterator size assertTrue hasNext next assertEquals offset assertEquals get record ensureValid record assertFalse hasNext
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIterator()
focal_class.declarator: WRITE_LIMIT_FOR_READABLE_ONLY = -1
focal_class.modifier: private final static
focal_class.original_string: private final static int WRITE_LIMIT_FOR_READABLE_ONLY = -1;
focal_class.type: int
focal_class.var_name: WRITE_LIMIT_FOR_READABLE_ONLY
focal_class.declarator: compressor
focal_class.modifier: private final
focal_class.original_string: private final Compressor compressor;
focal_class.type: Compressor
focal_class.var_name: compressor
focal_class.declarator: writeLimit
focal_class.modifier: private final
focal_class.original_string: private final int writeLimit;
focal_class.type: int
focal_class.var_name: writeLimit
focal_class.declarator: initialCapacity
focal_class.modifier: private final
focal_class.original_string: private final int initialCapacity;
focal_class.type: int
focal_class.var_name: initialCapacity
focal_class.declarator: buffer
focal_class.modifier: private
focal_class.original_string: private ByteBuffer buffer;
focal_class.type: ByteBuffer
focal_class.var_name: buffer
focal_class.declarator: writable
focal_class.modifier: private
focal_class.original_string: private boolean writable;
focal_class.type: boolean
focal_class.var_name: writable
focal_class.file: clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java
focal_class.identifier: MemoryRecords
focal_class.interfaces: implements Records
focal_class.class_method_signature: MemoryRecords.MemoryRecords(ByteBuffer buffer, CompressionType type, boolean writable, int writeLimit)
focal_class.full_signature: private  MemoryRecords(ByteBuffer buffer, CompressionType type, boolean writable, int writeLimit)
focal_class.identifier: MemoryRecords
focal_class.modifiers: private
focal_class.parameters: (ByteBuffer buffer, CompressionType type, boolean writable, int writeLimit)
focal_class.signature:  MemoryRecords(ByteBuffer buffer, CompressionType type, boolean writable, int writeLimit)
focal_class.class_method_signature: MemoryRecords.emptyRecords(ByteBuffer buffer, CompressionType type, int writeLimit)
focal_class.full_signature: public static MemoryRecords emptyRecords(ByteBuffer buffer, CompressionType type, int writeLimit)
focal_class.identifier: emptyRecords
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buffer, CompressionType type, int writeLimit)
focal_class.return: MemoryRecords
focal_class.signature: MemoryRecords emptyRecords(ByteBuffer buffer, CompressionType type, int writeLimit)
focal_class.class_method_signature: MemoryRecords.emptyRecords(ByteBuffer buffer, CompressionType type)
focal_class.full_signature: public static MemoryRecords emptyRecords(ByteBuffer buffer, CompressionType type)
focal_class.identifier: emptyRecords
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buffer, CompressionType type)
focal_class.return: MemoryRecords
focal_class.signature: MemoryRecords emptyRecords(ByteBuffer buffer, CompressionType type)
focal_class.class_method_signature: MemoryRecords.readableRecords(ByteBuffer buffer)
focal_class.full_signature: public static MemoryRecords readableRecords(ByteBuffer buffer)
focal_class.identifier: readableRecords
focal_class.modifiers: public static
focal_class.parameters: (ByteBuffer buffer)
focal_class.return: MemoryRecords
focal_class.signature: MemoryRecords readableRecords(ByteBuffer buffer)
focal_class.class_method_signature: MemoryRecords.append(long offset, Record record)
focal_class.full_signature: public void append(long offset, Record record)
focal_class.identifier: append
focal_class.modifiers: public
focal_class.parameters: (long offset, Record record)
focal_class.return: void
focal_class.signature: void append(long offset, Record record)
focal_class.class_method_signature: MemoryRecords.append(long offset, long timestamp, byte[] key, byte[] value)
focal_class.full_signature: public long append(long offset, long timestamp, byte[] key, byte[] value)
focal_class.identifier: append
focal_class.modifiers: public
focal_class.parameters: (long offset, long timestamp, byte[] key, byte[] value)
focal_class.return: long
focal_class.signature: long append(long offset, long timestamp, byte[] key, byte[] value)
focal_class.class_method_signature: MemoryRecords.isFull()
focal_class.full_signature: public boolean isFull()
focal_class.identifier: isFull
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isFull()
focal_class.class_method_signature: MemoryRecords.hasRoomFor(byte[] key, byte[] value)
focal_class.full_signature: public boolean hasRoomFor(byte[] key, byte[] value)
focal_class.identifier: hasRoomFor
focal_class.modifiers: public
focal_class.parameters: (byte[] key, byte[] value)
focal_class.return: boolean
focal_class.signature: boolean hasRoomFor(byte[] key, byte[] value)
focal_class.class_method_signature: MemoryRecords.close()
focal_class.full_signature: public void close()
focal_class.identifier: close
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: MemoryRecords.sizeInBytes()
focal_class.full_signature: public int sizeInBytes()
focal_class.identifier: sizeInBytes
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int sizeInBytes()
focal_class.class_method_signature: MemoryRecords.compressionRate()
focal_class.full_signature: public double compressionRate()
focal_class.identifier: compressionRate
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double compressionRate()
focal_class.class_method_signature: MemoryRecords.initialCapacity()
focal_class.full_signature: public int initialCapacity()
focal_class.identifier: initialCapacity
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int initialCapacity()
focal_class.class_method_signature: MemoryRecords.buffer()
focal_class.full_signature: public ByteBuffer buffer()
focal_class.identifier: buffer
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ByteBuffer
focal_class.signature: ByteBuffer buffer()
focal_class.class_method_signature: MemoryRecords.iterator()
focal_class.full_signature: @Override public Iterator<LogEntry> iterator()
focal_class.identifier: iterator
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Iterator<LogEntry>
focal_class.signature: Iterator<LogEntry> iterator()
focal_class.class_method_signature: MemoryRecords.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: MemoryRecords.isWritable()
focal_class.full_signature: public boolean isWritable()
focal_class.identifier: isWritable
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isWritable()
focal_method.body: @Override
      public Iterator<LogEntry> iterator() {
          if (writable) {
              // flip on a duplicate buffer for reading
              return new RecordsIterator((ByteBuffer) this.buffer.duplicate()
                                                                 .flip(), false);
          } else {
              // do not need to flip for non-writable buffer
              return new RecordsIterator(this.buffer.duplicate(), false);
          }
      }
focal_method.class_method_signature: MemoryRecords.iterator()
focal_method.full_signature: @Override public Iterator<LogEntry> iterator()
focal_method.identifier: iterator
focal_method.invocations: flip duplicate duplicate
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: Iterator<LogEntry>
focal_method.signature: Iterator<LogEntry> iterator()