Package org.kiji.schema.layout

Examples of org.kiji.schema.layout.KijiTableLayout


      HBaseScanOptions scanOptions = kijiScannerOptions.getHBaseScanOptions();

      final ReaderLayoutCapsule capsule = mReaderLayoutCapsule;
      final HBaseDataRequestAdapter dataRequestAdapter =
          new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator());
      final KijiTableLayout tableLayout = capsule.getLayout();
      validateRequestAgainstLayout(dataRequest, tableLayout);
      final Scan scan = dataRequestAdapter.toScan(tableLayout, scanOptions);

      if (null != startRow) {
        scan.setStartRow(startRow.getHBaseRowKey());
View Full Code Here


        "Cannot get scanner from KijiTableReader instance %s in state %s.", this, state);

    final ReaderLayoutCapsule capsule = mReaderLayoutCapsule;
    final HBaseDataRequestAdapter adapter =
        new HBaseDataRequestAdapter(request, capsule.getColumnNameTranslator());
    final KijiTableLayout layout = capsule.getLayout();
    validateRequestAgainstLayout(request, layout);
    final Scan scan = adapter.toScan(layout, scannerOptions.getHBaseScanOptions());
    if (null != scannerOptions.getStartRow()) {
      scan.setStartRow(scannerOptions.getStartRow().getHBaseRowKey());
    }
View Full Code Here

    final Kiji kiji = Kiji.Factory.open(argURI, getConf());
    try {
      final KijiTable table = kiji.openTable(argURI.getTable());
      try {
        final KijiTableLayout tableLayout = table.getLayout();

        final Map<FamilyLayout, List<String>> mapTypeFamilies =
            ToolUtils.getMapTypeFamilies(argURI.getColumns(), tableLayout);

        final Map<FamilyLayout, List<ColumnLayout>> groupTypeColumns =
View Full Code Here

        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw new RuntimeInterruptedException(e);
        }
      } else {
        final KijiTableLayout layout =
            mMetaTable.getTableLayout(mTableURI.getTable()).setSchemaTable(mSchemaTable);
        mLayout.set(layout);
      }
      return this;
    }
View Full Code Here

                mTableURI);
            mLayout.set(null);
            return;
          }

          final KijiTableLayout newLayout =
              mMetaTable.getTableLayout(mTableURI.getTable()).setSchemaTable(mSchemaTable);

          Preconditions.checkState(
              Objects.equal(newLayout.getDesc().getLayoutId(), notifiedLayoutID),
              "New layout ID %s does not match most recent layout ID %s from meta-table.",
              notifiedLayoutID, newLayout.getDesc().getLayoutId());

          mLayout.set(newLayout);

          // Propagates the new layout to all consumers. A copy of mConsumers is made in order to
          // avoid concurrent modifications while iterating. The contract of Guava's ImmutableSet
