Package org.kiji.schema.layout.KijiTableLayout.LocalityGroupLayout

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


    }
    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);
      final ColumnLayout qualifier =
          family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));
      if (qualifier == null) {
        throw new NoSuchColumnException(String.format(
            "No column with ID %s in family %s of table %s.",
            qualifierID.getId(), family.getName(), mLayout.getName()));
      }
      final KijiColumnName kijiColumnName =
          new KijiColumnName(family.getName(), qualifier.getName());
      LOG.debug("Translated to Kiji group column {}.", kijiColumnName);
      return kijiColumnName;
    } else {
      // Map type family.
      assert family.isMapType();
      final KijiColumnName kijiColumnName = new KijiColumnName(family.getName(), rawQualifier);
      LOG.debug("Translated to Kiji map column '{}'.", kijiColumnName);
      return kijiColumnName;
    }
  }
View Full Code Here


  public HBaseColumnName toHBaseColumnName(final KijiColumnName kijiColumnName)
      throws NoSuchColumnException {
    final String familyName = kijiColumnName.getFamily();
    final String qualifierName = kijiColumnName.getQualifier();

    final FamilyLayout family = mLayout.getFamilyMap().get(familyName);
    if (family == null) {
      throw new NoSuchColumnException(kijiColumnName.toString());
    }

    final ColumnId localityGroupID = family.getLocalityGroup().getId();
    final ColumnId familyID = family.getId();

    final byte[] localityGroupBytes = Bytes.toBytes(localityGroupID.toString());
    final byte[] familyBytes = Bytes.toBytes(familyID.toString());

    if (qualifierName == null) {
      // Unqualified column
      return new HBaseColumnName(localityGroupBytes,
          concatWithSeparator(SEPARATOR, familyBytes, new byte[]{}));
    } else if (family.isGroupType()) {
      // Group type family.
      final ColumnId qualifierID = family.getColumnIdNameMap().inverse().get(qualifierName);
      final byte[] qualifierBytes = Bytes.toBytes(qualifierID.toString());

      return new HBaseColumnName(localityGroupBytes,
          concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));
    } else {
      // Map type family.
      assert family.isMapType();
      final byte[] qualifierBytes = Bytes.toBytes(qualifierName);

      return new HBaseColumnName(
          localityGroupBytes,
          concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes));
View Full Code Here

    final State state = mState.get();
    Preconditions.checkState(state == State.OPEN,
        "Cannot delete family while KijiTableWriter %s is in state %s.", this, state);

    final WriterLayoutCapsule capsule = mWriterLayoutCapsule;
    final FamilyLayout familyLayout = capsule.getLayout().getFamilyMap().get(family);
    if (null == familyLayout) {
      throw new NoSuchColumnException(String.format("Family '%s' not found.", family));
    }

    if (familyLayout.getLocalityGroup().getFamilyMap().size() > 1) {
      // There are multiple families within the locality group, so we need to be clever.
      if (familyLayout.isGroupType()) {
        deleteGroupFamily(entityId, familyLayout, upToTimestamp);
      } else if (familyLayout.isMapType()) {
        deleteMapFamily(entityId, familyLayout, upToTimestamp);
      } else {
        throw new RuntimeException("Internal error: family is neither map-type nor group-type.");
      }
      return;
View Full Code Here

        // locality group is also requested.
        addColumn(get, hbaseColumnName);
        columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext));

      } else {
        final FamilyLayout fLayout = tableLayout.getFamilyMap().get(kijiColumnName.getFamily());
        if (fLayout.isGroupType()) {
          // Requests all columns in a Kiji group-type family.
          // Expand the family request into individual column requests:
          for (String qualifier : fLayout.getColumnMap().keySet()) {
            final KijiColumnName fqKijiColumnName =
                KijiColumnName.create(kijiColumnName.getFamily(), qualifier);
            final HBaseColumnName fqHBaseColumnName =
                mColumnNameTranslator.toHBaseColumnName(fqKijiColumnName);
            addColumn(get, fqHBaseColumnName);
            columnFilters.addFilter(toFilter(columnRequest, fqHBaseColumnName, filterContext));
          }

        } else if (fLayout.isMapType()) {
          // Requests all columns in a Kiji map-type family.
          // We need to request all columns in the HBase family (ie. in the Kiji locality group)
          // and add a column prefix-filter to select only the columns from that Kiji family:
          get.addFamily(hbaseColumnName.getFamily());
          columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext));
