You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by je...@apache.org on 2014/03/10 05:21:58 UTC
[27/36] git commit: remove ClientKeyValue
remove ClientKeyValue
Project: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/commit/52a57b5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/tree/52a57b5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/diff/52a57b5e
Branch: refs/heads/4.0
Commit: 52a57b5e452c1da13c3fbc3268974a61ed76037a
Parents: de488ea
Author: Jeffrey Zhong <jz...@JZhongs-MacBook-Pro.local>
Authored: Sun Mar 9 00:50:44 2014 -0800
Committer: Jeffrey Zhong <jz...@JZhongs-MacBook-Pro.local>
Committed: Sun Mar 9 00:50:44 2014 -0800
----------------------------------------------------------------------
.../hbase/index/util/ClientKeyValue.java | 445 -------------------
.../hbase/index/util/ClientKeyValueBuilder.java | 266 -----------
.../hbase/index/util/KeyValueBuilder.java | 8 +-
.../org/apache/phoenix/util/MetaDataUtil.java | 3 +-
.../phoenix/client/TestClientKeyValue.java | 184 --------
.../phoenix/client/TestClientKeyValueLocal.java | 271 -----------
.../phoenix/index/IndexMaintainerTest.java | 10 -
.../apache/phoenix/util/MetaDataUtilTest.java | 3 +-
8 files changed, 3 insertions(+), 1187 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValue.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValue.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValue.java
deleted file mode 100644
index accaf05..0000000
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValue.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
- * 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.phoenix.hbase.index.util;
-
-import java.util.Arrays;
-
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.hadoop.hbase.util.Bytes;
-
-/**
- * {@link KeyValue} that should only be used from the client side. Enables clients to be more
- * flexible with the byte arrays they use when building a {@link KeyValue}, but still wire
- * compatible.
- * <p>
- * All<tt> byte[]</tt> (or {@link ImmutableBytesWritable}) passed into the constructor are only ever
- * read once - when writing <tt>this</tt> onto the wire. They are never copied into another array or
- * reused. This has the advantage of being much more efficient than the usual {@link KeyValue}
- * <p>
- * The down side is that we no longer can support some of the usual methods like
- * {@link #getBuffer()} or {@link #getKey()} since its is backed with multiple <tt>byte[]</tt> and
- * <i>should only be used by the client to <b>send</b> information</i>
- * <p>
- * <b>WARNING:</b> should only be used by advanced users who know how to construct their own
- * KeyValues
- */
-public class ClientKeyValue extends KeyValue {
-
- private static ImmutableBytesWritable NULL = new ImmutableBytesWritable(new byte[0]);
- private ImmutableBytesWritable row;
- private ImmutableBytesWritable family;
- private ImmutableBytesWritable qualifier;
- private Type type;
- private long ts;
- private ImmutableBytesWritable value;
- private KeyValue delegate = null;
-
- /**
- * @param row must not be <tt>null</tt>
- * @param type must not be <tt>null</tt>
- */
- public ClientKeyValue(ImmutableBytesWritable row, ImmutableBytesWritable family,
- ImmutableBytesWritable qualifier, long ts, Type type, ImmutableBytesWritable value) {
- this.row = row;
- this.family = family == null ? NULL : family;
- this.qualifier = qualifier == null ? NULL : qualifier;
- this.type = type;
- this.ts = ts;
- this.value = value == null ? NULL : value;
- }
-
- /**
- * Convenience constructor that just wraps all the bytes in {@link ImmutableBytesWritable}
- */
- public ClientKeyValue(byte[] row, byte[] family, byte[] qualifier, long ts, Type t, byte[] value) {
- this(wrap(row), wrap(family), wrap(qualifier), ts, t, wrap(value));
- }
-
- /**
- * Convenience constructor that just wraps all the bytes in {@link ImmutableBytesWritable}
- */
- public ClientKeyValue(byte[] row, byte[] family, byte[] qualifier, long ts, Type t) {
- this(wrap(row), wrap(family), wrap(qualifier), ts, t, null);
- }
-
- private static ImmutableBytesWritable wrap(byte[] b) {
- return b == null ? NULL : new ImmutableBytesWritable(b);
- }
-
- @Override
- public KeyValue clone() {
- return new ClientKeyValue(copy(row), copy(family), copy(qualifier), ts, type, copy(value));
- }
-
- private ImmutableBytesWritable copy(ImmutableBytesWritable bytes) {
- return new ImmutableBytesWritable(bytes.copyBytes());
- }
-
- private static byte[] copyIfNecessary(ImmutableBytesWritable bytes) {
- byte[] b = bytes.get();
- if (bytes.getLength() == b.length && bytes.getOffset() == 0) {
- return b;
- }
- return Arrays.copyOfRange(b, bytes.getOffset(), bytes.getOffset() + bytes.getLength());
- }
-
- @Override
- public KeyValue shallowCopy() {
- return new ClientKeyValue(row, family, qualifier, ts, type, value);
- }
-
- @Override
- public int getValueOffset() {
- return value.getOffset();
- }
-
- @Override
- public int getValueLength() {
- return value.getLength();
- }
-
- @Override
- public int getRowOffset() {
- return row.getOffset();
- }
-
- @Override
- public short getRowLength() {
- return (short) row.getLength();
- }
-
- @Override
- public int getFamilyOffset() {
- return family.getOffset();
- }
-
- @Override
- public byte getFamilyLength() {
- return (byte) family.getLength();
- }
-
- @Override
- public byte getFamilyLength(int foffset) {
- return this.getFamilyLength();
- }
-
- @Override
- public int getQualifierOffset() {
- return qualifier.getOffset();
- }
-
- @Override
- public int getQualifierLength() {
- return qualifier.getLength();
- }
-
- @Override
- public byte[] getValue() {
- return copyIfNecessary(value);
- }
-
- @Override
- public byte [] getValueArray() {
- return this.value.get();
- }
-
- @Override
- public byte[] getRow() {
- return copyIfNecessary(row);
- }
-
- @Override
- public byte[] getRowArray() {
- return this.row.get();
- }
-
- @Override
- public long getTimestamp() {
- return ts;
- }
-
- @Override
- public byte[] getFamily() {
- return copyIfNecessary(family);
- }
-
- @Override
- public byte[] getFamilyArray() {
- return this.family.get();
- }
-
- @Override
- public byte[] getQualifier() {
- return copyIfNecessary(qualifier);
- }
-
- @Override
- public byte[] getQualifierArray() {
- return this.qualifier.get();
- }
-
- @Override
- public byte getType() {
- return this.type.getCode();
- }
-
- @Override
- public byte getTypeByte() {
- return this.type.getCode();
- }
-
- @Override
- public boolean matchingFamily(byte[] family) {
- if (family == null) {
- if (this.family.getLength() == 0) {
- return true;
- }
- return false;
- }
- return matchingFamily(family, 0, family.length);
- }
-
- public boolean matchingFamily(byte[] family, int offset, int length) {
- if (family == null) {
- if (this.family.getLength() == 0) {
- return true;
- }
- return false;
- }
- return matches(family, offset, length, this.family);
- }
-
- public boolean matchingFamily(KeyValue other) {
- if(other == null) {
- return false;
- }
- if(other instanceof ClientKeyValue) {
- ClientKeyValue kv = (ClientKeyValue)other;
- return this.family.compareTo(kv.family) == 0;
- }
- return matchingFamily(other.getFamilyArray(), other.getFamilyOffset(), other.getFamilyLength());
- }
-
- private boolean matches(byte[] b, int offset, int length, ImmutableBytesWritable bytes) {
- return Bytes.equals(b, offset, length, bytes.get(), bytes.getOffset(), bytes.getLength());
- }
-
- @Override
- public boolean matchingQualifier(byte[] qualifier) {
- if (qualifier == null) {
- if (this.qualifier.getLength() == 0) {
- return true;
- }
- return false;
- }
- return matchingQualifier(qualifier, 0, qualifier.length);
- }
-
- @Override
- public boolean matchingQualifier(byte[] qualifier, int offset, int length) {
- if (qualifier == null) {
- if (this.qualifier.getLength() == 0) {
- return true;
- }
- return false;
- }
- return matches(qualifier, offset, length, this.qualifier);
- }
-
- @Override
- public boolean matchingQualifier(KeyValue other) {
- if (other == null) {
- return false;
- }
- if (other instanceof ClientKeyValue) {
- ClientKeyValue kv = (ClientKeyValue) other;
- return this.row.compareTo(kv.row) == 0;
- }
- return matchingQualifier(other.getQualifierArray(), other.getQualifierOffset(),
- other.getQualifierLength());
- }
-
- @Override
- public boolean matchingRow(byte[] row){
- if (row == null) {
- return false;
- }
- return matches(row, 0, row.length, this.row);
- }
-
- @Override
- public boolean matchingRow(byte[] row, int offset, int length) {
- if (row == null) {
- return false;
- }
- return matches(row, offset, length, this.row);
- }
-
- @Override
- public boolean matchingRow(KeyValue other) {
- return matchingRow(other.getRowArray(), other.getRowOffset(), other.getRowLength());
- }
-
- @Override
- public boolean matchingColumn(byte[] family, byte[] qualifier) {
- return this.matchingFamily(family) && matchingQualifier(qualifier);
- }
-
- @Override
- public int getLength() {
- return KEYVALUE_INFRASTRUCTURE_SIZE + KeyValue.ROW_LENGTH_SIZE + row.getLength()
- + KeyValue.FAMILY_LENGTH_SIZE + family.getLength() + qualifier.getLength()
- + KeyValue.TIMESTAMP_SIZE + KeyValue.TYPE_SIZE + value.getLength();
- }
-
- @Override
- public String toString() {
- return keyToString() + "/vlen=" + getValueLength() + "/ts=" + this.getMvccVersion();
- }
-
- private String keyToString() {
- String row = Bytes.toStringBinary(this.row.get(), this.row.getOffset(), this.row.getLength());
- String family = this.family.getLength() == 0 ? "" : Bytes.toStringBinary(this.family.get(),
- this.family.getOffset(), this.family.getLength());
- String qualifier = this.qualifier.getLength() == 0 ? "" : Bytes.toStringBinary(
- this.qualifier.get(), this.qualifier.getOffset(), this.qualifier.getLength());
- String timestampStr = Long.toString(ts);
- byte type = this.type.getCode();
- return row + "/" + family + (family != null && family.length() > 0 ? ":" : "") + qualifier
- + "/" + timestampStr + "/" + Type.codeToType(type);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (!super.equals(obj)) return false;
- if (getClass() != obj.getClass()) return false;
- ClientKeyValue other = (ClientKeyValue) obj;
- if (family == null) {
- if (other.family != null) return false;
- } else if (!family.equals(other.family)) return false;
- if (qualifier == null) {
- if (other.qualifier != null) return false;
- } else if (!qualifier.equals(other.qualifier)) return false;
- if (row == null) {
- if (other.row != null) return false;
- } else if (!row.equals(other.row)) return false;
- if (ts != other.ts) return false;
- if (type != other.type) return false;
- if (value == null) {
- if (other.value != null) return false;
- } else if (!value.equals(other.value)) return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- // TODO do we need to keep the same hashcode logic as KeyValue? Everywhere else we don't keep
- // them by reference, but presumably clients might hash them.
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + family.hashCode();
- result = prime * result + qualifier.hashCode();
- result = prime * result + row.hashCode();
- result = prime * result + (int) (ts ^ (ts >>> 32));
- result = prime * result + type.hashCode();
- result = prime * result + value.hashCode();
- return result;
- }
-
- @Override
- public int getKeyOffset() {
- return 0;
- }
-
- @Override
- public int getTimestampOffset() {
- return 0;
- }
-
- @Override
- public int getOffset() {
- return 0;
- }
-
- @Override
- public boolean updateLatestStamp(byte[] now) {
- if (this.isLatestTimestamp()) {
- // unfortunately, this is a bit slower than the usual kv, but we don't expect this to happen
- // all that often on the client (unless users are updating the ts this way), as it generally
- // happens on the server
- this.ts = Bytes.toLong(now);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean isLatestTimestamp() {
- return this.ts == HConstants.LATEST_TIMESTAMP;
- }
-
- @Override
- public int getKeyLength() {
- return KEY_INFRASTRUCTURE_SIZE + getRowLength() + getFamilyLength() + getQualifierLength();
- }
-
- @Override
- public byte[] getKey() {
- throw new UnsupportedOperationException(ClientKeyValue.class.getSimpleName()
- + " does not support a single backing buffer.");
- }
-
- @Override
- public String getKeyString() {
- throw new UnsupportedOperationException(ClientKeyValue.class.getSimpleName()
- + " does not support a single backing buffer.");
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public byte[] getBuffer() {
- if (this.delegate != null) {
- return this.delegate.getBuffer();
- }
- this.delegate =
- new KeyValue(row.get(), row.getOffset(), row.getLength(), family.get(), family.getOffset(),
- family.getLength(), qualifier.get(), qualifier.getOffset(), qualifier.getLength(),
- this.ts, type, value.get(), value.getOffset(), value.getLength());
- return this.delegate.getBuffer();
- }
-
- public ImmutableBytesWritable getRawRow() {
- return this.row;
- }
-
- public ImmutableBytesWritable getRawFamily() {
- return this.family;
- }
-
- public ImmutableBytesWritable getRawQualifier() {
- return this.qualifier;
- }
-
- public ImmutableBytesWritable getRawValue() {
- return this.value;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValueBuilder.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValueBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValueBuilder.java
deleted file mode 100644
index 193f724..0000000
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/ClientKeyValueBuilder.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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.phoenix.hbase.index.util;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValue.KVComparator;
-import org.apache.hadoop.hbase.KeyValue.Type;
-import org.apache.hadoop.hbase.client.Mutation;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import com.google.common.collect.Lists;
-import com.google.common.primitives.Longs;
-
-/**
- * A {@link KeyValueBuilder} that builds {@link ClientKeyValue}, eliminating the extra byte copies inherent in the
- * standard {@link KeyValue} implementation.
- * <p>
- * This {@link KeyValueBuilder} is only supported in HBase 0.94.14+ with the addition of HBASE-9834.
- */
-public class ClientKeyValueBuilder extends KeyValueBuilder {
-
- public static final KeyValueBuilder INSTANCE = new ClientKeyValueBuilder();
-
- private ClientKeyValueBuilder() {
- // private ctor for singleton
- }
-
- @Override
- public KeyValue buildPut(ImmutableBytesWritable row, ImmutableBytesWritable family,
- ImmutableBytesWritable qualifier, long ts, ImmutableBytesWritable value) {
- return new ClientKeyValue(row, family, qualifier, ts, Type.Put, value);
- }
-
- @Override
- public KeyValue buildDeleteFamily(ImmutableBytesWritable row, ImmutableBytesWritable family,
- ImmutableBytesWritable qualifier, long ts) {
- return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteFamily, null);
- }
-
- @Override
- public KeyValue buildDeleteColumns(ImmutableBytesWritable row, ImmutableBytesWritable family,
- ImmutableBytesWritable qualifier, long ts) {
- return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteColumn, null);
- }
-
- @Override
- public KeyValue buildDeleteColumn(ImmutableBytesWritable row, ImmutableBytesWritable family,
- ImmutableBytesWritable qualifier, long ts) {
- return new ClientKeyValue(row, family, qualifier, ts, Type.Delete, null);
- }
-
- @Override
- public int compareQualifier(Cell kv, byte[] key, int offset, int length) {
- return Bytes.compareTo(kv.getQualifierArray(), kv.getQualifierOffset(),
- kv.getQualifierLength(), key, offset, length);
- }
-
- @Override
- public void getValueAsPtr(Cell kv, ImmutableBytesWritable ptr) {
- ClientKeyValue ckv = (ClientKeyValue)kv;
- ImmutableBytesWritable value = ckv.getRawValue();
- ptr.set(value.get(), value.getOffset(), value.getLength());
- }
-
- /**
- *
- * Singleton ClientKeyValue version of KVComparator that doesn't assume we
- * have a backing buffer for the key value
- *
- */
- private static class ClientKeyValueComparator extends KVComparator {
- private ClientKeyValueComparator() { // Singleton
- }
-
- public int compareTypes(final Cell left, final Cell right) {
- return left.getTypeByte() - right.getTypeByte();
- }
-
- public int compareMemstoreTimestamps(final Cell left, final Cell right) {
- // Descending order
- return Longs.compare(right.getMvccVersion(), left.getMvccVersion());
- }
-
- public int compareTimestamps(final long ltimestamp, final long rtimestamp) {
- if (ltimestamp < rtimestamp) {
- return 1;
- } else if (ltimestamp > rtimestamp) {
- return -1;
- }
- return 0;
- }
-
- @Override
- public int compareTimestamps(final KeyValue left, final KeyValue right) {
- // Descending order
- return Longs.compare(right.getTimestamp(), left.getTimestamp());
- }
-
-
- @Override
- public int compare(final Cell left, final Cell right) {
- int c = compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
- if (c != 0) return c;
- c = Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
- if (c != 0) return c;
- c = Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
- right.getQualifierLength());
- c = compareTimestamps(left.getTimestamp(), right.getTimestamp());
- if (c != 0) return c;
- c = compareTypes(left, right);
- if (c != 0) return c;
-
- return compareMemstoreTimestamps(left, right);
- }
-
- /**
- * @param left
- * @param right
- * @return Result comparing rows.
- */
- @Override
- public int compareRows(final KeyValue left, final KeyValue right) {
- return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
- }
-
- /**
- * @param left
- * @param lrowlength Length of left row.
- * @param right
- * @param rrowlength Length of right row.
- * @return Result comparing rows.
- */
- @Override
- public int compareRows(byte [] left, int loffset, int llength,
- byte [] right, int roffset, int rlength) {
- return Bytes.compareTo(left, loffset, llength,
- right, roffset, rlength);
- }
-
- /**
- * Compares the row and column of two keyvalues for equality
- * @param left
- * @param right
- * @return True if same row and column.
- */
- @Override
- public boolean matchingRowColumn(final KeyValue left, final KeyValue right) {
- if (compareRows(left, right) != 0) {
- return false;
- }
- if (Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(),
- left.getFamilyLength(), right.getFamilyArray(), right.getFamilyOffset(),
- right.getFamilyLength()) != 0) {
- return false;
- }
- if (Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
- right.getQualifierLength()) != 0) {
- return false;
- }
- return true;
- }
-
- /**
- * Compares the row of two keyvalues for equality
- * @param left
- * @param right
- * @return True if rows match.
- */
- @Override
- public boolean matchingRows(final KeyValue left, final KeyValue right) {
- return compareRows(left, right) == 0;
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- return this; // Makes no sense to clone this
- }
- }
-
- private static final KVComparator COMPARATOR = new ClientKeyValueComparator();
-
- @Override
- public KVComparator getKeyValueComparator() {
- return COMPARATOR;
- }
-
- @Override
- public int compareRow(Cell kv, byte[] rrow, int roffset, int rlength) {
- return Bytes.compareTo(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
- rrow, roffset, rlength);
- }
-
- @Override
- public int compareFamily(Cell kv, byte[] rbuf, int roffset, int rlength) {
- return Bytes.compareTo(kv.getFamilyArray(), kv.getFamilyOffset(),
- kv.getFamilyLength(), rbuf, roffset, rlength);
- }
-
- /**
- * Copy the mutations to that they have a real KeyValue as the memstore
- * requires this.
- */
- @Override
- public List<Mutation> cloneIfNecessary(List<Mutation> mutations) {
- boolean cloneNecessary = false;
- for (Mutation mutation : mutations) {
- if (mutation instanceof Put) {
- cloneNecessary = true;
- break;
- }
- }
- if (!cloneNecessary) {
- return mutations;
- }
- List<Mutation> newMutations = Lists.newArrayListWithExpectedSize(mutations.size());
- for (Mutation mutation : mutations) {
- if (mutation instanceof Put) {
- Put put = (Put)mutation;
- Put newPut = new Put(put.getRow(),put.getTimeStamp());
- Map<byte[],List<Cell>> newFamilyMap = newPut.getFamilyCellMap();
- for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) {
- List<Cell> values = entry.getValue();
- List<Cell> newValues = Lists.newArrayListWithExpectedSize(values.size());
- for (Cell value : values) {
- newValues.add(new KeyValue(value.getRowArray(), value.getRowOffset(),
- value.getRowLength(), value.getFamilyArray(), value.getFamilyOffset(),
- value.getFamilyLength(), value.getQualifierArray(), value.getQualifierOffset(),
- value.getQualifierLength(),value.getTimestamp(), Type.codeToType(value.getTypeByte()),
- value.getValueArray(), value.getValueOffset(), value.getValueLength()));
- }
- newFamilyMap.put(entry.getKey(), newValues);
- }
- newMutations.add(newPut);
- } else {
- newMutations.add(mutation);
- }
- }
- return newMutations;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/KeyValueBuilder.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/KeyValueBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/KeyValueBuilder.java
index fceae09..e3bd7a8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/KeyValueBuilder.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/util/KeyValueBuilder.java
@@ -33,9 +33,7 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
* Build {@link KeyValue} in an efficient way
*/
public abstract class KeyValueBuilder {
- public static final String CLIENT_KEY_VALUE_MIN_VERSION = "0.94.14";
- private static final int CUSTOM_KEY_VALUE_MIN_VERSION = VersionUtil.encodeVersion("0.94.14");
-
+
/**
* Helper method for a {@link KeyValueBuilder} that catches an IOException from a {@link Put}
* when adding a {@link KeyValue} generated by the KeyValueBuilder.
@@ -67,10 +65,6 @@ public abstract class KeyValueBuilder {
}
public static KeyValueBuilder get(String hbaseVersion) {
- int version = VersionUtil.encodeVersion(hbaseVersion);
- if (version >= CUSTOM_KEY_VALUE_MIN_VERSION) {
- return ClientKeyValueBuilder.INSTANCE;
- }
return GenericKeyValueBuilder.INSTANCE;
}
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
index 7cf2769..1af644f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
@@ -31,7 +31,6 @@ import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.coprocessor.MetaDataProtocol;
-import org.apache.phoenix.hbase.index.util.ClientKeyValue;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
import org.apache.phoenix.hbase.index.util.VersionUtil;
@@ -166,7 +165,7 @@ public class MetaDataUtil {
* Get the mutation who's qualifier matches the passed key
* <p>
* We need to pass in an {@link ImmutableBytesPtr} to pass the result back to make life easier
- * when dealing with a regular {@link KeyValue} vs. a {@link ClientKeyValue} as the latter doesn't
+ * when dealing with a regular {@link KeyValue} vs. a custom KeyValue as the latter may not
* support things like {@link KeyValue#getBuffer()}
* @param headerRow mutation to check
* @param key to check
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValue.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValue.java b/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValue.java
deleted file mode 100644
index 01ec4b6..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValue.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.phoenix.client;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValue.Type;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.hbase.index.util.ClientKeyValue;
-import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
-import org.apache.phoenix.util.MinVersionTestRunner;
-import org.apache.phoenix.util.MinVersionTestRunner.MinVersion;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(MinVersionTestRunner.class)
-@MinVersion(KeyValueBuilder.CLIENT_KEY_VALUE_MIN_VERSION)
-public class TestClientKeyValue {
- private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static byte[] ROW = Bytes.toBytes("testRow");
- private static byte[] FAMILY = Bytes.toBytes("testFamily");
- private static byte[] QUALIFIER = Bytes.toBytes("testQualifier");
-
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TEST_UTIL.startMiniCluster();
- }
-
- /**
- * @throws java.lang.Exception
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TEST_UTIL.shutdownMiniCluster();
- }
-
- /**
- * Simple test that a {@link ClientKeyValue} works as expected on a real table
- * @throws Exception
- */
- @Test
- public void testClientKeyValue() throws Exception {
- byte[] TABLE = Bytes.toBytes("testClientKeyValue");
- HTable table = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY });
-
- // create several rows
- Put p = new Put(ROW);
- byte[] v = Bytes.toBytes("v1");
- KeyValue kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 10, Type.Put, v);
- p.add(kv);
- byte[] v2 = Bytes.toBytes("v2");
- kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 11, Type.Put, v2);
- p.add(kv);
- byte[] v3 = Bytes.toBytes("v3");
- kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 12, Type.Put, v3);
- p.add(kv);
-
- table.put(p);
- table.flushCommits();
-
- byte[][] values = new byte[][] { v, v2, v3 };
- long[] times = new long[] { 10, 11, 12 };
- scanAllVersionsAndVerify(table, ROW, FAMILY, QUALIFIER, times, values, 0, 2);
-
- // do a delete of the row as well
- Delete d = new Delete(ROW);
- // start with a point delete
- kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 10, Type.Delete);
- d.addDeleteMarker(kv);
- table.delete(d);
- scanAllVersionsAndVerify(table, ROW, FAMILY, QUALIFIER, times, values, 1, 2);
-
- // delete just that column
- d = new Delete(ROW);
- kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 11, Type.DeleteColumn);
- d.addDeleteMarker(kv);
- table.delete(d);
- scanAllVersionsAndVerify(table, ROW, FAMILY, QUALIFIER, times, values, 2, 2);
-
- // delete the whole family
- kv = new ClientKeyValue(ROW, FAMILY, QUALIFIER, 12, Type.DeleteFamily);
- d.addDeleteMarker(kv);
- table.delete(d);
- scanVersionAndVerifyMissing(table, ROW, FAMILY, QUALIFIER, 12);
-
- // cleanup
- table.close();
- }
-
- private void scanAllVersionsAndVerify(HTable ht, byte[] row, byte[] family, byte[] qualifier,
- long[] stamps, byte[][] values, int start, int end) throws IOException {
- Scan scan = new Scan(row);
- scan.addColumn(family, qualifier);
- scan.setMaxVersions(Integer.MAX_VALUE);
- Result result = getSingleScanResult(ht, scan);
- assertNResult(result, row, family, qualifier, stamps, values, start, end);
- }
-
- private void scanVersionAndVerifyMissing(HTable ht, byte[] row, byte[] family, byte[] qualifier,
- long stamp) throws Exception {
- Scan scan = new Scan(row);
- scan.addColumn(family, qualifier);
- scan.setTimeStamp(stamp);
- scan.setMaxVersions(Integer.MAX_VALUE);
- Result result = getSingleScanResult(ht, scan);
- assertNullResult(result);
- }
-
- private void assertNullResult(Result result) throws Exception {
- assertTrue("expected null result but received a non-null result", result == null);
- }
-
- private Result getSingleScanResult(HTable ht, Scan scan) throws IOException {
- ResultScanner scanner = ht.getScanner(scan);
- Result result = scanner.next();
- scanner.close();
- return result;
- }
-
- private void assertNResult(Result result, byte[] row, byte[] family, byte[] qualifier,
- long[] stamps, byte[][] values, int start, int end) throws IOException {
- assertTrue(
- "Expected row [" + Bytes.toString(row) + "] " + "Got row [" + Bytes.toString(result.getRow())
- + "]", equals(row, result.getRow()));
- int expectedResults = end - start + 1;
- assertEquals(expectedResults, result.size());
-
- KeyValue[] keys = result.raw();
-
- for (int i = 0; i < keys.length; i++) {
- byte[] value = values[end - i];
- long ts = stamps[end - i];
- KeyValue key = keys[i];
-
- assertTrue("(" + i + ") Expected family [" + Bytes.toString(family) + "] " + "Got family ["
- + Bytes.toString(key.getFamily()) + "]", equals(family, key.getFamily()));
- assertTrue("(" + i + ") Expected qualifier [" + Bytes.toString(qualifier) + "] "
- + "Got qualifier [" + Bytes.toString(key.getQualifier()) + "]",
- equals(qualifier, key.getQualifier()));
- assertTrue("Expected ts [" + ts + "] " + "Got ts [" + key.getTimestamp() + "]",
- ts == key.getTimestamp());
- assertTrue("(" + i + ") Expected value [" + Bytes.toString(value) + "] " + "Got value ["
- + Bytes.toString(key.getValue()) + "]", equals(value, key.getValue()));
- }
- }
-
- private boolean equals(byte[] left, byte[] right) {
- if (left == null && right == null) return true;
- if (left == null && right.length == 0) return true;
- if (right == null && left.length == 0) return true;
- return Bytes.equals(left, right);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValueLocal.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValueLocal.java b/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValueLocal.java
deleted file mode 100644
index 4a1170f..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/client/TestClientKeyValueLocal.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * 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.phoenix.client;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValue.Type;
-import org.apache.hadoop.hbase.TestKeyValue;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.io.DataInputBuffer;
-import org.apache.hadoop.io.DataOutputBuffer;
-import org.apache.phoenix.hbase.index.util.ClientKeyValue;
-import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
-import org.apache.phoenix.util.MinVersionTestRunner;
-import org.apache.phoenix.util.MinVersionTestRunner.MinVersion;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Ensure that we can accss a {@link ClientKeyValue} as expected. For instance, write it to bytes
- * and then read it back into a {@link KeyValue} as expected or compare columns to other
- * {@link KeyValue}s.
- */
-@RunWith(MinVersionTestRunner.class)
-@MinVersion(KeyValueBuilder.CLIENT_KEY_VALUE_MIN_VERSION)
-public class TestClientKeyValueLocal {
-
- @Test
- public void testReadWrite() throws IOException {
- byte[] row = Bytes.toBytes("row");
- byte[] family = Bytes.toBytes("family");
- byte[] qualifier = Bytes.toBytes("qualifier");
- byte[] value = Bytes.toBytes("value");
- long ts = 10;
- Type type = KeyValue.Type.Put;
- ClientKeyValue kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type,
- wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
-
- type = Type.Delete;
- kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
-
- type = Type.DeleteColumn;
- kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
-
- type = Type.DeleteFamily;
- kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
-
- type = Type.Maximum;
- kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
-
- // test a couple different variables, to make sure we aren't faking it
- row = Bytes.toBytes("row-never-seen-before1234");
- family = Bytes.toBytes("family-to-test-more");
- qualifier = Bytes.toBytes("untested-qualifier");
- value = Bytes.toBytes("value-that-we-haven't_tested");
- ts = System.currentTimeMillis();
- kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, family, qualifier, ts, type, value);
- }
-
- /**
- * Corner case where values can be null
- * @throws IOException
- */
- @Test
- public void testNullValues() throws IOException {
- byte[] row = Bytes.toBytes("row");
- byte[] family = Bytes.toBytes("family");
- byte[] qualifier = Bytes.toBytes("qualifier");
- long ts = 10;
- Type type = KeyValue.Type.Put;
- byte[] empty = new byte[0];
- // values can be null
- ClientKeyValue kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, null);
- validate(kv, row, family, qualifier, ts, type, empty);
- kv = new ClientKeyValue(row, family, qualifier, ts, type, null);
- validate(kv, row, family, qualifier, ts, type, empty);
- kv = new ClientKeyValue(row, family, qualifier, ts, type);
- validate(kv, row, family, qualifier, ts, type, empty);
-
- // qualifiers can also be null and have null values
- kv = new ClientKeyValue(wrap(row), wrap(family), null, ts, type, null);
- validate(kv, row, family, empty, ts, type, empty);
- kv = new ClientKeyValue(row, family, null, ts, type, null);
- validate(kv, row, family, empty, ts, type, empty);
- kv = new ClientKeyValue(row, family, null, ts, type);
- validate(kv, row, family, empty, ts, type, empty);
- // and also have values
- byte[] value = Bytes.toBytes("value");
- kv = new ClientKeyValue(wrap(row), wrap(family), null, ts, type, wrap(value));
- validate(kv, row, family, empty, ts, type, value);
- kv = new ClientKeyValue(row, family, null, ts, type, value);
- validate(kv, row, family, empty, ts, type, value);
-
- // families can also be null
- kv = new ClientKeyValue(wrap(row), null, null, ts, type, null);
- validate(kv, row, empty, empty, ts, type, empty);
- kv = new ClientKeyValue(row, null, null, ts, type, null);
- validate(kv, row, empty, empty, ts, type, empty);
- kv = new ClientKeyValue(row, null, null, ts, type);
- validate(kv, row, empty, empty, ts, type, empty);
- // but we could have a qualifier
- kv = new ClientKeyValue(wrap(row), null, wrap(qualifier), ts, type, null);
- validate(kv, row, empty, qualifier, ts, type, empty);
- kv = new ClientKeyValue(row, null, qualifier, ts, type, null);
- validate(kv, row, empty, qualifier, ts, type, empty);
- kv = new ClientKeyValue(row, null, qualifier, ts, type);
- validate(kv, row, empty, qualifier, ts, type, empty);
- // or a real value
- kv = new ClientKeyValue(wrap(row), null, wrap(qualifier), ts, type, wrap(value));
- validate(kv, row, empty, qualifier, ts, type, value);
- kv = new ClientKeyValue(row, null, qualifier, ts, type, value);
- validate(kv, row, empty, qualifier, ts, type, value);
- }
-
- private void validate(KeyValue kv, byte[] row, byte[] family, byte[] qualifier, long ts,
- Type type, byte[] value) throws IOException {
- DataOutputBuffer out = new DataOutputBuffer();
- KeyValue.write(kv, out);
- out.close();
- byte[] data = out.getData();
- // read it back in
- DataInputBuffer in = new DataInputBuffer();
- in.reset(data, data.length);
- KeyValue read = KeyValue.create(in);
- in.close();
-
- // validate that its the same
- assertTrue("Row didn't match!", Bytes.equals(row, read.getRow()));
- assertTrue("Family didn't match!", Bytes.equals(family, read.getFamily()));
- assertTrue("Qualifier didn't match!", Bytes.equals(qualifier, read.getQualifier()));
- assertTrue("Value didn't match!", Bytes.equals(value, read.getValue()));
- assertEquals("Timestamp didn't match", ts, read.getTimestamp());
- assertEquals("Type didn't match", type.getCode(), read.getType());
- }
-
- /**
- * Copied from {@link TestKeyValue}
- * @throws Exception
- */
- @Test
- public void testColumnCompare() throws Exception {
- final byte [] a = Bytes.toBytes("aaa");
- byte [] family1 = Bytes.toBytes("abc");
- byte [] qualifier1 = Bytes.toBytes("def");
- byte [] family2 = Bytes.toBytes("abcd");
- byte [] qualifier2 = Bytes.toBytes("ef");
-
- KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
- assertFalse(aaa.matchingColumn(family2, qualifier2));
- assertTrue(aaa.matchingColumn(family1, qualifier1));
- aaa = new ClientKeyValue(a, family2, qualifier2, 0L, Type.Put, a);
- assertFalse(aaa.matchingColumn(family1, qualifier1));
- assertTrue(aaa.matchingColumn(family2,qualifier2));
- byte [] nullQualifier = new byte[0];
- aaa = new ClientKeyValue(a, family1, nullQualifier, 0L, Type.Put, a);
- assertTrue(aaa.matchingColumn(family1,null));
- assertFalse(aaa.matchingColumn(family2,qualifier2));
- }
-
- /**
- * Test a corner case when the family qualifier is a prefix of the column qualifier.
- */
- @Test
- public void testColumnCompare_prefix() throws Exception {
- final byte[] a = Bytes.toBytes("aaa");
- byte[] family1 = Bytes.toBytes("abc");
- byte[] qualifier1 = Bytes.toBytes("def");
- byte[] family2 = Bytes.toBytes("ab");
- byte[] qualifier2 = Bytes.toBytes("def");
-
- KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
- assertFalse(aaa.matchingColumn(family2, qualifier2));
- }
-
- /**
- * Test that we have the expected behavior when adding to a {@link Put}
- * @throws Exception
- */
- @Test
- public void testUsableWithPut() throws Exception {
- final byte[] a = Bytes.toBytes("aaa");
- byte[] family1 = Bytes.toBytes("abc");
- byte[] qualifier1 = Bytes.toBytes("def");
-
- // works fine - matching row
- KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
- Put p = new Put(a);
- p.add(aaa);
-
- // fails, not a matching row
- try {
- aaa = new ClientKeyValue(family1, family1, qualifier1, 0L, Type.Put, a);
- p.add(aaa);
- fail("Shouldn't have been able to add a KV with a row mismatch");
- } catch (IOException e) {
- // noop - as expected
- }
- }
-
- /**
- * Test that we have the expected behavior when adding to a {@link Delete}
- * @throws Exception
- */
- @Test
- public void testUsableWithDelete() throws Exception {
- final byte[] a = Bytes.toBytes("aaa");
- byte[] family1 = Bytes.toBytes("abc");
- byte[] qualifier1 = Bytes.toBytes("def");
-
- KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Delete, a);
- Delete d = new Delete(a);
- // simple cases should work fine
- d.addDeleteMarker(aaa);
- aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.DeleteColumn, a);
- d.addDeleteMarker(aaa);
- aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.DeleteFamily, a);
- d.addDeleteMarker(aaa);
-
- // fails, not a matching row
- try {
- aaa = new ClientKeyValue(family1, family1, qualifier1, 0L, Type.DeleteFamily, a);
- d.addDeleteMarker(aaa);
- fail("Shouldn't have been able to add a KV with a row mismatch");
- } catch (IOException e) {
- // noop - as expected
- }
-
- aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
- try {
- d.addDeleteMarker(aaa);
- fail("Shouldn't have been able to add a KV of type Put");
- } catch (IOException e) {
- // noop
- }
- }
-
- private static ImmutableBytesWritable wrap(byte[] b) {
- return new ImmutableBytesWritable(b);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java
index 8adf9fa..08f26bd 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java
@@ -37,11 +37,9 @@ import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.VersionInfo;
import org.apache.phoenix.end2end.index.IndexTestUtil;
import org.apache.phoenix.hbase.index.ValueGetter;
import org.apache.phoenix.hbase.index.covered.update.ColumnReference;
-import org.apache.phoenix.hbase.index.util.ClientKeyValueBuilder;
import org.apache.phoenix.hbase.index.util.GenericKeyValueBuilder;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
@@ -85,14 +83,6 @@ public class IndexMaintainerTest extends BaseConnectionlessQueryTest {
private void testIndexRowKeyBuilding(String schemaName, String tableName, String dataColumns, String pk, String indexColumns, Object[] values, String includeColumns, String dataProps, String indexProps) throws Exception {
KeyValueBuilder builder = GenericKeyValueBuilder.INSTANCE;
testIndexRowKeyBuilding(schemaName, tableName, dataColumns, pk, indexColumns, values, includeColumns, dataProps, indexProps, builder);
-
- //do the same, but with the client key-value builder, to ensure that works the same
-
- String hbaseVersion = VersionInfo.getVersion();
- if (KeyValueBuilder.get(hbaseVersion) == ClientKeyValueBuilder.INSTANCE) {
- builder = ClientKeyValueBuilder.INSTANCE;
- testIndexRowKeyBuilding(schemaName, tableName, dataColumns, pk, indexColumns, values, includeColumns, dataProps, indexProps, builder);
- }
}
private void testIndexRowKeyBuilding(String schemaName, String tableName, String dataColumns,
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/52a57b5e/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
index f0334f5..427b3bf 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.VersionInfo;
-import org.apache.phoenix.hbase.index.util.ClientKeyValueBuilder;
import org.apache.phoenix.hbase.index.util.GenericKeyValueBuilder;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
@@ -57,7 +56,7 @@ public class MetaDataUtilTest {
}
/**
- * Ensure it supports both the {@link GenericKeyValueBuilder} and {@link ClientKeyValueBuilder}
+ * Ensure it supports {@link GenericKeyValueBuilder}
* @throws Exception on failure
*/
@Test