Github user lewismc commented on a diff in the pull request:
https://github.com/apache/gora/pull/86#discussion_r78889929
--- Diff:
gora-hbase/src/main/java/org/apache/gora/hbase/store/HBaseTableConnection.java
---
@@ -83,288 +87,129 @@
public HBaseTableConnection(Configuration conf, String tableName,
boolean autoflush)
throws IOException {
this.conf = conf;
+
this.tables = new ThreadLocal<>();
+ this.buffers = new ThreadLocal<>();
+ this.connection = ConnectionFactory.createConnection(conf);
this.tableName = TableName.valueOf(tableName);
+ this.regionLocator = this.connection.getRegionLocator(this.tableName);
+
this.autoFlush = autoflush;
}
-
- private HTable getTable() throws IOException {
- HTable table = tables.get();
+
+ private Table getTable() throws IOException {
+ Table table = tables.get();
if (table == null) {
- table = new HTable(conf, tableName) {
- @Override
- public synchronized void flushCommits() throws
RetriesExhaustedWithDetailsException, InterruptedIOException {
- super.flushCommits();
- }
- };
- table.setAutoFlushTo(autoFlush);
- pool.add(table); //keep track
+ table = connection.getTable(tableName);
+// table.setAutoFlushTo(autoFlush);
+ tPool.add(table); //keep track
tables.set(table);
}
return table;
}
-
- @Override
+
+ private ConcurrentLinkedQueue<Mutation> getBuffer() throws IOException {
+ ConcurrentLinkedQueue<Mutation> buffer = buffers.get();
+ if (buffer == null) {
+// BufferedMutatorParams params = new
BufferedMutatorParams(this.tableName).listener(listener);
+// buffer = connection.getBufferedMutator(this.tableName);
+ buffer = new ConcurrentLinkedQueue<>();
+ bPool.add(buffer);
+ buffers.set(buffer);
+ }
+ return buffer;
+ }
+
+ public void flushCommits() throws IOException {
+ BufferedMutator bufMutator =
connection.getBufferedMutator(this.tableName);
+ for (ConcurrentLinkedQueue<Mutation> buffer : bPool) {
+ for (Mutation m: buffer) {
+ bufMutator.mutate(m);
+ bufMutator.flush();
--- End diff --
OK thanks. I've pushed a PR to @renato2099 which I hope he will add to this
one. You can see the PR at https://github.com/renato2099/gora/pull/1
@renato2099 can you please merge and push the combined PR to this one?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---