Package org.kiji.schema

Examples of org.kiji.schema.KijiDataRequestBuilder$ColumnsDef


      final KijiColumnName column,
      final KijiDataRequest dataRequest
  ) {
    final List<Column> columnRequests = getColumnRequests(column, dataRequest);

    final KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());
    for (Column columnRequest : columnRequests) {
      builder.newColumnsDef(columnRequest);
    }

    return builder.build();
  }
View Full Code Here


  }

  /** {@inheritDoc} */
  @Override
  public KijiDataRequest getDataRequest() {
    KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().add(mFamily, mQualifier);
    return builder.build();
  }
View Full Code Here

      final CassandraKijiTable table,
      final KijiTableLayout layout,
      final CassandraColumnNameTranslator columnTranslator,
      final CellDecoderProvider decoderProvider
  ) throws IOException {
    final KijiDataRequestBuilder unpagedRequestBuilder = KijiDataRequest.builder();
    final KijiDataRequestBuilder pagedRequestBuilder = KijiDataRequest.builder();
    unpagedRequestBuilder.withTimeRange(
        dataRequest.getMinTimestamp(),
        dataRequest.getMaxTimestamp());
    pagedRequestBuilder.withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());

    for (final Column columnRequest : dataRequest.getColumns()) {
      if (columnRequest.getFilter() != null) {
        throw new UnsupportedOperationException(
            String.format("Cassandra Kiji does not support filters on column requests: %s.",
                columnRequest));
      }
      if (columnRequest.isPagingEnabled()) {
        pagedRequestBuilder.newColumnsDef(columnRequest);
      } else {
        unpagedRequestBuilder.newColumnsDef(columnRequest);
      }
    }

    final CellDecoderProvider requestDecoderProvider =
        decoderProvider.getDecoderProviderForRequest(dataRequest);

    final KijiDataRequest unpagedRequest = unpagedRequestBuilder.build();
    final KijiDataRequest pagedRequest = pagedRequestBuilder.build();

    if (unpagedRequest.isEmpty() && pagedRequest.isEmpty()) {
      return new EmptyKijiResult<T>(entityId, dataRequest);
    }
View Full Code Here

  @Test
  public void testReadInts() throws Exception {
    // Put some data into the table.
    mWriter.put(mEntityId, FAMILY, QUAL3, 1L, 42);

    KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().add(FAMILY, QUAL3);
    KijiDataRequest dataRequest = builder.build();

    // Read out the results to get a KijiRowData
    final KijiRowData input = mReader.get(mEntityId, dataRequest);

    assertNotNull(input.getMostRecentValue(FAMILY, QUAL3));
View Full Code Here

      Map<FamilyLayout, List<String>> mapTypeFamilies,
      Map<FamilyLayout, List<ColumnLayout>> groupTypeColumns,
      int maxVersions,
      long minTimestamp,
      long maxTimestamp) {
    final KijiDataRequestBuilder builder = KijiDataRequest.builder()
        .withTimeRange(minTimestamp, maxTimestamp);

    final KijiDataRequestBuilder.ColumnsDef colBuilder =
        builder.newColumnsDef().withMaxVersions(maxVersions);

    for (Entry<FamilyLayout, List<String>> entry : mapTypeFamilies.entrySet()) {
      String familyName = entry.getKey().getName();
      // If the map family is without qualifiers, add entire family.
      if (entry.getValue().isEmpty()) {
        LOG.debug("Adding family to data request: " + familyName);
        colBuilder.addFamily(familyName);
      } else {
        // If the map family is with qualifiers, add only the columns of interest.
        for (String qualifier : entry.getValue()) {
          LOG.debug("Adding column to data request: " + familyName + ":" + qualifier);
          colBuilder.add(familyName, qualifier);
        }
      }
    }

    for (Entry<FamilyLayout, List<ColumnLayout>> entry : groupTypeColumns.entrySet()) {
      String familyName = entry.getKey().getName();
      for (ColumnLayout column : entry.getValue()) {
        LOG.debug("Adding column to data request: " + column.getName());
        colBuilder.add(familyName, column.getName());
      }
    }
    return builder.build();
  }
