void genReadMethod( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname, @Tainted String tag, @Tainted boolean decl) { if (decl) { cb.append(name + " " + fname + ";\n"); } cb.append( fname + "=" + Consts.RECORD_INPUT + ".read" + methodSuffix + "(\"" + tag + "\");\n"); }
void genCompareBytes(CodeBuffer cb) { cb.append("{\n"); cb.append("if (l1<8 || l2<8) {\n"); cb.append( "throw new java.io.IOException(\"Double is exactly 8 bytes." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append("double d1 = org.apache.hadoop.record.Utils.readDouble(b1, s1);\n"); cb.append("double d2 = org.apache.hadoop.record.Utils.readDouble(b2, s2);\n"); cb.append("if (d1 != d2) {\n"); cb.append("return ((d1-d2) < 0) ? -1 : 0;\n"); cb.append("}\n"); cb.append("s1+=8; s2+=8; l1-=8; l2-=8;\n"); cb.append("}\n"); }
void genCompareBytes(CodeBuffer cb) { cb.append("{\n"); cb.append("if (l1<4 || l2<4) {\n"); cb.append( "throw new java.io.IOException(\"Float is exactly 4 bytes." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append("float f1 = org.apache.hadoop.record.Utils.readFloat(b1, s1);\n"); cb.append("float f2 = org.apache.hadoop.record.Utils.readFloat(b2, s2);\n"); cb.append("if (f1 != f2) {\n"); cb.append("return ((f1-f2) < 0) ? -1 : 0;\n"); cb.append("}\n"); cb.append("s1+=4; s2+=4; l1-=4; l2-=4;\n"); cb.append("}\n"); }
void genEquals( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname, @Tainted String peer) { cb.append(Consts.RIO_PREFIX + "ret = (" + fname + "==" + peer + ");\n"); }
// In Binary format, boolean is written as byte. true = 1, false = 0 void genCompareBytes(CodeBuffer cb) { cb.append("{\n"); cb.append("if (l1<1 || l2<1) {\n"); cb.append( "throw new java.io.IOException(\"Boolean is exactly 1 byte." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append("if (b1[s1] != b2[s2]) {\n"); cb.append("return (b1[s1]<b2[s2])? -1 : 0;\n"); cb.append("}\n"); cb.append("s1++; s2++; l1--; l2--;\n"); cb.append("}\n"); }
void genWriteMethod( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname, @Tainted String tag) { cb.append( Consts.RECORD_OUTPUT + ".write" + methodSuffix + "(" + fname + ",\"" + tag + "\");\n"); }
void genCompareTo(CodeBuffer cb, String fname, String other) { cb.append( Consts.RIO_PREFIX + "ret = (" + fname + " == " + other + ")? 0 : (" + fname + "?1:-1);\n"); }
void genGetSet(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append("public " + name + " get" + toCamelCase(fname) + "() {\n"); cb.append("return " + fname + ";\n"); cb.append("}\n"); cb.append("public void set" + toCamelCase(fname) + "(final " + name + " " + fname + ") {\n"); cb.append("this." + fname + "=" + fname + ";\n"); cb.append("}\n"); }
void genGetSet(@Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append("virtual " + name + " get" + toCamelCase(fname) + "() const {\n"); cb.append("return " + fname + ";\n"); cb.append("}\n"); cb.append("virtual void set" + toCamelCase(fname) + "(" + name + " m_) {\n"); cb.append(fname + "=m_;\n"); cb.append("}\n"); }
// In Binary format, boolean is written as byte. true = 1, false = 0 void genSlurpBytes(CodeBuffer cb, String b, String s, String l) { cb.append("{\n"); cb.append("if (" + l + "<1) {\n"); cb.append( "throw new java.io.IOException(\"Boolean is exactly 1 byte." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append(s + "++; " + l + "--;\n"); cb.append("}\n"); }
void genSlurpBytes(CodeBuffer cb, String b, String s, String l) { cb.append("{\n"); cb.append("if (" + l + "<8) {\n"); cb.append( "throw new java.io.IOException(\"Double is exactly 8 bytes." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append(s + "+=8; " + l + "-=8;\n"); cb.append("}\n"); }
@Override void genSlurpBytes(CodeBuffer cb, String b, String s, String l) { cb.append("{\n"); cb.append("if (" + l + "<4) {\n"); cb.append( "throw new java.io.IOException(\"Float is exactly 4 bytes." + " Provided buffer is smaller.\");\n"); cb.append("}\n"); cb.append(s + "+=4; " + l + "-=4;\n"); cb.append("}\n"); }
void genCompareTo( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname, @Tainted String other) { cb.append( Consts.RIO_PREFIX + "ret = (" + fname + " == " + other + ")? 0 :((" + fname + "<" + other + ")?-1:1);\n"); }
void genDecl(@Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append(name + " " + fname + ";\n"); }
@Override void genHashCode(CodeBuffer cb, String fname) { cb.append(Consts.RIO_PREFIX + "ret = Float.floatToIntBits(" + fname + ");\n"); }
void genHashCode(CodeBuffer cb, String fname) { cb.append(Consts.RIO_PREFIX + "ret = (" + fname + ")?0:1;\n"); }
void genHashCode(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append(Consts.RIO_PREFIX + "ret = (int)" + fname + ";\n"); }
void genConstructorParam( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append("final " + name + " " + fname); }
void genConstructorSet( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append("this." + fname + " = " + fname + ";\n"); }
void genStaticTypeInfo( @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append( Consts.RTI_VAR + ".addField(\"" + fname + "\", " + getTypeIDObjectString() + ");\n"); }
void genDecl(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append("private " + name + " " + fname + ";\n"); }
void genClone(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append(Consts.RIO_PREFIX + "other." + fname + " = this." + fname + ";\n"); }
void genStaticTypeInfo( @Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) { cb.append( "p->addField(new ::std::string(\"" + fname + "\"), " + getTypeIDObjectString() + ");\n"); }
void genHashCode(CodeBuffer cb, String fname) { String tmp = "Double.doubleToLongBits(" + fname + ")"; cb.append(Consts.RIO_PREFIX + "ret = (int)(" + tmp + "^(" + tmp + ">>>32));\n"); }