Skip to content

Commit 5a445ad

Browse files
committed
PHOENIX-7476 HBase 3 compatibility changes for Filters, ByteStringer, and Paging
1 parent 095617f commit 5a445ad

File tree

31 files changed

+454
-40
lines changed

31 files changed

+454
-40
lines changed

phoenix-core-client/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
4848
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.BlockingRpcCallback;
4949
import org.apache.hadoop.hbase.ipc.ServerRpcController;
50-
import org.apache.hadoop.hbase.util.ByteStringer;
50+
import org.apache.phoenix.compat.hbase.ByteStringer;
5151
import org.apache.hadoop.hbase.util.Bytes;
5252
import org.apache.phoenix.compile.QueryPlan;
5353
import org.apache.phoenix.compile.ScanRanges;

phoenix-core-client/src/main/java/org/apache/phoenix/coprocessorclient/MetaDataProtocol.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.NavigableMap;
2525
import java.util.TreeMap;
2626

27-
import org.apache.hadoop.hbase.util.ByteStringer;
27+
import org.apache.phoenix.compat.hbase.ByteStringer;
2828
import org.apache.phoenix.coprocessor.generated.MetaDataProtos;
2929
import org.apache.phoenix.coprocessor.generated.MetaDataProtos.MetaDataResponse;
3030
import org.apache.phoenix.coprocessor.generated.MetaDataProtos.MetaDataService;

phoenix-core-client/src/main/java/org/apache/phoenix/filter/AllVersionsIndexRebuildFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public AllVersionsIndexRebuildFilter(Filter originalFilter) {
3333
super(originalFilter);
3434
}
3535

36-
@Override
36+
// No @Override for HBase 3 compatibility
3737
public ReturnCode filterKeyValue(Cell v) throws IOException {
3838
return filterCell(v);
3939
}

phoenix-core-client/src/main/java/org/apache/phoenix/filter/DelegateFilter.java

-11
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222

2323
import org.apache.hadoop.hbase.Cell;
24-
import org.apache.hadoop.hbase.KeyValue;
2524
import org.apache.hadoop.hbase.filter.Filter;
2625
import org.apache.hadoop.hbase.filter.FilterBase;
2726

@@ -38,11 +37,6 @@ public void reset() throws IOException {
3837
delegate.reset();
3938
}
4039

