Example usage for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY.

Prototype

null EMPTY_BYTE_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY.

Click Source Link

Document

An empty immutable byte array.

Usage

From source file:com.facebook.infrastructure.db.ColumnFamily.java

public byte[] digest() {
    Set<IColumn> columns = columns_.getSortedColumns();
    byte[] xorHash = ArrayUtils.EMPTY_BYTE_ARRAY;
    for (IColumn column : columns) {
        if (xorHash.length == 0) {
            xorHash = column.digest();/*from w w w.ja  va2s .  c  o  m*/
        } else {
            byte[] tmpHash = column.digest();
            xorHash = FBUtilities.xor(xorHash, tmpHash);
        }
    }
    return xorHash;
}

From source file:com.google.gdt.eclipse.designer.core.model.widgets.ClassLoaderTest.java

/**
 * Makes single {@link File} empty./*  ww  w.  j ava  2s .  c  om*/
 */
private static void makeGwtJarEmpty(File file) throws IOException {
    // try delete
    try {
        FileUtils.forceDelete(file);
    } catch (Throwable e) {
    }
    // if not possible, make it empty
    IOUtils2.writeBytes(file, ArrayUtils.EMPTY_BYTE_ARRAY);
}

From source file:com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService.java

private void putInternal(String tableName, Collection<Map.Entry<Cell, Value>> values,
        boolean doNotOverwriteWithSameValue) {
    Table table = getTableMap(tableName);
    for (Map.Entry<Cell, Value> e : values) {
        Cell cell = e.getKey();/*from  w  ww  . j  a  va2  s  .  co  m*/
        byte[] row = cell.getRowName();
        byte[] col = cell.getColumnName();
        byte[] contents = e.getValue().getContents();
        long timestamp = e.getValue().getTimestamp();

        Key nextKey = table.entries.ceilingKey(new Key(row, ArrayUtils.EMPTY_BYTE_ARRAY, Long.MIN_VALUE));
        if (nextKey != null && nextKey.matchesRow(row)) {
            // Save memory by sharing rows.
            row = nextKey.row;
        }
        byte[] oldContents = table.entries.putIfAbsent(new Key(row, col, timestamp), contents);
        if (oldContents != null && (doNotOverwriteWithSameValue || !Arrays.equals(oldContents, contents))) {
            throw new KeyAlreadyExistsException("We already have a value for this timestamp");
        }
    }
}

From source file:com.bigdata.dastor.thrift.server.DastorThriftServer.java

public int get_count(String table, String key, ColumnParent column_parent, ConsistencyLevel consistency_level)
        throws InvalidRequestException, UnavailableException, TimedOutException {
    if (logger.isDebugEnabled())
        logger.debug("get_count");

    checkLoginDone();// ww w.  j a v  a 2  s.  c  o m

    SliceRange range = new SliceRange(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false,
            Integer.MAX_VALUE);
    SlicePredicate predicate = new SlicePredicate().setSlice_range(range);
    return get_slice(table, key, column_parent, predicate, consistency_level).size();
}

From source file:com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService.java

@Override
public byte[] getMetadataForTable(String tableName) {
    if (!tables.containsKey(tableName)) {
        throw new IllegalArgumentException("No such table");
    }/*from   w w w. ja  v  a 2  s.  c  o m*/
    byte[] ret = tableMetadata.get(tableName);
    return ret == null ? ArrayUtils.EMPTY_BYTE_ARRAY : ret;
}

From source file:com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService.java

@Override
public void addGarbageCollectionSentinelValues(String tableName, Set<Cell> cells) {
    ConcurrentSkipListMap<Key, byte[]> table = getTableMap(tableName).entries;
    for (Cell cell : cells) {
        table.put(new Key(cell, Value.INVALID_VALUE_TIMESTAMP), ArrayUtils.EMPTY_BYTE_ARRAY);
    }//from   w  w w.j a va  2 s  . c o m
}

From source file:com.facebook.infrastructure.io.SSTable.java

public SSTable(String directory, String filename) throws IOException {
    dataFile_ = directory + System.getProperty("file.separator") + filename + "-Data.db";
    dataWriter_ = SequenceFile.bufferedWriter(dataFile_, 32 * 1024 * 1024);
    // dataWriter_ = SequenceFile.checksumWriter(dataFile_);
    /* Write the block index first. This is an empty one */
    dataWriter_.append(SSTable.blockIndexKey_, ArrayUtils.EMPTY_BYTE_ARRAY);
    SSTable.positionAfterFirstBlockIndex_ = dataWriter_.getCurrentPosition();
}

