Package org.kiji.schema

Examples of org.kiji.schema.KijiColumnName


    // Deconstruct map of column name => version => value
    // to family => qualifier => versions => value
    NavigableMap<String, NavigableMap<String, NavigableMap<Long, Object>>> families =
        Maps.newTreeMap();
    for (Entry<KijiColumnName, NavigableMap<Long, ?>> columnEntry : ROW_DATA.entrySet()) {
      final KijiColumnName column = columnEntry.getKey();
      NavigableMap<String, NavigableMap<Long, Object>> qualifiers =
          families.get(column.getFamily());
      if (qualifiers == null) {
        qualifiers = Maps.newTreeMap();
        families.put(column.getFamily(), qualifiers);
      }
      NavigableMap<Long, Object> cells = qualifiers.get(column.getQualifier());
      if (cells == null) {
        cells = Maps.newTreeMap();
        qualifiers.put(column.getQualifier(), cells);
      }
      for (Entry<Long, ?> cellEntry : columnEntry.getValue().entrySet()) {
        cells.put(cellEntry.getKey(), cellEntry.getValue());
      }
    }
View Full Code Here


    }
  }

  @Test
  public void testGetMultipleFullyQualifiedColumns() throws Exception {
    final KijiColumnName column1 = PRIMITIVE_STRING;
    final KijiColumnName column2 = STRING_MAP_1;

    for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {

      { // Single version | no timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .add(column1.getFamily(), column1.getQualifier())
                    .add(column2.getFamily(), column2.getQualifier()))
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries =
            Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);
        final Iterable<? extends Entry<Long, ?>> column2Entries =
            Iterables.limit(ROW_DATA.get(column2).entrySet(), 1);

        testViewGet(request, Iterables.concat(column1Entries, column2Entries));
      }

      { // Single version | timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .add(column1.getFamily(), column1.getQualifier())
                    .add(column2.getFamily(), column2.getQualifier()))
            .withTimeRange(4, 6)
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries =
            Iterables.limit(ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet(), 1);
        final Iterable<? extends Entry<Long, ?>> column2Entries =
            Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);

        testViewGet(request, Iterables.concat(column1Entries, column2Entries));
      }

      { // Multiple versions | no timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(100)
                    .add(column1.getFamily(), column1.getQualifier())
                    .add(column2.getFamily(), column2.getQualifier()))
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column1).entrySet();
        final Iterable<? extends Entry<Long, ?>> column2Entries = ROW_DATA.get(column2).entrySet();

        testViewGet(request, Iterables.concat(column1Entries, column2Entries));
      }

      { // Multiple versions | timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(100)
                    .add(column1.getFamily(), column1.getQualifier())
                    .add(column2.getFamily(), column2.getQualifier()))
            .withTimeRange(4, 6)
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries =
            ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();
        final Iterable<? extends Entry<Long, ?>> column2Entries =
            ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet();

        testViewGet(request, Iterables.concat(column1Entries, column2Entries));
      }

      { // Mixed versions | timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(100)
                    .add(column1.getFamily(), column1.getQualifier()))
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(1)
                    .add(column2.getFamily(), column2.getQualifier()))
            .withTimeRange(4, 6)
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries =
            ROW_DATA.get(column1).subMap(6L, false, 4L, true).entrySet();
        final Iterable<? extends Entry<Long, ?>> column2Entries =
            Iterables.limit(ROW_DATA.get(column2).subMap(6L, false, 4L, true).entrySet(), 1);

        testViewGet(request, Iterables.concat(column1Entries, column2Entries));
      }

      { // Mixed versions | no timerange
        final KijiDataRequest request = KijiDataRequest
            .builder()
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(1)
                    .add(column1.getFamily(), column1.getQualifier()))
            .addColumns(
                ColumnsDef.create()
                    .withPageSize(pageSize)
                    .withMaxVersions(100)
                    .add(column2.getFamily(), column2.getQualifier()))
            .build();

        final Iterable<? extends Entry<Long, ?>> column1Entries =
            Iterables.limit(ROW_DATA.get(column1).entrySet(), 1);
        final Iterable<? extends Entry<Long, ?>> column2Entries =