View Full Code Here

   * Implements the --do=dump operation.
   *
   * @throws Exception on error.
   */
  private void dumpLayout() throws Exception {
    final KijiTableLayout layout = mKiji.getMetaTable().getTableLayout(mTableURI.getTable());
    final StringBuilder json = new StringBuilder();
    json.append("/*\n");
    json.append("   The raw JSON view of table layouts is intended for use by\n");
    json.append("   system administrators or for debugging purposes.\n");
    json.append("\n");
    json.append("   Most users should use the 'kiji-schema-shell' DDL tool to modify\n");
    json.append("   your table layouts instead.\n");
    json.append("*/\n");
    json.append(ToJson.toJsonString(layout.getDesc()));
    if (mWriteTo.isEmpty()) {
      System.out.println(json.toString());
    } else {
      final String fileName = String.format("%s.json", mWriteTo);
      final FileOutputStream fos = new FileOutputStream(fileName);
View Full Code Here

    if (timedLayouts.isEmpty()) {
      throw new RuntimeException("No such table: " + mTableURI.getTable());
    }
    for (Map.Entry<Long, KijiTableLayout> entry: timedLayouts.entrySet()) {
      final long timestamp = entry.getKey();
      final KijiTableLayout layout = entry.getValue();
      final String json = ToJson.toJsonString(layout.getDesc());

      if (mWriteTo.isEmpty()) {
        // SCHEMA-14: Add a newline to separate the dumped JSON versions of the layout.
        System.out.printf("timestamp: %d:%n%s%n", timestamp, json);
      } else {
View Full Code Here

            .setSchemaFormat(SchemaFormat.UID));

    // Fetch all the layout history:
    final List<KijiTableLayout> layouts =
        getTableLayoutVersions(tableName, HConstants.ALL_VERSIONS);
    final KijiTableLayout currentLayout = layouts.isEmpty() ? null : layouts.get(0);
    final KijiTableLayout tableLayout = KijiTableLayout.createUpdatedLayout(update, currentLayout);

    Preconditions.checkArgument(tableName.equals(tableLayout.getName()));

    // Set of all the former layout IDs:
    final Set<String> layoutIDs = Sets.newHashSet();
    for (KijiTableLayout layout : layouts) {
      layoutIDs.add(layout.getDesc().getLayoutId());
    }

    final String refLayoutIdStr = update.getReferenceLayout();

    final boolean hasCurrentLayout = (null != currentLayout);
    final boolean hasRefLayoutId = (null != refLayoutIdStr);
    if (hasCurrentLayout && !hasRefLayoutId) {
      throw new IOException(String.format(
          "Layout for table '%s' does not specify reference layout ID.", tableName));
    }
    if (!hasCurrentLayout && hasRefLayoutId) {
      throw new IOException(String.format(
          "Initial layout for table '%s' must not specify reference layout ID.", tableName));
    }

    final String layoutId = tableLayout.getDesc().getLayoutId();

    if (layoutIDs.contains(layoutId)) {
      throw new InvalidLayoutException(tableLayout,
          String.format("Layout ID '%s' already exists", layoutId));
    }

    // Construct the Put request to write the layout to the HTable.
    final byte[] tableNameBytes = Bytes.toBytes(tableName);
    final Put put = new Put(tableNameBytes)
        .add(mFamilyBytes, QUALIFIER_UPDATE_BYTES, encodeTableLayoutDesc(update))
        .add(mFamilyBytes, QUALIFIER_LAYOUT_BYTES, encodeTableLayoutDesc(tableLayout.getDesc()))
        .add(mFamilyBytes, QUALIFIER_LAYOUT_ID_BYTES, Bytes.toBytes(layoutId));

    // Flush the writer schema for the Avro table layout first so other readers can see it.
    mSchemaTable.flush();
View Full Code Here

    Preconditions.checkState(qualifierMap.size() == 1);
    final NavigableMap<Long, byte[]> timeSerieMap = qualifierMap.get(qualifierMap.firstKey());
    for (Map.Entry<Long, byte[]> timeSerieEntry : timeSerieMap.entrySet()) {
      final long timestamp = timeSerieEntry.getKey();
      final byte[] bytes = timeSerieEntry.getValue();
      final KijiTableLayout layout = KijiTableLayout.newLayout(decodeTableLayoutDesc(bytes));
      Preconditions.checkState(timedLayouts.put(timestamp, layout) == null);
    }
    return timedLayouts;
  }
View Full Code Here

            .withFilter(mColumnRequest.getFilter())
            .withMaxVersions(maxVersions)
            .add(mColumnName))
        .build();

    final KijiTableLayout layout = mTable.getLayout();
    final HBaseDataRequestAdapter adapter =
        new HBaseDataRequestAdapter(nextPageDataRequest, HBaseColumnNameTranslator.from(layout));
    try {
      final Get hbaseGet = adapter.toGet(mEntityId, layout);
      LOG.debug("Sending HBase Get: {}", hbaseGet);
View Full Code Here

TOP

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

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.