Esempio n. 1
0
 internal override void GenCompareTo(CodeBuffer cb, string fname, string other)
 {
     cb.Append("{\n");
     JVector.IncrLevel();
     cb.Append("int " + JVector.GetId(Consts.RioPrefix + "len1") + " = " + fname + ".size();\n"
               );
     cb.Append("int " + JVector.GetId(Consts.RioPrefix + "len2") + " = " + other + ".size();\n"
               );
     cb.Append("for(int " + JVector.GetId(Consts.RioPrefix + "vidx") + " = 0; " + JVector
               .GetId(Consts.RioPrefix + "vidx") + "<" + JVector.GetId(Consts.RioPrefix + "len1"
                                                                       ) + " && " + JVector.GetId(Consts.RioPrefix + "vidx") + "<" + JVector.GetId(Consts
                                                                                                                                                   .RioPrefix + "len2") + "; " + JVector.GetId(Consts.RioPrefix + "vidx") + "++) {\n"
               );
     cb.Append(this.element.GetType() + " " + JVector.GetId(Consts.RioPrefix + "e1") +
               " = " + fname + ".get(" + JVector.GetId(Consts.RioPrefix + "vidx") + ");\n");
     cb.Append(this.element.GetType() + " " + JVector.GetId(Consts.RioPrefix + "e2") +
               " = " + other + ".get(" + JVector.GetId(Consts.RioPrefix + "vidx") + ");\n");
     this.element.GenCompareTo(cb, JVector.GetId(Consts.RioPrefix + "e1"), JVector.GetId
                                   (Consts.RioPrefix + "e2"));
     cb.Append("if (" + Consts.RioPrefix + "ret != 0) { return " + Consts.RioPrefix +
               "ret; }\n");
     cb.Append("}\n");
     cb.Append(Consts.RioPrefix + "ret = (" + JVector.GetId(Consts.RioPrefix + "len1")
               + " - " + JVector.GetId(Consts.RioPrefix + "len2") + ");\n");
     JVector.DecrLevel();
     cb.Append("}\n");
 }
Esempio n. 2
0
 internal override void GenSlurpBytes(CodeBuffer cb, string b, string s, string l)
 {
     cb.Append("{\n");
     JVector.IncrLevel();
     cb.Append("int " + JVector.GetId("vi") + " = org.apache.hadoop.record.Utils.readVInt("
               + b + ", " + s + ");\n");
     cb.Append("int " + JVector.GetId("vz") + " = org.apache.hadoop.record.Utils.getVIntSize("
               + JVector.GetId("vi") + ");\n");
     cb.Append(s + "+=" + JVector.GetId("vz") + "; " + l + "-=" + JVector.GetId("vz")
               + ";\n");
     cb.Append("for (int " + JVector.GetId("vidx") + " = 0; " + JVector.GetId("vidx")
               + " < " + JVector.GetId("vi") + "; " + JVector.GetId("vidx") + "++)");
     this.element.GenSlurpBytes(cb, b, s, l);
     JVector.DecrLevel();
     cb.Append("}\n");
 }
Esempio n. 3
0
 internal override void GenWriteMethod(CodeBuffer cb, string fname, string tag)
 {
     cb.Append("{\n");
     JVector.IncrLevel();
     cb.Append(Consts.RecordOutput + ".startVector(" + fname + ",\"" + tag + "\");\n");
     cb.Append("int " + JVector.GetId(Consts.RioPrefix + "len") + " = " + fname + ".size();\n"
               );
     cb.Append("for(int " + JVector.GetId(Consts.RioPrefix + "vidx") + " = 0; " + JVector
               .GetId(Consts.RioPrefix + "vidx") + "<" + JVector.GetId(Consts.RioPrefix + "len"
                                                                       ) + "; " + JVector.GetId(Consts.RioPrefix + "vidx") + "++) {\n");
     cb.Append(this.element.GetType() + " " + JVector.GetId(Consts.RioPrefix + "e") +
               " = " + fname + ".get(" + JVector.GetId(Consts.RioPrefix + "vidx") + ");\n");
     this.element.GenWriteMethod(cb, JVector.GetId(Consts.RioPrefix + "e"), JVector.GetId
                                     (Consts.RioPrefix + "e"));
     cb.Append("}\n");
     cb.Append(Consts.RecordOutput + ".endVector(" + fname + ",\"" + tag + "\");\n");
     cb.Append("}\n");
     JVector.DecrLevel();
 }
Esempio n. 4
0
 internal override void GenReadMethod(CodeBuffer cb, string fname, string tag, bool
                                      decl)
 {
     if (decl)
     {
         cb.Append(this.GetType() + " " + fname + ";\n");
     }
     cb.Append("{\n");
     JVector.IncrLevel();
     cb.Append("org.apache.hadoop.record.Index " + JVector.GetId(Consts.RioPrefix + "vidx"
                                                                 ) + " = " + Consts.RecordInput + ".startVector(\"" + tag + "\");\n");
     cb.Append(fname + "=new " + this.GetType() + "();\n");
     cb.Append("for (; !" + JVector.GetId(Consts.RioPrefix + "vidx") + ".done(); " + JVector
               .GetId(Consts.RioPrefix + "vidx") + ".incr()) {\n");
     this.element.GenReadMethod(cb, JVector.GetId(Consts.RioPrefix + "e"), JVector.GetId
                                    (Consts.RioPrefix + "e"), true);
     cb.Append(fname + ".add(" + JVector.GetId(Consts.RioPrefix + "e") + ");\n");
     cb.Append("}\n");
     cb.Append(Consts.RecordInput + ".endVector(\"" + tag + "\");\n");
     JVector.DecrLevel();
     cb.Append("}\n");
 }
Esempio n. 5
0
 internal override void GenCompareBytes(CodeBuffer cb)
 {
     cb.Append("{\n");
     JVector.IncrLevel();
     cb.Append("int " + JVector.GetId("vi1") + " = org.apache.hadoop.record.Utils.readVInt(b1, s1);\n"
               );
     cb.Append("int " + JVector.GetId("vi2") + " = org.apache.hadoop.record.Utils.readVInt(b2, s2);\n"
               );
     cb.Append("int " + JVector.GetId("vz1") + " = org.apache.hadoop.record.Utils.getVIntSize("
               + JVector.GetId("vi1") + ");\n");
     cb.Append("int " + JVector.GetId("vz2") + " = org.apache.hadoop.record.Utils.getVIntSize("
               + JVector.GetId("vi2") + ");\n");
     cb.Append("s1+=" + JVector.GetId("vz1") + "; s2+=" + JVector.GetId("vz2") + "; l1-="
               + JVector.GetId("vz1") + "; l2-=" + JVector.GetId("vz2") + ";\n");
     cb.Append("for (int " + JVector.GetId("vidx") + " = 0; " + JVector.GetId("vidx")
               + " < " + JVector.GetId("vi1") + " && " + JVector.GetId("vidx") + " < " + JVector
               .GetId("vi2") + "; " + JVector.GetId("vidx") + "++)");
     this.element.GenCompareBytes(cb);
     cb.Append("if (" + JVector.GetId("vi1") + " != " + JVector.GetId("vi2") + ") { return ("
               + JVector.GetId("vi1") + "<" + JVector.GetId("vi2") + ")?-1:0; }\n");
     JVector.DecrLevel();
     cb.Append("}\n");
 }