// Path: src/main/java/com/db/logger/api/FluentLogBuilder.java
// public interface FluentLogBuilder {
// 	public FluentLogBuilder with( final double value );
// 
// 	public FluentLogBuilder with( final long value );
// 
// 	public void submit();
// }
// 
// Path: src/main/java/com/db/logger/api/LogMessage.java
// public interface LogMessage {
// 	public String format();
// 
// 	public int argumentsCount();
// 
// 	public FluentLogBuilder with( final double value );
// 
// 	public FluentLogBuilder with( final long value );
// 
// 	public void submit();
// 
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/RingBuffer.java
// public final class RingBuffer {
// 	private final ICircularLongsBuffer buffer;
// 	private final Sequencer sequencer;
// 	private final WaitingStrategy waitingStrategy;
// 
// 	public RingBuffer( final Sequencer sequencer,
// 	                   final ICircularLongsBuffer buffer,
// 	                   final WaitingStrategy waitingStrategy ) {
// 		this.waitingStrategy = waitingStrategy;
// 		this.sequencer = sequencer;
// 		this.buffer = buffer;
// 	}
// 
// 	public int length() {
// 		return buffer.length();
// 	}
// 
// 	public ICircularLongsBuffer buffer() {
// 		return buffer;
// 	}
// 
// 	public void drainTo( final Sequencer.Drainer drainer ) {
// 		sequencer.drainTo( drainer );
// 	}
// 
// 	public long claim( final int size ) {
// 		return sequencer.claim(
// 				size,
// 				waitingStrategy
// 		);
// 	}
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/RecordHelper.java
// public abstract class RecordHelper {
// 
// 	public static final long NOT_SET = -1L;
// 
// 	public enum RecordType {
// 		LOG_RECORD( 1 ),
// 		TIMESTAMP( 2 );
// 		private final byte id;
// 
// 		private RecordType( final int id ) {
// 			this.id = ( byte ) id;
// 		}
// 
// 		public byte id() {
// 			return id;
// 		}
// 	}
// 
// 	public static long header( final RecordType type,
// 	                           final int formatId,
// 	                           final int argumentsCount ) {
// 		//[type x 15][formatId x 32][argumentsCount x 16]
// 		return ( ( ( long ) type.id() ) << 48 )
// 				| ( formatId << 16 )
// 				| argumentsCount;
// 	}
// 
// 	public static boolean isValidHeader( final long header ) {
// 		return header > 0;
// 	}
// 
// 	public static RecordType type( final long header ) {
// 		final int typeNo = ( int ) ( header >> 48 );
// 		switch( typeNo ) {
// 			case 1:
// 				return RecordType.LOG_RECORD;
// 			case 2:
// 				return RecordType.TIMESTAMP;
// 			default:
// 				throw new IllegalArgumentException( "type " + typeNo + " is unknown" );
// 		}
// 	}
// 
// 	public static int formatId( final long header ) {
// 		return ( int ) ( ( header >> 16 ) & 0xFFFFFFFFL );
// 	}
// 
// 	public static int argumentsCount( final long header ) {
// 		return ( int ) ( header & 0xFFFFL );
// 	}
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/formatters/AbstractLogBuilder.java
// public static final int NOT_SET = -1;


import com.db.logger.api.FluentLogBuilder;
import com.db.logger.api.LogMessage;
import com.db.logger.api.impl.logger.RingBuffer;
import com.db.logger.api.impl.logger.RecordHelper;
import static com.db.logger.api.impl.logger.MCSDSequencer.INVALID_INDEX;
import static com.db.logger.api.impl.logger.RecordHelper.RecordType.LOG_RECORD;
import static com.db.logger.api.impl.logger.formatters.AbstractLogBuilder.NOT_SET;
import static com.google.common.base.Preconditions.checkState;
package com.db.logger.api.impl.logger.formatters;



/**
 * TODO Unsafe!
 *
 * @author ruslan
 *         created 20.11.13 at 23:48
 */
public final class SimpleLogMessageExpanded implements LogMessage, FluentLogBuilder {

	private final RingBuffer buffer;

	private int argumentIndex = NOT_SET;
	private long position = INVALID_INDEX;

	private final String format;
	private final int formatId;

	private final int argumentsCount;

