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:com.google.step2.util.EncodingUtil.java
public static byte[] getUtf8Bytes(String s) { if (s == null) { return ArrayUtils.EMPTY_BYTE_ARRAY; }/* w ww .j a v a 2 s . co m*/ ByteBuffer bb = UTF8.encode(s); return ArrayUtils.subarray(bb.array(), 0, bb.limit()); }
From source file:com.bigdata.dastor.db.filter.IdentityQueryFilter.java
/** * Only for use in testing; will read entire CF into memory. */// www .ja v a2 s. co m public IdentityQueryFilter(String key, QueryPath path) { super(key, path, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, Integer.MAX_VALUE); }
From source file:net.sf.beanlib.utils.BlobUtils.java
public byte[] toByteArray(Blob fromBlob, int bufferSize) { if (fromBlob == null) return ArrayUtils.EMPTY_BYTE_ARRAY; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {/* w ww . j a v a 2s. com*/ return toByteArrayImpl(fromBlob, baos, bufferSize); } catch (SQLException e) { log.error("", e); throw new BeanlibException(e); } catch (IOException e) { log.error("", e); throw new BeanlibException(e); } finally { if (baos != null) { try { baos.close(); } catch (IOException ex) { log.warn("", ex); } } } }
From source file:com.facebook.infrastructure.db.Column.java
Column(String name) {
this(name, ArrayUtils.EMPTY_BYTE_ARRAY);
}
From source file:com.bigdata.dastor.db.Column.java
Column(byte[] name) { this(name, ArrayUtils.EMPTY_BYTE_ARRAY); }
From source file:com.facebook.infrastructure.net.io.StartState.java
protected byte[] doRead(ByteBuffer buffer) throws IOException, ReadNotCompleteException { SocketChannel socketChannel = stream_.getStream(); int bytesRead = socketChannel.read(buffer); if (bytesRead == -1 && buffer.remaining() > 0) { throw new IOException("Reached an EOL or something bizzare occured. Reading from: " + socketChannel.socket().getInetAddress() + " BufferSizeRemaining: " + buffer.remaining()); }/* ww w.j a v a2 s . c om*/ if (buffer.remaining() == 0) { morphState(); } else { throw new ReadNotCompleteException( "Specified number of bytes have not been read from the Socket Channel"); } return ArrayUtils.EMPTY_BYTE_ARRAY; }
From source file:com.facebook.infrastructure.utils.FBUtilities.java
public static byte[] serializeToStream(Object o) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] bytes = ArrayUtils.EMPTY_BYTE_ARRAY; try {/*from ww w . java2s . com*/ ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(o); oos.flush(); bytes = bos.toByteArray(); oos.close(); bos.close(); } catch (IOException e) { LogUtil.getLogger(FBUtilities.class.getName()).info(LogUtil.throwableToString(e)); } return bytes; }
From source file:com.facebook.infrastructure.net.io.TcpReader.java
public byte[] read() throws IOException { byte[] bytes = ArrayUtils.EMPTY_BYTE_ARRAY; while (socketState_ != null) { try {//from ww w .j a va2s .c o m bytes = socketState_.read(); } catch (ReadNotCompleteException e) { break; } } return bytes; }
From source file:com.facebook.infrastructure.service.ReadResponseResolver.java
public Row resolve(List<Message<byte[]>> responses) throws DigestMismatchException { long startTime = System.currentTimeMillis(); Row retRow = null;//from w w w .j a v a 2 s.c om List<Row> rowList = new ArrayList<Row>(); List<EndPoint> endPoints = new ArrayList<EndPoint>(); String key = null; String table = null; byte[] digest = ArrayUtils.EMPTY_BYTE_ARRAY; boolean isDigestQuery = false; /* * Populate the list of rows from each of the messages * Check to see if there is a digest query. If a digest * query exists then we need to compare the digest with * the digest of the data that is received. */ DataInputBuffer bufIn = new DataInputBuffer(); for (Message<byte[]> response : responses) { byte[] body = response.getMessageBody(); bufIn.reset(body, body.length); long start = System.currentTimeMillis(); ReadResponse result = null; try { result = ReadResponse.serializer().deserialize(bufIn); } catch (IOException e) { throw new RuntimeException(e); } logger_.trace("Response deserialization time : " + (System.currentTimeMillis() - start) + " ms."); if (!result.isDigestQuery()) { rowList.add(result.row()); endPoints.add(response.getFrom()); key = result.row().key(); table = result.table(); } else { digest = result.digest(); isDigestQuery = true; } } // If there was a digest query compare it withh all teh data digests // If there is a mismatch then thwrow an exception so that read repair can happen. if (isDigestQuery) { for (Row row : rowList) { if (!Arrays.equals(row.digest(), digest)) { throw new DigestMismatchException("The Digest does not match"); } } } /* If the rowList is empty then we had some exception above. */ if (rowList.size() == 0) { return retRow; } /* Now calculate the resolved row */ retRow = new Row(key); for (int i = 0; i < rowList.size(); i++) { retRow.repair(rowList.get(i)); } // At this point we have the return row . // Now we need to calculate the differnce // so that we can schedule read repairs for (int i = 0; i < rowList.size(); i++) { // calculate the difference , since retRow is the resolved // row it can be used as the super set , remember no deletes // will happen with diff its only for additions so far // TODO : handle deletes Row diffRow = rowList.get(i).diff(retRow); if (diffRow == null) // no repair needs to happen continue; // create the row mutation message based on the diff and schedule a read repair RowMutation rowMutation = new RowMutation(table, key); for (ColumnFamily cf : diffRow.getColumnFamilies()) { rowMutation.add(cf); } // schedule the read repair ReadRepairManager.instance().schedule(endPoints.get(i), rowMutation); } logger_.trace("resolve: " + (System.currentTimeMillis() - startTime) + " ms."); return retRow; }
From source file:com.bigdata.dastor.db.filter.QueryPath.java
public void serialize(DataOutputStream dos) throws IOException { assert !"".equals(columnFamilyName); assert superColumnName == null || superColumnName.length > 0; assert columnName == null || columnName.length > 0; dos.writeUTF(columnFamilyName == null ? "" : columnFamilyName); ColumnSerializer.writeName(superColumnName == null ? ArrayUtils.EMPTY_BYTE_ARRAY : superColumnName, dos); ColumnSerializer.writeName(columnName == null ? ArrayUtils.EMPTY_BYTE_ARRAY : columnName, dos); }