[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-03 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r434750284



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,543 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Private
+public final class ImmutableScan extends Scan {
+
+  private final Scan delegateScan;
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {

Review comment:
   Now we dont have to keep this throws IOE at this constructor.  So below 
catch stuff in CustomizedScanInfoBuilder also can be avoided.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-02 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r434041695



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,549 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Private
+public final class ImmutableScan extends Scan {
+
+  private final Scan delegateScan;
+
+  /**
+   * Create Immutable instance of Scan
+   */
+  public ImmutableScan() {
+this.delegateScan = new Scan();
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {
+this.delegateScan = new Scan(scan);

Review comment:
   As we are not exposing the original Scan directly, why to create a new 
Scan again here? No need 

##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,549 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Private
+public final class ImmutableScan extends Scan {
+
+  private final Scan delegateScan;
+
+  /**
+   * Create Immutable instance of Scan
+   */
+  public ImmutableScan() {
+this.delegateScan = new Scan();
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {
+this.delegateScan = new Scan(scan);
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Get object
+   *
+   * @param get Get to model Scan after
+   */
+  public ImmutableScan(Get get) {

Review comment:
   As of now we dont have this constructor req right? If not better not add 
now. When there is a need, we can add. At the place where we create this 
ImmutableScan, already the Get would have been converted to scan

##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,549 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additio

[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-02 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r434041067



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,549 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Private
+public final class ImmutableScan extends Scan {
+
+  private final Scan delegateScan;
+
+  /**
+   * Create Immutable instance of Scan
+   */
+  public ImmutableScan() {

Review comment:
   When it is delegate model, better get the delegate via constructor arg 
always. Let the creator pass a new Scan() to this explicitly. Pls avoid this 
constructor.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-01 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r433431811



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,477 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Public
+public final class ImmutableScan extends Scan {
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {
+super(scan);
+super.setIsolationLevel(scan.getIsolationLevel());
+Map> familyMap = scan.getFamilyMap();
+for (Map.Entry> entry : familyMap.entrySet()) 
{
+  byte[] family = entry.getKey();
+  NavigableSet cols = entry.getValue();
+  if (cols != null && cols.size() > 0) {
+for (byte[] col : cols) {
+  super.addColumn(family, col);
+}
+  } else {
+super.addFamily(family);
+  }
+}
+for (Map.Entry attr : scan.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
scan.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(scan.getPriority());
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Get object
+   *
+   * @param get Get to model Scan after
+   */
+  public ImmutableScan(Get get) {
+super(get);
+super.setIsolationLevel(get.getIsolationLevel());
+for (Map.Entry attr : get.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
get.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(get.getPriority());
+  }
+
+  /**
+   * Create a new Scan with a cursor. It only set the position information 
like start row key.
+   * The others (like cfs, stop row, limit) should still be filled in by the 
user.
+   * {@link Result#isCursor()}
+   * {@link Result#getCursor()}
+   * {@link Cursor}
+   */
+  public static Scan createScanFromCursor(Cursor cursor) {

Review comment:
   It is not just wrapper.  ImmutableScan will have both is-a and has-a 
relationship.  So what we will pass to CPs will be Scan type only. In reality 
that will be a wrapper.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-01 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r433387520



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,477 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Public
+public final class ImmutableScan extends Scan {
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {
+super(scan);
+super.setIsolationLevel(scan.getIsolationLevel());
+Map> familyMap = scan.getFamilyMap();
+for (Map.Entry> entry : familyMap.entrySet()) 
{
+  byte[] family = entry.getKey();
+  NavigableSet cols = entry.getValue();
+  if (cols != null && cols.size() > 0) {
+for (byte[] col : cols) {
+  super.addColumn(family, col);
+}
+  } else {
+super.addFamily(family);
+  }
+}
+for (Map.Entry attr : scan.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
scan.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(scan.getPriority());
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Get object
+   *
+   * @param get Get to model Scan after
+   */
+  public ImmutableScan(Get get) {
+super(get);
+super.setIsolationLevel(get.getIsolationLevel());
+for (Map.Entry attr : get.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
get.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(get.getPriority());
+  }
+
+  /**
+   * Create a new Scan with a cursor. It only set the position information 
like start row key.
+   * The others (like cfs, stop row, limit) should still be filled in by the 
user.
+   * {@link Result#isCursor()}
+   * {@link Result#getCursor()}
+   * {@link Cursor}
+   */
+  public static Scan createScanFromCursor(Cursor cursor) {

Review comment:
   can we try making ImmutableScan as a wrapper over actual Scan object.  
The setters in the ImmutableScan can throw Exception and getter can just 
delegate to original Scan object





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-01 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r433221328



##
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ImmutableScan.java
##
@@ -0,0 +1,477 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.NavigableSet;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.io.TimeRange;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Immutable version of Scan
+ */
+@InterfaceAudience.Public
+public final class ImmutableScan extends Scan {
+
+  /**
+   * Create Immutable instance of Scan from given Scan object
+   *
+   * @param scan Copy all values from Scan
+   * @throws IOException From parent constructor
+   */
+  public ImmutableScan(Scan scan) throws IOException {
+super(scan);
+super.setIsolationLevel(scan.getIsolationLevel());
+Map> familyMap = scan.getFamilyMap();
+for (Map.Entry> entry : familyMap.entrySet()) 
{
+  byte[] family = entry.getKey();
+  NavigableSet cols = entry.getValue();
+  if (cols != null && cols.size() > 0) {
+for (byte[] col : cols) {
+  super.addColumn(family, col);
+}
+  } else {
+super.addFamily(family);
+  }
+}
+for (Map.Entry attr : scan.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
scan.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(scan.getPriority());
+  }
+
+  /**
+   * Create Immutable instance of Scan from given Get object
+   *
+   * @param get Get to model Scan after
+   */
+  public ImmutableScan(Get get) {
+super(get);
+super.setIsolationLevel(get.getIsolationLevel());
+for (Map.Entry attr : get.getAttributesMap().entrySet()) {
+  super.setAttribute(attr.getKey(), attr.getValue());
+}
+for (Map.Entry entry : 
get.getColumnFamilyTimeRange().entrySet()) {
+  TimeRange tr = entry.getValue();
+  super.setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
+}
+super.setPriority(get.getPriority());
+  }
+
+  /**
+   * Create a new Scan with a cursor. It only set the position information 
like start row key.
+   * The others (like cfs, stop row, limit) should still be filled in by the 
user.
+   * {@link Result#isCursor()}
+   * {@link Result#getCursor()}
+   * {@link Cursor}
+   */
+  public static Scan createScanFromCursor(Cursor cursor) {

Review comment:
   This ImmutableScan is not exposed and will not be exposed in future 
also. This is a way for us to make sure the CPs wont try set any thing on the 
passed Scan object.  So why we need this createScanFromCursor() method at all?  
 Because of this u have this isObjInit based code in many places. Keep it 
simple I would say. Just get rid of all these.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [hbase] anoopsjohn commented on a change in pull request #1818: HBASE-24456 : Create ImmutableScan and use it for CustomizedScanInfoBuilder

2020-06-01 Thread GitBox


anoopsjohn commented on a change in pull request #1818:
URL: https://github.com/apache/hbase/pull/1818#discussion_r433219336



##
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CustomizedScanInfoBuilder.java
##
@@ -42,13 +43,18 @@
 
   public CustomizedScanInfoBuilder(ScanInfo scanInfo) {
 this.scanInfo = scanInfo;
-this.scan = new Scan();
+try {
+  this.scan = new ImmutableScan(new Scan());

Review comment:
   This is used by tests only ?
   Do u want to create ImmutableScan over a new Scan()?  Or direct new 
ImmutableScan is enough?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org