use of org.apache.phoenix.schema.types.PBinaryBase in project phoenix by apache.
the class SetBitFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
// get offset parameter
Expression offsetExpr = children.get(1);
if (!offsetExpr.evaluate(tuple, ptr))
return false;
int offset = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder());
// get newValue parameter
Expression newValueExpr = children.get(2);
if (!newValueExpr.evaluate(tuple, ptr))
return false;
int newValue = (Integer) PInteger.INSTANCE.toObject(ptr, newValueExpr.getSortOrder());
byte newByteValue = (byte) (newValue & 0x1);
// get binary data parameter
Expression dataExpr = children.get(0);
if (!dataExpr.evaluate(tuple, ptr))
return false;
if (ptr.getLength() == 0)
return true;
int len = ptr.getLength() * Byte.SIZE;
offset = (offset % len + len) % len;
// set result
((PBinaryBase) dataExpr.getDataType()).setBit(ptr, dataExpr.getSortOrder(), offset, newByteValue, ptr);
return true;
}
use of org.apache.phoenix.schema.types.PBinaryBase in project phoenix by apache.
the class GetBitFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
// get offset parameter
int offset;
if (offsetPreCompute == null) {
Expression offsetExpr = children.get(1);
if (!offsetExpr.evaluate(tuple, ptr))
return false;
offset = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder());
} else
offset = offsetPreCompute;
// get binary data parameter
Expression dataExpr = children.get(0);
if (!dataExpr.evaluate(tuple, ptr))
return false;
if (ptr.getLength() == 0)
return true;
int len = ptr.getLength() * Byte.SIZE;
offset = (offset % len + len) % len;
// set result
((PBinaryBase) dataExpr.getDataType()).getBit(ptr, dataExpr.getSortOrder(), offset, ptr);
return true;
}
use of org.apache.phoenix.schema.types.PBinaryBase in project phoenix by apache.
the class GetByteFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
// get offset parameter
int offset;
if (offsetPreCompute == null) {
Expression offsetExpr = children.get(1);
if (!offsetExpr.evaluate(tuple, ptr))
return false;
offset = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder());
} else
offset = offsetPreCompute;
// get binary data parameter
Expression dataExpr = children.get(0);
if (!dataExpr.evaluate(tuple, ptr))
return false;
if (ptr.getLength() == 0)
return true;
int len = ptr.getLength();
offset = (offset % len + len) % len;
// set result
((PBinaryBase) dataExpr.getDataType()).getByte(ptr, dataExpr.getSortOrder(), offset, ptr);
return true;
}
use of org.apache.phoenix.schema.types.PBinaryBase in project phoenix by apache.
the class SetByteFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
// get offset parameter
Expression offsetExpr = children.get(1);
if (!offsetExpr.evaluate(tuple, ptr))
return false;
int offset = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder());
// get newValue parameter
Expression newValueExpr = children.get(2);
if (!newValueExpr.evaluate(tuple, ptr))
return false;
int newValue = (Integer) PInteger.INSTANCE.toObject(ptr, newValueExpr.getSortOrder());
byte newByteValue = (byte) (newValue & 0xff);
// get binary data parameter
Expression dataExpr = children.get(0);
if (!dataExpr.evaluate(tuple, ptr))
return false;
if (ptr.getLength() == 0)
return true;
int len = ptr.getLength();
offset = (offset % len + len) % len;
// set result
((PBinaryBase) dataExpr.getDataType()).setByte(ptr, dataExpr.getSortOrder(), offset, newByteValue, ptr);
return true;
}
use of org.apache.phoenix.schema.types.PBinaryBase in project phoenix by apache.
the class OctetLengthFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
// get binary data parameter
Expression dataExpr = children.get(0);
if (!dataExpr.evaluate(tuple, ptr))
return false;
// set result
((PBinaryBase) dataExpr.getDataType()).octetLength(ptr, dataExpr.getSortOrder(), ptr);
return true;
}
Aggregations