From source file:com.palantir.atlasdb.keyvalue.rdbms.PostgresKeyValueService.java

@Override
@Idempotent//from w w w .  java2 s . com
public void createTable(final String tableName, int maxValueSizeInBytes)
        throws InsufficientConsistencyException {
    getDbi().inTransaction(new TransactionCallback<Void>() {
        @Override
        public Void inTransaction(Handle handle, TransactionStatus status) throws Exception {
            handle.execute("CREATE TABLE IF NOT EXISTS " + USR_TABLE(tableName) + " ( " + "    " + Columns.ROW
                    + " BYTEA NOT NULL, " + "    " + Columns.COLUMN + " BYTEA NOT NULL, " + "    "
                    + Columns.TIMESTAMP + " INT NOT NULL, " + "    " + Columns.CONTENT + " BYTEA NOT NULL,"
                    + "    PRIMARY KEY (" + "        " + Columns.ROW + ", " + "        " + Columns.COLUMN + ", "
                    + "        " + Columns.TIMESTAMP + "))");
            try {
                handle.execute("INSERT INTO " + MetaTable.META_TABLE_NAME + " (" + "    "
                        + MetaTable.Columns.TABLE_NAME + ", " + "    " + MetaTable.Columns.METADATA
                        + " ) VALUES (" + "    ?, ?)", tableName, ArrayUtils.EMPTY_BYTE_ARRAY);
            } catch (RuntimeException e) {
                if (AtlasSqlUtils.isKeyAlreadyExistsException(e)) {
                    // The table has existed perviously: no-op
                } else {
                    throw e;
                }
            }
            return null;
        }
    });
}

From source file:com.palantir.atlasdb.keyvalue.rdbms.PostgresKeyValueService.java

@Override
@Idempotent//from   w  ww .j  a v a  2 s .c o m
public void addGarbageCollectionSentinelValues(final String tableName, final Set<Cell> cells) {
    getDbi().inTransaction(new TransactionCallback<Void>() {
        @Override
        public Void inTransaction(Handle conn, TransactionStatus status) throws Exception {
            Map<Cell, byte[]> cellsWithInvalidValues = Maps2.createConstantValueMap(cells,
                    ArrayUtils.EMPTY_BYTE_ARRAY);
            Multimap<Cell, Long> cellsAsMultimap = Multimaps
                    .forMap(Maps2.createConstantValueMap(cells, Value.INVALID_VALUE_TIMESTAMP));
            deleteInTransaction(tableName, cellsAsMultimap, conn);
            putInTransaction(tableName, cellsWithInvalidValues, Value.INVALID_VALUE_TIMESTAMP, conn);
            return null;
        }
    });
}

From source file:ome.formats.importer.transfers.UploadFileTransfer.java

public String transfer(TransferState state) throws IOException, ServerError {

    final RawFileStorePrx rawFileStore = start(state);
    final File file = state.getFile();
    final byte[] buf = state.getBuffer();
    final ChecksumProvider cp = state.getChecksumProvider();

    FileInputStream stream = null;

    try {/*from w  ww  .j av  a  2  s.  co m*/
        stream = new FileInputStream(file);
        int rlen = 0;
        long offset = 0;

        state.uploadStarted();

        // "touch" the file otherwise zero-length files
        rawFileStore.write(ArrayUtils.EMPTY_BYTE_ARRAY, offset, 0);
        state.stop();
        state.uploadBytes(offset);

        while (true) {
            state.start();
            rlen = stream.read(buf);
            if (rlen == -1) {
                break;
            }
            cp.putBytes(buf, 0, rlen);
            final byte[] bufferToWrite;
            if (rlen < buf.length) {
                bufferToWrite = new byte[rlen];
                System.arraycopy(buf, 0, bufferToWrite, 0, rlen);
            } else {
                bufferToWrite = buf;
            }
            rawFileStore.write(bufferToWrite, offset, rlen);
            offset += rlen;
            state.stop(rlen);
            state.uploadBytes(offset);
        }

        return finish(state, offset);
    } finally {
        cleanupUpload(rawFileStore, stream);
    }
}