	public SimpleLogMessageExpanded( final String format,
	                                 final int formatId,
	                                 final int argumentsCount,
	                                 final RingBuffer ringBuffer ) {
		this.buffer = ringBuffer;
		this.format = format;

		this.formatId = formatId;
// Path: src/main/java/com/db/logger/api/FluentLogBuilder.java
// public interface FluentLogBuilder {
// 	public FluentLogBuilder with( final double value );
// 
// 	public FluentLogBuilder with( final long value );
// 
// 	public void submit();
// }
// 
// Path: src/main/java/com/db/logger/api/LogMessage.java
// public interface LogMessage {
// 	public String format();
// 
// 	public int argumentsCount();
// 
// 	public FluentLogBuilder with( final double value );
// 
// 	public FluentLogBuilder with( final long value );
// 
// 	public void submit();
// 
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/RingBuffer.java
// public final class RingBuffer {
// 	private final ICircularLongsBuffer buffer;
// 	private final Sequencer sequencer;
// 	private final WaitingStrategy waitingStrategy;
// 
// 	public RingBuffer( final Sequencer sequencer,
// 	                   final ICircularLongsBuffer buffer,
// 	                   final WaitingStrategy waitingStrategy ) {
// 		this.waitingStrategy = waitingStrategy;
// 		this.sequencer = sequencer;
// 		this.buffer = buffer;
// 	}
// 
// 	public int length() {
// 		return buffer.length();
// 	}
// 
// 	public ICircularLongsBuffer buffer() {
// 		return buffer;
// 	}
// 
// 	public void drainTo( final Sequencer.Drainer drainer ) {
// 		sequencer.drainTo( drainer );
// 	}
// 
// 	public long claim( final int size ) {
// 		return sequencer.claim(
// 				size,
// 				waitingStrategy
// 		);
// 	}
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/RecordHelper.java
// public abstract class RecordHelper {
// 
// 	public static final long NOT_SET = -1L;
// 
// 	public enum RecordType {
// 		LOG_RECORD( 1 ),
// 		TIMESTAMP( 2 );
// 		private final byte id;
// 
// 		private RecordType( final int id ) {
// 			this.id = ( byte ) id;
// 		}
// 
// 		public byte id() {
// 			return id;
// 		}
// 	}
// 
// 	public static long header( final RecordType type,
// 	                           final int formatId,
// 	                           final int argumentsCount ) {
// 		//[type x 15][formatId x 32][argumentsCount x 16]
// 		return ( ( ( long ) type.id() ) << 48 )
// 				| ( formatId << 16 )
// 				| argumentsCount;
// 	}
// 
// 	public static boolean isValidHeader( final long header ) {
// 		return header > 0;
// 	}
// 
// 	public static RecordType type( final long header ) {
// 		final int typeNo = ( int ) ( header >> 48 );
// 		switch( typeNo ) {
// 			case 1:
// 				return RecordType.LOG_RECORD;
// 			case 2:
// 				return RecordType.TIMESTAMP;
// 			default:
// 				throw new IllegalArgumentException( "type " + typeNo + " is unknown" );
// 		}
// 	}
// 
// 	public static int formatId( final long header ) {
// 		return ( int ) ( ( header >> 16 ) & 0xFFFFFFFFL );
// 	}
// 
// 	public static int argumentsCount( final long header ) {
// 		return ( int ) ( header & 0xFFFFL );
// 	}
// }
// 
// Path: src/main/java/com/db/logger/api/impl/logger/formatters/AbstractLogBuilder.java
// public static final int NOT_SET = -1;


// Path: src/main/java/com/db/logger/api/impl/logger/formatters/SimpleLogMessageExpanded.java
import com.db.logger.api.FluentLogBuilder;
import com.db.logger.api.LogMessage;
import com.db.logger.api.impl.logger.RingBuffer;
import com.db.logger.api.impl.logger.RecordHelper;
import static com.db.logger.api.impl.logger.MCSDSequencer.INVALID_INDEX;
import static com.db.logger.api.impl.logger.RecordHelper.RecordType.LOG_RECORD;
import static com.db.logger.api.impl.logger.formatters.AbstractLogBuilder.NOT_SET;
import static com.google.common.base.Preconditions.checkState;

package com.db.logger.api.impl.logger.formatters;



/**
 * TODO Unsafe!
 *
 * @author ruslan
 *         created 20.11.13 at 23:48
 */
public final class SimpleLogMessageExpanded implements LogMessage, FluentLogBuilder {

	private final RingBuffer buffer;

	private int argumentIndex = NOT_SET;
	private long position = INVALID_INDEX;

	private final String format;
	private final int formatId;

	private final int argumentsCount;

	public SimpleLogMessageExpanded( final String format,
	                                 final int formatId,
	                                 final int argumentsCount,
	                                 final RingBuffer ringBuffer ) {
		this.buffer = ringBuffer;
		this.format = format;

		this.formatId = formatId;
		this.argumentsCount = argumentsCount;