41-
@Override
42-
public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException {
43-
return delegate.filterRowKey(buffer, offset, length);
44-
}
45-
4640
@Override
4741
public boolean filterRowKey(Cell cell) throws IOException {
4842
return delegate.filterRowKey(cell);
@@ -58,11 +52,6 @@ public boolean filterAllRemaining() throws IOException {
5852
return delegate.filterAllRemaining();
5953
}
6054

61-
@Override
62-
public ReturnCode filterKeyValue(Cell v) throws IOException {
63-
return delegate.filterKeyValue(v);
64-
}
65-
6655
@Override
6756
public Cell transformCell(Cell v) throws IOException {
6857
return delegate.transformCell(v);

phoenix-core-client/src/main/java/org/apache/phoenix/filter/DistinctPrefixFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void setOffset(int offset) {
5757
this.offset = offset;
5858
}
5959

60-
@Override
60+
// No @Override for HBase 3 compatibility
6161
public ReturnCode filterKeyValue(Cell v) throws IOException {
6262
return filterCell(v);
6363
}

phoenix-core-client/src/main/java/org/apache/phoenix/filter/PagingFilter.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.hadoop.hbase.filter.FilterBase;
3333
import org.apache.hadoop.hbase.util.Writables;
3434
import org.apache.hadoop.io.Writable;
35+
import org.apache.phoenix.compat.hbase.CompatPagingFilter;
3536
import org.apache.phoenix.util.EnvironmentEdgeManager;
3637

3738
/**
@@ -71,19 +72,19 @@
7172
* filterRowKey(). In this method, PagingFilter records the last row that is scanned.
7273
*
7374
*/
74-
public class PagingFilter extends FilterBase implements Writable {
75+
public class PagingFilter extends CompatPagingFilter implements Writable {
7576
private long pageSizeMs;
7677
private long startTime;
7778
// tracks the row we last visited
7879
private Cell currentCell;
7980
private boolean isStopped;
80-
private Filter delegate = null;
8181

8282
public PagingFilter() {
83+
super(null);
8384
}
8485

8586
public PagingFilter(Filter delegate, long pageSizeMs) {
86-
this.delegate = delegate;
87+
super(delegate);
8788
this.pageSizeMs = pageSizeMs;
8889
}
8990

@@ -208,14 +209,6 @@ public boolean isFamilyEssential(byte[] name) throws IOException {
208209
return super.isFamilyEssential(name);
209210
}
210211

211-
@Override
212-
public ReturnCode filterKeyValue(Cell v) throws IOException {
213-
if (delegate != null) {
214-
return delegate.filterKeyValue(v);
215-
}
216-
return super.filterKeyValue(v);
217-
}
218-
219212
@Override
220213
public Filter.ReturnCode filterCell(Cell c) throws IOException {
221214
if (delegate != null) {

phoenix-core-client/src/main/java/org/apache/phoenix/filter/RowKeyComparisonFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void reset() {
6565
* Evaluate in filterKeyValue instead of filterRowKey, because HBASE-6562 causes filterRowKey
6666
* to be called with deleted or partial row keys.
6767
*/
68-
@Override
68+
// No @Override for HBase 3 compatibility
6969
public ReturnCode filterKeyValue(Cell v) {
7070
return filterCell(v);
7171
}

phoenix-core-client/src/main/java/org/apache/phoenix/filter/UnverifiedRowFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void reset() throws IOException {
6868
delegate.reset();
6969
}
7070

71-
@Override
71+
// No @Override for HBase 3 compatibility
7272
public ReturnCode filterKeyValue(Cell v) throws IOException {
7373
return filterCell(v);
7474
}

phoenix-core-client/src/main/java/org/apache/phoenix/index/CDCTableInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.phoenix.index;
2020

21-
import org.apache.hadoop.hbase.util.ByteStringer;
21+
import org.apache.phoenix.compat.hbase.ByteStringer;
2222
import org.apache.phoenix.compile.StatementContext;
2323
import org.apache.phoenix.compile.TupleProjectionCompiler;
2424
import org.apache.phoenix.coprocessor.generated.CDCInfoProtos;

phoenix-core-client/src/main/java/org/apache/phoenix/index/IndexMaintainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import org.apache.hadoop.hbase.client.Mutation;
5151
import org.apache.hadoop.hbase.client.Put;
5252
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
53-
import org.apache.hadoop.hbase.util.ByteStringer;
53+
import org.apache.phoenix.compat.hbase.ByteStringer;
5454
import org.apache.hadoop.hbase.util.Bytes;
5555
import org.apache.hadoop.hbase.util.Pair;
5656
import org.apache.hadoop.io.Writable;

phoenix-core-client/src/main/java/org/apache/phoenix/parse/PFunction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.List;
2323

2424
import org.apache.hadoop.hbase.HConstants;
25-
import org.apache.hadoop.hbase.util.ByteStringer;
25+
import org.apache.phoenix.compat.hbase.ByteStringer;
2626
import org.apache.phoenix.coprocessor.generated.PFunctionProtos;
2727
import org.apache.phoenix.coprocessor.generated.PFunctionProtos.PFunctionArg;
2828
import org.apache.phoenix.expression.LiteralExpression;

phoenix-core-client/src/main/java/org/apache/phoenix/protobuf/ProtobufUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.hadoop.hbase.ipc.ServerRpcController;
2929
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;
3030
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
31-
import org.apache.hadoop.hbase.util.ByteStringer;
31+
import org.apache.phoenix.compat.hbase.ByteStringer;
3232
import org.apache.hadoop.util.StringUtils;
3333
import org.apache.phoenix.coprocessor.generated.ChildLinkMetaDataProtos.CreateViewAddChildLinkRequest;
3434
import org.apache.phoenix.coprocessor.generated.MetaDataProtos;

phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
import org.apache.hadoop.hbase.security.AccessDeniedException;
182182
import org.apache.hadoop.hbase.security.User;
183183
import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
184-
import org.apache.hadoop.hbase.util.ByteStringer;
184+
import org.apache.phoenix.compat.hbase.ByteStringer;
185185
import org.apache.hadoop.hbase.util.Bytes;
186186
import org.apache.hadoop.hbase.util.Pair;
187187
import org.apache.hadoop.hbase.util.VersionInfo;

phoenix-core-client/src/main/java/org/apache/phoenix/schema/PColumnImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.phoenix.schema;
1919

2020
import org.apache.hadoop.hbase.HConstants;
21-
import org.apache.hadoop.hbase.util.ByteStringer;
21+
import org.apache.phoenix.compat.hbase.ByteStringer;
2222
import org.apache.phoenix.coprocessor.generated.PTableProtos;
2323
import org.apache.phoenix.query.QueryConstants;
2424
import org.apache.phoenix.schema.types.PDataType;

phoenix-core-client/src/main/java/org/apache/phoenix/schema/PTableImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import org.apache.hadoop.hbase.client.Mutation;
6060
import org.apache.hadoop.hbase.client.Put;
6161
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
62-
import org.apache.hadoop.hbase.util.ByteStringer;
62+
import org.apache.phoenix.compat.hbase.ByteStringer;
6363
import org.apache.hadoop.hbase.util.Bytes;
6464
import org.apache.hadoop.hbase.util.Pair;
6565
import org.apache.phoenix.compile.ExpressionCompiler;
@@ -141,7 +141,7 @@
141141
import org.apache.hadoop.hbase.client.Mutation;
142142
import org.apache.hadoop.hbase.client.Put;
143143
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
144-
import org.apache.hadoop.hbase.util.ByteStringer;
144+
import org.apache.phoenix.compat.hbase.ByteStringer;
145145
import org.apache.hadoop.hbase.util.Bytes;
146146
import org.apache.hadoop.hbase.util.Pair;
147147
import org.apache.phoenix.compile.ExpressionCompiler;

phoenix-core-client/src/main/java/org/apache/phoenix/schema/transform/TransformMaintainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.hadoop.hbase.client.Delete;
2525
import org.apache.hadoop.hbase.client.Put;
2626
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
27-
import org.apache.hadoop.hbase.util.ByteStringer;
27+
import org.apache.phoenix.compat.hbase.ByteStringer;
2828
import org.apache.hadoop.hbase.util.Pair;
2929
import org.apache.hadoop.io.WritableUtils;
3030
import org.apache.phoenix.coprocessor.generated.ServerCachingProtos;

phoenix-core-client/src/main/java/org/apache/phoenix/util/ValidateLastDDLTimestampUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.hadoop.hbase.HConstants;
2929
import org.apache.hadoop.hbase.ServerName;
3030
import org.apache.hadoop.hbase.client.Admin;
31-
import org.apache.hadoop.hbase.util.ByteStringer;
31+
import org.apache.phoenix.compat.hbase.ByteStringer;
3232
import org.apache.phoenix.coprocessor.generated.RegionServerEndpointProtos;
3333
import org.apache.phoenix.exception.StaleMetadataCacheException;
3434
import org.apache.phoenix.jdbc.PhoenixConnection;

phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRegionServerEndpointIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.apache.hadoop.hbase.HConstants;
2121
import org.apache.hadoop.hbase.ipc.ServerRpcController;
2222
import org.apache.hadoop.hbase.regionserver.HRegionServer;
23-
import org.apache.hadoop.hbase.util.ByteStringer;
23+
import org.apache.phoenix.compat.hbase.ByteStringer;
2424
import org.apache.hadoop.hbase.util.Bytes;
2525
import org.apache.phoenix.coprocessor.PhoenixRegionServerEndpoint;
2626
import org.apache.phoenix.coprocessor.generated.RegionServerEndpointProtos;

phoenix-core/src/it/java/org/apache/phoenix/end2end/index/InvalidIndexStateClientSideIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.apache.hadoop.hbase.client.coprocessor.Batch;
3232
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.BlockingRpcCallback;
3333
import org.apache.hadoop.hbase.ipc.ServerRpcController;
34-
import org.apache.hadoop.hbase.util.ByteStringer;
34+
import org.apache.phoenix.compat.hbase.ByteStringer;
3535
import org.apache.phoenix.coprocessor.generated.MetaDataProtos.GetTableRequest;
3636
import org.apache.phoenix.coprocessor.generated.MetaDataProtos.MetaDataResponse;
3737
import org.apache.phoenix.coprocessor.generated.MetaDataProtos.MetaDataService;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.phoenix.compat.hbase;
19+
20+
import com.google.protobuf.ByteString;
21+
22+
// This has different signature in the HBase 2 and 3 modules
23+
// This only comes together after the maven-replacer plugin relocates all protobuf code.
24+
public class ByteStringer {
25+
public static ByteString wrap(final byte[] array) {
26+
return org.apache.hadoop.hbase.util.ByteStringer.wrap(array);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.phoenix.compat.hbase;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.hadoop.hbase.Cell;
23+
import org.apache.hadoop.hbase.filter.Filter;
24+
import org.apache.hadoop.hbase.filter.FilterBase;
25+
26+
public class CompatDelegateFilter extends FilterBase {
27+
protected Filter delegate = null;
28+
29+
public CompatDelegateFilter(Filter delegate) {
30+
this.delegate = delegate;
31+
}
32+
33+
@Override
34+
public ReturnCode filterKeyValue(Cell v) throws IOException {
35+
return delegate.filterKeyValue(v);
36+
}
37+
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.phoenix.compat.hbase;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.hadoop.hbase.Cell;
23+
import org.apache.hadoop.hbase.filter.Filter;
24+
import org.apache.hadoop.hbase.filter.FilterBase;
25+
26+
public abstract class CompatPagingFilter extends FilterBase {
27+
protected Filter delegate = null;
28+
29+
public CompatPagingFilter(Filter delegate) {
30+
this.delegate = delegate;
31+
}
32+
33+
@Override
34+
public ReturnCode filterKeyValue(Cell v) throws IOException {
35+
36+
if (delegate != null) {
37+
return delegate.filterKeyValue(v);
38+
}
39+
return super.filterKeyValue(v);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.phoenix.compat.hbase;
19+
20+
import com.google.protobuf.ByteString;
21+
22+
// This has different signature in the HBase 2 and 3 modules
23+
// This only comes together after the maven-replacer plugin relocates all protobuf code.
24+
public class ByteStringer {
25+
public static ByteString wrap(final byte[] array) {
26+
return org.apache.hadoop.hbase.util.ByteStringer.wrap(array);
27+
}
28+
}

0 commit comments

Comments
 (0)