Package org.kiji.schema.layout.KijiTableLayout

Examples of org.kiji.schema.layout.KijiTableLayout.LocalityGroupLayout


            .build()))
        .build();
    final KijiTableLayout layout2 = KijiTableLayout.createUpdatedLayout(desc2, mRefLayout);
    assertEquals(1, layout2.getLocalityGroups().size());
    assertEquals(1, layout2.getLocalityGroupMap().size());
    final LocalityGroupLayout lgLayout2 =
        layout2.getLocalityGroupMap().get("renamed_locality_group_name");
    assertNotNull(lgLayout2);

    assertEquals(1, lgLayout2.getFamilyMap().size());
    assertNotNull(lgLayout2.getFamilyMap().get("family_name"));
  }
View Full Code Here


    // and validate the reader/writer schema sets.
    // If no matching family/column exists in the reference layout the newly create column is valid.
    for (FamilyLayout flayout : layout.getFamilies()) {
      final ColumnId lgid = flayout.getLocalityGroup().getId();

      LocalityGroupLayout refLGLayout = null;
      if (reference != null) {
        // If there is a reference layout, check for a locality group matching the ID of the LG for
        // this family.  Locality Group IDs should not change between layouts.
        final String refLGName = reference.getLocalityGroupIdNameMap().get(lgid);
        if (refLGName != null) {
          // If there is a matching reference LG get its layout by name.
          refLGLayout = reference.getLocalityGroupMap().get(refLGName);
        }
      }

      // The ColumnId of the FamilyLayout from the table layout.  Also matches the FamilyLayout for
      // this family in the reference layout if present.
      final ColumnId familyId = flayout.getId();

      if (flayout.isMapType()) {
        // If the family is map-type, get the CellSchema for all values in the family.
        final CellSchema cellSchema = flayout.getDesc().getMapSchema();

        FamilyLayout refFamilyLayout = null;
        if (refLGLayout != null) {
          // If there is a matching reference LG, check for the existence of this family.
          final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);
          if (refFamilyName != null) {
            refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);
          }
        }

        if (refFamilyLayout != null) {
          if (refFamilyLayout.isMapType()) {
            // If the FamilyLayout from both table layouts are map type, compare their CellSchemas.
            final CellSchema refCellSchema = refFamilyLayout.getDesc().getMapSchema();

            incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(
                flayout.getName(), null, validateCellSchema(refCellSchema, cellSchema)));
          } else if (refFamilyLayout.isGroupType()) {
            // If the FamilyLayout changed from group-type to map-type between table layout versions
            // that is an incompatible change.
            incompatabilityMessages.add(String.format(
                "Family: %s changed from group-type to map-type.", refFamilyLayout.getName()));
          } else {
            throw new InternalKijiError(String.format(
                "Family: %s is neither map-type nor group-type.", refFamilyLayout.getName()));
          }
        } else {
          // If the reference FamilyLayout is null this indicates a new family, which is inherently
          // compatible, but we still have to validate that the new readers and writers are
          // internally compatible.
          incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages(
              flayout.getName(), null, validateCellSchema(null, cellSchema)));
        }
      } else if (flayout.isGroupType()) {
        // Check for a matching family from the reference layout.
        FamilyLayout refFamilyLayout = null;
        if (refLGLayout != null) {
          final String refFamilyName = refLGLayout.getFamilyIdNameMap().get(familyId);
          if (refFamilyName != null) {
            refFamilyLayout = refLGLayout.getFamilyMap().get(refFamilyName);
          }
        }

        if (refFamilyLayout != null) {
          if (refFamilyLayout.isGroupType()) {
View Full Code Here

      final CassandraColumnName cassandraColumnName
  ) throws NoSuchColumnException {

    final String localityGroupName =
        mLayout.getLocalityGroupIdNameMap().get(localityGroupTable.getLocalityGroupId());
    final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);
        mLayout.getLocalityGroupIdNameMap().get(localityGroupTable.getLocalityGroupId());
    if (localityGroup == null) {
      throw new NoSuchColumnException(
          String.format("No locality group for Cassandra table %s in Kiji table %s.",
              localityGroupTable, mLayout.getName()));
    }

    final ColumnId familyID = ColumnId.fromByteArray(cassandraColumnName.getFamily());
    final FamilyLayout family =
        localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));
    if (family == null) {
      throw new NoSuchColumnException(String.format(
          "No family with ID %s in locality group %s of table %s.",
          familyID.getId(), localityGroup.getName(), mLayout.getName()));
    }

    final KijiColumnName kijiColumnName;
    if (family.isGroupType()) {
      // Group type family.
View Full Code Here

  @Override
  public KijiColumnName toKijiColumnName(HBaseColumnName hbaseColumnName)
      throws NoSuchColumnException {
    LOG.debug("Translating HBase column name '{}' to Kiji column name...", hbaseColumnName);
    final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());
    final LocalityGroupLayout localityGroup =
        mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));
    if (localityGroup == null) {
      throw new NoSuchColumnException(String.format("No locality group with ID %s in table %s.",
          localityGroupID.getId(), mLayout.getName()));
    }

    // Parse the HBase qualifier as a byte[] in order to save a String instantiation
    final byte[] hbaseQualifier = hbaseColumnName.getQualifier();
    final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);
    if (index == -1) {
      throw new NoSuchColumnException(String.format(
          "Missing separator in HBase column %s.", hbaseColumnName));
    }
    final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));
    final String rawQualifier =
        Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);

    final FamilyLayout family =
        localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));
    if (family == null) {
      throw new NoSuchColumnException(String.format(
          "No family with ID %s in locality group %s of table %s.",
          familyID.getId(), localityGroup.getName(), mLayout.getName()));
    }

    if (family.isGroupType()) {
      // Group type family.
      final ColumnId qualifierID = ColumnId.fromString(rawQualifier);
View Full Code Here

      throws NoSuchColumnException {
    LOG.debug("Translating HBase column name {} to Kiji column name.", hbaseColumnName);

    final String localityGroupName = Bytes.toString(hbaseColumnName.getFamily());

    final LocalityGroupLayout localityGroup = mLayout.getLocalityGroupMap().get(localityGroupName);
    if (localityGroup == null) {
      throw new NoSuchColumnException(String.format("No locality group %s in table %s.",
          localityGroupName, mLayout.getName()));
    }
View Full Code Here

TOP

Related Classes of org.kiji.schema.layout.KijiTableLayout.LocalityGroupLayout

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.