List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY
null EMPTY_BYTE_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY.
Click Source Link
byte
array. From source file:org.lab41.hbase.TitanHbaseThreePartSplitter.java
public HTableDescriptor createAndSplitTable(String tableName, HBaseAdmin hBaseAdmin, Configuration conf) throws IOException { int numSplits = conf.getInt(NUM_SPLITS_KEY, NUM_SPLITS_DEFAULT); logger.info("Splitting! " + numSplits); HTableDescriptor hTableDescriptor = new HTableDescriptor(tableName); byte[] lowStart = ArrayUtils.EMPTY_BYTE_ARRAY; byte[] lowEnd = new byte[] { 0x01, (byte) 0x00, (int) 0x00, (byte) 0x00, 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[][] lowsplits = Bytes.split(lowStart, lowEnd, (int) Math.ceil(numSplits * 0.05)); //remove endpointsj lowsplits = Arrays.copyOfRange(lowsplits, 1, lowsplits.length - 1); byte[] midStart = new byte[] { 0x01, (byte) 0x00, (int) 0x00, (byte) 0x00, 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[] midEnd = new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[][] midsplits = Bytes.split(midStart, midEnd, (int) Math.ceil(numSplits * 0.25)); midsplits = Arrays.copyOfRange(midsplits, 0, midsplits.length - 1); byte[] highStart = new byte[] { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; byte[] highEnd = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }; byte[][] highsplits = Bytes.split(highStart, highEnd, (int) Math.ceil(numSplits * 0.60)); highsplits = Arrays.copyOfRange(highsplits, 0, highsplits.length - 1); byte[][] splits = new byte[lowsplits.length + midsplits.length + highsplits.length][8]; int i;/*from w w w . j a va2s . co m*/ for (i = 0; i < lowsplits.length; i++) { splits[i] = lowsplits[i]; } for (i = 0; i < midsplits.length; i++) { splits[i + lowsplits.length] = midsplits[i]; } for (i = 0; i < highsplits.length; i++) { splits[i + lowsplits.length + midsplits.length] = highsplits[i]; } //debug loop logger.info("Splits : " + splits.length); for (int j = 0; j < splits.length; j++) { logger.info("createAndSplitTable" + Hex.encodeHexString(splits[j]) + " Bytes.toBytesString : " + Bytes.toStringBinary(splits[j])); } hBaseAdmin.createTable(hTableDescriptor, splits); return hTableDescriptor; }
From source file:org.lab41.hbase.TitanHbaseThreePartSplitter2.java
public HTableDescriptor createAndSplitTable(String tableName, HBaseAdmin hBaseAdmin, Configuration conf) throws IOException { int numSplits = conf.getInt(NUM_SPLITS_KEY, NUM_SPLITS_DEFAULT); logger.info("Splitting! " + numSplits); HTableDescriptor hTableDescriptor = new HTableDescriptor(tableName); byte[] lowStart = ArrayUtils.EMPTY_BYTE_ARRAY; byte[] lowEnd = new byte[] { 0x01, (byte) 0x00, (int) 0x00, (byte) 0x00, 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[][] lowsplits = Bytes.split(lowStart, lowEnd, (int) Math.ceil(numSplits * 0.50)); //remove endpointsj lowsplits = Arrays.copyOfRange(lowsplits, 1, lowsplits.length - 1); byte[] midStart = new byte[] { 0x01, (byte) 0x00, (int) 0x00, (byte) 0x00, 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[] midEnd = new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; byte[][] midsplits = Bytes.split(midStart, midEnd, (int) Math.ceil(numSplits * 0.25)); midsplits = Arrays.copyOfRange(midsplits, 0, midsplits.length - 1); byte[] highStart = new byte[] { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; byte[] highEnd = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }; byte[][] highsplits = Bytes.split(highStart, highEnd, (int) Math.ceil(numSplits * 0.25)); highsplits = Arrays.copyOfRange(highsplits, 0, highsplits.length - 1); byte[][] splits = new byte[lowsplits.length + midsplits.length + highsplits.length][8]; int i;//from ww w . ja v a 2s .com for (i = 0; i < lowsplits.length; i++) { splits[i] = lowsplits[i]; } for (i = 0; i < midsplits.length; i++) { splits[i + lowsplits.length] = midsplits[i]; } for (i = 0; i < highsplits.length; i++) { splits[i + lowsplits.length + midsplits.length] = highsplits[i]; } //debug loop logger.info("Splits : " + splits.length); for (int j = 0; j < splits.length; j++) { logger.info("createAndSplitTable" + Hex.encodeHexString(splits[j]) + " Bytes.toBytesString : " + Bytes.toStringBinary(splits[j])); } hBaseAdmin.createTable(hTableDescriptor, splits); return hTableDescriptor; }
From source file:org.marketcetera.util.exec.ExecTest.java
@Test public void stdOutDisposition() throws Exception { Redirector result = Redirector.get(Disposition.STDOUT); assertEquals(TEST_EXIT_CODE, result.getExitCode()); assertArrayEquals(TEST_OUTPUT, result.getStdOut()); assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result.getStdErr()); assertNull(result.getOutput());/*from w w w. ja v a2 s.c om*/ }
From source file:org.marketcetera.util.exec.ExecTest.java
@Test public void stdErrDisposition() throws Exception { Redirector result = Redirector.get(Disposition.STDERR); assertEquals(TEST_EXIT_CODE, result.getExitCode()); assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result.getStdOut()); assertArrayEquals(TEST_OUTPUT, result.getStdErr()); assertNull(result.getOutput());/*from ww w . j a v a2 s . c o m*/ }
From source file:org.marketcetera.util.exec.ExecTest.java
@Test public void memoryDisposition() throws Exception { Redirector result = Redirector.get(Disposition.MEMORY); assertEquals(TEST_EXIT_CODE, result.getExitCode()); assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result.getStdOut()); assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result.getStdErr()); assertArrayEquals(TEST_OUTPUT, result.getOutput()); }
From source file:org.marketcetera.util.unicode.DecoderTestBase.java
@Override protected void testNative() throws Exception { testDecode(HELLO_EN_NAT, HELLO_EN);//from ww w. j av a2 s . c om testDecode(null, HELLO_EN_NAT, HELLO_EN); testDecode(null, null, HELLO_EN_NAT, HELLO_EN); testDecode(ArrayUtils.EMPTY_BYTE_ARRAY, StringUtils.EMPTY); testDecode(null, ArrayUtils.EMPTY_BYTE_ARRAY, StringUtils.EMPTY); testDecode(null, null, ArrayUtils.EMPTY_BYTE_ARRAY, StringUtils.EMPTY); }
From source file:org.marketcetera.util.unicode.DecoderTestBase.java
@Override protected void testSignatureCharset(SignatureCharset sc, byte[] bytes) throws Exception { testDecode(sc, bytes, COMBO);//from ww w . ja v a 2 s .co m testDecode(sc, ArrayUtils.EMPTY_BYTE_ARRAY, StringUtils.EMPTY); }
From source file:org.marketcetera.util.unicode.DecoderTestBase.java
@Override protected void testStrategy(DecodingStrategy strategy, SignatureCharset sc, String string, byte[] bytes) throws Exception { testDecode(strategy, sc, bytes, string); testDecode(strategy, sc, ArrayUtils.EMPTY_BYTE_ARRAY, StringUtils.EMPTY); testDecode(strategy, SignatureCharset.UTF8_UTF8, ArrayUtils.addAll(Signature.UTF8.getMark(), COMBO_UTF8), COMBO);//from ww w .j av a2 s . c om testDecode(strategy, SignatureCharset.UTF16BE_UTF16BE, ArrayUtils.addAll(Signature.UTF16BE.getMark(), COMBO_UTF16BE), COMBO); testDecode(strategy, SignatureCharset.UTF16LE_UTF16LE, ArrayUtils.addAll(Signature.UTF16LE.getMark(), COMBO_UTF16LE), COMBO); testDecode(strategy, SignatureCharset.UTF32BE_UTF32BE, ArrayUtils.addAll(Signature.UTF32BE.getMark(), COMBO_UTF32BE), COMBO); testDecode(strategy, SignatureCharset.UTF32LE_UTF32LE, ArrayUtils.addAll(Signature.UTF32LE.getMark(), COMBO_UTF32LE), COMBO); }
From source file:org.marketcetera.util.unicode.FileEncoderFileTest.java
@Override protected void testEncode(byte[] bytes, String string) throws Exception { super.testEncode(bytes, string); int halfLength = string.length() / 2; String firstPart = string.substring(0, halfLength); String secondPart = string.substring(halfLength); encode(new WriterCreator() { @Override/*from w w w . jav a 2s .com*/ public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), false); } }, null, null, firstPart); assertArrayEquals(bytes, encode(new WriterCreator() { @Override public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), true); } }, null, null, secondPart)); Deleter.apply(TEST_FILE); CopyBytesUtils.copy(ArrayUtils.EMPTY_BYTE_ARRAY, TEST_FILE); assertArrayEquals(bytes, encode(new WriterCreator() { @Override public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), true); } }, null, null, string)); }
From source file:org.marketcetera.util.unicode.FileEncoderFileTest.java
@Override protected void testEncode(final SignatureCharset sc, byte[] bytes, String string) throws Exception { super.testEncode(sc, bytes, string); int halfLength = string.length() / 2; String firstPart = string.substring(0, halfLength); String secondPart = string.substring(halfLength); encode(new WriterCreator() { @Override// w w w. j a v a 2s . c om public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), false, sc); } }, sc, sc, firstPart); assertArrayEquals(bytes, encode(new WriterCreator() { @Override public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), true, sc); } }, sc, sc, secondPart)); Deleter.apply(TEST_FILE); CopyBytesUtils.copy(ArrayUtils.EMPTY_BYTE_ARRAY, TEST_FILE); assertArrayEquals(bytes, encode(new WriterCreator() { @Override public UnicodeFileWriter create() throws Exception { return new UnicodeFileWriter(new File(TEST_FILE), true, sc); } }, sc, sc, string)); }