/** {@inheritDoc} */ @Override public int hashCode() { return getDesc().hashCode(); }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(CassandraFijiTable.class) .add("id", System.identityHashCode(this)) .add("uri", mTableURI) .add("retain_counter", mRetainCount.get()) .add("layout_id", getLayout().getDesc().getLayoutId()) .add("state", mState.get()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { String layoutId = mState.get() == State.OPEN ? mLayoutMonitor.getLayout().getDesc().getLayoutId() : "unknown"; return Objects.toStringHelper(HBaseFijiTable.class) .add("id", System.identityHashCode(this)) .add("uri", mTableURI) .add("retain_counter", mRetainCount.get()) .add("layout_id", layoutId) .add("state", mState.get()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(CassandraFijiTableReader.class) .add("id", System.identityHashCode(this)) .add("table", mTable.getURI()) .add("layout-version", mReaderLayoutCapsule.getLayout().getDesc().getLayoutId()) .add("state", mState.get()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(HBaseFijiTableReader.class) .add("id", System.identityHashCode(this)) .add("table", mTable.getURI()) .add("layout-version", mReaderLayoutCapsule.getLayout().getDesc().getLayoutId()) .add("state", mState.get()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(HBaseFijiTableWriter.class) .add("id", System.identityHashCode(this)) .add("table", mTable.getURI()) .add("layout-version", mWriterLayoutCapsule.getLayout().getDesc().getLayoutId()) .add("state", mState) .toString(); } }
/** {@inheritDoc} */ @Deprecated @Override public void createTable(String tableName, FijiTableLayout tableLayout) throws IOException { if (!tableName.equals(tableLayout.getName())) { throw new RuntimeException(String.format( "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName)); } createTable(tableLayout.getDesc()); }
/** {@inheritDoc} */ @Deprecated @Override public void createTable(String tableName, FijiTableLayout tableLayout) throws IOException { if (!tableName.equals(tableLayout.getName())) { throw new RuntimeException(String.format( "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName)); } createTable(tableLayout.getDesc()); }
/** {@inheritDoc} */ @Deprecated @Override public void createTable(String tableName, FijiTableLayout tableLayout, int numRegions) throws IOException { if (!tableName.equals(tableLayout.getName())) { throw new RuntimeException(String.format( "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName)); } createTable(tableLayout.getDesc(), numRegions); }
/** * Gets the RowKeyFormat2 of the provided layout, if it exists. Otherwise, null. * * @param layout of the table to find the RowKeyFormat2. * @return the RowKeyFormat2, null if the layout has RowKeyFormat1. * @throws IOException if the keys format can not be ascertained. */ private static RowKeyFormat2 getRKF2(final FijiTableLayout layout) throws IOException { if (null != layout && RowKeyEncoding.FORMATTED == getEncoding(layout.getDesc().getKeysFormat())) { return (RowKeyFormat2) layout.getDesc().getKeysFormat(); } else { return null; } }
/** * Gets the RowKeyFormat2 of the provided layout, if it exists. Otherwise, null. * * @param layout of the table to find the RowKeyFormat2. * @return the RowKeyFormat2, null if the layout has RowKeyFormat1. * @throws IOException if the keys format can not be ascertained. */ private static RowKeyFormat2 getRKF2(final FijiTableLayout layout) throws IOException { if (null != layout && RowKeyEncoding.FORMATTED == getEncoding(layout.getDesc().getKeysFormat())) { return (RowKeyFormat2) layout.getDesc().getKeysFormat(); } else { return null; } }
/** * Create a new {@code FormattedRowKeyDecoder}. * * @param layout The table layout. */ private FormattedRowKeyDecoder(final FijiTableLayout layout) { mTokenColumn = CQLUtils.getTokenColumn(layout); mKeyFormat = (RowKeyFormat2) layout.getDesc().getKeysFormat(); }
/** {@inheritDoc} */ @Deprecated @Override public void createTable( final String tableName, final FijiTableLayout tableLayout, final byte[][] splitKeys ) throws IOException { Preconditions.checkArgument(tableName.equals(tableLayout.getName()), "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName); createTable(tableLayout.getDesc()); }
/** {@inheritDoc} */ @Deprecated @Override public void createTable( final String tableName, final FijiTableLayout tableLayout, final int numRegions ) throws IOException { Preconditions.checkArgument(tableName.equals(tableLayout.getName()), "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName); createTable(tableLayout.getDesc(), numRegions); }
/** * Creates a new {@link CassandraColumnNameTranslator} instance. Supports the * {@link ShortColumnNameTranslator} based on the table layout. * * @param tableLayout The layout of the table to translate column names for. * @return {@link CassandraColumnNameTranslator} of the appropriate type. */ public static CassandraColumnNameTranslator from(FijiTableLayout tableLayout) { switch (tableLayout.getDesc().getColumnNameTranslator()) { case SHORT: return new ShortColumnNameTranslator(tableLayout); default: throw new UnsupportedOperationException(String.format( "Unsupported CassandraColumnNameTranslator: %s for column: %s.", tableLayout.getDesc().getColumnNameTranslator(), tableLayout.getName())); } }
/** * Creates an entity ID factory for the row key format given by the specified * table layout. * * @param fijiTableLayout the layout of the fiji table. * @return a new entity ID factory. */ public static EntityIdFactory getFactory(FijiTableLayout fijiTableLayout) { Object rowKeyFormat = fijiTableLayout.getDesc().getKeysFormat(); if (rowKeyFormat instanceof RowKeyFormat) { return getFactory((RowKeyFormat) rowKeyFormat); } else if (rowKeyFormat instanceof RowKeyFormat2) { return getFactory((RowKeyFormat2) rowKeyFormat); } else { throw new RuntimeException("Fiji Table has unknown RowKeyFormat" + rowKeyFormat.getClass().getName()); } }
/** * Constructs an Entity ID factory from a layout capsule. * * @param layout layout to construct an entity ID factory from. * @return a new entity ID factory as described from the table layout. */ private static EntityIdFactory createEntityIdFactory(final FijiTableLayout layout) { final Object format = layout.getDesc().getKeysFormat(); if (format instanceof RowKeyFormat) { return EntityIdFactory.getFactory((RowKeyFormat) format); } else if (format instanceof RowKeyFormat2) { return EntityIdFactory.getFactory((RowKeyFormat2) format); } else { throw new RuntimeException("Invalid Row Key format found in Fiji Table: " + format); } }
/** * Return the ordered list of columns in the partition key for the table layout. * * @param layout to return partition key columns for. * @return the primary key columns for the layout. */ public static List<String> getPartitionKeyColumns(FijiTableLayout layout) { RowKeyFormat2 keyFormat = (RowKeyFormat2) layout.getDesc().getKeysFormat(); switch (keyFormat.getEncoding()) { case RAW: return Lists.newArrayList(RAW_KEY_COL); case FORMATTED: return transformToColumns( keyFormat.getComponents().subList(0, keyFormat.getRangeScanStartIndex())); default: throw new IllegalArgumentException( String.format("Unknown row key encoding %s.", keyFormat.getEncoding())); } }
/** {@inheritDoc} */ @Deprecated @Override public void createTable(String tableName, FijiTableLayout tableLayout, byte[][] splitKeys) throws IOException { if (getMetaTable().tableExists(tableName)) { final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); throw new FijiAlreadyExistsException(String.format( "Fiji table '%s' already exists.", tableURI), tableURI); } if (!tableName.equals(tableLayout.getName())) { throw new RuntimeException(String.format( "Table name from layout descriptor '%s' does match table name '%s'.", tableLayout.getName(), tableName)); } createTable(tableLayout.getDesc(), splitKeys); }