IGNITE-1803: Implemented. old implementation works.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3b4e6393 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3b4e6393 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3b4e6393 Branch: refs/heads/ignite-1803 Commit: 3b4e6393217cbbab42e393b66b7f615fbb73e9de Parents: a91b98d Author: vozerov-gridgain <[email protected]> Authored: Thu Oct 29 17:10:50 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Thu Oct 29 17:10:50 2015 +0300 ---------------------------------------------------------------------- .../internal/portable/PortableContext.java | 100 ++++----------- .../portable/PortableFIeldDescriptorImpl.java | 82 ++++++++++++ .../internal/portable/PortableObjectEx.java | 24 +++- .../internal/portable/PortableObjectImpl.java | 43 ++++++- .../portable/PortableObjectOffheapImpl.java | 38 ++++++ .../internal/portable/PortableReaderExImpl.java | 128 +++++++++++-------- .../portable/PortableFieldDescriptor.java | 39 ++++++ .../apache/ignite/portable/PortableObject.java | 2 +- .../portable/PortableObjectFieldDescriptor.java | 39 ------ 9 files changed, 327 insertions(+), 168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java index 0265a55..d8cb0be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java @@ -156,7 +156,7 @@ public class PortableContext implements Externalizable { private boolean keepDeserialized; /** Object schemas. */ - private volatile Map<Integer, Object> schemas; + private volatile Map<Integer, PortableSchemaRegistry> schemas; /** * For {@link Externalizable}. @@ -857,95 +857,51 @@ public class PortableContext implements Externalizable { } /** - * Get schema for the given schema ID. + * Get schema registry for type ID. * - * @param schemaId Schema ID. - * @return Schema or {@code null} if there are no such schema. + * @param typeId Type ID. + * @return Schema registry for type ID. */ - @SuppressWarnings("unchecked") - @Nullable public PortableObjectSchema schema(int typeId, int schemaId) { - Map<Integer, Object> schemas0 = schemas; - - if (schemas0 != null) { - Object typeSchemas = schemas0.get(typeId); - - if (typeSchemas instanceof IgniteBiTuple) { - // The most common case goes first. - IgniteBiTuple<Integer, PortableObjectSchema> schema = - (IgniteBiTuple<Integer, PortableObjectSchema>)typeSchemas; + public PortableSchemaRegistry schemaRegistry(int typeId) { + Map<Integer, PortableSchemaRegistry> schemas0 = schemas; - if (schema.get1() == schemaId) - return schema.get2(); - } - else if (typeSchemas instanceof Map) { - Map<Integer, PortableObjectSchema> curSchemas = (Map<Integer, PortableObjectSchema>)typeSchemas; - - return curSchemas.get(schemaId); - } - } - - return null; - } - - /** - * Add schema. - * - * @param schemaId Schema ID. - * @param newTypeSchema New schema. - */ - @SuppressWarnings("unchecked") - public void addSchema(int typeId, int schemaId, PortableObjectSchema newTypeSchema) { - synchronized (this) { - if (schemas == null) { - // This is the very first schema recorded. - Map<Integer, Object> newSchemas = new HashMap<>(); + if (schemas0 == null) { + synchronized (this) { + schemas0 = schemas; - newSchemas.put(typeId, new IgniteBiTuple<>(schemaId, newTypeSchema)); + if (schemas0 == null) { + schemas0 = new HashMap<>(); - schemas = newSchemas; - } - else { - Object typeSchemas = schemas.get(typeId); + PortableSchemaRegistry reg = new PortableSchemaRegistry(); - if (typeSchemas == null) { - // This is the very first object schema. - Map<Integer, Object> newSchemas = new HashMap<>(schemas); + schemas0.put(typeId, reg); - newSchemas.put(typeId, new IgniteBiTuple<>(schemaId, newTypeSchema)); + schemas = schemas0; - schemas = newSchemas; + return reg; } - else if (typeSchemas instanceof IgniteBiTuple) { - IgniteBiTuple<Integer, PortableObjectSchema> typeSchema = - (IgniteBiTuple<Integer, PortableObjectSchema>)typeSchemas; - - if (typeSchema.get1() != schemaId) { - Map<Integer, PortableObjectSchema> newTypeSchemas = new HashMap(); - - newTypeSchemas.put(typeSchema.get1(), typeSchema.get2()); - newTypeSchemas.put(schemaId, newTypeSchema); - - Map<Integer, Object> newSchemas = new HashMap<>(schemas); + } + } - newSchemas.put(typeId, newTypeSchemas); + PortableSchemaRegistry reg = schemas0.get(typeId); - schemas = newSchemas; - } - } - else { - Map<Integer, PortableObjectSchema> newTypeSchemas = - new HashMap((Map<Integer, PortableObjectSchema>)typeSchemas); + if (reg == null) { + synchronized (this) { + reg = schemas.get(typeId); - newTypeSchemas.put(schemaId, newTypeSchema); + if (reg == null) { + reg = new PortableSchemaRegistry(); - Map<Integer, Object> newSchemas = new HashMap<>(schemas); + schemas0 = new HashMap<>(schemas); - newSchemas.put(typeId, newTypeSchemas); + schemas0.put(typeId, reg); - schemas = newSchemas; + schemas = schemas0; } } } + + return reg; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFIeldDescriptorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFIeldDescriptorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFIeldDescriptorImpl.java new file mode 100644 index 0000000..10fad1d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFIeldDescriptorImpl.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.portable; + +import org.apache.ignite.portable.PortableFieldDescriptor; +import org.apache.ignite.portable.PortableObject; + +/** + * Implementation of portable field descriptor. + */ +public class PortableFIeldDescriptorImpl implements PortableFieldDescriptor { + /** Well-known object schemas. */ + private final PortableSchemaRegistry schemas; + + /** Pre-calculated field ID. */ + private final int fieldId; + + /** + * Constructor. + * + * @param schemas Schemas. + * @param fieldId Field ID. + */ + public PortableFIeldDescriptorImpl(PortableSchemaRegistry schemas, int fieldId) { + this.schemas = schemas; + this.fieldId = fieldId; + } + + /** {@inheritDoc} */ + @Override public boolean exists(PortableObject obj) { + PortableObjectEx obj0 = (PortableObjectEx)obj; + + return fieldOffset(obj0) != 0; + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public <T> T value(PortableObject obj) { + PortableObjectEx obj0 = (PortableObjectEx)obj; + + int offset = fieldOffset(obj0); + + return offset != 0 ? (T)obj0.fieldByOffset(offset) : null; + } + + /** + * Get relative field offset. + * + * @param obj Object. + * @return Field offset. + */ + private int fieldOffset(PortableObjectEx obj) { + int schemaId = obj.schemaId(); + + PortableSchema schema = schemas.schema(schemaId); + + if (schema == null) { + schema = obj.createSchema(); + + schemas.addSchema(schemaId, schema); + } + + assert schema != null; + + return schema.offset(fieldId); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java index ef9ee24..42c973b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java @@ -67,12 +67,34 @@ public abstract class PortableObjectEx implements PortableObject { @Nullable public abstract <F> F field(int fieldId) throws PortableException; /** + * Get field by offset. + * + * @param fieldOffset Field offset. + * @return Field value. + */ + @Nullable protected abstract <F> F fieldByOffset(int fieldOffset); + + /** * @param ctx Reader context. * @param fieldName Field name. - * @return Field name. + * @return Field value. */ @Nullable protected abstract <F> F field(PortableReaderContext ctx, String fieldName); + /** + * Get schema ID. + * + * @return Schema ID. + */ + protected abstract int schemaId(); + + /** + * Create schema for object. + * + * @return Schema. + */ + protected abstract PortableSchema createSchema(); + /** {@inheritDoc} */ @Override public PortableObject clone() throws CloneNotSupportedException { return (PortableObject)super.clone(); http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java index f1868b1..84cb812 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java @@ -17,11 +17,6 @@ package org.apache.ignite.internal.portable; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.nio.ByteBuffer; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.IgniteCodeGeneratingFail; @@ -35,10 +30,17 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableFieldDescriptor; import org.apache.ignite.portable.PortableMetadata; import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.nio.ByteBuffer; + /** * Portable object implementation. */ @@ -248,6 +250,14 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern /** {@inheritDoc} */ @SuppressWarnings("unchecked") + @Nullable @Override protected <F> F fieldByOffset(int fieldOffset) { + PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null); + + return (F)reader.unmarshalFieldByOffset(fieldOffset); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Nullable @Override protected <F> F field(PortableReaderContext rCtx, String fieldName) { PortableReaderExImpl reader = new PortableReaderExImpl(ctx, new PortableHeapInputStream(arr), @@ -298,6 +308,29 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern } /** {@inheritDoc} */ + @Override protected int schemaId() { + return PRIM.readInt(arr, start + GridPortableMarshaller.SCHEMA_ID_POS); + } + + /** {@inheritDoc} */ + @Override protected PortableSchema createSchema() { + PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null); + + return reader.createSchema(); + } + + /** {@inheritDoc} */ + @Override public PortableFieldDescriptor fieldDescriptor(String fieldName) throws PortableException { + int typeId = typeId(); + + PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId); + + int fieldId = ctx.userTypeIdMapper(typeId).fieldId(typeId, fieldName); + + return new PortableFIeldDescriptorImpl(schemaReg, fieldId); + } + + /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(ctx); http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java index 0b3e3ea..b6ffa59 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableFieldDescriptor; import org.apache.ignite.portable.PortableMetadata; import org.apache.ignite.portable.PortableObject; import org.jetbrains.annotations.Nullable; @@ -101,6 +102,32 @@ public class PortableObjectOffheapImpl extends PortableObjectEx implements Exter } /** {@inheritDoc} */ + @Override protected int schemaId() { + return UNSAFE.getInt(ptr + start + GridPortableMarshaller.SCHEMA_ID_POS); + } + + /** {@inheritDoc} */ + @Override protected PortableSchema createSchema() { + PortableReaderExImpl reader = new PortableReaderExImpl(ctx, + new PortableOffheapInputStream(ptr, size, false), + start, + null); + + return reader.createSchema(); + } + + /** {@inheritDoc} */ + @Override public PortableFieldDescriptor fieldDescriptor(String fieldName) throws PortableException { + int typeId = typeId(); + + PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId); + + int fieldId = ctx.userTypeIdMapper(typeId).fieldId(typeId, fieldName); + + return new PortableFIeldDescriptorImpl(schemaReg, fieldId); + } + + /** {@inheritDoc} */ @Override public int start() { return start; } @@ -152,6 +179,17 @@ public class PortableObjectOffheapImpl extends PortableObjectEx implements Exter /** {@inheritDoc} */ @SuppressWarnings("unchecked") + @Nullable @Override protected <F> F fieldByOffset(int fieldOffset) { + PortableReaderExImpl reader = new PortableReaderExImpl(ctx, + new PortableOffheapInputStream(ptr, size, false), + start, + null); + + return (F)reader.unmarshalFieldByOffset(fieldOffset); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Nullable @Override protected <F> F field(PortableReaderContext rCtx, String fieldName) { PortableReaderExImpl reader = new PortableReaderExImpl(ctx, new PortableOffheapInputStream(ptr, size, false), http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java index 7736826..9a20a1c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java @@ -47,6 +47,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Map; import java.util.Properties; @@ -160,7 +161,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx private int schemaId; /** Object schema. */ - private PortableObjectSchema schema; + private PortableSchema schema; /** * @param ctx Context. @@ -303,6 +304,21 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx } /** + * @param fieldOffset Field offset. + * @return Unmarshalled value. + * @throws PortableException In case of error. + */ + @Nullable Object unmarshalFieldByOffset(int fieldOffset) throws PortableException { + parseHeaderIfNeeded(); + + int offset = in.readIntPositioned(footerStart + fieldOffset); + + in.position(start + offset); + + return unmarshal(); + } + + /** * @param fieldId Field ID. * @return Value. * @throws PortableException In case of error. @@ -2528,68 +2544,80 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx } /** + * Create schema. + * + * @return Schema. + */ + public PortableSchema createSchema() { + parseHeaderIfNeeded(); + + LinkedHashMap<Integer, Integer> fields = new LinkedHashMap<>(); + + int searchPos = footerStart; + + while (searchPos < footerEnd) { + int fieldId = in.readIntPositioned(searchPos); + + fields.put(fieldId, searchPos + 4 - footerStart); + + searchPos += 8; + } + + return new PortableSchema(fields); + } + + /** * @param id Field ID. * @return Field offset. */ private boolean hasField(int id) { - // TODO: Constant-time lookup. -// if (schema == null) { -// PortableObjectSchema schema0 = ctx.schema(typeId, schemaId); -// -// if (schema0 == null) { -// Map<Integer, Integer> fields = new HashMap<>(256, 0.5f); -// -// int searchPos = footerStart; -// -// while (searchPos < footerEnd) { -// int fieldId = in.readIntPositioned(searchPos); -// -// fields.put(fieldId, searchPos + 4 - footerStart); -// -// searchPos += 8; -// } -// -// schema0 = new PortableObjectSchema(schemaId, fields); -// -// ctx.addSchema(typeId, schemaId, schema0); -// } -// -// schema = schema0; -// } -// -// int fieldOffsetPos = schema.fieldOffsetPosition(id); -// -// if (fieldOffsetPos != 0) { -// int fieldOffset = in.readIntPositioned(footerStart + fieldOffsetPos); -// -// in.position(start + fieldOffset); -// -// return true; -// } -// else -// return false; + if (schema == null) { + PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId); - assert hdrLen != 0; + PortableSchema schema0 = schemaReg.schema(schemaId); - int searchHead = footerStart; - int searchTail = footerEnd; + if (schema0 == null) { + schema0 = createSchema(); - while (true) { - if (searchHead >= searchTail) - return false; + schemaReg.addSchema(schemaId, schema0); + } - int id0 = in.readIntPositioned(searchHead); + schema = schema0; + } - if (id0 == id) { - int offset = in.readIntPositioned(searchHead + 4); + int fieldOffsetPos = schema.offset(id); - in.position(start + offset); + if (fieldOffsetPos != 0) { + int fieldOffset = in.readIntPositioned(footerStart + fieldOffsetPos); - return true; - } + in.position(start + fieldOffset); - searchHead += 8; + return true; } + else + return false; + +// assert hdrLen != 0; +// +// int searchHead = footerStart; +// int searchTail = footerEnd; +// +// while (true) { +// if (searchHead >= searchTail) +// return false; +// +// int id0 = in.readIntPositioned(searchHead); +// +// if (id0 == id) { +// int offset = in.readIntPositioned(searchHead + 4); +// +// in.position(start + offset); +// +// return true; +// } +// +// searchHead += 8; +// } } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/portable/PortableFieldDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableFieldDescriptor.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableFieldDescriptor.java new file mode 100644 index 0000000..27700ee --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableFieldDescriptor.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.portable; + +/** + * Portable object field. Can be used to speed object field lookup. + */ +public interface PortableFieldDescriptor { + /** + * Check whether field exists in the object. + * + * @param obj Object. + * @return {@code True} if exists. + */ + public boolean exists(PortableObject obj); + + /** + * Get field's value from the given object. + * + * @param obj Object. + * @return Value. + */ + public <T> T value(PortableObject obj); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java index 08c6622..1df45a4 100644 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java +++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java @@ -143,7 +143,7 @@ public interface PortableObject extends Serializable, Cloneable { * @return Field descriptor. * @throws PortableException If failed. */ - public PortableObjectFieldDescriptor fieldDescriptor(String fieldName) throws PortableException; + public PortableFieldDescriptor fieldDescriptor(String fieldName) throws PortableException; /** * Gets fully deserialized instance of portable object. http://git-wip-us.apache.org/repos/asf/ignite/blob/3b4e6393/modules/core/src/main/java/org/apache/ignite/portable/PortableObjectFieldDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableObjectFieldDescriptor.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableObjectFieldDescriptor.java deleted file mode 100644 index 182233a..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableObjectFieldDescriptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portable; - -/** - * Portable object field. Can be used to speed object field lookup. - */ -public interface PortableObjectFieldDescriptor { - /** - * Check whether field exists in the object. - * - * @param obj Object. - * @return {@code True} if exists. - */ - public boolean exists(PortableObject obj); - - /** - * Get field's value from the given object. - * - * @param obj Object. - * @return Value. - */ - public <T> T value(PortableObject obj); -}
