當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。