当前位置: 首页>>代码示例>>Java>>正文


Java ColumnsDef类代码示例

本文整理汇总了Java中org.kiji.schema.KijiDataRequestBuilder.ColumnsDef的典型用法代码示例。如果您正苦于以下问题:Java ColumnsDef类的具体用法?Java ColumnsDef怎么用?Java ColumnsDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColumnsDef类属于org.kiji.schema.KijiDataRequestBuilder包,在下文中一共展示了ColumnsDef类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColumnsDefFromEntityClass

import org.kiji.schema.KijiDataRequestBuilder.ColumnsDef; //导入依赖的package包/类
/**
 * Get the column definitions from entity class
 * @return ColumnsDef
 */
private ColumnsDef getColumnsDefFromEntityClass ( ) {
	
	// Add column definition
	ColumnsDef columnsDef = ColumnsDef.create();
	for (String f : familySet ) {
		columnsDef.addFamily(f);
	}
	return columnsDef;
}
 
开发者ID:CodeGerm,项目名称:HBaseMate,代码行数:14,代码来源:GenericKijiDao.java

示例2: testTopNextSongPipeline

import org.kiji.schema.KijiDataRequestBuilder.ColumnsDef; //导入依赖的package包/类
/**
 * This is a unit test that executes two MapReduce jobs in local mode and checks that the outputs
 * are as expected. Notice that the only difference between the job definition here and what you
 * would use in production are the tableURIs and file paths.
 */
@Test
public void testTopNextSongPipeline() throws Exception {
  // Configure and run job.
  final File outputDir = new File(getLocalTempDir(), "output.sequence_file");
  final Path path = new Path("file://" + outputDir);
  // Configure first job.
  final KijiMapReduceJob mrjob1 = KijiGatherJobBuilder.create()
      .withConf(getConf())
      .withGatherer(SequentialPlayCounter.class)
      .withReducer(SequentialPlayCountReducer.class)
      .withInputTable(mUserTableURI)
      // Note: the local map/reduce job runner does not allow more than one reducer:
      .withOutput(MapReduceJobOutputs.newAvroKeyValueMapReduceJobOutput(path, 1))
      .build();
  // Configure second job.
  final MapReduceJobOutput tableOutput =
      MapReduceJobOutputs.newDirectKijiTableMapReduceJobOutput(mSongTableURI, 1);
  final KijiMapReduceJob mrjob2 = KijiMapReduceJobBuilder.create()
      .withConf(getConf())
      .withInput(MapReduceJobInputs.newAvroKeyValueMapReduceJobInput(path))
      .withMapper(IdentityMapper.class)
      .withReducer(TopNextSongsReducer.class)
      .withOutput(tableOutput).build();

  // Run both jobs and confirm that they are successful.
  assertTrue(mrjob1.run());
  assertTrue(mrjob2.run());

  KijiDataRequest request = KijiDataRequest.builder()
      .addColumns(ColumnsDef.create()
          .withMaxVersions(Integer.MAX_VALUE)
          .add("info", "top_next_songs"))
      .build();

  TopSongs valuesForSong1 = mSongTableReader.get(mSongTable.getEntityId("song-1"), request)
      .getMostRecentValue("info", "top_next_songs");
  assertEquals("Wrong number of most popular songs played next for song-1", 3,
      valuesForSong1.getTopSongs().size());

  TopSongs valuesForSong2 = mSongTableReader.get(mSongTable.getEntityId("song-2"), request)
      .getMostRecentValue("info", "top_next_songs");
  LOG.info("the list of song counts {}", valuesForSong2.getTopSongs().toString());
  assertEquals("Wrong number of most popular songs played next for song-2", 2,
      valuesForSong2.getTopSongs().size());

  TopSongs valuesForSong8 = mSongTableReader.get(mSongTable.getEntityId("song-8"), request)
      .getMostRecentValue("info", "top_next_songs");
  LOG.info("the list of song counts {}", valuesForSong2.getTopSongs().toString());
  assertEquals("Wrong number of most popular songs played next for song-8", 1,
      valuesForSong8.getTopSongs().size());
  assertEquals("The onyl song played aftert song-8 is song-1.", "song-1",
      valuesForSong8.getTopSongs().get(0).getSongId().toString());
}
 
开发者ID:kijiproject,项目名称:kiji-music,代码行数:59,代码来源:TestTopNextSongsPipeline.java

示例3: addColumnDefs

import org.kiji.schema.KijiDataRequestBuilder.ColumnsDef; //导入依赖的package包/类
/**
 * Returns a list of fully qualified KijiColumnNames to return to the client.
 *
 * @param tableLayout is the layout of the table from which the row is being fetched.
 *
 * @param columnsDef is the columns definition object being modified to be passed down to the
 *        KijiTableReader.
 * @param requestedColumns the list of user requested columns to display.
 * @return the list of KijiColumns that will ultimately be displayed. Since this method validates
 *         the list of incoming columns, it's not necessarily the case that what was specified in
 *         the requestedColumns string correspond exactly to the list of outgoing columns. In some
 *         cases it could be less (in case of an invalid column/qualifier) or more in case of
 *         specifying only the family but no qualifiers.
 */
public static List<KijiColumnName> addColumnDefs(KijiTableLayout tableLayout,
    ColumnsDef columnsDef, String requestedColumns) {

  List<KijiColumnName> returnCols = Lists.newArrayList();
  Collection<KijiColumnName> requestedColumnList = null;
  // Check for whether or not *all* columns were requested
  if (requestedColumns == null || requestedColumns.trim().equals("*")) {
    requestedColumnList = tableLayout.getColumnNames();
  } else {
    requestedColumnList = Lists.newArrayList();
    String[] requestedColumnArray = requestedColumns.split(",");
    for (String s : requestedColumnArray) {
      requestedColumnList.add(new KijiColumnName(s));
    }
  }

  Map<String, FamilyLayout> colMap = tableLayout.getFamilyMap();
  // Loop over the columns requested and validate that they exist and/or
  // expand qualifiers
  // in case only family names were specified (in the case of group type
  // families).
  for (KijiColumnName kijiColumn : requestedColumnList) {
    FamilyLayout layout = colMap.get(kijiColumn.getFamily());
    if (null != layout) {
      if (layout.isMapType()) {
        columnsDef.add(kijiColumn);
        returnCols.add(kijiColumn);
      } else {
        Map<String, ColumnLayout> groupColMap = layout.getColumnMap();
        if (kijiColumn.isFullyQualified()) {
          ColumnLayout groupColLayout = groupColMap.get(kijiColumn.getQualifier());
          if (null != groupColLayout) {
            columnsDef.add(kijiColumn);
            returnCols.add(kijiColumn);
          }
        } else {
          for (ColumnLayout c : groupColMap.values()) {
            KijiColumnName fullyQualifiedGroupCol = new KijiColumnName(kijiColumn.getFamily(),
                c.getName());
            columnsDef.add(fullyQualifiedGroupCol);
            returnCols.add(fullyQualifiedGroupCol);
          }
        }
      }
    }
  }

  if (returnCols.isEmpty()) {
    throw new WebApplicationException(new IllegalArgumentException("No columns selected!"),
        Status.BAD_REQUEST);
  }

  return returnCols;
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:69,代码来源:RowResourceUtil.java


注:本文中的org.kiji.schema.KijiDataRequestBuilder.ColumnsDef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。