View Full Code Here

        .create()
        .withFilter(mColumnRequest.getFilter())
        .withPageSize(KijiDataRequest.PAGING_DISABLED)
        .withMaxVersions(mColumnRequest.getMaxVersions())
        .add(column, mColumnRequest.getReaderSpec());
    final KijiDataRequestBuilder dataRequest = KijiDataRequest.builder();
    dataRequest.addColumns(columnDef);

    final List<KijiCell<Object>> cells = Lists.newArrayListWithCapacity(pageSize);

    while (mCells.hasNext() && cells.size() < pageSize) {
      final KijiCell<Object> cell = mCells.next();
      final String qualifier = cell.getColumn().getQualifier();
      if (!qualifier.equals(mLastQualifier)) {
        cells.add(
            KijiCell.create(
                cell.getColumn(),
                cell.getTimestamp(),
                new DecodedCell<Object>(cell.getWriterSchema(), null)));
        mLastQualifier = qualifier;
      }
    }

    final KijiResult<Object> result = MaterializedKijiResult.create(
        mResult.getEntityId(),
        dataRequest.build(),
        mLayout,
        ImmutableSortedMap.<KijiColumnName, List<KijiCell<Object>>>naturalOrder()
            .put(column, cells)
            .build());
    return new KijiResultRowData(mLayout, result);
View Full Code Here

    }
  }

  @Test
  public void testGetMatContents() throws Exception {
    KijiDataRequestBuilder builder = KijiDataRequest.builder().addColumns(ColumnsDef.create()
        .withMaxVersions(10)
        .add(PRIMITIVE_STRING, null)
            .add(STRING_MAP_1, null));
    KijiDataRequest request = builder.build();
    final EntityId eid = mTable.getEntityId(ROW);
    KijiResult<Object> view = mReader.getResult(eid, request);
    SortedMap<KijiColumnName, List<KijiCell<Object>>> map =
        KijiResult.Helpers.getMaterializedContents(view);
    for (KijiColumnName col: map.keySet()) {
View Full Code Here

    mColumnNameTranslator = HBaseColumnNameTranslator.from(mTableLayout);
  }

  @Test
  public void testDataRequestToScan() throws IOException {
    KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(1).add("info", "name");
    builder.newColumnsDef().withMaxVersions(2).addFamily("purchases");
    builder.withTimeRange(1L, 3L);
    KijiDataRequest request = builder.build();

    Scan expectedScan = new Scan();
    HBaseColumnName hbaseColumn = mColumnNameTranslator.toHBaseColumnName(
        KijiColumnName.create("info:name"));
    expectedScan.addColumn(hbaseColumn.getFamily(), hbaseColumn.getQualifier());
View Full Code Here

    assertFalse(hbaseDataRequest.toScan(mTableLayout).hasFamilies());
  }

  @Test
  public void testDataRequestToGet() throws IOException {
    KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(1).add("info", "name");
    builder.newColumnsDef().withMaxVersions(2).addFamily("purchases");
    builder.withTimeRange(1L, 3L);
    KijiDataRequest request = builder.build();

    EntityId entityId = mEntityIdFactory.getEntityId("entity");
    Get expectedGet = new Get(entityId.getHBaseRowKey());
    HBaseColumnName hbaseColumn = mColumnNameTranslator.toHBaseColumnName(
        KijiColumnName.create("info:name"));
View Full Code Here

        String.format("Paging is not enabled for column '%s' from table %s.",
            colName, table.getURI()));
    }

    // Construct a data request for only this column.
    final KijiDataRequestBuilder builder = KijiDataRequest.builder()
        .withTimeRange(dataRequest.getMinTimestamp(), dataRequest.getMaxTimestamp());
    builder.newColumnsDef(mColumnRequest);

    mColumnName = colName;
    mDataRequest = builder.build();
    mDefaultPageSize = mColumnRequest.getPageSize();
    mEntityId = entityId;
    mTable = table;
    mCellDecoderProvider = cellDecoderProvider;
    mHasNext = true// there might be no page to read, but we don't know until we issue an RPC
View Full Code Here

TOP

Related Classes of org.kiji.schema.KijiDataRequestBuilder$ColumnsDef

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.