-
Notifications
You must be signed in to change notification settings - Fork 39
Refactor out Non API code #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
956b4a9
Refactor error-throwing imports
DomGarguilo c8b6cf4
Move constants to TestProps.java
DomGarguilo 50488ad
Copy over FastFormat to acc-testing
DomGarguilo 9bcb46f
Remove traces of Trace
DomGarguilo 96ff1ac
Added exception if trace is enabled
DomGarguilo 02248ad
revise exception
DomGarguilo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/org/apache/accumulo/testing/util/FastFormat.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * 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.testing.util; | ||
|
|
||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
|
|
||
| public class FastFormat { | ||
| // Copied over from accumulo | ||
| // this 7 to 8 times faster than String.format("%s%06d",prefix, num) | ||
| public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { | ||
| Preconditions.checkArgument(num >= 0); | ||
| String strNum = Long.toString(num, radix); | ||
| byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; | ||
| if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) | ||
| throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " | ||
| + radix + " " + new String(prefix, UTF_8)); | ||
| return ret; | ||
| } | ||
|
|
||
| public static int toZeroPaddedString(byte[] output, int outputOffset, long num, int width, | ||
| int radix, byte[] prefix) { | ||
| Preconditions.checkArgument(num >= 0); | ||
|
|
||
| String strNum = Long.toString(num, radix); | ||
|
|
||
| return toZeroPaddedString(output, outputOffset, strNum, width, prefix); | ||
| } | ||
|
|
||
| private static int toZeroPaddedString(byte[] output, int outputOffset, String strNum, int width, | ||
| byte[] prefix) { | ||
|
|
||
| int index = outputOffset; | ||
|
|
||
| for (byte b : prefix) { | ||
| output[index++] = b; | ||
| } | ||
|
|
||
| int end = width - strNum.length() + index; | ||
|
|
||
| while (index < end) | ||
| output[index++] = '0'; | ||
|
|
||
| for (int i = 0; i < strNum.length(); i++) { | ||
| output[index++] = (byte) strNum.charAt(i); | ||
| } | ||
|
|
||
| return index - outputOffset; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.