Skip to content

Commit

Permalink
IGNITE-5779 - Fixes #3471.
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Rudyak <igor.rudyak@rallyhealth.com>
  • Loading branch information
igorrudyak committed Feb 5, 2018
1 parent 54bac75 commit 08f9659
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
Expand Up @@ -272,7 +272,8 @@ else if (obj instanceof String) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override protected void process(Row row) { @Override protected void process(Row row) {
data.put((K)controller.buildKeyObject(row), (V)controller.buildValueObject(row)); if (row != null)
data.put((K)controller.buildKeyObject(row), (V)controller.buildValueObject(row));
} }
}, keys); }, keys);
} }
Expand Down
Expand Up @@ -46,8 +46,8 @@ public class PropertyMappingHelper {
put(String.class, DataType.Name.TEXT); put(String.class, DataType.Name.TEXT);
put(Integer.class, DataType.Name.INT); put(Integer.class, DataType.Name.INT);
put(int.class, DataType.Name.INT); put(int.class, DataType.Name.INT);
put(Short.class, DataType.Name.INT); put(Short.class, DataType.Name.SMALLINT);
put(short.class, DataType.Name.INT); put(short.class, DataType.Name.SMALLINT);
put(Long.class, DataType.Name.BIGINT); put(Long.class, DataType.Name.BIGINT);
put(long.class, DataType.Name.BIGINT); put(long.class, DataType.Name.BIGINT);
put(Double.class, DataType.Name.DOUBLE); put(Double.class, DataType.Name.DOUBLE);
Expand Down Expand Up @@ -129,7 +129,7 @@ public static Object getCassandraColumnValue(Row row, String col, Class clazz, S
return row.getInt(col); return row.getInt(col);


if (Short.class.equals(clazz) || short.class.equals(clazz)) if (Short.class.equals(clazz) || short.class.equals(clazz))
return (short)row.getInt(col); return row.getShort(col);


if (Long.class.equals(clazz) || long.class.equals(clazz)) if (Long.class.equals(clazz) || long.class.equals(clazz))
return row.getLong(col); return row.getLong(col);
Expand All @@ -148,7 +148,6 @@ public static Object getCassandraColumnValue(Row row, String col, Class clazz, S


if (PropertyMappingHelper.BYTES_ARRAY_CLASS.equals(clazz)) { if (PropertyMappingHelper.BYTES_ARRAY_CLASS.equals(clazz)) {
ByteBuffer buf = row.getBytes(col); ByteBuffer buf = row.getBytes(col);

return buf == null ? null : buf.array(); return buf == null ? null : buf.array();
} }


Expand Down
Expand Up @@ -286,8 +286,7 @@ else if (prepStatEx != null)
ResultSet resSet = futureResult.getValue().getUninterruptibly(); ResultSet resSet = futureResult.getValue().getUninterruptibly();
Row row = resSet != null && resSet.iterator().hasNext() ? resSet.iterator().next() : null; Row row = resSet != null && resSet.iterator().hasNext() ? resSet.iterator().next() : null;


if (row != null) assistant.process(row, futureResult.getKey());
assistant.process(row, futureResult.getKey());
} }
catch (Throwable e) { catch (Throwable e) {
if (CassandraHelper.isTableAbsenceError(e)) if (CassandraHelper.isTableAbsenceError(e))
Expand Down
Expand Up @@ -38,6 +38,6 @@ public class PersonGenerator implements Generator {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public Object generate(long i) { @Override public Object generate(long i) {
return new Person(i, Long.toString(i), Long.toString(i), (int)(i % 100), i % 2 == 0, i, i, DATE, PHONES); return new Person(i, Long.toString(i), Long.toString(i), (short)(i % 100), i % 2 == 0, i, i, DATE, PHONES);
} }
} }
Expand Up @@ -41,7 +41,7 @@ public class Person implements Externalizable {
private String fullName; private String fullName;


/** */ /** */
private int age; private short age;


/** */ /** */
private boolean married; private boolean married;
Expand All @@ -64,7 +64,7 @@ public Person() {
} }


/** */ /** */
public Person(long personNum, String firstName, String lastName, int age, boolean married, public Person(long personNum, String firstName, String lastName, short age, boolean married,
long height, float weight, Date birthDate, List<String> phones) { long height, float weight, Date birthDate, List<String> phones) {
this.personNum = personNum; this.personNum = personNum;
this.firstName = firstName; this.firstName = firstName;
Expand All @@ -83,7 +83,7 @@ public Person(long personNum, String firstName, String lastName, int age, boolea
out.writeLong(personNum); out.writeLong(personNum);
out.writeObject(firstName); out.writeObject(firstName);
out.writeObject(lastName); out.writeObject(lastName);
out.writeInt(age); out.writeShort(age);
out.writeBoolean(married); out.writeBoolean(married);
out.writeLong(height); out.writeLong(height);
out.writeFloat(weight); out.writeFloat(weight);
Expand All @@ -97,7 +97,7 @@ public Person(long personNum, String firstName, String lastName, int age, boolea
personNum = in.readLong(); personNum = in.readLong();
firstName = (String)in.readObject(); firstName = (String)in.readObject();
lastName = (String)in.readObject(); lastName = (String)in.readObject();
age = in.readInt(); age = in.readShort();
married = in.readBoolean(); married = in.readBoolean();
height = in.readLong(); height = in.readLong();
weight = in.readFloat(); weight = in.readFloat();
Expand Down Expand Up @@ -209,13 +209,13 @@ public String getFullName() {


/** */ /** */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public void setAge(int age) { public void setAge(short age) {
this.age = age; this.age = age;
} }


/** */ /** */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public int getAge() { public short getAge() {
return age; return age;
} }


Expand Down
Expand Up @@ -44,7 +44,7 @@ public class SimplePerson implements Externalizable {


/** */ /** */
@QuerySqlField(name = "age") @QuerySqlField(name = "age")
private int age; private short age;


/** */ /** */
@QuerySqlField(name = "married", index = true) @QuerySqlField(name = "married", index = true)
Expand Down Expand Up @@ -85,7 +85,7 @@ public SimplePerson(Person person) {
} }


/** */ /** */
public SimplePerson(long personNum, String firstName, String lastName, int age, boolean married, public SimplePerson(long personNum, String firstName, String lastName, short age, boolean married,
long height, float weight, Date birthDate, List<String> phones) { long height, float weight, Date birthDate, List<String> phones) {
this.personNum = personNum; this.personNum = personNum;
this.firstName = firstName; this.firstName = firstName;
Expand All @@ -104,7 +104,7 @@ public SimplePerson(long personNum, String firstName, String lastName, int age,
out.writeLong(personNum); out.writeLong(personNum);
out.writeObject(firstName); out.writeObject(firstName);
out.writeObject(lastName); out.writeObject(lastName);
out.writeInt(age); out.writeShort(age);
out.writeBoolean(married); out.writeBoolean(married);
out.writeLong(height); out.writeLong(height);
out.writeFloat(weight); out.writeFloat(weight);
Expand All @@ -118,7 +118,7 @@ public SimplePerson(long personNum, String firstName, String lastName, int age,
personNum = in.readLong(); personNum = in.readLong();
firstName = (String)in.readObject(); firstName = (String)in.readObject();
lastName = (String)in.readObject(); lastName = (String)in.readObject();
age = in.readInt(); age = in.readShort();
married = in.readBoolean(); married = in.readBoolean();
height = in.readLong(); height = in.readLong();
weight = in.readFloat(); weight = in.readFloat();
Expand Down
Expand Up @@ -490,7 +490,7 @@ public static SimplePerson generateRandomSimplePerson(long personNum) {
for (int i = 0; i < phonesCnt; i++) for (int i = 0; i < phonesCnt; i++)
phones.add(randomNumber(4)); phones.add(randomNumber(4));


return new SimplePerson(personNum, randomString(4), randomString(4), RANDOM.nextInt(100), return new SimplePerson(personNum, randomString(4), randomString(4), (short)RANDOM.nextInt(100),
RANDOM.nextBoolean(), RANDOM.nextLong(), RANDOM.nextFloat(), new Date(), phones); RANDOM.nextBoolean(), RANDOM.nextLong(), RANDOM.nextFloat(), new Date(), phones);
} }


Expand All @@ -508,7 +508,7 @@ public static Person generateRandomPerson(long personNum) {
for (int i = 0; i < phonesCnt; i++) for (int i = 0; i < phonesCnt; i++)
phones.add(randomNumber(4)); phones.add(randomNumber(4));


return new Person(personNum, randomString(4), randomString(4), RANDOM.nextInt(100), return new Person(personNum, randomString(4), randomString(4), (short)RANDOM.nextInt(100),
RANDOM.nextBoolean(), RANDOM.nextLong(), RANDOM.nextFloat(), new Date(), phones); RANDOM.nextBoolean(), RANDOM.nextLong(), RANDOM.nextFloat(), new Date(), phones);
} }


Expand Down

0 comments on commit 08f9659

Please sign in to comment.