/** {@inheritDoc} */ @Override public void deleteTable(String tableName) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot delete table in Fiji instance %s in state %s.", this, state); // Delete from Cassandra. final FijiURI tableURI = FijiURI.newBuilder(mURI).withTableName(tableName).build(); final FijiTableLayout layout = mMetaTable.getTableLayout(tableName); final List<ResultSetFuture> futures = Lists.newArrayListWithCapacity(layout.getLocalityGroups().size()); for (LocalityGroupLayout localityGroup : layout.getLocalityGroups()) { final String delete = CQLUtils.getDropTableStatement( CassandraTableName.getLocalityGroupTableName(tableURI, localityGroup.getId())); futures.add(mAdmin.executeAsync(delete)); } // Delete from the meta table getMetaTable().deleteTable(tableName); for (ResultSetFuture future : futures) { future.getUninterruptibly(); } }
/** * Creates a buffered fiji table writer that stores modifications to be sent on command * or when the buffer is full. * * @param table A fiji table. * @throws com.moz.fiji.schema.FijiTableNotFoundException in case of an invalid table parameter * @throws java.io.IOException in case of IO errors. */ public CassandraFijiBufferedWriter(final CassandraFijiTable table) throws IOException { mTable = table; mLayoutConsumerRegistration = mTable.registerLayoutConsumer(new InnerLayoutUpdater()); Preconditions.checkState( mCapsule != null, "CassandraFijiBufferedWriter for table: %s failed to initialize.", mTable.getURI()); mBufferedStatements = ArrayListMultimap.create( mTable.getLayout().getLocalityGroups().size(), (int) mMaxWriteBufferSize); // Retain the table only after everything else succeeded: mTable.retain(); synchronized (mMonitor) { Preconditions.checkState(mState == State.UNINITIALIZED, "Cannot open CassandraFijiBufferedWriter instance in state %s.", mState); mState = State.OPEN; } ResourceTracker.get().registerResource(this); }
/** {@inheritDoc} */ @Override public void deleteRow(final EntityId entityId) throws IOException { synchronized (mMonitor) { final FijiTableLayout layout = mCapsule.getLayout(); final CassandraFijiTable tableURI = mTable; for (LocalityGroupLayout localityGroup : layout.getLocalityGroups()) { final CassandraTableName table = CassandraTableName.getLocalityGroupTableName(tableURI.getURI(), localityGroup.getId()); final Statement delete = mTable.getStatementCache().createLocalityGroupDeleteStatement(table, entityId); mBufferedStatements.put(table, delete); mCurrentWriteBufferSize += 1; } if (mCurrentWriteBufferSize > mMaxWriteBufferSize) { flush(); } } }
/** * Delete all cells from a row with a timestamp less than or equal to the specified timestamp. * * <p>Note HBase does not represent row deletions with individual (cross-family) * tombstones. Instead, this method issues a family delete for each locality group * individually.</p> * * @param entityId Entity ID of the row to delete data from. * @param upToTimestamp Delete cells with a timestamp older or equal to this parameter. * @throws IOException on I/O error. */ @Override public void deleteRow(EntityId entityId, long upToTimestamp) throws IOException { for (LocalityGroupLayout localityGroupLayout : mTable.getLayout().getLocalityGroups()) { final HFileKeyValue mrKey = new HFileKeyValue( entityId.getHBaseRowKey(), localityGroupLayout.getId().toByteArray(), HConstants.EMPTY_BYTE_ARRAY, upToTimestamp, HFileKeyValue.Type.DeleteFamily, HConstants.EMPTY_BYTE_ARRAY); write(mrKey); } }
Lists.newArrayListWithCapacity(tableLayout.getLocalityGroups().size()); for (LocalityGroupLayout localityGroup : layout.getLocalityGroups()) { tables.add(CassandraTableName.getLocalityGroupTableName(tableURI, localityGroup.getId()));