Esempio n. 1
0
 private static KeyValueSchema buildSchema(PTable table) {
   KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0);
   if (table != null) {
     for (PColumn column : table.getColumns()) {
       if (!SchemaUtil.isPKColumn(column)) {
         builder.addField(column);
       }
     }
   }
   return builder.build();
 }
Esempio n. 2
0
 public TupleProjector(ProjectedPTableWrapper projected) {
   List<PColumn> columns = projected.getTable().getColumns();
   expressions = new Expression[columns.size() - projected.getTable().getPKColumns().size()];
   // we do not count minNullableIndex for we might do later merge.
   KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0);
   int i = 0;
   for (PColumn column : projected.getTable().getColumns()) {
     if (!SchemaUtil.isPKColumn(column)) {
       builder.addField(column);
       expressions[i++] = projected.getSourceExpression(column);
     }
   }
   schema = builder.build();
   valueSet = ValueBitSet.newInstance(schema);
 }
  private KeyValueSchema generateSchema(int nFields, int nRepeating, final int nNotNull) {
    KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(nNotNull);
    for (int i = 0; i < nFields; i++) {
      final int fieldIndex = i;
      for (int j = 0; j < nRepeating; j++) {
        PDatum datum =
            new PDatum() {
              @Override
              public boolean isNullable() {
                return fieldIndex <= nNotNull;
              }

              @Override
              public PDataType getDataType() {
                return PDataType.values()[fieldIndex % PDataType.values().length];
              }

              @Override
              public Integer getByteSize() {
                return !getDataType().isFixedWidth()
                    ? null
                    : getDataType().getByteSize() == null
                        ? FIXED_WIDTH_CHAR_SIZE
                        : getDataType().getByteSize();
              }

              @Override
              public Integer getMaxLength() {
                return null;
              }

              @Override
              public Integer getScale() {
                return null;
              }

              @Override
              public SortOrder getSortOrder() {
                return SortOrder.getDefault();
              }
            };
        builder.addField(datum);
      }
    }
    KeyValueSchema schema = builder.build();
    return schema;
  }