Package com.foundationdb.util

Examples of com.foundationdb.util.WrappingByteSource


            case FLOAT:
                return valueSource.getFloat();
            case DOUBLE:
                return valueSource.getDouble();
            case BYTES:
                return new WrappingByteSource(valueSource.getBytes());
            case STRING:
                return valueSource.getString();
            default:
                throw new AssertionError(valueSource.getType());
            }
View Full Code Here


        int columnCount = ((Integer)row.get(COLUMN_COUNT_FIELD_INDEX)).intValue();
        int itemNumber = ((Integer)row.get(ITEM_NUMBER_FIELD_INDEX)).intValue();
        String keyString = (String)row.get(KEY_STRING_FIELD_INDEX);

        WrappingByteSource byteSource = (WrappingByteSource)row.get(KEY_BYTES_FIELD_INDEX);
        byte[] keyBytes = byteSource.toByteSubarray();

        long eqCount = (Long)row.get(EQ_COUNT_FIELD_INDEX);
        long ltCount = (Long)row.get(LT_COUNT_FIELD_INDEX);
        long distinctCount = (Long)row.get(DISTINCT_COUNT_FIELD_INDEX);
View Full Code Here

    public void setString(int index, String x) {
        setValue(index, x, jdbcInstance(Types.VARCHAR));
    }

    public void setBytes(int index, byte x[]) {
        setValue(index, new WrappingByteSource(x), jdbcInstance(Types.VARBINARY));
    }
View Full Code Here

        value = new String(b, 0, l, "UTF-8");
        setValue(index, value, jdbcInstance(Types.VARCHAR));
    }

    public void setBinaryStream(int index, InputStream x, int length) throws IOException {
        WrappingByteSource value;
        byte[] b = new byte[length];
        int l = x.read(b);
        value = new WrappingByteSource().wrap(b, 0, l);
        setValue(index, value, jdbcInstance(Types.VARBINARY));
    }
View Full Code Here

        value = new String(ostr.toByteArray(), "ASCII");
        setValue(index, value, jdbcInstance(Types.VARCHAR));
    }

    public void setBinaryStream(int index, InputStream x) throws IOException {
        WrappingByteSource value;
        ByteArrayOutputStream ostr = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];
        while (true) {
            int len = x.read(buf);
            if (len < 0) break;
            ostr.write(buf, 0, len);
        }
        value = new WrappingByteSource(ostr.toByteArray());
        setValue(index, value, jdbcInstance(Types.VARBINARY));
    }
View Full Code Here

        final StringBuilder sb= new StringBuilder(length);
        sb.append(length);
        for (int i = sb.length() ; i < length; i++) {
            sb.append("#");
        }
        return new WrappingByteSource(sb.toString().getBytes());
    }
View Full Code Here

        if (source.getType().typeClass() == MBinary.LONGBLOB ||
             source.getType().typeClass() == MBinary.BLOB ||
             source.getType().typeClass() == MBinary.MEDIUMBLOB ||
             source.getType().typeClass() == MBinary.TINYBLOB ||
             source.getType().typeClass() == MBinary.VARBINARY) {
            return new WrappingByteSource(source.getBytes());
        }
       
        UnderlyingType underlying = underlyingType(source);
        switch (underlying) {
        case BOOL:      return source.getBoolean();
View Full Code Here

    private static List<List<Object>> blist(int... ints) {
        byte[] bytes = new byte[ints.length];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte)ints[i];
        }
        return asList(asList((Object)new WrappingByteSource(bytes)));
    }
View Full Code Here

            throw new IllegalArgumentException(String.format(
                    "String is wider than available bytes: %d > %d", length, width));
        }
        byte[] result = new byte[length];
        System.arraycopy(bytes, offset+prefixSize, result, 0, length);
        return new WrappingByteSource(result);
    }
View Full Code Here

    private static Object decodeValue(IndexColumn keyColumn, String value) {
        try {
            if (keyColumn.getColumn().getType().typeClass() instanceof TBinary) {
                String[] pair = value.split(":");
                if (pair.length == 1) {
                    return new WrappingByteSource(URLDecoder.decode(value, BINARY_SBCS_ENCODING).getBytes(BINARY_SBCS_ENCODING));
                }
                else if (pair.length == 2) {
                    if ("hex".equals(pair[0])) {
                        return Strings.parseHexWithout0x(pair[1]);
                    }
                    else if ("base64".equals(pair[0])) {
                        return new WrappingByteSource(Strings.fromBase64(pair[1]));
                    }
                    else {
                        throw new KeyColumnMismatchException("Malformed encoding:encoded binary value");
                    }
                }
View Full Code Here

TOP

Related Classes of com.foundationdb.util.WrappingByteSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.