/** * Little helper to set the table byte array. If it's different than the last * table we reset the byte array. Otherwise we just use the existing array. * @param table The table we're operating against */ private void setTable(final String table) { if (!lastTable.equals(table)) { lastTable = table; BigtableTableName tableName = options .getInstanceName() .toTableName(table); lastTableBytes = tableName .toString() .getBytes(); synchronized(this) { if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } bulkMutation = session.createBulkMutation(tableName); } } }
BigtableWriterImpl(BigtableSession session, BigtableTableName tableName) { this.session = session; bulkMutation = session.createBulkMutation(tableName); }
/** * <p>createBulkMutation.</p> * * @param tableName a {@link com.google.cloud.bigtable.grpc.BigtableTableName} object. * @param asyncExecutor a {@link com.google.cloud.bigtable.grpc.async.AsyncExecutor} object. * @return a {@link com.google.cloud.bigtable.grpc.async.BulkMutation} object. * @deprecated use {@link #createBulkMutation(BigtableTableName)} instead. */ @Deprecated public BulkMutation createBulkMutation(BigtableTableName tableName, AsyncExecutor asyncExecutor) { return createBulkMutation(tableName); }
protected BulkOperation( BigtableSession session, BigtableTableName tableName) { this.bulkRead = session.createBulkRead(tableName); this.bulkMutation = session.createBulkMutation(tableName); }
protected BulkOperation( BigtableSession session, BigtableTableName tableName) { this.bulkRead = session.createBulkRead(tableName); this.bulkMutation = session.createBulkMutation(tableName); }
/** * <p> * Constructor for BigtableBufferedMutator. * </p> * @param adapter Converts HBase objects to Bigtable protos * @param configuration For Additional configuration. TODO: move this to options * @param session a {@link com.google.cloud.bigtable.grpc.BigtableSession} to get * {@link com.google.cloud.bigtable.config.BigtableOptions}, * {@link com.google.cloud.bigtable.grpc.async.AsyncExecutor} and * {@link com.google.cloud.bigtable.grpc.async.BulkMutation} objects from starting the * async operations on the BigtableDataClient. */ public BigtableBufferedMutatorHelper( HBaseRequestAdapter adapter, Configuration configuration, BigtableSession session) { this.adapter = adapter; this.configuration = configuration; this.options = session.getOptions(); this.asyncExecutor = session.createAsyncExecutor(); BigtableTableName tableName = this.adapter.getBigtableTableName(); this.bulkMutation = session.createBulkMutation(tableName); }
/** * <p> * Constructor for BigtableBufferedMutator. * </p> * @param adapter Converts HBase objects to Bigtable protos * @param configuration For Additional configuration. TODO: move this to options * @param session a {@link com.google.cloud.bigtable.grpc.BigtableSession} to get * {@link com.google.cloud.bigtable.config.BigtableOptions}, * {@link com.google.cloud.bigtable.grpc.async.AsyncExecutor} and * {@link com.google.cloud.bigtable.grpc.async.BulkMutation} objects from starting the * async operations on the BigtableDataClient. */ public BigtableBufferedMutatorHelper( HBaseRequestAdapter adapter, Configuration configuration, BigtableSession session) { this.adapter = adapter; this.configuration = configuration; this.options = session.getOptions(); this.asyncExecutor = session.createAsyncExecutor(); BigtableTableName tableName = this.adapter.getBigtableTableName(); this.bulkMutation = session.createBulkMutation(tableName); }
@Before public void setup() { MockitoAnnotations.initMocks(this); BigtableOptions options = new BigtableOptions.Builder().setProjectId("project").setInstanceId("instance").build(); when(mockSession.getOptions()).thenReturn(options); when(mockSession.createBulkMutation(eq(TABLE_NAME))).thenReturn(mockBulkMutation); when(mockSession.getDataClient()).thenReturn(mockBigtableDataClient); }