You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2017/08/02 16:33:54 UTC
[22/51] [partial] hbase git commit: HBASE-17056 Remove checked in PB
generated files
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyFieldLite.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyFieldLite.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyFieldLite.java
deleted file mode 100644
index 91b70e0..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyFieldLite.java
+++ /dev/null
@@ -1,437 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-import java.io.IOException;
-
-/**
- * LazyFieldLite encapsulates the logic of lazily parsing message fields. It stores
- * the message in a ByteString initially and then parses it on-demand.
- *
- * LazyFieldLite is thread-compatible: concurrent reads are safe once the proto that this
- * LazyFieldLite is a part of is no longer being mutated by its Builder. However, explicit
- * synchronization is needed under read/write situations.
- *
- * When a LazyFieldLite is used in the context of a MessageLite object, its behavior is considered
- * to be immutable and none of the setter methods in its API are expected to be invoked. All of the
- * getters are expected to be thread-safe. When used in the context of a MessageLite.Builder,
- * setters can be invoked, but there is no guarantee of thread safety.
- *
- * TODO(yatin,dweis): Consider splitting this class's functionality and put the mutable methods
- * into a separate builder class to allow us to give stronger compile-time guarantees.
- *
- * This class is internal implementation detail of the protobuf library, so you don't need to use it
- * directly.
- *
- * @author xiangl@google.com (Xiang Li)
- */
-public class LazyFieldLite {
- private static final ExtensionRegistryLite EMPTY_REGISTRY =
- ExtensionRegistryLite.getEmptyRegistry();
-
- /**
- * The value associated with the LazyFieldLite object is stored in one or more of the following
- * three fields (delayedBytes, value, memoizedBytes). They should together be interpreted as
- * follows.
- * 1) delayedBytes can be non-null, while value and memoizedBytes is null. The object will be in
- * this state while the value for the object has not yet been parsed.
- * 2) Both delayedBytes and value are non-null. The object transitions to this state as soon as
- * some caller needs to access the value (by invoking getValue()).
- * 3) memoizedBytes is merely an optimization for calls to LazyFieldLite.toByteString() to avoid
- * recomputing the ByteString representation on each call. Instead, when the value is parsed
- * from delayedBytes, we will also assign the contents of delayedBytes to memoizedBytes (since
- * that is the ByteString representation of value).
- * 4) Finally, if the LazyFieldLite was created directly with a parsed MessageLite value, then
- * delayedBytes will be null, and memoizedBytes will be initialized only upon the first call to
- * LazyFieldLite.toByteString().
- *
- * Given the above conditions, any caller that needs a serialized representation of this object
- * must first check if the memoizedBytes or delayedBytes ByteString is non-null and use it
- * directly; if both of those are null, it can look at the parsed value field. Similarly, any
- * caller that needs a parsed value must first check if the value field is already non-null, if
- * not it must parse the value from delayedBytes.
- */
-
- /**
- * A delayed-parsed version of the contents of this field. When this field is non-null, then the
- * "value" field is allowed to be null until the time that the value needs to be read.
- *
- * When delayedBytes is non-null then {@code extensionRegistry} is required to also be non-null.
- * {@code value} and {@code memoizedBytes} will be initialized lazily.
- */
- private ByteString delayedBytes;
-
- /**
- * An {@code ExtensionRegistryLite} for parsing bytes. It is non-null on a best-effort basis. It
- * is only guaranteed to be non-null if this message was initialized using bytes and an
- * {@code ExtensionRegistry}. If it directly had a value set then it will be null, unless it has
- * been merged with another {@code LazyFieldLite} that had an {@code ExtensionRegistry}.
- */
- private ExtensionRegistryLite extensionRegistry;
-
- /**
- * The parsed value. When this is null and a caller needs access to the MessageLite value, then
- * {@code delayedBytes} will be parsed lazily at that time.
- */
- protected volatile MessageLite value;
-
- /**
- * The memoized bytes for {@code value}. This is an optimization for the toByteString() method to
- * not have to recompute its return-value on each invocation.
- * TODO(yatin): Figure out whether this optimization is actually necessary.
- */
- private volatile ByteString memoizedBytes;
-
- /**
- * Constructs a LazyFieldLite with bytes that will be parsed lazily.
- */
- public LazyFieldLite(ExtensionRegistryLite extensionRegistry, ByteString bytes) {
- checkArguments(extensionRegistry, bytes);
- this.extensionRegistry = extensionRegistry;
- this.delayedBytes = bytes;
- }
-
- /**
- * Constructs a LazyFieldLite with no contents, and no ability to parse extensions.
- */
- public LazyFieldLite() {
- }
-
- /**
- * Constructs a LazyFieldLite instance with a value. The LazyFieldLite may not be able to parse
- * the extensions in the value as it has no ExtensionRegistry.
- */
- public static LazyFieldLite fromValue(MessageLite value) {
- LazyFieldLite lf = new LazyFieldLite();
- lf.setValue(value);
- return lf;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof LazyFieldLite)) {
- return false;
- }
-
- LazyFieldLite other = (LazyFieldLite) o;
-
- // Lazy fields do not work well with equals... If both are delayedBytes, we do not have a
- // mechanism to deserialize them so we rely on bytes equality. Otherwise we coerce into an
- // actual message (if necessary) and call equals on the message itself. This implies that two
- // messages can by unequal but then be turned equal simply be invoking a getter on a lazy field.
- MessageLite value1 = value;
- MessageLite value2 = other.value;
- if (value1 == null && value2 == null) {
- return toByteString().equals(other.toByteString());
- } else if (value1 != null && value2 != null) {
- return value1.equals(value2);
- } else if (value1 != null) {
- return value1.equals(other.getValue(value1.getDefaultInstanceForType()));
- } else {
- return getValue(value2.getDefaultInstanceForType()).equals(value2);
- }
- }
-
- @Override
- public int hashCode() {
- // We can't provide a memoizable hash code for lazy fields. The byte strings may have different
- // hash codes but evaluate to equivalent messages. And we have no facility for constructing
- // a message here if we were not already holding a value.
- return 1;
- }
-
- /**
- * Determines whether this LazyFieldLite instance represents the default instance of this type.
- */
- public boolean containsDefaultInstance() {
- return memoizedBytes == ByteString.EMPTY
- || value == null && (delayedBytes == null || delayedBytes == ByteString.EMPTY);
- }
-
- /**
- * Clears the value state of this instance.
- *
- * <p>LazyField is not thread-safe for write access. Synchronizations are needed
- * under read/write situations.
- */
- public void clear() {
- // Don't clear the ExtensionRegistry. It might prove useful later on when merging in another
- // value, but there is no guarantee that it will contain all extensions that were directly set
- // on the values that need to be merged.
- delayedBytes = null;
- value = null;
- memoizedBytes = null;
- }
-
- /**
- * Overrides the contents of this LazyField.
- *
- * <p>LazyField is not thread-safe for write access. Synchronizations are needed
- * under read/write situations.
- */
- public void set(LazyFieldLite other) {
- this.delayedBytes = other.delayedBytes;
- this.value = other.value;
- this.memoizedBytes = other.memoizedBytes;
- // If the other LazyFieldLite was created by directly setting the value rather than first by
- // parsing, then it will not have an extensionRegistry. In this case we hold on to the existing
- // extensionRegistry, which has no guarantees that it has all the extensions that will be
- // directly set on the value.
- if (other.extensionRegistry != null) {
- this.extensionRegistry = other.extensionRegistry;
- }
- }
-
- /**
- * Returns message instance. It may do some thread-safe delayed parsing of bytes.
- *
- * @param defaultInstance its message's default instance. It's also used to get parser for the
- * message type.
- */
- public MessageLite getValue(MessageLite defaultInstance) {
- ensureInitialized(defaultInstance);
- return value;
- }
-
- /**
- * Sets the value of the instance and returns the old value without delay parsing anything.
- *
- * <p>LazyField is not thread-safe for write access. Synchronizations are needed
- * under read/write situations.
- */
- public MessageLite setValue(MessageLite value) {
- MessageLite originalValue = this.value;
- this.delayedBytes = null;
- this.memoizedBytes = null;
- this.value = value;
- return originalValue;
- }
-
- /**
- * Merges another instance's contents. In some cases may drop some extensions if both fields
- * contain data. If the other field has an {@code ExtensionRegistry} but this does not, then this
- * field will copy over that {@code ExtensionRegistry}.
- *
- * <p>LazyField is not thread-safe for write access. Synchronizations are needed
- * under read/write situations.
- */
- public void merge(LazyFieldLite other) {
- if (other.containsDefaultInstance()) {
- return;
- }
-
- if (this.containsDefaultInstance()) {
- set(other);
- return;
- }
-
- // If the other field has an extension registry but this does not, copy over the other extension
- // registry.
- if (this.extensionRegistry == null) {
- this.extensionRegistry = other.extensionRegistry;
- }
-
- // In the case that both of them are not parsed we simply concatenate the bytes to save time. In
- // the (probably rare) case that they have different extension registries there is a chance that
- // some of the extensions may be dropped, but the tradeoff of making this operation fast seems
- // to outway the benefits of combining the extension registries, which is not normally done for
- // lite protos anyways.
- if (this.delayedBytes != null && other.delayedBytes != null) {
- this.delayedBytes = this.delayedBytes.concat(other.delayedBytes);
- return;
- }
-
- // At least one is parsed and both contain data. We won't drop any extensions here directly, but
- // in the case that the extension registries are not the same then we might in the future if we
- // need to serialze and parse a message again.
- if (this.value == null && other.value != null) {
- setValue(mergeValueAndBytes(other.value, this.delayedBytes, this.extensionRegistry));
- return;
- } else if (this.value != null && other.value == null) {
- setValue(mergeValueAndBytes(this.value, other.delayedBytes, other.extensionRegistry));
- return;
- }
-
- // At this point we have two fully parsed messages.
- setValue(this.value.toBuilder().mergeFrom(other.value).build());
- }
-
- /**
- * Merges another instance's contents from a stream.
- *
- * <p>LazyField is not thread-safe for write access. Synchronizations are needed
- * under read/write situations.
- */
- public void mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
- throws IOException {
- if (this.containsDefaultInstance()) {
- setByteString(input.readBytes(), extensionRegistry);
- return;
- }
-
- // If the other field has an extension registry but this does not, copy over the other extension
- // registry.
- if (this.extensionRegistry == null) {
- this.extensionRegistry = extensionRegistry;
- }
-
- // In the case that both of them are not parsed we simply concatenate the bytes to save time. In
- // the (probably rare) case that they have different extension registries there is a chance that
- // some of the extensions may be dropped, but the tradeoff of making this operation fast seems
- // to outway the benefits of combining the extension registries, which is not normally done for
- // lite protos anyways.
- if (this.delayedBytes != null) {
- setByteString(this.delayedBytes.concat(input.readBytes()), this.extensionRegistry);
- return;
- }
-
- // We are parsed and both contain data. We won't drop any extensions here directly, but in the
- // case that the extension registries are not the same then we might in the future if we
- // need to serialize and parse a message again.
- try {
- setValue(value.toBuilder().mergeFrom(input, extensionRegistry).build());
- } catch (InvalidProtocolBufferException e) {
- // Nothing is logged and no exceptions are thrown. Clients will be unaware that a proto
- // was invalid.
- }
- }
-
- private static MessageLite mergeValueAndBytes(
- MessageLite value, ByteString otherBytes, ExtensionRegistryLite extensionRegistry) {
- try {
- return value.toBuilder().mergeFrom(otherBytes, extensionRegistry).build();
- } catch (InvalidProtocolBufferException e) {
- // Nothing is logged and no exceptions are thrown. Clients will be unaware that a proto
- // was invalid.
- return value;
- }
- }
-
- /**
- * Sets this field with bytes to delay-parse.
- */
- public void setByteString(ByteString bytes, ExtensionRegistryLite extensionRegistry) {
- checkArguments(extensionRegistry, bytes);
- this.delayedBytes = bytes;
- this.extensionRegistry = extensionRegistry;
- this.value = null;
- this.memoizedBytes = null;
- }
-
- /**
- * Due to the optional field can be duplicated at the end of serialized
- * bytes, which will make the serialized size changed after LazyField
- * parsed. Be careful when using this method.
- */
- public int getSerializedSize() {
- // We *must* return delayed bytes size if it was ever set because the dependent messages may
- // have memoized serialized size based off of it.
- if (memoizedBytes != null) {
- return memoizedBytes.size();
- } else if (delayedBytes != null) {
- return delayedBytes.size();
- } else if (value != null) {
- return value.getSerializedSize();
- } else {
- return 0;
- }
- }
-
- /**
- * Returns a BytesString for this field in a thread-safe way.
- */
- public ByteString toByteString() {
- if (memoizedBytes != null) {
- return memoizedBytes;
- }
- // We *must* return delayed bytes if it was set because the dependent messages may have
- // memoized serialized size based off of it.
- if (delayedBytes != null) {
- return delayedBytes;
- }
- synchronized (this) {
- if (memoizedBytes != null) {
- return memoizedBytes;
- }
- if (value == null) {
- memoizedBytes = ByteString.EMPTY;
- } else {
- memoizedBytes = value.toByteString();
- }
- return memoizedBytes;
- }
- }
-
- /**
- * Might lazily parse the bytes that were previously passed in. Is thread-safe.
- */
- protected void ensureInitialized(MessageLite defaultInstance) {
- if (value != null) {
- return;
- }
- synchronized (this) {
- if (value != null) {
- return;
- }
- try {
- if (delayedBytes != null) {
- // The extensionRegistry shouldn't be null here since we have delayedBytes.
- MessageLite parsedValue = defaultInstance.getParserForType()
- .parseFrom(delayedBytes, extensionRegistry);
- this.value = parsedValue;
- this.memoizedBytes = delayedBytes;
- } else {
- this.value = defaultInstance;
- this.memoizedBytes = ByteString.EMPTY;
- }
- } catch (InvalidProtocolBufferException e) {
- // Nothing is logged and no exceptions are thrown. Clients will be unaware that this proto
- // was invalid.
- this.value = defaultInstance;
- this.memoizedBytes = ByteString.EMPTY;
- }
- }
- }
-
-
- private static void checkArguments(ExtensionRegistryLite extensionRegistry, ByteString bytes) {
- if (extensionRegistry == null) {
- throw new NullPointerException("found null ExtensionRegistry");
- }
- if (bytes == null) {
- throw new NullPointerException("found null ByteString");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringArrayList.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringArrayList.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringArrayList.java
deleted file mode 100644
index 1f99489..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringArrayList.java
+++ /dev/null
@@ -1,423 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.RandomAccess;
-
-/**
- * An implementation of {@link LazyStringList} that wraps an ArrayList. Each
- * element is one of String, ByteString, or byte[]. It caches the last one
- * requested which is most likely the one needed next. This minimizes memory
- * usage while satisfying the most common use cases.
- * <p>
- * <strong>Note that this implementation is not synchronized.</strong>
- * If multiple threads access an <tt>ArrayList</tt> instance concurrently,
- * and at least one of the threads modifies the list structurally, it
- * <i>must</i> be synchronized externally. (A structural modification is
- * any operation that adds or deletes one or more elements, or explicitly
- * resizes the backing array; merely setting the value of an element is not
- * a structural modification.) This is typically accomplished by
- * synchronizing on some object that naturally encapsulates the list.
- * <p>
- * If the implementation is accessed via concurrent reads, this is thread safe.
- * Conversions are done in a thread safe manner. It's possible that the
- * conversion may happen more than once if two threads attempt to access the
- * same element and the modifications were not visible to each other, but this
- * will not result in any corruption of the list or change in behavior other
- * than performance.
- *
- * @author jonp@google.com (Jon Perlow)
- */
-public class LazyStringArrayList extends AbstractProtobufList<String>
- implements LazyStringList, RandomAccess {
-
- private static final LazyStringArrayList EMPTY_LIST = new LazyStringArrayList();
- static {
- EMPTY_LIST.makeImmutable();
- }
-
- static LazyStringArrayList emptyList() {
- return EMPTY_LIST;
- }
-
- // For compatibility with older runtimes.
- public static final LazyStringList EMPTY = EMPTY_LIST;
-
- private final List<Object> list;
-
- public LazyStringArrayList() {
- this(DEFAULT_CAPACITY);
- }
-
- public LazyStringArrayList(int intialCapacity) {
- this(new ArrayList<Object>(intialCapacity));
- }
-
- public LazyStringArrayList(LazyStringList from) {
- list = new ArrayList<Object>(from.size());
- addAll(from);
- }
-
- public LazyStringArrayList(List<String> from) {
- this(new ArrayList<Object>(from));
- }
-
- private LazyStringArrayList(ArrayList<Object> list) {
- this.list = list;
- }
-
- @Override
- public LazyStringArrayList mutableCopyWithCapacity(int capacity) {
- if (capacity < size()) {
- throw new IllegalArgumentException();
- }
- ArrayList<Object> newList = new ArrayList<Object>(capacity);
- newList.addAll(list);
- return new LazyStringArrayList(newList);
- }
-
- @Override
- public String get(int index) {
- Object o = list.get(index);
- if (o instanceof String) {
- return (String) o;
- } else if (o instanceof ByteString) {
- ByteString bs = (ByteString) o;
- String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- list.set(index, s);
- }
- return s;
- } else {
- byte[] ba = (byte[]) o;
- String s = Internal.toStringUtf8(ba);
- if (Internal.isValidUtf8(ba)) {
- list.set(index, s);
- }
- return s;
- }
- }
-
- @Override
- public int size() {
- return list.size();
- }
-
- @Override
- public String set(int index, String s) {
- ensureIsMutable();
- Object o = list.set(index, s);
- return asString(o);
- }
-
- @Override
- public void add(int index, String element) {
- ensureIsMutable();
- list.add(index, element);
- modCount++;
- }
-
- private void add(int index, ByteString element) {
- ensureIsMutable();
- list.add(index, element);
- modCount++;
- }
-
- private void add(int index, byte[] element) {
- ensureIsMutable();
- list.add(index, element);
- modCount++;
- }
-
- @Override
- public boolean addAll(Collection<? extends String> c) {
- // The default implementation of AbstractCollection.addAll(Collection)
- // delegates to add(Object). This implementation instead delegates to
- // addAll(int, Collection), which makes a special case for Collections
- // which are instances of LazyStringList.
- return addAll(size(), c);
- }
-
- @Override
- public boolean addAll(int index, Collection<? extends String> c) {
- ensureIsMutable();
- // When copying from another LazyStringList, directly copy the underlying
- // elements rather than forcing each element to be decoded to a String.
- Collection<?> collection = c instanceof LazyStringList
- ? ((LazyStringList) c).getUnderlyingElements() : c;
- boolean ret = list.addAll(index, collection);
- modCount++;
- return ret;
- }
-
- @Override
- public boolean addAllByteString(Collection<? extends ByteString> values) {
- ensureIsMutable();
- boolean ret = list.addAll(values);
- modCount++;
- return ret;
- }
-
- @Override
- public boolean addAllByteArray(Collection<byte[]> c) {
- ensureIsMutable();
- boolean ret = list.addAll(c);
- modCount++;
- return ret;
- }
-
- @Override
- public String remove(int index) {
- ensureIsMutable();
- Object o = list.remove(index);
- modCount++;
- return asString(o);
- }
-
- @Override
- public void clear() {
- ensureIsMutable();
- list.clear();
- modCount++;
- }
-
- @Override
- public void add(ByteString element) {
- ensureIsMutable();
- list.add(element);
- modCount++;
- }
-
- @Override
- public void add(byte[] element) {
- ensureIsMutable();
- list.add(element);
- modCount++;
- }
-
- @Override
- public Object getRaw(int index) {
- return list.get(index);
- }
-
- @Override
- public ByteString getByteString(int index) {
- Object o = list.get(index);
- ByteString b = asByteString(o);
- if (b != o) {
- list.set(index, b);
- }
- return b;
- }
-
- @Override
- public byte[] getByteArray(int index) {
- Object o = list.get(index);
- byte[] b = asByteArray(o);
- if (b != o) {
- list.set(index, b);
- }
- return b;
- }
-
- @Override
- public void set(int index, ByteString s) {
- setAndReturn(index, s);
- }
-
- private Object setAndReturn(int index, ByteString s) {
- ensureIsMutable();
- return list.set(index, s);
- }
-
- @Override
- public void set(int index, byte[] s) {
- setAndReturn(index, s);
- }
-
- private Object setAndReturn(int index, byte[] s) {
- ensureIsMutable();
- return list.set(index, s);
- }
-
- private static String asString(Object o) {
- if (o instanceof String) {
- return (String) o;
- } else if (o instanceof ByteString) {
- return ((ByteString) o).toStringUtf8();
- } else {
- return Internal.toStringUtf8((byte[]) o);
- }
- }
-
- private static ByteString asByteString(Object o) {
- if (o instanceof ByteString) {
- return (ByteString) o;
- } else if (o instanceof String) {
- return ByteString.copyFromUtf8((String) o);
- } else {
- return ByteString.copyFrom((byte[]) o);
- }
- }
-
- private static byte[] asByteArray(Object o) {
- if (o instanceof byte[]) {
- return (byte[]) o;
- } else if (o instanceof String) {
- return Internal.toByteArray((String) o);
- } else {
- return ((ByteString) o).toByteArray();
- }
- }
-
- @Override
- public List<?> getUnderlyingElements() {
- return Collections.unmodifiableList(list);
- }
-
- @Override
- public void mergeFrom(LazyStringList other) {
- ensureIsMutable();
- for (Object o : other.getUnderlyingElements()) {
- if (o instanceof byte[]) {
- byte[] b = (byte[]) o;
- // Byte array's content is mutable so they should be copied rather than
- // shared when merging from one message to another.
- list.add(Arrays.copyOf(b, b.length));
- } else {
- list.add(o);
- }
- }
- }
-
- private static class ByteArrayListView extends AbstractList<byte[]>
- implements RandomAccess {
- private final LazyStringArrayList list;
-
- ByteArrayListView(LazyStringArrayList list) {
- this.list = list;
- }
-
- @Override
- public byte[] get(int index) {
- return list.getByteArray(index);
- }
-
- @Override
- public int size() {
- return list.size();
- }
-
- @Override
- public byte[] set(int index, byte[] s) {
- Object o = list.setAndReturn(index, s);
- modCount++;
- return asByteArray(o);
- }
-
- @Override
- public void add(int index, byte[] s) {
- list.add(index, s);
- modCount++;
- }
-
- @Override
- public byte[] remove(int index) {
- Object o = list.remove(index);
- modCount++;
- return asByteArray(o);
- }
- }
-
- @Override
- public List<byte[]> asByteArrayList() {
- return new ByteArrayListView(this);
- }
-
- private static class ByteStringListView extends AbstractList<ByteString>
- implements RandomAccess {
- private final LazyStringArrayList list;
-
- ByteStringListView(LazyStringArrayList list) {
- this.list = list;
- }
-
- @Override
- public ByteString get(int index) {
- return list.getByteString(index);
- }
-
- @Override
- public int size() {
- return list.size();
- }
-
- @Override
- public ByteString set(int index, ByteString s) {
- Object o = list.setAndReturn(index, s);
- modCount++;
- return asByteString(o);
- }
-
- @Override
- public void add(int index, ByteString s) {
- list.add(index, s);
- modCount++;
- }
-
- @Override
- public ByteString remove(int index) {
- Object o = list.remove(index);
- modCount++;
- return asByteString(o);
- }
- }
-
- @Override
- public List<ByteString> asByteStringList() {
- return new ByteStringListView(this);
- }
-
- @Override
- public LazyStringList getUnmodifiableView() {
- if (isModifiable()) {
- return new UnmodifiableLazyStringList(this);
- }
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringList.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringList.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringList.java
deleted file mode 100644
index 5412763..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LazyStringList.java
+++ /dev/null
@@ -1,174 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * An interface extending {@code List<String>} that also provides access to the
- * items of the list as UTF8-encoded ByteString or byte[] objects. This is
- * used by the protocol buffer implementation to support lazily converting bytes
- * parsed over the wire to String objects until needed and also increases the
- * efficiency of serialization if the String was never requested as the
- * ByteString or byte[] is already cached. The ByteString methods are used in
- * immutable API only and byte[] methods used in mutable API only for they use
- * different representations for string/bytes fields.
- *
- * @author jonp@google.com (Jon Perlow)
- */
-public interface LazyStringList extends ProtocolStringList {
-
- /**
- * Returns the element at the specified position in this list as a ByteString.
- *
- * @param index index of the element to return
- * @return the element at the specified position in this list
- * @throws IndexOutOfBoundsException if the index is out of range
- * ({@code index < 0 || index >= size()})
- */
- ByteString getByteString(int index);
-
- /**
- * Returns the element at the specified position in this list as an Object
- * that will either be a String or a ByteString.
- *
- * @param index index of the element to return
- * @return the element at the specified position in this list
- * @throws IndexOutOfBoundsException if the index is out of range
- * ({@code index < 0 || index >= size()})
- */
- Object getRaw(int index);
-
- /**
- * Returns the element at the specified position in this list as byte[].
- *
- * @param index index of the element to return
- * @return the element at the specified position in this list
- * @throws IndexOutOfBoundsException if the index is out of range
- * ({@code index < 0 || index >= size()})
- */
- byte[] getByteArray(int index);
-
- /**
- * Appends the specified element to the end of this list (optional
- * operation).
- *
- * @param element element to be appended to this list
- * @throws UnsupportedOperationException if the <tt>add</tt> operation
- * is not supported by this list
- */
- void add(ByteString element);
-
- /**
- * Appends the specified element to the end of this list (optional
- * operation).
- *
- * @param element element to be appended to this list
- * @throws UnsupportedOperationException if the <tt>add</tt> operation
- * is not supported by this list
- */
- void add(byte[] element);
-
- /**
- * Replaces the element at the specified position in this list with the
- * specified element (optional operation).
- *
- * @param index index of the element to replace
- * @param element the element to be stored at the specified position
- * @throws UnsupportedOperationException if the <tt>set</tt> operation
- * is not supported by this list
- * IndexOutOfBoundsException if the index is out of range
- * ({@code index < 0 || index >= size()})
- */
- void set(int index, ByteString element);
-
- /**
- * Replaces the element at the specified position in this list with the
- * specified element (optional operation).
- *
- * @param index index of the element to replace
- * @param element the element to be stored at the specified position
- * @throws UnsupportedOperationException if the <tt>set</tt> operation
- * is not supported by this list
- * IndexOutOfBoundsException if the index is out of range
- * ({@code index < 0 || index >= size()})
- */
- void set(int index, byte[] element);
-
- /**
- * Appends all elements in the specified ByteString collection to the end of
- * this list.
- *
- * @param c collection whose elements are to be added to this list
- * @return true if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>addAllByteString</tt>
- * operation is not supported by this list
- */
- boolean addAllByteString(Collection<? extends ByteString> c);
-
- /**
- * Appends all elements in the specified byte[] collection to the end of
- * this list.
- *
- * @param c collection whose elements are to be added to this list
- * @return true if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>addAllByteArray</tt>
- * operation is not supported by this list
- */
- boolean addAllByteArray(Collection<byte[]> c);
-
- /**
- * Returns an unmodifiable List of the underlying elements, each of which is
- * either a {@code String} or its equivalent UTF-8 encoded {@code ByteString}
- * or byte[]. It is an error for the caller to modify the returned
- * List, and attempting to do so will result in an
- * {@link UnsupportedOperationException}.
- */
- List<?> getUnderlyingElements();
-
- /**
- * Merges all elements from another LazyStringList into this one. This method
- * differs from {@link #addAll(Collection)} on that underlying byte arrays are
- * copied instead of reference shared. Immutable API doesn't need to use this
- * method as byte[] is not used there at all.
- */
- void mergeFrom(LazyStringList other);
-
- /**
- * Returns a mutable view of this list. Changes to the view will be made into
- * the original list. This method is used in mutable API only.
- */
- List<byte[]> asByteArrayList();
-
- /** Returns an unmodifiable view of the list. */
- LazyStringList getUnmodifiableView();
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValue.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValue.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValue.java
deleted file mode 100644
index 4ddc71b..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValue.java
+++ /dev/null
@@ -1,814 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/struct.proto
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-/**
- * <pre>
- * `ListValue` is a wrapper around a repeated field of values.
- * The JSON representation for `ListValue` is JSON array.
- * </pre>
- *
- * Protobuf type {@code google.protobuf.ListValue}
- */
-public final class ListValue extends
- org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3 implements
- // @@protoc_insertion_point(message_implements:google.protobuf.ListValue)
- ListValueOrBuilder {
- // Use ListValue.newBuilder() to construct.
- private ListValue(org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
- super(builder);
- }
- private ListValue() {
- values_ = java.util.Collections.emptyList();
- }
-
- @java.lang.Override
- public final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet.getDefaultInstance();
- }
- private ListValue(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- this();
- int mutable_bitField0_ = 0;
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!input.skipField(tag)) {
- done = true;
- }
- break;
- }
- case 10: {
- if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
- values_ = new java.util.ArrayList<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value>();
- mutable_bitField0_ |= 0x00000001;
- }
- values_.add(
- input.readMessage(org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.parser(), extensionRegistry));
- break;
- }
- }
- }
- } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException(
- e).setUnfinishedMessage(this);
- } finally {
- if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
- values_ = java.util.Collections.unmodifiableList(values_);
- }
- makeExtensionsImmutable();
- }
- }
- public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_descriptor;
- }
-
- protected org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.class, org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.Builder.class);
- }
-
- public static final int VALUES_FIELD_NUMBER = 1;
- private java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value> values_;
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value> getValuesList() {
- return values_;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public java.util.List<? extends org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder>
- getValuesOrBuilderList() {
- return values_;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public int getValuesCount() {
- return values_.size();
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Value getValues(int index) {
- return values_.get(index);
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder getValuesOrBuilder(
- int index) {
- return values_.get(index);
- }
-
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- for (int i = 0; i < values_.size(); i++) {
- output.writeMessage(1, values_.get(i));
- }
- }
-
- public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) return size;
-
- size = 0;
- for (int i = 0; i < values_.size(); i++) {
- size += org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedOutputStream
- .computeMessageSize(1, values_.get(i));
- }
- memoizedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- public boolean equals(final java.lang.Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue)) {
- return super.equals(obj);
- }
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue other = (org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue) obj;
-
- boolean result = true;
- result = result && getValuesList()
- .equals(other.getValuesList());
- return result;
- }
-
- @java.lang.Override
- public int hashCode() {
- if (memoizedHashCode != 0) {
- return memoizedHashCode;
- }
- int hash = 41;
- hash = (19 * hash) + getDescriptor().hashCode();
- if (getValuesCount() > 0) {
- hash = (37 * hash) + VALUES_FIELD_NUMBER;
- hash = (53 * hash) + getValuesList().hashCode();
- }
- hash = (29 * hash) + unknownFields.hashCode();
- memoizedHashCode = hash;
- return hash;
- }
-
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString data)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString data,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(byte[] data)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- byte[] data,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- java.io.InputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseDelimitedFrom(
- java.io.InputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parseFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder() {
- return DEFAULT_INSTANCE.toBuilder();
- }
- public static Builder newBuilder(org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue prototype) {
- return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() {
- return this == DEFAULT_INSTANCE
- ? new Builder() : new Builder().mergeFrom(this);
- }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * <pre>
- * `ListValue` is a wrapper around a repeated field of values.
- * The JSON representation for `ListValue` is JSON array.
- * </pre>
- *
- * Protobuf type {@code google.protobuf.ListValue}
- */
- public static final class Builder extends
- org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:google.protobuf.ListValue)
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValueOrBuilder {
- public static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_descriptor;
- }
-
- protected org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.class, org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.Builder.class);
- }
-
- // Construct using org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3
- .alwaysUseFieldBuilders) {
- getValuesFieldBuilder();
- }
- }
- public Builder clear() {
- super.clear();
- if (valuesBuilder_ == null) {
- values_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000001);
- } else {
- valuesBuilder_.clear();
- }
- return this;
- }
-
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_descriptor;
- }
-
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue getDefaultInstanceForType() {
- return org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.getDefaultInstance();
- }
-
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue build() {
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue buildPartial() {
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue result = new org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue(this);
- int from_bitField0_ = bitField0_;
- if (valuesBuilder_ == null) {
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- values_ = java.util.Collections.unmodifiableList(values_);
- bitField0_ = (bitField0_ & ~0x00000001);
- }
- result.values_ = values_;
- } else {
- result.values_ = valuesBuilder_.build();
- }
- onBuilt();
- return result;
- }
-
- public Builder clone() {
- return (Builder) super.clone();
- }
- public Builder setField(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return (Builder) super.setField(field, value);
- }
- public Builder clearField(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor field) {
- return (Builder) super.clearField(field);
- }
- public Builder clearOneof(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.OneofDescriptor oneof) {
- return (Builder) super.clearOneof(oneof);
- }
- public Builder setRepeatedField(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
- int index, Object value) {
- return (Builder) super.setRepeatedField(field, index, value);
- }
- public Builder addRepeatedField(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return (Builder) super.addRepeatedField(field, value);
- }
- public Builder mergeFrom(org.apache.hadoop.hbase.shaded.com.google.protobuf.Message other) {
- if (other instanceof org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue) {
- return mergeFrom((org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue other) {
- if (other == org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue.getDefaultInstance()) return this;
- if (valuesBuilder_ == null) {
- if (!other.values_.isEmpty()) {
- if (values_.isEmpty()) {
- values_ = other.values_;
- bitField0_ = (bitField0_ & ~0x00000001);
- } else {
- ensureValuesIsMutable();
- values_.addAll(other.values_);
- }
- onChanged();
- }
- } else {
- if (!other.values_.isEmpty()) {
- if (valuesBuilder_.isEmpty()) {
- valuesBuilder_.dispose();
- valuesBuilder_ = null;
- values_ = other.values_;
- bitField0_ = (bitField0_ & ~0x00000001);
- valuesBuilder_ =
- org.apache.hadoop.hbase.shaded.com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
- getValuesFieldBuilder() : null;
- } else {
- valuesBuilder_.addAllMessages(other.values_);
- }
- }
- }
- onChanged();
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue) e.getUnfinishedMessage();
- throw e.unwrapIOException();
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- private java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value> values_ =
- java.util.Collections.emptyList();
- private void ensureValuesIsMutable() {
- if (!((bitField0_ & 0x00000001) == 0x00000001)) {
- values_ = new java.util.ArrayList<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value>(values_);
- bitField0_ |= 0x00000001;
- }
- }
-
- private org.apache.hadoop.hbase.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder, org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder> valuesBuilder_;
-
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value> getValuesList() {
- if (valuesBuilder_ == null) {
- return java.util.Collections.unmodifiableList(values_);
- } else {
- return valuesBuilder_.getMessageList();
- }
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public int getValuesCount() {
- if (valuesBuilder_ == null) {
- return values_.size();
- } else {
- return valuesBuilder_.getCount();
- }
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Value getValues(int index) {
- if (valuesBuilder_ == null) {
- return values_.get(index);
- } else {
- return valuesBuilder_.getMessage(index);
- }
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder setValues(
- int index, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value value) {
- if (valuesBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureValuesIsMutable();
- values_.set(index, value);
- onChanged();
- } else {
- valuesBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder setValues(
- int index, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder builderForValue) {
- if (valuesBuilder_ == null) {
- ensureValuesIsMutable();
- values_.set(index, builderForValue.build());
- onChanged();
- } else {
- valuesBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder addValues(org.apache.hadoop.hbase.shaded.com.google.protobuf.Value value) {
- if (valuesBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureValuesIsMutable();
- values_.add(value);
- onChanged();
- } else {
- valuesBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder addValues(
- int index, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value value) {
- if (valuesBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureValuesIsMutable();
- values_.add(index, value);
- onChanged();
- } else {
- valuesBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder addValues(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder builderForValue) {
- if (valuesBuilder_ == null) {
- ensureValuesIsMutable();
- values_.add(builderForValue.build());
- onChanged();
- } else {
- valuesBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder addValues(
- int index, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder builderForValue) {
- if (valuesBuilder_ == null) {
- ensureValuesIsMutable();
- values_.add(index, builderForValue.build());
- onChanged();
- } else {
- valuesBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder addAllValues(
- java.lang.Iterable<? extends org.apache.hadoop.hbase.shaded.com.google.protobuf.Value> values) {
- if (valuesBuilder_ == null) {
- ensureValuesIsMutable();
- org.apache.hadoop.hbase.shaded.com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, values_);
- onChanged();
- } else {
- valuesBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder clearValues() {
- if (valuesBuilder_ == null) {
- values_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000001);
- onChanged();
- } else {
- valuesBuilder_.clear();
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public Builder removeValues(int index) {
- if (valuesBuilder_ == null) {
- ensureValuesIsMutable();
- values_.remove(index);
- onChanged();
- } else {
- valuesBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder getValuesBuilder(
- int index) {
- return getValuesFieldBuilder().getBuilder(index);
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder getValuesOrBuilder(
- int index) {
- if (valuesBuilder_ == null) {
- return values_.get(index); } else {
- return valuesBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public java.util.List<? extends org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder>
- getValuesOrBuilderList() {
- if (valuesBuilder_ != null) {
- return valuesBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(values_);
- }
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder addValuesBuilder() {
- return getValuesFieldBuilder().addBuilder(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.getDefaultInstance());
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder addValuesBuilder(
- int index) {
- return getValuesFieldBuilder().addBuilder(
- index, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.getDefaultInstance());
- }
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- public java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder>
- getValuesBuilderList() {
- return getValuesFieldBuilder().getBuilderList();
- }
- private org.apache.hadoop.hbase.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder, org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder>
- getValuesFieldBuilder() {
- if (valuesBuilder_ == null) {
- valuesBuilder_ = new org.apache.hadoop.hbase.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value, org.apache.hadoop.hbase.shaded.com.google.protobuf.Value.Builder, org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder>(
- values_,
- ((bitField0_ & 0x00000001) == 0x00000001),
- getParentForChildren(),
- isClean());
- values_ = null;
- }
- return valuesBuilder_;
- }
- public final Builder setUnknownFields(
- final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
- return this;
- }
-
- public final Builder mergeUnknownFields(
- final org.apache.hadoop.hbase.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
- return this;
- }
-
-
- // @@protoc_insertion_point(builder_scope:google.protobuf.ListValue)
- }
-
- // @@protoc_insertion_point(class_scope:google.protobuf.ListValue)
- private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue DEFAULT_INSTANCE;
- static {
- DEFAULT_INSTANCE = new org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue();
- }
-
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue getDefaultInstance() {
- return DEFAULT_INSTANCE;
- }
-
- private static final org.apache.hadoop.hbase.shaded.com.google.protobuf.Parser<ListValue>
- PARSER = new org.apache.hadoop.hbase.shaded.com.google.protobuf.AbstractParser<ListValue>() {
- public ListValue parsePartialFrom(
- org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream input,
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException {
- return new ListValue(input, extensionRegistry);
- }
- };
-
- public static org.apache.hadoop.hbase.shaded.com.google.protobuf.Parser<ListValue> parser() {
- return PARSER;
- }
-
- @java.lang.Override
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.Parser<ListValue> getParserForType() {
- return PARSER;
- }
-
- public org.apache.hadoop.hbase.shaded.com.google.protobuf.ListValue getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValueOrBuilder.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValueOrBuilder.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValueOrBuilder.java
deleted file mode 100644
index 77b3c19..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/ListValueOrBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/struct.proto
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-public interface ListValueOrBuilder extends
- // @@protoc_insertion_point(interface_extends:google.protobuf.ListValue)
- org.apache.hadoop.hbase.shaded.com.google.protobuf.MessageOrBuilder {
-
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- java.util.List<org.apache.hadoop.hbase.shaded.com.google.protobuf.Value>
- getValuesList();
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- org.apache.hadoop.hbase.shaded.com.google.protobuf.Value getValues(int index);
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- int getValuesCount();
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- java.util.List<? extends org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder>
- getValuesOrBuilderList();
- /**
- * <pre>
- * Repeated field of dynamically typed values.
- * </pre>
- *
- * <code>repeated .google.protobuf.Value values = 1;</code>
- */
- org.apache.hadoop.hbase.shaded.com.google.protobuf.ValueOrBuilder getValuesOrBuilder(
- int index);
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/7a6de1bd/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LongArrayList.java
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LongArrayList.java b/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LongArrayList.java
deleted file mode 100644
index 39d14b2..0000000
--- a/hbase-protocol-shaded/src/main/java/org/apache/hadoop/hbase/shaded/com/google/protobuf/LongArrayList.java
+++ /dev/null
@@ -1,272 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package org.apache.hadoop.hbase.shaded.com.google.protobuf;
-
-import org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.LongList;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.RandomAccess;
-
-/**
- * An implementation of {@link LongList} on top of a primitive array.
- *
- * @author dweis@google.com (Daniel Weis)
- */
-final class LongArrayList
- extends AbstractProtobufList<Long>
- implements LongList, RandomAccess {
-
- private static final LongArrayList EMPTY_LIST = new LongArrayList();
- static {
- EMPTY_LIST.makeImmutable();
- }
-
- public static LongArrayList emptyList() {
- return EMPTY_LIST;
- }
-
- /**
- * The backing store for the list.
- */
- private long[] array;
-
- /**
- * The size of the list distinct from the length of the array. That is, it is the number of
- * elements set in the list.
- */
- private int size;
-
- /**
- * Constructs a new mutable {@code LongArrayList} with default capacity.
- */
- LongArrayList() {
- this(new long[DEFAULT_CAPACITY], 0);
- }
-
- /**
- * Constructs a new mutable {@code LongArrayList}
- * containing the same elements as {@code other}.
- */
- private LongArrayList(long[] other, int size) {
- array = other;
- this.size = size;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof LongArrayList)) {
- return super.equals(o);
- }
- LongArrayList other = (LongArrayList) o;
- if (size != other.size) {
- return false;
- }
-
- final long[] arr = other.array;
- for (int i = 0; i < size; i++) {
- if (array[i] != arr[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = 1;
- for (int i = 0; i < size; i++) {
- result = (31 * result) + Internal.hashLong(array[i]);
- }
- return result;
- }
-
- @Override
- public LongList mutableCopyWithCapacity(int capacity) {
- if (capacity < size) {
- throw new IllegalArgumentException();
- }
- return new LongArrayList(Arrays.copyOf(array, capacity), size);
- }
-
- @Override
- public Long get(int index) {
- return getLong(index);
- }
-
- @Override
- public long getLong(int index) {
- ensureIndexInRange(index);
- return array[index];
- }
-
- @Override
- public int size() {
- return size;
- }
-
- @Override
- public Long set(int index, Long element) {
- return setLong(index, element);
- }
-
- @Override
- public long setLong(int index, long element) {
- ensureIsMutable();
- ensureIndexInRange(index);
- long previousValue = array[index];
- array[index] = element;
- return previousValue;
- }
-
- @Override
- public void add(int index, Long element) {
- addLong(index, element);
- }
-
- /**
- * Like {@link #add(Long)} but more efficient in that it doesn't box the element.
- */
- @Override
- public void addLong(long element) {
- addLong(size, element);
- }
-
- /**
- * Like {@link #add(int, Long)} but more efficient in that it doesn't box the element.
- */
- private void addLong(int index, long element) {
- ensureIsMutable();
- if (index < 0 || index > size) {
- throw new IndexOutOfBoundsException(makeOutOfBoundsExceptionMessage(index));
- }
-
- if (size < array.length) {
- // Shift everything over to make room
- System.arraycopy(array, index, array, index + 1, size - index);
- } else {
- // Resize to 1.5x the size
- int length = ((size * 3) / 2) + 1;
- long[] newArray = new long[length];
-
- // Copy the first part directly
- System.arraycopy(array, 0, newArray, 0, index);
-
- // Copy the rest shifted over by one to make room
- System.arraycopy(array, index, newArray, index + 1, size - index);
- array = newArray;
- }
-
- array[index] = element;
- size++;
- modCount++;
- }
-
- @Override
- public boolean addAll(Collection<? extends Long> collection) {
- ensureIsMutable();
-
- if (collection == null) {
- throw new NullPointerException();
- }
-
- // We specialize when adding another LongArrayList to avoid boxing elements.
- if (!(collection instanceof LongArrayList)) {
- return super.addAll(collection);
- }
-
- LongArrayList list = (LongArrayList) collection;
- if (list.size == 0) {
- return false;
- }
-
- int overflow = Integer.MAX_VALUE - size;
- if (overflow < list.size) {
- // We can't actually represent a list this large.
- throw new OutOfMemoryError();
- }
-
- int newSize = size + list.size;
- if (newSize > array.length) {
- array = Arrays.copyOf(array, newSize);
- }
-
- System.arraycopy(list.array, 0, array, size, list.size);
- size = newSize;
- modCount++;
- return true;
- }
-
- @Override
- public boolean remove(Object o) {
- ensureIsMutable();
- for (int i = 0; i < size; i++) {
- if (o.equals(array[i])) {
- System.arraycopy(array, i + 1, array, i, size - i);
- size--;
- modCount++;
- return true;
- }
- }
- return false;
- }
-
- @Override
- public Long remove(int index) {
- ensureIsMutable();
- ensureIndexInRange(index);
- long value = array[index];
- System.arraycopy(array, index + 1, array, index, size - index);
- size--;
- modCount++;
- return value;
- }
-
- /**
- * Ensures that the provided {@code index} is within the range of {@code [0, size]}. Throws an
- * {@link IndexOutOfBoundsException} if it is not.
- *
- * @param index the index to verify is in range
- */
- private void ensureIndexInRange(int index) {
- if (index < 0 || index >= size) {
- throw new IndexOutOfBoundsException(makeOutOfBoundsExceptionMessage(index));
- }
- }
-
- private String makeOutOfBoundsExceptionMessage(int index) {
- return "Index:" + index + ", Size:" + size;
- }
-}