Example usage for java.lang Byte MAX_VALUE

List of usage examples for java.lang Byte MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Byte MAX_VALUE.

Prototype

byte MAX_VALUE

To view the source code for java.lang Byte MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value a byte can have, 27-1.

Usage

From source file:org.apache.hadoop.hbase.KeyValue.java

/**
 * Checks the parameters passed to a constructor.
 *
 * @param row row key/*from w  w  w.  j a va2s  .  c o m*/
 * @param rlength row length
 * @param family family name
 * @param flength family length
 * @param qlength qualifier length
 * @param vlength value length
 *
 * @throws IllegalArgumentException an illegal value was passed
 */
private static void checkParameters(final byte[] row, final int rlength, final byte[] family, int flength,
        int qlength, int vlength) throws IllegalArgumentException {
    if (rlength > Short.MAX_VALUE) {
        throw new IllegalArgumentException("Row > " + Short.MAX_VALUE);
    }
    if (row == null) {
        throw new IllegalArgumentException("Row is null");
    }
    // Family length
    flength = family == null ? 0 : flength;
    if (flength > Byte.MAX_VALUE) {
        throw new IllegalArgumentException("Family > " + Byte.MAX_VALUE);
    }
    // Qualifier length
    if (qlength > Integer.MAX_VALUE - rlength - flength) {
        throw new IllegalArgumentException("Qualifier > " + Integer.MAX_VALUE);
    }
    // Key length
    long longKeyLength = getKeyDataStructureSize(rlength, flength, qlength);
    if (longKeyLength > Integer.MAX_VALUE) {
        throw new IllegalArgumentException("keylength " + longKeyLength + " > " + Integer.MAX_VALUE);
    }
    // Value length
    if (vlength > HConstants.MAXIMUM_VALUE_LENGTH) { // FindBugs INT_VACUOUS_COMPARISON
        throw new IllegalArgumentException("Value length " + vlength + " > " + HConstants.MAXIMUM_VALUE_LENGTH);
    }
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFieldFormatterMgr.java

/**
 * Constructs a the fields for a numeric formatter.
 * /*  ww w.  ja v a2s .c o  m*/
 * @param formatter the formatter to be augmented
 */
protected void addFieldsForNumeric(final UIFieldFormatter formatter) {
    int len;
    Class<?> cls = formatter.getDataClass();
    if (cls == BigDecimal.class) {
        len = formatter.getPrecision() + formatter.getScale() + 1;
    } else {
        if (cls == Long.class) {
            len = Long.toString(Long.MAX_VALUE).length();
        } else if (cls == Integer.class) {
            len = Integer.toString(Integer.MAX_VALUE).length();
        } else if (cls == Short.class) {
            len = Short.toString(Short.MAX_VALUE).length();
        } else if (cls == Byte.class) {
            len = Byte.toString(Byte.MAX_VALUE).length();
        } else if (cls == Double.class) {
            len = String.format("%f", Double.MAX_VALUE).length();
        } else if (cls == Float.class) {
            len = String.format("%f", Float.MAX_VALUE).length();

        } else {
            len = formatter.getLength();
            //throw new RuntimeException("Missing case for numeric class ["+ cls.getName() + "]");
        }
        len = Math.min(len, 10);
    }
    StringBuilder sb = new StringBuilder(len);
    for (int i = 0; i < len; i++) {
        sb.append(' ');
    }
    formatter.getFields()
            .add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, len, sb.toString(), false));
}

From source file:org.apache.hadoop.hbase.mapreduce.TestHFileOutputFormat.java

/**
 * Write random values to the writer assuming a table created using
 * {@link #FAMILIES} as column family descriptors
 */// w w w. java  2 s.  co m
private void writeRandomKeyValues(RecordWriter<ImmutableBytesWritable, KeyValue> writer,
        TaskAttemptContext context, Set<byte[]> families, int numRows)
        throws IOException, InterruptedException {
    byte keyBytes[] = new byte[Bytes.SIZEOF_INT];
    int valLength = 10;
    byte valBytes[] = new byte[valLength];

    int taskId = context.getTaskAttemptID().getTaskID().getId();
    assert taskId < Byte.MAX_VALUE : "Unit tests dont support > 127 tasks!";

    Random random = new Random();
    for (int i = 0; i < numRows; i++) {

        Bytes.putInt(keyBytes, 0, i);
        random.nextBytes(valBytes);
        ImmutableBytesWritable key = new ImmutableBytesWritable(keyBytes);

        for (byte[] family : families) {
            KeyValue kv = new KeyValue(keyBytes, family, PerformanceEvaluation.QUALIFIER_NAME, valBytes);
            writer.write(key, kv);
        }
    }
}