View Full Code Here

            STRING_MAP_FAMILY, ImmutableList.of(STRING_MAP_1, STRING_MAP_2));

    for (Entry<String, ? extends List<KijiColumnName>> family : families.entrySet()) {
      for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {

        final KijiColumnName familyColumn = KijiColumnName.create(family.getKey(), null);
        final KijiColumnName column1 = family.getValue().get(0);
        final KijiColumnName column2 = family.getValue().get(1);

        { // Single version | no timerange
          final KijiDataRequest request = KijiDataRequest
              .builder()
              .addColumns(ColumnsDef.create().withPageSize(pageSize).add(familyColumn))
View Full Code Here

    }
  }

  @Test
  public void testGetMultipleFamilyColumns() throws Exception {
    final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);
    final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);

    final KijiColumnName column1 = PRIMITIVE_DOUBLE;
    final KijiColumnName column2 = PRIMITIVE_STRING;
    final KijiColumnName column3 = STRING_MAP_1;
    final KijiColumnName column4 = STRING_MAP_2;

    for (int pageSize : ImmutableList.of(0, 1, 2, 10)) {

      { // Single version | no timerange
        final KijiDataRequest request = KijiDataRequest
View Full Code Here

    }
  }

  @Test
  public void testNarrowView() throws Exception {
    final KijiColumnName familyColumn1 = KijiColumnName.create(PRIMITIVE_FAMILY, null);
    final KijiColumnName familyColumn2 = KijiColumnName.create(STRING_MAP_FAMILY, null);

    final KijiColumnName column1 = PRIMITIVE_DOUBLE;
    final KijiColumnName column2 = PRIMITIVE_STRING;
    final KijiColumnName column3 = STRING_MAP_1;
    final KijiColumnName column4 = STRING_MAP_2;

    for (int pageSize : ImmutableList.of(0)) {

      final KijiDataRequest request = KijiDataRequest
          .builder()
View Full Code Here

    }
  }

  @Test(expected = UnsupportedOperationException.class)
  public void testGetWithFilters() throws Exception {
    final KijiColumnName column2 = STRING_MAP_1;

    final KijiDataRequest request = KijiDataRequest
        .builder()
        .addColumns(
            ColumnsDef.create()
                .withFilter(
                    new KijiColumnRangeFilter(
                        STRING_MAP_1.getQualifier(), true,
                        STRING_MAP_2.getQualifier(), false))
                .withMaxVersions(10)
                .add(column2.getFamily(), null))
        .build();

    final Iterable<? extends Entry<Long, ?>> column1Entries = ROW_DATA.get(column2).entrySet();

    testViewGet(request, column1Entries);
View Full Code Here

  @Override
  public KijiRowData next(final int pageSize) {
    if (!hasNext()) {
      throw new NoSuchElementException("Kiji pager is exhausted.");
    }
    final KijiColumnName column = mColumnRequest.getColumnName();
    final ColumnsDef columnDef = ColumnsDef
        .create()
        .withFilter(mColumnRequest.getFilter())
        .withPageSize(KijiDataRequest.PAGING_DISABLED)
        .withMaxVersions(mColumnRequest.getMaxVersions())
View Full Code Here

               : familyEntry.getValue().entrySet()) {
        final HBaseColumnName hbaseColumnName =
            new HBaseColumnName(familyEntry.getKey(), columnEntry.getKey());

        // Translate the HBase column name to a Kiji column name.
        KijiColumnName kijiColumnName;
        try {
          kijiColumnName = columnNameTranslator.toKijiColumnName(
              new HBaseColumnName(familyEntry.getKey(), columnEntry.getKey()));
        } catch (NoSuchColumnException e) {
          LOG.info("Ignoring HBase column '{}:{}' because it doesn't contain Kiji data.",
              Bytes.toStringBinary(hbaseColumnName.getFamily()),
              Bytes.toStringBinary(hbaseColumnName.getQualifier()));
          continue;
        }
        LOG.debug("Adding family [{}] to getMap() result.", kijiColumnName.getName());

        // First check if all columns were requested.
        KijiDataRequest.Column columnRequest =
            mDataRequest.getColumn(kijiColumnName.getFamily(), null);
        if (null == columnRequest) {
          // Not all columns were requested, so check if this particular column was.
          columnRequest =
              mDataRequest.getColumn(kijiColumnName.getFamily(), kijiColumnName.getQualifier());
        }
        if (null == columnRequest) {
          LOG.debug("Ignoring unrequested data: " + kijiColumnName.getFamily() + ":"
              + kijiColumnName.getQualifier());
          continue;
        }

        // Loop over the versions.
        int numVersions = 0;
        for (NavigableMap.Entry<Long, byte[]> versionEntry : columnEntry.getValue().entrySet()) {
          if (numVersions >= columnRequest.getMaxVersions()) {
            LOG.debug("Skipping remaining cells because we hit max versions requested: "
                + columnRequest.getMaxVersions());
            break;
          }

          // Read the timestamp.
          final long timestamp = versionEntry.getKey();
          if (mDataRequest.isTimestampInRange(timestamp)) {
            // Add the cell to the filtered map.
            if (!mFilteredMap.containsKey(kijiColumnName.getFamily())) {
              mFilteredMap.put(kijiColumnName.getFamily(),
                  new TreeMap<String, NavigableMap<Long, byte[]>>());
            }
            final NavigableMap<String, NavigableMap<Long, byte[]>> columnMap =
                mFilteredMap.get(kijiColumnName.getFamily());
            if (!columnMap.containsKey(kijiColumnName.getQualifier())) {
              columnMap.put(kijiColumnName.getQualifier(),
                  new TreeMap<Long, byte[]>(TimestampComparator.INSTANCE));
            }
            final NavigableMap<Long, byte[]> versionMap =
                columnMap.get(kijiColumnName.getQualifier());
            versionMap.put(versionEntry.getKey(), versionEntry.getValue());
            ++numVersions;
          } else {
            LOG.debug("Excluding cell at timestamp " + timestamp + " because it is out of range ["
                + mDataRequest.getMinTimestamp() + "," + mDataRequest.getMaxTimestamp() + ")");
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public <T> Iterator<KijiCell<T>> iterator(String family, String qualifier)
      throws IOException {
    final KijiColumnName column = KijiColumnName.create(family, qualifier);
    Preconditions.checkArgument(
        mDataRequest.getRequestForColumn(column) != null,
        "Column %s has no data request.", column);
    return new KijiCellIterator<T>(this, column, mTable.getColumnNameTranslator());
  }
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public <T> Iterator<KijiCell<T>> iterator(String family)
      throws IOException {
    final KijiColumnName column = KijiColumnName.create(family, null);
    Preconditions.checkArgument(
        mDataRequest.getRequestForColumn(column) != null,
        "Column %s has no data request.", column);
    Preconditions.checkState(mTableLayout.getFamilyMap().get(family).isMapType(),
        "iterator(String family) is only enabled"
View Full Code Here

TOP

Related Classes of org.kiji.schema.KijiColumnName

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.