A SchemaTuple is a type aware tuple that is much faster and more memory efficient. In our implementation, given a Schema, code generation is used to extend this class. This class provides a broad range of functionality that minimizes the complexity of the code that must be generated. The odd looking
| 51 | * comparisons when types match (since the code is generated, there is no other way to know). |
| 52 | */ |
| 53 | @InterfaceAudience.Public |
| 54 | @InterfaceStability.Unstable |
| 55 | public abstract class SchemaTuple<T extends SchemaTuple<T>> extends AbstractTuple implements TypeAwareTuple { |
| 56 | private static final Log LOG = LogFactory.getLog(SchemaTuple.class); |
| 57 | |
| 58 | private static final long serialVersionUID = 1L; |
| 59 | private static final int ONE_MINUTE = 60000; |
| 60 | private static final BinInterSedes bis = new BinInterSedes(); |
| 61 | |
| 62 | @NotImplemented |
| 63 | @Override |
| 64 | public void append(Object val) { |
| 65 | throw MethodHelper.methodNotImplemented(); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * This only accounts for the size of members (adjusting for word alignment). It also includes |
| 70 | * the size of the object itself, since this never affects word boundaries. |
| 71 | */ |
| 72 | @Override |
| 73 | public long getMemorySize() { |
| 74 | return 16 //Object header |
| 75 | + getGeneratedCodeMemorySize(); |
| 76 | } |
| 77 | |
| 78 | protected abstract long getGeneratedCodeMemorySize(); |
| 79 | |
| 80 | /** |
| 81 | * This method will return the identifier that the generated code |
| 82 | * was generated with. This is useful because when the classes |
| 83 | * are resolved generically, this let's us know the identifier, which |
| 84 | * is used when serlializing and deserializing tuples. |
| 85 | * @return the identifire as Int. |
| 86 | */ |
| 87 | public abstract int getSchemaTupleIdentifier(); |
| 88 | protected abstract int schemaSize(); |
| 89 | |
| 90 | public String getSchemaString() { |
| 91 | return getSchema().toString(); |
| 92 | } |
| 93 | |
| 94 | protected SchemaTuple<T> set(SchemaTuple<?> t, boolean checkType) throws ExecException { |
| 95 | return generatedCodeSet(t, checkType); |
| 96 | } |
| 97 | |
| 98 | protected abstract SchemaTuple<T> generatedCodeSet(SchemaTuple<?> t, boolean checkType) throws ExecException; |
| 99 | |
| 100 | protected SchemaTuple<T> setSpecific(T t) { |
| 101 | return generatedCodeSetSpecific(t); |
| 102 | } |
| 103 | |
| 104 | protected abstract SchemaTuple<T> generatedCodeSetSpecific(T t); |
| 105 | |
| 106 | public SchemaTuple<T> set(Tuple t) throws ExecException { |
| 107 | return set(t, true); |
| 108 | } |
| 109 | |
| 110 | @SuppressWarnings("unchecked") //this is ok because we only cast to T after checking |
nothing calls this directly
no outgoing calls
no test coverage detected