From source file:org.apache.hadoop.hbase.mapreduce.TestHFileOutputFormat2.java

/**
 * Write random values to the writer assuming a table created using
 * {@link #FAMILIES} as column family descriptors
 *//*from w  ww  . jav  a  2  s.  c o m*/
private void writeRandomKeyValues(RecordWriter<ImmutableBytesWritable, Cell> writer, TaskAttemptContext context,
        Set<byte[]> families, int numRows) throws IOException, InterruptedException {
    byte keyBytes[] = new byte[Bytes.SIZEOF_INT];
    int valLength = 10;
    byte valBytes[] = new byte[valLength];

    int taskId = context.getTaskAttemptID().getTaskID().getId();
    assert taskId < Byte.MAX_VALUE : "Unit tests dont support > 127 tasks!";

    Random random = new Random();
    for (int i = 0; i < numRows; i++) {

        Bytes.putInt(keyBytes, 0, i);
        random.nextBytes(valBytes);
        ImmutableBytesWritable key = new ImmutableBytesWritable(keyBytes);

        for (byte[] family : families) {
            Cell kv = new KeyValue(keyBytes, family, PerformanceEvaluation.QUALIFIER_NAME, valBytes);
            writer.write(key, kv);
        }
    }
}

From source file:net.spfbl.core.Core.java

public static synchronized void setFloodTimeIP(float time) {
    if (time < 0.0f || time > Byte.MAX_VALUE) {
        Server.logError("invalid FLOOD IP time '" + time + "s'.");
    } else {//from   ww w  . j av a2  s  .com
        Core.FLOOD_TIME_IP = time;
    }
}

From source file:net.spfbl.core.Core.java

public static synchronized void setFloodTimeHELO(float time) {
    if (time < 0.0f || time > Byte.MAX_VALUE) {
        Server.logError("invalid FLOOD HELO time '" + time + "s'.");
    } else {/*w w w .  j ava 2  s .  c  o m*/
        Core.FLOOD_TIME_HELO = time;
    }
}

From source file:org.jenkinsci.plugins.structs.describable.DescribableModelTest.java

@Issue("JENKINS-31967")
@Test//from  w w w .j  a v a  2s. com
public void testJavaStandardTypes() throws Exception {
    // check instantiate with not default values
    roundTrip(AllJavaStandardTypesClass.class,
            map("booleanValue1", Boolean.TRUE, "byteValue1", Byte.MAX_VALUE, "shortValue1", Short.MAX_VALUE,
                    "intValue1", Integer.MAX_VALUE, "longValue1", Long.MAX_VALUE, "floatValue1",
                    Float.MAX_VALUE, "doubleValue1", Double.MAX_VALUE));
    // check with default values
    roundTrip(AllJavaStandardTypesClass.class,
            map("booleanValue1", false, "byteValue1", (byte) 0, "shortValue1", (short) 0, "intValue1", 0,
                    "longValue1", (long) 0, "floatValue1", (float) 0.0, "doubleValue1", 0.0));
}

From source file:net.spfbl.core.Core.java

public static synchronized void setFloodTimeSender(float time) {
    if (time < 0.0f || time > Byte.MAX_VALUE) {
        Server.logError("invalid FLOOD SENDER time '" + time + "s'.");
    } else {//from ww w.  j  a v a  2  s  .c om
        Core.FLOOD_TIME_SENDER = time;
    }
}

From source file:net.spfbl.core.Core.java

public static synchronized void setFloodMaxRetry(int max) {
    if (max < 0 || max > Byte.MAX_VALUE) {
        Server.logError("invalid FLOOD max retry '" + max + "'.");
    } else {/*from  w  ww  .j  a v  a  2s  . c  o  m*/
        Core.FLOOD_MAX_RETRY = (byte) max;
    }
}

From source file:net.spfbl.core.Core.java

public static synchronized void setDeferTimeFLOOD(int time) {
    if (time < 0 || time > Byte.MAX_VALUE) {
        Server.logError("invalid DEFER time for FLOOD '" + time + "'.");
    } else {/*from   ww w . j av  a2  s  .co m*/
        Core.DEFER_TIME_FLOOD = (byte) time;
    }
}