Github user ilganeli commented on a diff in the pull request:
https://github.com/apache/spark/pull/5574#discussion_r28901624
--- Diff:
network/common/src/main/java/org/apache/spark/network/util/ByteUnit.java ---
@@ -0,0 +1,63 @@
+/*
+ * 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.spark.network.util;
+
+public enum ByteUnit {
+ BYTE (1),
+ KiB (1024l),
+ MiB ((long) Math.pow(1024l, 2l)),
+ GiB ((long) Math.pow(1024l, 3l)),
+ TiB ((long) Math.pow(1024l, 4l)),
+ PiB ((long) Math.pow(1024l, 5l));
+
+ private ByteUnit(long multiplier) {
+ this.multiplier = multiplier;
+ }
+
+ // Interpret the provided number (d) with suffix (u) as this unit type.
+ // E.g. KiB.interpret(1, MiB) interprets 1MiB as its KiB representation
= 1024k
+ public long interpret(long d, ByteUnit u) {
+ return u.toBytes(d) / multiplier;
+ }
+
+ // Convert the provided number (d) interpreted as this unit type to unit
type (u).
+ public long convert(long d, ByteUnit u) {
+ return toBytes(d) / u.multiplier;
+ }
+
+ public long toBytes(long d) { return x(d, multiplier); }
+ public long toKiB(long d) { return convert(d, KiB); }
+ public long toMiB(long d) { return convert(d, MiB); }
+ public long toGiB(long d) { return convert(d, GiB); }
+ public long toTiB(long d) { return convert(d, TiB); }
+ public long toPiB(long d) { return convert(d, PiB); }
+
+ long multiplier = 0;
+ static final long MAX = Long.MAX_VALUE;
--- End diff --
Wanted to still keep these in case they were used down the line. Would you
recommend getting rid of them?
Thank you,
Ilya Ganelin
From: Marcelo Vanzin
<[email protected]<mailto:[email protected]>>
Reply-To: apache/spark
<[email protected]<mailto:[email protected]>>
Date: Wednesday, April 22, 2015 at 11:35 AM
To: apache/spark <[email protected]<mailto:[email protected]>>
Cc: "Ganelin, Ilya"
<[email protected]<mailto:[email protected]>>
Subject: Re: [spark] [SPARK-5932][CORE] Use consistent naming for size
properties (#5574)
In
network/common/src/main/java/org/apache/spark/network/util/ByteUnit.java<https://github.com/apache/spark/pull/5574#discussion_r28901488>:
> + }
> +
> + // Convert the provided number (d) interpreted as this unit type to
unit type (u).
> + public long convert(long d, ByteUnit u) {
> + return toBytes(d) / u.multiplier;
> + }
> +
> + public long toBytes(long d) { return x(d, multiplier); }
> + public long toKiB(long d) { return convert(d, KiB); }
> + public long toMiB(long d) { return convert(d, MiB); }
> + public long toGiB(long d) { return convert(d, GiB); }
> + public long toTiB(long d) { return convert(d, TiB); }
> + public long toPiB(long d) { return convert(d, PiB); }
> +
> + long multiplier = 0;
> + static final long MAX = Long.MAX_VALUE;
not used anywhere?
â
Reply to this email directly or view it on
GitHub<https://github.com/apache/spark/pull/5574/files#r28901488>.
________________________________________________________
The information contained in this e-mail is confidential and/or proprietary
to Capital One and/or its affiliates. The information transmitted herewith is
intended only for use by the individual or entity to which it is addressed. If
the reader of this message is not the intended recipient, you are hereby
notified that any review, retransmission, dissemination, distribution, copying
or other use of, or taking of any action in reliance upon this information is
strictly prohibited. If you have received this communication in error, please
contact the sender and delete the material from your computer.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]