gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tedyu <...@git.apache.org>
Subject [GitHub] gora pull request #86: GORA-443 Upgrade HBase to 1.2.0
Date Sun, 11 Sep 2016 18:16:59 GMT
Github user tedyu commented on a diff in the pull request:

    https://github.com/apache/gora/pull/86#discussion_r78299720
  
    --- 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 --
    
    This can be lifted outside the for loop.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message