Package org.kiji.schema.layout

Examples of org.kiji.schema.layout.TableLayoutBuilder


    final KijiTable table = kiji.openTable(TABLE_NAME);
    try {

      final TableLayoutDesc updateWithReader =
          new TableLayoutBuilder(table.getLayout().getDesc(), kiji)
              .withReader(KijiColumnName.create("info""gender"), readerEnum)
              .build();
      LOG.debug("Applying update with enum reader: %s", updateWithReader);
      kiji.modifyTableLayout(updateWithReader);

      final TableLayoutDesc updateWithWriter=
          new TableLayoutBuilder(table.getLayout().getDesc(), kiji)
              .withWriter(KijiColumnName.create("info""gender"), writerEnum)
              .build();
      LOG.debug("Applying update with enum writer: %s", updateWithWriter);
      try {
        kiji.modifyTableLayout(updateWithWriter);
View Full Code Here


            @Override
            public TableLayoutDesc apply(final KijiTableLayout refLayout) {
              Preconditions.checkNotNull(refLayout);
              try {
                final TableLayoutDesc refDesc = refLayout.getDesc();
                return new TableLayoutBuilder(refDesc, kiji)
                    .withLayoutId(nextLayoutId(refDesc.getLayoutId()))
                    .withWriter(column, writerSchema)
                    .withWritten(column, writerSchema)
                    .build();
              } catch (InvalidLayoutException ile) {
View Full Code Here

  @Override
  public KijiTableLayout updateTableLayout(String tableName, TableLayoutDesc layoutUpdate)
      throws IOException {

    // Normalize the new layout to use schema UIDs:
    final TableLayoutBuilder layoutBuilder = new TableLayoutBuilder(mSchemaTable);
    final TableLayoutDesc update = layoutBuilder.normalizeTableLayoutDesc(
        layoutUpdate,
        new LayoutOptions()
            .setSchemaFormat(SchemaFormat.UID));

    // Fetch all the layout history:
View Full Code Here

      throws IOException {

    final TableLayoutDesc desc = KijiTableLayouts.getLayout(KijiTableLayouts.SCHEMA_REG_TEST);
    desc.setVersion("layout-1.3.0");

    final TableLayoutDesc originalDesc = new TableLayoutBuilder(desc, kiji)
        .withAvroValidationPolicy(
            KijiColumnName.create("info:fullname"), policy)
        .withReader(KijiColumnName.create("info:fullname"), STRING_SCHEMA)
        .build();

    kiji.createTable(originalDesc);

    final TableLayoutDesc newDesc = new TableLayoutBuilder(originalDesc, kiji)
        .withWriter(KijiColumnName.create("info:fullname"), INT_SCHEMA)
        .build();
    return newDesc;
  }
View Full Code Here

    basicDesc.setVersion("layout-1.3.0");
    final KijiColumnName validatedColumn = KijiColumnName.create("info:fullname");
    final Schema intSchema = Schema.create(Type.INT);
    final Schema stringSchema = Schema.create(Type.STRING);

    final TableLayoutDesc strictIntDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)
        .withReader(validatedColumn, intSchema)
        .build();
    final TableLayoutDesc strictStringDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)
        .withWriter(validatedColumn, stringSchema)
        .build();
    final TableLayoutDesc developerIntDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.DEVELOPER)
        .withReader(validatedColumn, intSchema)
        .build();
    final TableLayoutDesc developerStringDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.DEVELOPER)
        .withWriter(validatedColumn, stringSchema)
        .build();
    final TableLayoutDesc noneIntDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.NONE)
        .withReader(validatedColumn, intSchema)
        .build();
    final TableLayoutDesc noneStringDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.NONE)
        .withWriter(validatedColumn, stringSchema)
        .build();
    final TableLayoutDesc schema10IntDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.SCHEMA_1_0)
        .withReader(validatedColumn, intSchema)
        .build();
    final TableLayoutDesc schema10StringDesc = new TableLayoutBuilder(basicDesc, getKiji())
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.SCHEMA_1_0)
        .withWriter(validatedColumn, stringSchema)
        .build();

    final List<TableLayoutDesc> intDescs =
View Full Code Here

  @Test
  public void testAddRemoveModifyColumns() throws IOException {
    final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(getKiji());
    final KijiColumnName validatedColumn = KijiColumnName.create("info:qual0");
    final TableLayoutDesc desc = new TableLayoutBuilder(
        KijiTableLayouts.getLayout(AVRO_VALIDATION_TEST), getKiji())
        .withReader(validatedColumn, TestRecord5.SCHEMA$)
        .withAvroValidationPolicy(validatedColumn, AvroValidationPolicy.STRICT)
        .withLayoutId("original")
        .build();

    // The initial layout is valid.
    validator.validate(null, KijiTableLayout.newLayout(desc));

    // Create an update which removes a column, adds a column, and modifies the set of readers for a
    // column in a compatible way.
    final TableLayoutDesc updateDesc =
        KijiTableLayouts.getLayout(AVRO_VALIDATION_UPDATE_TEST);
    updateDesc.setReferenceLayout("original");
    updateDesc.setLayoutId("updated");
    final TableLayoutDesc newDesc = new TableLayoutBuilder(updateDesc, getKiji())
        .withReader(validatedColumn, TestRecord4.SCHEMA$)
        .build();

    validator.validate(KijiTableLayout.newLayout(desc), KijiTableLayout.newLayout(newDesc));
  }
View Full Code Here

    final Schema optIntRecordSchema = Schema.createRecord("Record", null, "org.ns", false);
    optIntRecordSchema.setFields(Lists.newArrayList(
        new Field("a", INT_SCHEMA, null, IntNode.valueOf(0))));

    final TableLayoutDesc originalDesc = new TableLayoutBuilder(desc, kiji)
        .withAvroValidationPolicy(
            KijiColumnName.create("info:fullname"), AvroValidationPolicy.STRICT)
        .withReader(KijiColumnName.create("info:fullname"), emptyRecordSchema)
        .build();

    kiji.createTable(originalDesc);

    final TableLayoutDesc newDesc = new TableLayoutBuilder(originalDesc, kiji)
        .withWriter(KijiColumnName.create("info:fullname"), optIntRecordSchema)
        .build();

    kiji.modifyTableLayout(newDesc);
  }
View Full Code Here

  @Override
  public KijiTableLayout updateTableLayout(String tableName, TableLayoutDesc layoutUpdate)
      throws IOException {

    // Normalize the new layout to use schema UIDs:
    TableLayoutBuilder layoutBuilder = new TableLayoutBuilder(mSchemaTable);
    final TableLayoutDesc update = layoutBuilder.normalizeTableLayoutDesc(
        layoutUpdate,
        new LayoutOptions()
            .setSchemaFormat(SchemaFormat.UID));

    // Fetch all the layout history:
View Full Code Here

TOP

Related Classes of org.kiji.schema.layout.TableLayoutBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.