View Full Code Here

    }
    final String familyName = Bytes.toString(hbaseQualifier, 0, index);
    final String qualifierName =
        Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);

    final FamilyLayout family = mLayout.getFamilyMap().get(familyName);
    if (family == null) {
      throw new NoSuchColumnException(String.format(
          "No family %s in locality group %s of table %s.",
          familyName, localityGroupName, mLayout.getName()));
    }

    if (family.isGroupType()) {
      // Group type family.
      if (!family.getColumnMap().containsKey(qualifierName)) {
        throw new NoSuchColumnException(String.format(
            "No qualifier %s in family %s of table %s.",
            qualifierName, familyName, mLayout.getName()));
      }
      final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);
      LOG.debug("Translated to Kiji group type column {}.", kijiColumnName);
      return kijiColumnName;
    } else {
      // Map type family.
      assert family.isMapType();
      final KijiColumnName kijiColumnName = new KijiColumnName(familyName, qualifierName);
      LOG.debug("Translated to Kiji map type column '{}'.", kijiColumnName);
      return kijiColumnName;
    }
  }
View Full Code Here

    final String familyName = kijiColumnName.getFamily();
    final String qualifierName = kijiColumnName.getQualifier();

    // Validate the Kiji family
    final FamilyLayout family = mLayout.getFamilyMap().get(familyName);
    if (family == null) {
      throw new NoSuchColumnException(kijiColumnName.toString());
    }

    // Validate the Kiji qualifier
    if (family.isGroupType() && !family.getColumnMap().containsKey(qualifierName)) {
      throw new NoSuchColumnException(kijiColumnName.toString());
    }

    final byte[] localityGroupBytes = Bytes.toBytes(family.getLocalityGroup().getName());
    final byte[] familyBytes = Bytes.toBytes(familyName);
    final byte[] qualifierBytes = Bytes.toBytes(qualifierName);

    final byte[] hbaseQualifierBytes =
        ShortColumnNameTranslator.concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes);
View Full Code Here

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

    final String familyName = Bytes.toString(hbaseColumnName.getFamily());
    final String qualifierName = Bytes.toString(hbaseColumnName.getQualifier());

    final FamilyLayout family = mLayout.getFamilyMap().get(familyName);

    // Validate that the family exists
    if (family == null) {
      throw new NoSuchColumnException(String.format("No family %s in layout for table %s.",
          familyName, mLayout.getName()));
    }

    // Validate that the qualifier exists
    final ColumnLayout qualifier = family.getColumnMap().get(qualifierName);
    if (qualifier == null) {
      throw new NoSuchColumnException(String.format("No qualifier %s in family %s of table %s.",
          qualifierName, familyName, mLayout.getName()));
    }
View Full Code Here

      throws NoSuchColumnException {
    final String familyName = kijiColumnName.getFamily();
    final String qualifierName = kijiColumnName.getQualifier();

    // Validate that the family exists
    final FamilyLayout family = mLayout.getFamilyMap().get(familyName);
    if (family == null) {
      throw new NoSuchColumnException(String.format("No family %s in table %s.",
          familyName, mLayout.getName()));
    }

    // Validate that the qualifier exists within the layout
    if (!family.getColumnMap().containsKey(qualifierName)) {
      throw new NoSuchColumnException(String.format(
          "No qualifier %s in family %s of table %s.",
          qualifierName, familyName, mLayout.getName()));
    }
View Full Code Here

      Preconditions.checkState(mState == State.OPEN,
          "Can not put cell to an AtomicKijiPutter instance in state %s.", mState);

      final KijiURI tableURI = mTable.getURI();

      final FamilyLayout familyLayout = mCapsule.getLayout().getFamilyMap().get(family);
      if (familyLayout == null) {
        throw new IllegalArgumentException(
            String.format("Unknown family '%s' in table %s.", family, tableURI));
      }

      final ColumnLayout columnLayout = familyLayout.getColumnMap().get(qualifier);
      if (columnLayout == null) {
        throw new IllegalArgumentException(
            String.format("Unknown qualifier '%s' in family '%s' of table %s.",
                qualifier, family, tableURI));
      }

      if (columnLayout.getDesc().getColumnSchema().getType() == SchemaType.COUNTER) {
        throw new UnsupportedOperationException(
            "Cassandra Kiji does not support puts to counter columns.");
      }

      final ColumnId localityGroupId = familyLayout.getLocalityGroup().getId();
      if (mTableName == null) {
        // first put in transaction; set the table.
        mTableName = CassandraTableName.getLocalityGroupTableName(
            tableURI, familyLayout.getLocalityGroup().getId());
      } else {
        Preconditions.checkArgument(mTableName.getLocalityGroupId().equals(localityGroupId),
            "Kiji Cassandra does not support transactions across multiple locality groups.");
      }

      // In Cassandra Kiji, a write to HConstants.LATEST_TIMESTAMP should be a write with the
      // current transaction time.
      final long version;
      if (timestamp == HConstants.LATEST_TIMESTAMP) {
        version = mTimestamp;
      } else {
        version = timestamp;
      }

      int ttl = familyLayout.getLocalityGroup().getDesc().getTtlSeconds();

      final KijiColumnName columnName = KijiColumnName.create(family, qualifier);
      final CassandraColumnName cassandraColumn =
          mCapsule.getColumnNameTranslator().toCassandraColumnName(columnName);
View Full Code Here

TOP

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

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.