Package org.lilyproject.bytes.api

Examples of org.lilyproject.bytes.api.DataOutput


    }

    @Override
    public byte[] toBytes(Object value, IdentityRecordStack parentRecords) throws RepositoryException,
            InterruptedException {
        DataOutput dataOutput = new DataOutputImpl();
        write(value, dataOutput, parentRecords);
        return dataOutput.toByteArray();
    }
View Full Code Here


                .value("boolean", Boolean.TRUE)
                .value("bytes", new ByteArray("foobar".getBytes()))
                .value("date", time)
                .build();

        DataOutput output = new DataOutputImpl();
        MetadataSerDeser.write(metadata, output);
        byte[] metadataBytes = output.toByteArray();

        Metadata readMetadata = MetadataSerDeser.read(new DataInputImpl(metadataBytes));
        assertEquals("value", readMetadata.get("string"));
        assertEquals(5, (int)readMetadata.getInt("int", null));
        assertEquals(99999999999L, (long)readMetadata.getLong("long", null));
View Full Code Here

     * @param variantPropertiesPattern pattern to serialize
     * @return serialized pattern
     */
    byte[] serializeVariantPropertiesPattern(DerefMapVariantPropertiesPattern variantPropertiesPattern)
            throws IOException {
        final DataOutput dataOutput = new DataOutputImpl();

        // total number of entries
        dataOutput.writeInt(variantPropertiesPattern.pattern.size());

        for (Map.Entry<String, String> patternEntry : variantPropertiesPattern.pattern.entrySet()) {
            // name
            final String name = patternEntry.getKey();
            dataOutput.writeUTF(name);

            // value (potentially null)
            final String value = patternEntry.getValue();
            dataOutput.writeUTF(value);
        }

        return dataOutput.toByteArray();
    }
View Full Code Here

    public static byte[] encodeName(QName qname) {
        String name = qname.getName();
        String namespace = qname.getNamespace();

        int sizeEstimate = (((name == null) ? 1 : (name.length() * 2)) + ((namespace == null) ? 1 : (namespace.length() * 2)));
        DataOutput dataOutput = new DataOutputImpl(sizeEstimate);

        dataOutput.writeUTF(namespace);
        dataOutput.writeUTF(name);
        return dataOutput.toByteArray();
    }
View Full Code Here

    public static byte[] encodeValueType(ValueType valueType) {
        return encodeValueType(valueType.getName());
    }

    public static byte[] encodeValueType(String valueTypeName) {
        DataOutput dataOutput = new DataOutputImpl();
        dataOutput.writeByte(valueTypeEncodingVersion);
        dataOutput.writeUTF(valueTypeName);
        return dataOutput.toByteArray();
    }
View Full Code Here

        for (QName fieldName : record.getFields().keySet()) {
            FieldType fieldType = typeManager.getFieldTypeByName(fieldName);
            Metadata metadata = record.getMetadata(fieldName);
            boolean hasMetadata = metadata != null && !metadata.getMap().isEmpty();

            DataOutput output = new DataOutputImpl();

            output.writeByte(hasMetadata ? FieldFlags.METADATA_V1 : FieldFlags.DEFAULT);
            output.writeBytes(fieldType.getValueType().toBytes(record.getField(fieldName), new IdentityRecordStack()));
            if (hasMetadata) {
                HBaseRepository.writeMetadataWithLengthSuffix(metadata, output);
            }

            event.addUpdatedField(fieldType.getId());

            kvs.add(new KeyValue(rowKey, family,
                    Bytes.add(new byte[]{LilyHBaseSchema.RecordColumn.DATA_PREFIX}, fieldType.getId().getBytes()),
                    output.toByteArray()));
        }
       
        // fields to delete, should we add these too?
        kvs.add(new KeyValue(rowKey, family, LilyHBaseSchema.RecordColumn.PAYLOAD.bytes, event.toJsonBytes()));
View Full Code Here

    public static void setExtraPermissions(Set<String> permissions, OperationWithAttributes op) {
        op.setAttribute(EXTRA_PERMISSION_ATT, serialize(permissions));
    }

    public static byte[] serialize(Set<String> strings) {
        DataOutput builder = new DataOutputImpl();
        builder.writeVInt(strings.size());
        for (String permission : strings) {
            builder.writeVUTF(permission);
        }
        return builder.toByteArray();
    }
View Full Code Here

    public Set<String> getRoles() {
        return roles;
    }

    public byte[] serialize() {
        DataOutput buffer = new DataOutputImpl();

        buffer.writeVUTF(name);
        buffer.writeVUTF(tenant);

        buffer.writeVInt(roles.size());
        for (String role : roles) {
            buffer.writeVUTF(role);
        }

        return buffer.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.bytes.api.DataOutput

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.