private static void log(FieldType<?> fieldType, StringBuilder buf) { buf.insert(0, ": "); buf.insert(0, fieldType); if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, "> "); } buf.insert(0, spaces(currentDebugLevel())); incrementDebugLevel(); LOG.debug(buf.toString()); }
private static void incrementDebugLevel() { int[] indentLevel = debugIndent(); indentLevel[0]+=2; }
private static void unlog(FieldType<?> fieldType, StringBuilder buf) { if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, "< "); } decrementDebugLevel(); if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, spaces(currentDebugLevel())); LOG.debug(buf.toString()); } }
public final T read(DataInputExtended input) throws IOException { DataInputStream inputStream = input.getDataInputStream(); byte fieldTypeIdxAndNullability = inputStream.readByte(); boolean isNull = fieldTypeIdxAndNullability >= NULL_BIT; byte fieldTypeIdx = (byte) (fieldTypeIdxAndNullability - (isNull ? NULL_BIT : 0)); try { FieldType<?> fieldType = FieldType.get(fieldTypeIdx); if (fieldType.checksStream() && fieldType != this) { throw new IllegalStateException("Mismatch in stream: expected " + this + " but got " + fieldType); } if (isNull && LOG.isDebugEnabled()) { // only log if reading a null; otherwise actual value read logged later log(this, new StringBuilder().append("(null)")); } if (isNull) { return null; } else { return doRead(input); } } finally { if (isNull && LOG.isDebugEnabled()) { // only unlog if reading a null unlog(this); } } }
byte fieldTypeIdx = (byte) (fieldTypeIdxAndNullability - (isNull ? NULL_BIT : 0)); try { FieldType<?> fieldType = FieldType.get(fieldTypeIdx); if (fieldType.checksStream() && fieldType != this) { throw new IllegalStateException("Mismatch in stream: expected " + this + " but got " + fieldType); log(this, new StringBuilder().append("(null)")); return null; } else { return doReadArray(input, elementType); if (isNull && LOG.isDebugEnabled()) { unlog(this);
public final void write(DataOutputExtended output, T value) throws IOException { byte fieldTypeIdxAndNullability = getIdx(); boolean isNull = value == null; if (isNull) { // set high order bit fieldTypeIdxAndNullability += NULL_BIT; } try { DataOutputStream outputStream = output.getDataOutputStream(); outputStream.write(fieldTypeIdxAndNullability); if (isNull && LOG.isDebugEnabled()) { // only log if writing a null; otherwise actual value logged later log(this, new StringBuilder().append("(null)")); } if(!isNull) { doWrite(output, value); } } finally { if (isNull && LOG.isDebugEnabled()) { // only unlog if writing a null unlog(this); } } }
@Override public String toString() { return getCls().getSimpleName(); }
public final T read(DataInputExtended input) throws IOException { DataInputStream inputStream = input.getDataInputStream(); byte fieldTypeIdxAndNullability = inputStream.readByte(); boolean isNull = fieldTypeIdxAndNullability >= NULL_BIT; byte fieldTypeIdx = (byte) (fieldTypeIdxAndNullability - (isNull ? NULL_BIT : 0)); try { FieldType<?> fieldType = FieldType.get(fieldTypeIdx); if (fieldType.checksStream() && fieldType != this) { throw new IllegalStateException("Mismatch in stream: expected " + this + " but got " + fieldType); } if (isNull && LOG.isDebugEnabled()) { // only log if reading a null; otherwise actual value read logged later log(this, new StringBuilder().append("(null)")); } if (isNull) { return null; } else { return doRead(input); } } finally { if (isNull && LOG.isDebugEnabled()) { // only unlog if reading a null unlog(this); } } }
byte fieldTypeIdx = (byte) (fieldTypeIdxAndNullability - (isNull ? NULL_BIT : 0)); try { FieldType<?> fieldType = FieldType.get(fieldTypeIdx); if (fieldType.checksStream() && fieldType != this) { throw new IllegalStateException("Mismatch in stream: expected " + this + " but got " + fieldType); log(this, new StringBuilder().append("(null)")); return null; } else { return doReadArray(input, elementType); if (isNull && LOG.isDebugEnabled()) { unlog(this);
public final void write(DataOutputExtended output, T value) throws IOException { byte fieldTypeIdxAndNullability = getIdx(); boolean isNull = value == null; if (isNull) { // set high order bit fieldTypeIdxAndNullability += NULL_BIT; } try { DataOutputStream outputStream = output.getDataOutputStream(); outputStream.write(fieldTypeIdxAndNullability); if (isNull && LOG.isDebugEnabled()) { // only log if writing a null; otherwise actual value logged later log(this, new StringBuilder().append("(null)")); } if(!isNull) { doWrite(output, value); } } finally { if (isNull && LOG.isDebugEnabled()) { // only unlog if writing a null unlog(this); } } }
@Override public String toString() { return getCls().getSimpleName(); }
private static void log(FieldType<?> fieldType, StringBuilder buf) { buf.insert(0, ": "); buf.insert(0, fieldType); if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, "> "); } buf.insert(0, spaces(currentDebugLevel())); incrementDebugLevel(); LOG.debug(buf.toString()); }
private static void unlog(FieldType<?> fieldType, StringBuilder buf) { if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, "< "); } decrementDebugLevel(); if (fieldType.isIndentingAndOutdenting()) { buf.insert(0, spaces(currentDebugLevel())); LOG.debug(buf.toString()); } }
private static void incrementDebugLevel() { int[] indentLevel = debugIndent(); indentLevel[0]+=2; }
private static void decrementDebugLevel() { int[] indentLevel = debugIndent(); indentLevel[0]-=2; }
private static void decrementDebugLevel() { int[] indentLevel = debugIndent(); indentLevel[0]-=2; }
private static int currentDebugLevel() { return debugIndent()[0]; }
private static int currentDebugLevel() { return debugIndent()[0]; }