Package com.facebook.presto.jdbc.internal.jol.datamodel

Examples of com.facebook.presto.jdbc.internal.jol.datamodel.CurrentDataModel


*/
public class CurrentLayouter implements Layouter {

    @Override
    public ClassLayout layout(ClassData data) {
        CurrentDataModel model = new CurrentDataModel();

        if (data.isArray()) {
            // special case of arrays
            try {
                int base = VMSupport.U.arrayBaseOffset(Class.forName(data.arrayClass()));
                int scale = VMSupport.U.arrayIndexScale(Class.forName(data.arrayClass()));

                int instanceSize = VMSupport.align(base + (data.arrayLength()) * scale, 8);

                SortedSet<FieldLayout> result = new TreeSet<FieldLayout>();
                result.add(new FieldLayout(FieldData.create(data.arrayClass(), "length", "int"), model.headerSize(), model.sizeOf("int")));
                result.add(new FieldLayout(FieldData.create(data.arrayClass(), "<elements>", data.arrayComponentType()), base, scale * data.arrayLength()));
                return new ClassLayout(data, result, model.headerSize(), instanceSize, false);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException("Should not reach here.", e);
            }
        }

        Collection<FieldData> fields = data.fields();

        SortedSet<FieldLayout> result = new TreeSet<FieldLayout>();
        for (FieldData f : fields) {
            result.add(new FieldLayout(f, f.vmOffset(), model.sizeOf(f.typeClass())));
        }

        int instanceSize;
        if (result.isEmpty()) {
            instanceSize = VMSupport.align(model.headerSize());
        } else {
            FieldLayout f = result.last();
            instanceSize = VMSupport.align(f.offset() + f.size());
        }
        return new ClassLayout(data, result, model.headerSize(), instanceSize, true);
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.jdbc.internal.jol.datamodel.CurrentDataModel

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.