Skip to content

Commit

Permalink
Merge pull request #36 from chenyun/patch-1
Browse files Browse the repository at this point in the history
AbstractRowsDeserializer: make logic flow more reasonable
  • Loading branch information
shyiko committed Apr 3, 2015
2 parents f1fb18b + b9f4214 commit 633d5d2
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,28 @@ protected Serializable[] deserializeRow(long tableId, BitSet includedColumns, By
Serializable[] result = new Serializable[numberOfBitsSet(includedColumns)];
BitSet nullColumns = inputStream.readBitSet(result.length, true);
for (int i = 0, numberOfSkippedColumns = 0; i < types.length; i++) {
int typeCode = types[i] & 0xFF, meta = metadata[i], length = 0;
if (typeCode == ColumnType.STRING.getCode() && meta > 256) {
int meta0 = meta >> 8, meta1 = meta & 0xFF;
if ((meta0 & 0x30) != 0x30) { // long CHAR field
typeCode = meta0 | 0x30;
length = meta1 | (((meta0 & 0x30) ^ 0x30) << 4);
} else {
if (meta0 == ColumnType.SET.getCode() || meta0 == ColumnType.ENUM.getCode() ||
meta0 == ColumnType.STRING.getCode()) {
typeCode = meta0;
length = meta1;
} else {
throw new IOException("Unexpected meta " + meta + " for column of type " + typeCode);
}
}
}
if (!includedColumns.get(i)) {
numberOfSkippedColumns++;
continue;
}
int index = i - numberOfSkippedColumns;
if (!nullColumns.get(index)) {
int typeCode = types[i] & 0xFF, meta = metadata[i], length = 0;
if (typeCode == ColumnType.STRING.getCode() && meta > 256) {
int meta0 = meta >> 8, meta1 = meta & 0xFF;
if ((meta0 & 0x30) != 0x30) { // long CHAR field
typeCode = meta0 | 0x30;
length = meta1 | (((meta0 & 0x30) ^ 0x30) << 4);
} else {
if (meta0 == ColumnType.SET.getCode() || meta0 == ColumnType.ENUM.getCode() ||
meta0 == ColumnType.STRING.getCode()) {
typeCode = meta0;
length = meta1;
} else {
throw new IOException("Unexpected meta " + meta + " for column of type " + typeCode);
}
}
}
result[index] = deserializeCell(ColumnType.byCode(typeCode), meta, length, inputStream);
}
}
Expand Down Expand Up @@ -374,4 +374,4 @@ private static long bigEndianLong(byte[] bytes, int offset, int length) {
return result;
}

}
}

0 comments on commit 633d5d2

Please sign in to comment.