Repository: incubator-apex-malhar Updated Branches: refs/heads/devel-3 365237d5c -> 16b198109
MLHR-1941 #resolve #comment added slice comparator Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/commit/ad108dbd Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/tree/ad108dbd Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/diff/ad108dbd Branch: refs/heads/devel-3 Commit: ad108dbde90cb0024aa80fa4b4580f827c430357 Parents: 365237d Author: Thomas Weise <[email protected]> Authored: Thu Dec 10 00:56:36 2015 -0800 Committer: Chandni Singh <[email protected]> Committed: Sat Dec 12 22:50:26 2015 -0800 ---------------------------------------------------------------------- .../lib/util/comparator/SliceComparator.java | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/ad108dbd/library/src/main/java/com/datatorrent/lib/util/comparator/SliceComparator.java ---------------------------------------------------------------------- diff --git a/library/src/main/java/com/datatorrent/lib/util/comparator/SliceComparator.java b/library/src/main/java/com/datatorrent/lib/util/comparator/SliceComparator.java new file mode 100644 index 0000000..4a284fe --- /dev/null +++ b/library/src/main/java/com/datatorrent/lib/util/comparator/SliceComparator.java @@ -0,0 +1,37 @@ +/** + * 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 com.datatorrent.lib.util.comparator; + +import java.util.Comparator; + +import org.apache.hadoop.io.WritableComparator; + +import com.datatorrent.netlet.util.Slice; + +/** + * Default key comparator that performs lexicographical comparison of the byte arrays. + */ +public class SliceComparator implements Comparator<Slice> +{ + @Override + public int compare(Slice o1, Slice o2) + { + return WritableComparator.compareBytes(o1.buffer, o1.offset, o1.length, o2.buffer, o2.offset, o2.length); + } +}
