Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 00F2D19C1F for ; Tue, 12 Apr 2016 13:58:19 +0000 (UTC) Received: (qmail 37833 invoked by uid 500); 12 Apr 2016 13:58:18 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 37599 invoked by uid 500); 12 Apr 2016 13:58:18 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 37416 invoked by uid 99); 12 Apr 2016 13:58:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Apr 2016 13:58:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 62E72E0901; Tue, 12 Apr 2016 13:58:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dlmarion@apache.org To: commits@accumulo.apache.org Date: Tue, 12 Apr 2016 13:58:26 -0000 Message-Id: <14cdd951db8644e28e011b9e93b8a2af@git.apache.org> In-Reply-To: <28ce56b801f84481baae935b546b14cd@git.apache.org> References: <28ce56b801f84481baae935b546b14cd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/39] accumulo git commit: Merge branch '1.6' into 1.7 Merge branch '1.6' into 1.7 Conflicts: server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f181cf6a Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f181cf6a Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f181cf6a Branch: refs/heads/ACCUMULO-4173 Commit: f181cf6a90a913e5453352a56d3ab470f15b068c Parents: 2b286ba 41e002d Author: Josh Elser Authored: Fri Apr 1 09:56:17 2016 -0400 Committer: Josh Elser Committed: Fri Apr 1 09:56:17 2016 -0400 ---------------------------------------------------------------------- .../apache/accumulo/tserver/InMemoryMap.java | 28 +- .../org/apache/accumulo/tserver/MemKey.java | 10 +- .../accumulo/tserver/MemKeyComparator.java | 2 +- .../org/apache/accumulo/tserver/NativeMap.java | 27 +- .../PartialMutationSkippingIterator.java | 2 +- .../org/apache/accumulo/test/InMemoryMapIT.java | 319 +++++++++++++++++++ 6 files changed, 362 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f181cf6a/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f181cf6a/server/tserver/src/main/java/org/apache/accumulo/tserver/MemKey.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f181cf6a/server/tserver/src/main/java/org/apache/accumulo/tserver/MemKeyComparator.java ---------------------------------------------------------------------- diff --cc server/tserver/src/main/java/org/apache/accumulo/tserver/MemKeyComparator.java index 739b923,0000000..a623cac mode 100644,000000..100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/MemKeyComparator.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/MemKeyComparator.java @@@ -1,44 -1,0 +1,44 @@@ +/* + * 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.accumulo.tserver; + +import java.io.Serializable; +import java.util.Comparator; + +import org.apache.accumulo.core.data.Key; + +class MemKeyComparator implements Comparator, Serializable { + + private static final long serialVersionUID = 1L; + + @Override + public int compare(Key k1, Key k2) { + int cmp = k1.compareTo(k2); + + if (cmp == 0) { + if (k1 instanceof MemKey) + if (k2 instanceof MemKey) - cmp = ((MemKey) k2).kvCount - ((MemKey) k1).kvCount; ++ cmp = ((MemKey) k2).getKVCount() - ((MemKey) k1).getKVCount(); + else + cmp = 1; + else if (k2 instanceof MemKey) + cmp = -1; + } + + return cmp; + } +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/f181cf6a/server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java ---------------------------------------------------------------------- diff --cc server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java index 6eb8e4e,7e1435e..a6f7cf1 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java @@@ -502,29 -531,17 +503,18 @@@ public class NativeMap implements Itera long uid = startUpdate(nmPointer, mutation.getRow()); for (ColumnUpdate update : updates) { update(nmPointer, uid, update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(), update.getTimestamp(), update.isDeleted(), - update.getValue(), mutationCount); + update.getValue(), mutationCount++); } - } + return mutationCount; } + @VisibleForTesting public void mutate(Mutation mutation, int mutationCount) { - wlock.lock(); - try { - if (nmPointer == 0) { - throw new IllegalStateException("Native Map Deleted"); - } - - modCount++; - - _mutate(mutation, mutationCount); - } finally { - wlock.unlock(); - } + mutate(Collections.singletonList(mutation), mutationCount); } - public void mutate(List mutations, int mutationCount) { + void mutate(List mutations, int mutationCount) { Iterator iter = mutations.iterator(); while (iter.hasNext()) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/f181cf6a/server/tserver/src/main/java/org/apache/accumulo/tserver/PartialMutationSkippingIterator.java ---------------------------------------------------------------------- diff --cc server/tserver/src/main/java/org/apache/accumulo/tserver/PartialMutationSkippingIterator.java index 5d0733b,0000000..3373c88 mode 100644,000000..100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/PartialMutationSkippingIterator.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/PartialMutationSkippingIterator.java @@@ -1,54 -1,0 +1,54 @@@ +/* + * 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.accumulo.tserver; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.iterators.IteratorEnvironment; +import org.apache.accumulo.core.iterators.SkippingIterator; +import org.apache.accumulo.core.iterators.SortedKeyValueIterator; +import org.apache.accumulo.core.iterators.system.InterruptibleIterator; + +class PartialMutationSkippingIterator extends SkippingIterator implements InterruptibleIterator { + + private int kvCount; + + public PartialMutationSkippingIterator(SortedKeyValueIterator source, int maxKVCount) { + setSource(source); + this.kvCount = maxKVCount; + } + + @Override + protected void consume() throws IOException { - while (getSource().hasTop() && ((MemKey) getSource().getTopKey()).kvCount > kvCount) ++ while (getSource().hasTop() && ((MemKey) getSource().getTopKey()).getKVCount() > kvCount) + getSource().next(); + } + + @Override + public SortedKeyValueIterator deepCopy(IteratorEnvironment env) { + return new PartialMutationSkippingIterator(getSource().deepCopy(env), kvCount); + } + + @Override + public void setInterruptFlag(AtomicBoolean flag) { + ((InterruptibleIterator) getSource()).setInterruptFlag(flag); + } + +}