IGNITE-950 - Renaming.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/20f5b9cd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/20f5b9cd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/20f5b9cd Branch: refs/heads/ignite-1753-1282 Commit: 20f5b9cd75f59aaac4cc4720e3b5aba5494820ab Parents: 71d18bb Author: Alexey Goncharuk <[email protected]> Authored: Mon Nov 2 20:21:16 2015 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Mon Nov 2 20:21:18 2015 +0300 ---------------------------------------------------------------------- .../ignite/examples/portable/Address.java | 16 +- ...mputeClientPortableTaskExecutionExample.java | 4 +- .../portable/computegrid/ComputeClientTask.java | 16 +- .../CacheClientPortablePutGetExample.java | 12 +- .../CacheClientPortableQueryExample.java | 30 +- .../java/org/apache/ignite/IgniteCache.java | 12 +- .../java/org/apache/ignite/IgniteObjects.java | 58 +- .../org/apache/ignite/binary/BinaryField.java | 39 + .../binary/BinaryInvalidTypeException.java | 58 + .../org/apache/ignite/binary/BinaryObject.java | 162 + .../ignite/binary/BinaryObjectBuilder.java | 136 + .../ignite/binary/BinaryObjectException.java | 57 + .../apache/ignite/binary/BinaryRawReader.java | 240 ++ .../apache/ignite/binary/BinaryRawWriter.java | 225 ++ .../org/apache/ignite/binary/BinaryReader.java | 291 ++ .../apache/ignite/binary/BinarySerializer.java | 49 + .../ignite/binary/BinaryTypeConfiguration.java | 155 + .../ignite/binary/BinaryTypeIdMapper.java | 56 + .../ignite/binary/BinaryTypeMetadata.java | 60 + .../org/apache/ignite/binary/BinaryWriter.java | 273 ++ .../org/apache/ignite/binary/Binarylizable.java | 48 + .../org/apache/ignite/binary/package-info.java | 22 + .../ignite/igniteobject/IgniteObject.java | 163 -- .../igniteobject/IgniteObjectBuilder.java | 136 - .../igniteobject/IgniteObjectConfiguration.java | 155 - .../igniteobject/IgniteObjectException.java | 57 - .../igniteobject/IgniteObjectIdMapper.java | 56 - .../IgniteObjectInvalidClassException.java | 58 - .../igniteobject/IgniteObjectMarshalAware.java | 48 - .../igniteobject/IgniteObjectMetadata.java | 60 - .../ignite/igniteobject/IgniteObjectReader.java | 291 -- .../igniteobject/IgniteObjectSerializer.java | 49 - .../ignite/igniteobject/IgniteObjectWriter.java | 273 -- .../ignite/igniteobject/package-info.java | 22 - .../communication/GridIoMessageFactory.java | 4 +- .../internal/portable/BinaryFieldImpl.java | 82 + .../portable/BinaryMetaDataCollector.java | 263 ++ .../internal/portable/BinaryMetaDataImpl.java | 150 + .../internal/portable/BinaryObjectEx.java | 245 ++ .../internal/portable/BinaryObjectImpl.java | 538 ++++ .../portable/BinaryObjectOffheapImpl.java | 304 ++ .../internal/portable/BinaryRawReaderEx.java | 33 + .../internal/portable/BinaryRawWriterEx.java | 60 + .../internal/portable/BinaryReaderExImpl.java | 2765 ++++++++++++++++++ .../internal/portable/BinaryWriterExImpl.java | 1855 ++++++++++++ .../portable/GridPortableMarshaller.java | 30 +- .../internal/portable/IgniteObjectEx.java | 245 -- .../internal/portable/IgniteObjectImpl.java | 538 ---- .../portable/IgniteObjectMetaDataCollector.java | 263 -- .../portable/IgniteObjectMetaDataImpl.java | 150 - .../portable/IgniteObjectOffheapImpl.java | 304 -- .../portable/IgniteObjectRawReaderEx.java | 33 - .../portable/IgniteObjectRawWriterEx.java | 60 - .../portable/IgniteObjectReaderExImpl.java | 2765 ------------------ .../portable/IgniteObjectWriterExImpl.java | 1855 ------------ .../portable/PortableClassDescriptor.java | 153 +- .../internal/portable/PortableContext.java | 124 +- .../internal/portable/PortableFieldImpl.java | 82 - .../portable/PortableMetaDataHandler.java | 12 +- .../portable/PortableReaderContext.java | 8 +- .../ignite/internal/portable/PortableUtils.java | 14 +- .../builder/BinaryObjectBuilderImpl.java | 551 ++++ .../builder/IgniteObjectBuilderImpl.java | 551 ---- .../portable/builder/PortableBuilderEnum.java | 8 +- .../portable/builder/PortableBuilderReader.java | 56 +- .../PortableBuilderSerializationAware.java | 2 +- .../builder/PortableBuilderSerializer.java | 30 +- .../builder/PortableEnumArrayLazyValue.java | 12 +- .../portable/builder/PortableLazyArrayList.java | 2 +- .../builder/PortableLazyLinkedList.java | 2 +- .../portable/builder/PortableLazyMap.java | 2 +- .../portable/builder/PortableLazyMapEntry.java | 2 +- .../portable/builder/PortableLazySet.java | 4 +- .../builder/PortableModifiableLazyValue.java | 2 +- .../builder/PortableObjectArrayLazyValue.java | 8 +- .../builder/PortablePlainLazyValue.java | 2 +- .../builder/PortablePlainPortableObject.java | 22 +- .../portable/builder/PortableValueWithType.java | 4 +- .../streams/PortableAbstractInputStream.java | 6 +- .../affinity/GridAffinityAssignmentCache.java | 4 +- .../affinity/GridAffinityProcessor.java | 6 +- .../processors/cache/CacheOperationContext.java | 22 +- .../cache/GridCacheConcurrentMap.java | 2 +- .../processors/cache/GridCacheContext.java | 2 +- .../processors/cache/GridCacheMapEntry.java | 2 +- .../processors/cache/GridCacheProxyImpl.java | 4 +- .../processors/cache/IgniteCacheProxy.java | 6 +- .../processors/cache/IgniteInternalCache.java | 4 +- .../dht/GridDhtTransactionalCacheAdapter.java | 4 +- .../dht/atomic/GridDhtAtomicCache.java | 5 +- .../dht/colocated/GridDhtColocatedCache.java | 2 +- .../near/GridNearTransactionalCache.java | 2 +- .../local/atomic/GridLocalAtomicCache.java | 27 +- .../CacheDefaultPortableAffinityKeyMapper.java | 6 +- .../portable/CacheObjectPortableProcessor.java | 20 +- .../CacheObjectPortableProcessorImpl.java | 192 +- .../cache/portable/IgniteObjectsImpl.java | 24 +- .../transactions/IgniteTxLocalAdapter.java | 6 +- .../platform/PlatformAbstractTarget.java | 30 +- .../processors/platform/PlatformContext.java | 26 +- .../platform/PlatformContextImpl.java | 46 +- .../platform/PlatformExtendedException.java | 4 +- .../platform/PlatformProcessorImpl.java | 4 +- .../platform/cache/PlatformCache.java | 42 +- .../cache/PlatformCacheEntryFilterImpl.java | 6 +- .../cache/PlatformCacheEntryProcessorImpl.java | 12 +- .../platform/cache/PlatformCacheIterator.java | 4 +- .../PlatformCachePartialUpdateException.java | 4 +- .../cache/affinity/PlatformAffinity.java | 8 +- .../query/PlatformAbstractQueryCursor.java | 10 +- .../PlatformContinuousQueryRemoteFilter.java | 4 +- .../cache/query/PlatformFieldsQueryCursor.java | 4 +- .../cache/query/PlatformQueryCursor.java | 4 +- .../cache/store/PlatformCacheStoreCallback.java | 6 +- .../platform/cluster/PlatformClusterGroup.java | 12 +- .../cluster/PlatformClusterNodeFilterImpl.java | 4 +- .../platform/compute/PlatformAbstractJob.java | 4 +- .../platform/compute/PlatformAbstractTask.java | 6 +- .../platform/compute/PlatformClosureJob.java | 4 +- .../platform/compute/PlatformCompute.java | 24 +- .../platform/compute/PlatformFullJob.java | 6 +- .../platform/compute/PlatformFullTask.java | 12 +- .../datastreamer/PlatformDataStreamer.java | 4 +- .../PlatformStreamReceiverImpl.java | 4 +- .../dotnet/PlatformDotNetCacheStore.java | 50 +- .../PlatformDotNetConfigurationClosure.java | 14 +- .../events/PlatformEventFilterListenerImpl.java | 6 +- .../platform/events/PlatformEvents.java | 18 +- .../messaging/PlatformMessageFilterImpl.java | 6 +- .../messaging/PlatformMessageLocalFilter.java | 4 +- .../platform/messaging/PlatformMessaging.java | 8 +- .../services/PlatformAbstractService.java | 16 +- .../platform/services/PlatformServices.java | 20 +- .../transactions/PlatformTransactions.java | 4 +- .../platform/utils/PlatformFutureUtils.java | 10 +- .../platform/utils/PlatformReaderBiClosure.java | 4 +- .../platform/utils/PlatformReaderClosure.java | 4 +- .../platform/utils/PlatformUtils.java | 60 +- .../platform/utils/PlatformWriterBiClosure.java | 4 +- .../platform/utils/PlatformWriterClosure.java | 4 +- .../processors/query/GridQueryProcessor.java | 6 +- .../marshaller/portable/PortableMarshaller.java | 41 +- .../apache/ignite/portable/PortableField.java | 41 - ...idBinaryObjectBuilderAdditionalSelfTest.java | 1289 ++++++++ .../GridBinaryObjectBuilderSelfTest.java | 1069 +++++++ ...tBuilderStringAsCharsAdditionalSelfTest.java | 28 + ...inaryObjectBuilderStringAsCharsSelfTest.java | 28 + ...idIgniteObjectBuilderAdditionalSelfTest.java | 1289 -------- .../GridIgniteObjectBuilderSelfTest.java | 1069 ------- ...tBuilderStringAsCharsAdditionalSelfTest.java | 28 - ...gniteObjectBuilderStringAsCharsSelfTest.java | 28 - .../GridPortableAffinityKeySelfTest.java | 4 +- ...idPortableMarshallerCtxDisabledSelfTest.java | 24 +- .../GridPortableMarshallerSelfTest.java | 440 +-- .../GridPortableMetaDataDisabledSelfTest.java | 36 +- .../portable/GridPortableMetaDataSelfTest.java | 36 +- .../portable/GridPortableWildcardsSelfTest.java | 70 +- .../GridBinaryMarshalerAwareTestClass.java | 67 + ...GridIgniteObjectMarshalerAwareTestClass.java | 67 - .../mutabletest/GridPortableTestClasses.java | 6 +- ...naryObjectsAbstractDataStreamerSelfTest.java | 190 ++ ...aryObjectsAbstractMultiThreadedSelfTest.java | 231 ++ .../GridCacheBinaryObjectsAbstractSelfTest.java | 981 +++++++ ...ntNodeBinaryObjectMetadataMultinodeTest.java | 295 ++ ...CacheClientNodeBinaryObjectMetadataTest.java | 290 ++ ...ntNodeIgniteObjectMetadataMultinodeTest.java | 295 -- ...CacheClientNodeIgniteObjectMetadataTest.java | 290 -- ...niteObjectsAbstractDataStreamerSelfTest.java | 190 -- ...iteObjectsAbstractMultiThreadedSelfTest.java | 231 -- .../GridCacheIgniteObjectsAbstractSelfTest.java | 981 ------- ...GridCachePortableStorePortablesSelfTest.java | 6 +- ...ridPortableCacheEntryMemorySizeSelfTest.java | 8 +- ...leDuplicateIndexObjectsAbstractSelfTest.java | 8 +- .../GridDataStreamerImplSelfTest.java | 26 +- ...ridCacheAffinityRoutingPortableSelfTest.java | 4 +- ...rtableDataStreamerMultithreadedSelfTest.java | 4 +- ...tionedOnlyPortableMultithreadedSelfTest.java | 4 +- ...AtomicNearDisabledOffheapTieredSelfTest.java | 29 + ...BinaryObjectsAtomicNearDisabledSelfTest.java | 51 + ...inaryObjectsAtomicOffheapTieredSelfTest.java | 29 + .../GridCacheBinaryObjectsAtomicSelfTest.java | 51 + ...tionedNearDisabledOffheapTieredSelfTest.java | 30 + ...yObjectsPartitionedNearDisabledSelfTest.java | 51 + ...ObjectsPartitionedOffheapTieredSelfTest.java | 30 + ...idCacheBinaryObjectsPartitionedSelfTest.java | 51 + ...AtomicNearDisabledOffheapTieredSelfTest.java | 29 - ...IgniteObjectsAtomicNearDisabledSelfTest.java | 51 - ...gniteObjectsAtomicOffheapTieredSelfTest.java | 29 - .../GridCacheIgniteObjectsAtomicSelfTest.java | 51 - ...tionedNearDisabledOffheapTieredSelfTest.java | 30 - ...eObjectsPartitionedNearDisabledSelfTest.java | 51 - ...ObjectsPartitionedOffheapTieredSelfTest.java | 30 - ...idCacheIgniteObjectsPartitionedSelfTest.java | 51 - ...eapTieredEvictionAtomicPortableSelfTest.java | 6 +- ...heOffHeapTieredEvictionPortableSelfTest.java | 6 +- ...ridCacheBinaryObjectsReplicatedSelfTest.java | 51 + ...ridCacheIgniteObjectsReplicatedSelfTest.java | 51 - ...idCacheBinaryObjectsAtomicLocalSelfTest.java | 32 + ...BinaryObjectsLocalOffheapTieredSelfTest.java | 29 + .../GridCacheBinaryObjectsLocalSelfTest.java | 51 + ...idCacheIgniteObjectsAtomicLocalSelfTest.java | 32 - ...IgniteObjectsLocalOffheapTieredSelfTest.java | 29 - .../GridCacheIgniteObjectsLocalSelfTest.java | 51 - .../PlatformComputePortableArgTask.java | 8 +- .../platform/PlatformEventsWriteEventTask.java | 4 +- .../IgnitePortableObjectsTestSuite.java | 72 +- .../Config/Compute/compute-grid1.xml | 6 +- parent/pom.xml | 4 +- 208 files changed, 14840 insertions(+), 14390 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/examples/src/main/java/org/apache/ignite/examples/portable/Address.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java index 1c23e41..77278aa 100644 --- a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java +++ b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java @@ -17,19 +17,19 @@ package org.apache.ignite.examples.portable; -import org.apache.ignite.igniteobject.IgniteObjectException; -import org.apache.ignite.igniteobject.IgniteObjectMarshalAware; -import org.apache.ignite.igniteobject.IgniteObjectReader; -import org.apache.ignite.igniteobject.IgniteObjectWriter; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.Binarylizable; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; /** * Employee address. * <p> - * This class implements {@link org.apache.ignite.igniteobject.IgniteObjectMarshalAware} only for example purposes, + * This class implements {@link org.apache.ignite.binary.Binarylizable} only for example purposes, * in order to show how to customize serialization and deserialization of * portable objects. */ -public class Address implements IgniteObjectMarshalAware { +public class Address implements Binarylizable { /** Street. */ private String street; @@ -53,13 +53,13 @@ public class Address implements IgniteObjectMarshalAware { } /** {@inheritDoc} */ - @Override public void writePortable(IgniteObjectWriter writer) throws IgniteObjectException { + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { writer.writeString("street", street); writer.writeInt("zip", zip); } /** {@inheritDoc} */ - @Override public void readPortable(IgniteObjectReader reader) throws IgniteObjectException { + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { street = reader.readString("street"); zip = reader.readInt("zip"); } http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java index 15eed07..b281655 100644 --- a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java @@ -25,7 +25,7 @@ import org.apache.ignite.Ignition; import org.apache.ignite.examples.portable.Address; import org.apache.ignite.examples.portable.Employee; import org.apache.ignite.examples.portable.ExamplePortableNodeStartup; -import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.binary.BinaryObject; /** * This example demonstrates use of portable objects with task execution. @@ -74,7 +74,7 @@ public class ComputeClientPortableTaskExecutionExample { // Convert collection of employees to collection of portable objects. // This allows to send objects across nodes without requiring to have // Employee class on classpath of these nodes. - Collection<IgniteObject> portables = ignite.portables().toPortable(employees); + Collection<BinaryObject> portables = ignite.portables().toPortable(employees); // Execute task and get average salary. Long avgSalary = ignite.compute(ignite.cluster().forRemotes()).execute(new ComputeClientTask(), portables); http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java index 94b4e0c..c83dbf2 100644 --- a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java +++ b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java @@ -25,7 +25,7 @@ import org.apache.ignite.compute.ComputeJobAdapter; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.compute.ComputeTaskSplitAdapter; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.binary.BinaryObject; import org.jetbrains.annotations.Nullable; /** @@ -37,19 +37,19 @@ import org.jetbrains.annotations.Nullable; * for each batch. After all jobs are executed, there results are reduced to * get the average salary. */ -public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<IgniteObject>, Long> { +public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<BinaryObject>, Long> { /** {@inheritDoc} */ @Override protected Collection<? extends ComputeJob> split( int gridSize, - Collection<IgniteObject> arg + Collection<BinaryObject> arg ) { Collection<ComputeClientJob> jobs = new ArrayList<>(); - Collection<IgniteObject> employees = new ArrayList<>(); + Collection<BinaryObject> employees = new ArrayList<>(); // Split provided collection into batches and // create a job for each batch. - for (IgniteObject employee : arg) { + for (BinaryObject employee : arg) { employees.add(employee); if (employees.size() == 3) { @@ -85,12 +85,12 @@ public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<Ignite */ private static class ComputeClientJob extends ComputeJobAdapter { /** Collection of employees. */ - private final Collection<IgniteObject> employees; + private final Collection<BinaryObject> employees; /** * @param employees Collection of employees. */ - private ComputeClientJob(Collection<IgniteObject> employees) { + private ComputeClientJob(Collection<BinaryObject> employees) { this.employees = employees; } @@ -99,7 +99,7 @@ public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<Ignite long sum = 0; int cnt = 0; - for (IgniteObject employee : employees) { + for (BinaryObject employee : employees) { System.out.println(">>> Processing employee: " + employee.field("name")); // Get salary from portable object. Note that object http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java index 793bfbf..0adb5b7 100644 --- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java @@ -32,7 +32,7 @@ import org.apache.ignite.examples.portable.Address; import org.apache.ignite.examples.portable.ExamplePortableNodeStartup; import org.apache.ignite.examples.portable.Organization; import org.apache.ignite.examples.portable.OrganizationType; -import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.binary.BinaryObject; /** * This example demonstrates use of portable objects with Ignite cache. @@ -133,10 +133,10 @@ public class CacheClientPortablePutGetExample { cache.put(1, org); // Get cache that will get values as portable objects. - IgniteCache<Integer, IgniteObject> portableCache = cache.withKeepBinary(); + IgniteCache<Integer, BinaryObject> portableCache = cache.withKeepBinary(); // Get recently created organization as a portable object. - IgniteObject po = portableCache.get(1); + BinaryObject po = portableCache.get(1); // Get organization's name from portable object (note that // object doesn't need to be fully deserialized). @@ -212,16 +212,16 @@ public class CacheClientPortablePutGetExample { cache.putAll(map); // Get cache that will get values as portable objects. - IgniteCache<Integer, IgniteObject> portableCache = cache.withKeepBinary(); + IgniteCache<Integer, BinaryObject> portableCache = cache.withKeepBinary(); // Get recently created organizations as portable objects. - Map<Integer, IgniteObject> poMap = portableCache.getAll(map.keySet()); + Map<Integer, BinaryObject> poMap = portableCache.getAll(map.keySet()); Collection<String> names = new ArrayList<>(); // Get organizations' names from portable objects (note that // objects don't need to be fully deserialized). - for (IgniteObject po : poMap.values()) + for (BinaryObject po : poMap.values()) names.add(po.<String>field("name")); System.out.println(); http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java index cbeed12..0975c29 100644 --- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java @@ -39,7 +39,7 @@ import org.apache.ignite.examples.portable.EmployeeKey; import org.apache.ignite.examples.portable.ExamplePortableNodeStartup; import org.apache.ignite.examples.portable.Organization; import org.apache.ignite.examples.portable.OrganizationType; -import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.binary.BinaryObject; /** * This example demonstrates use of portable objects with cache queries. @@ -98,7 +98,7 @@ public class CacheClientPortableQueryExample { populateCache(orgCache, employeeCache); // Get cache that will work with portable objects. - IgniteCache<IgniteObject, IgniteObject> portableCache = employeeCache.withKeepBinary(); + IgniteCache<BinaryObject, BinaryObject> portableCache = employeeCache.withKeepBinary(); // Run SQL query example. sqlQuery(portableCache); @@ -180,17 +180,17 @@ public class CacheClientPortableQueryExample { * * @param cache Ignite cache. */ - private static void sqlQuery(IgniteCache<IgniteObject, IgniteObject> cache) { - SqlQuery<IgniteObject, IgniteObject> query = new SqlQuery<>(Employee.class, "zip = ?"); + private static void sqlQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class, "zip = ?"); int zip = 94109; - QueryCursor<Cache.Entry<IgniteObject, IgniteObject>> employees = cache.query(query.setArgs(zip)); + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query.setArgs(zip)); System.out.println(); System.out.println(">>> Employees with zip " + zip + ':'); - for (Cache.Entry<IgniteObject, IgniteObject> e : employees.getAll()) + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) System.out.println(">>> " + e.getValue().deserialize()); } @@ -199,20 +199,20 @@ public class CacheClientPortableQueryExample { * * @param cache Ignite cache. */ - private static void sqlJoinQuery(IgniteCache<IgniteObject, IgniteObject> cache) { - SqlQuery<IgniteObject, IgniteObject> query = new SqlQuery<>(Employee.class, + private static void sqlJoinQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class, "from Employee, \"" + ORGANIZATION_CACHE_NAME + "\".Organization as org " + "where Employee.organizationId = org._key and org.name = ?"); String organizationName = "GridGain"; - QueryCursor<Cache.Entry<IgniteObject, IgniteObject>> employees = + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query.setArgs(organizationName)); System.out.println(); System.out.println(">>> Employees working for " + organizationName + ':'); - for (Cache.Entry<IgniteObject, IgniteObject> e : employees.getAll()) + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) System.out.println(">>> " + e.getValue()); } @@ -221,7 +221,7 @@ public class CacheClientPortableQueryExample { * * @param cache Ignite cache. */ - private static void sqlFieldsQuery(IgniteCache<IgniteObject, IgniteObject> cache) { + private static void sqlFieldsQuery(IgniteCache<BinaryObject, BinaryObject> cache) { SqlFieldsQuery query = new SqlFieldsQuery("select name, salary from Employee"); QueryCursor<List<?>> employees = cache.query(query); @@ -238,15 +238,15 @@ public class CacheClientPortableQueryExample { * * @param cache Ignite cache. */ - private static void textQuery(IgniteCache<IgniteObject, IgniteObject> cache) { - TextQuery<IgniteObject, IgniteObject> query = new TextQuery<>(Employee.class, "TX"); + private static void textQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + TextQuery<BinaryObject, BinaryObject> query = new TextQuery<>(Employee.class, "TX"); - QueryCursor<Cache.Entry<IgniteObject, IgniteObject>> employees = cache.query(query); + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query); System.out.println(); System.out.println(">>> Employees living in Texas:"); - for (Cache.Entry<IgniteObject, IgniteObject> e : employees.getAll()) + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) System.out.println(">>> " + e.getValue().deserialize()); } http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index d58ba30..099a3f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -132,9 +132,9 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS public IgniteCache<K, V> withNoRetries(); /** - * Returns cache that will operate with portable objects. + * Returns cache that will operate with binary objects. * <p> - * Cache returned by this method will not be forced to deserialize portable objects, + * Cache returned by this method will not be forced to deserialize binary objects, * so keys and values will be returned from cache API methods without changes. Therefore, * signature of the cache can contain only following types: * <ul> @@ -153,16 +153,16 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * </ul> * <p> * For example, if you use {@link Integer} as a key and {@code Value} class as a value - * (which will be stored in portable format), you should acquire following projection + * (which will be stored in binary format), you should acquire following projection * to avoid deserialization: * <pre> - * IgniteCache<Integer, PortableObject> prj = cache.withKeepBinary(); + * IgniteCache<Integer, BinaryObject> prj = cache.withKeepBinary(); * * // Value is not deserialized and returned in portable format. - * PortableObject po = prj.get(1); + * BinaryObject po = prj.get(1); * </pre> * <p> - * Note that this method makes sense only if cache is working in portable mode ({@link PortableMarshaller} is used). + * Note that this method makes sense only if cache is working in binary mode ({@link PortableMarshaller} is used). * If not, this method is no-op and will return current cache. * * @return New cache instance for portable objects. http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/IgniteObjects.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteObjects.java b/modules/core/src/main/java/org/apache/ignite/IgniteObjects.java index 4afd15b..ace9865 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteObjects.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteObjects.java @@ -26,10 +26,10 @@ import java.util.LinkedList; import java.util.TreeMap; import java.util.UUID; import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.igniteobject.IgniteObjectBuilder; -import org.apache.ignite.igniteobject.IgniteObjectException; -import org.apache.ignite.igniteobject.IgniteObjectMetadata; -import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.binary.BinaryObjectBuilder; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryTypeMetadata; +import org.apache.ignite.binary.BinaryObject; import org.jetbrains.annotations.Nullable; /** @@ -42,7 +42,7 @@ import org.jetbrains.annotations.Nullable; * <li>Automatically convert collections and maps between Java, .NET, and C++.</li> * <li> * Optionally avoid deserialization of objects on the server side - * (objects are stored in {@link org.apache.ignite.igniteobject.IgniteObject} format). + * (objects are stored in {@link org.apache.ignite.binary.BinaryObject} format). * </li> * <li>Avoid need to have concrete class definitions on the server side.</li> * <li>Dynamically change structure of the classes without having to restart the cluster.</li> @@ -86,7 +86,7 @@ import org.jetbrains.annotations.Nullable; * IgniteCache<Integer.class, PortableObject> prj = cache.withKeepBinary(); * </pre> * <h1 class="header">Automatic Portable Types</h1> - * Note that only portable classes are converted to {@link org.apache.ignite.igniteobject.IgniteObject} format. Following + * Note that only portable classes are converted to {@link org.apache.ignite.binary.BinaryObject} format. Following * classes are never converted (e.g., {@link #toPortable(Object)} method will return original * object, and instances of these classes will be stored in cache without changes): * <ul> @@ -110,7 +110,7 @@ import org.jetbrains.annotations.Nullable; * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} * in C#, etc. * <h1 class="header">Building Portable Objects</h1> - * Ignite comes with {@link org.apache.ignite.igniteobject.IgniteObjectBuilder} which allows to build portable objects dynamically: + * Ignite comes with {@link org.apache.ignite.binary.BinaryObjectBuilder} which allows to build portable objects dynamically: * <pre name=code class=java> * PortableBuilder builder = Ignition.ignite().portables().builder(); * @@ -188,7 +188,7 @@ import org.jetbrains.annotations.Nullable; * * cfg.setMarshaller(marsh); * </pre> - * You can also specify class name for a portable object via {@link org.apache.ignite.igniteobject.IgniteObjectConfiguration}. + * You can also specify class name for a portable object via {@link org.apache.ignite.binary.BinaryTypeConfiguration}. * Do it in case if you need to override other configuration properties on per-type level, like * ID-mapper, or serializer. * <h1 class="header">Custom Affinity Keys</h1> @@ -215,7 +215,7 @@ import org.jetbrains.annotations.Nullable; * </pre> * <h1 class="header">Serialization</h1> * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom - * serialization logic by optionally implementing {@link org.apache.ignite.igniteobject.IgniteObjectMarshalAware} interface, like so: + * serialization logic by optionally implementing {@link org.apache.ignite.binary.Binarylizable} interface, like so: * <pre name=code class=java> * public class Address implements PortableMarshalAware { * private String street; @@ -224,20 +224,20 @@ import org.jetbrains.annotations.Nullable; * // Empty constructor required for portable deserialization. * public Address() {} * - * @Override public void writePortable(PortableWriter writer) throws PortableException { + * @Override public void writeBinary(PortableWriter writer) throws PortableException { * writer.writeString("street", street); * writer.writeInt("zip", zip); * } * - * @Override public void readPortable(PortableReader reader) throws PortableException { + * @Override public void readBinary(PortableReader reader) throws PortableException { * street = reader.readString("street"); * zip = reader.readInt("zip"); * } * } * </pre> * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link org.apache.ignite.igniteobject.IgniteObjectSerializer} either globally in {@link PortableMarshaller} or - * for a specific type via {@link org.apache.ignite.igniteobject.IgniteObjectConfiguration} instance. + * logic in {@link org.apache.ignite.binary.BinarySerializer} either globally in {@link PortableMarshaller} or + * for a specific type via {@link org.apache.ignite.binary.BinaryTypeConfiguration} instance. * <p> * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. * <ul> @@ -254,10 +254,10 @@ import org.jetbrains.annotations.Nullable; * <h1 class="header">Custom ID Mappers</h1> * Ignite implementation uses name hash codes to generate IDs for class names or field names * internally. However, in cases when you want to provide your own ID mapping schema, - * you can provide your own {@link org.apache.ignite.igniteobject.IgniteObjectIdMapper} implementation. + * you can provide your own {@link org.apache.ignite.binary.BinaryTypeIdMapper} implementation. * <p> * ID-mapper may be provided either globally in {@link PortableMarshaller}, - * or for a specific type via {@link org.apache.ignite.igniteobject.IgniteObjectConfiguration} instance. + * or for a specific type via {@link org.apache.ignite.binary.BinaryTypeConfiguration} instance. * <h1 class="header">Query Indexing</h1> * Portable objects can be indexed for querying by specifying index fields in * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific @@ -297,13 +297,13 @@ public interface IgniteObjects { public int typeId(String typeName); /** - * Converts provided object to instance of {@link org.apache.ignite.igniteobject.IgniteObject}. + * Converts provided object to instance of {@link org.apache.ignite.binary.BinaryObject}. * * @param obj Object to convert. * @return Converted object. - * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error. + * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - public <T> T toPortable(@Nullable Object obj) throws IgniteObjectException; + public <T> T toPortable(@Nullable Object obj) throws BinaryObjectException; /** * Creates new portable builder. @@ -311,7 +311,7 @@ public interface IgniteObjects { * @param typeId ID of the type. * @return Newly portable builder. */ - public IgniteObjectBuilder builder(int typeId); + public BinaryObjectBuilder builder(int typeId); /** * Creates new portable builder. @@ -319,7 +319,7 @@ public interface IgniteObjects { * @param typeName Type name. * @return Newly portable builder. */ - public IgniteObjectBuilder builder(String typeName); + public BinaryObjectBuilder builder(String typeName); /** * Creates portable builder initialized by existing portable object. @@ -327,40 +327,40 @@ public interface IgniteObjects { * @param portableObj Portable object to initialize builder. * @return Portable builder. */ - public IgniteObjectBuilder builder(IgniteObject portableObj); + public BinaryObjectBuilder builder(BinaryObject portableObj); /** * Gets metadata for provided class. * * @param cls Class. * @return Metadata. - * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error. + * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - @Nullable public IgniteObjectMetadata metadata(Class<?> cls) throws IgniteObjectException; + @Nullable public BinaryTypeMetadata metadata(Class<?> cls) throws BinaryObjectException; /** * Gets metadata for provided class name. * * @param typeName Type name. * @return Metadata. - * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error. + * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - @Nullable public IgniteObjectMetadata metadata(String typeName) throws IgniteObjectException; + @Nullable public BinaryTypeMetadata metadata(String typeName) throws BinaryObjectException; /** * Gets metadata for provided type ID. * * @param typeId Type ID. * @return Metadata. - * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error. + * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - @Nullable public IgniteObjectMetadata metadata(int typeId) throws IgniteObjectException; + @Nullable public BinaryTypeMetadata metadata(int typeId) throws BinaryObjectException; /** * Gets metadata for all known types. * * @return Metadata. - * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error. + * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - public Collection<IgniteObjectMetadata> metadata() throws IgniteObjectException; + public Collection<BinaryTypeMetadata> metadata() throws BinaryObjectException; } http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryField.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryField.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryField.java new file mode 100644 index 0000000..efc5a7a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryField.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.binary; + +/** + * Portable object field. Can be used to speed object field lookup. + */ +public interface BinaryField { + /** + * Check whether field exists in the object. + * + * @param obj Object. + * @return {@code True} if exists. + */ + public boolean exists(BinaryObject obj); + + /** + * Get field's value from the given object. + * + * @param obj Object. + * @return Value. + */ + public <T> T value(BinaryObject obj); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryInvalidTypeException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryInvalidTypeException.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryInvalidTypeException.java new file mode 100644 index 0000000..63f7be6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryInvalidTypeException.java @@ -0,0 +1,58 @@ +/* + * 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.binary; + +import org.jetbrains.annotations.Nullable; + +/** + * Exception indicating that class needed for deserialization of portable object does not exist. + * <p> + * Thrown from {@link BinaryObject#deserialize()} method. + */ +public class BinaryInvalidTypeException extends BinaryObjectException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Creates invalid class exception with error message. + * + * @param msg Error message. + */ + public BinaryInvalidTypeException(String msg) { + super(msg); + } + + /** + * Creates invalid class exception with {@link Throwable} as a cause. + * + * @param cause Cause. + */ + public BinaryInvalidTypeException(Throwable cause) { + super(cause); + } + + /** + * Creates invalid class exception with error message and {@link Throwable} as a cause. + * + * @param msg Error message. + * @param cause Cause. + */ + public BinaryInvalidTypeException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java new file mode 100644 index 0000000..3a00a77 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java @@ -0,0 +1,162 @@ +/* + * 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.binary; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.TreeMap; +import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.jetbrains.annotations.Nullable; + +/** + * Wrapper for portable object in portable binary format. Once an object is defined as portable, + * Ignite will always store it in memory in the portable (i.e. binary) format. + * User can choose to work either with the portable format or with the deserialized form + * (assuming that class definitions are present in the classpath). + * <p> + * <b>NOTE:</b> user does not need to (and should not) implement this interface directly. + * <p> + * To work with the portable format directly, user should create a cache projection + * over {@code PortableObject} class and then retrieve individual fields as needed: + * <pre name=code class=java> + * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepBinary(); + * + * // Convert instance of MyKey to portable format. + * // We could also use GridPortableBuilder to create the key in portable format directly. + * PortableObject key = grid.portables().toPortable(new MyKey()); + * + * PortableObject val = prj.get(key); + * + * String field = val.field("myFieldName"); + * </pre> + * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized + * typed objects at all times. In this case we do incur the deserialization cost. However, if + * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access + * and will cache the deserialized object, so it does not have to be deserialized again: + * <pre name=code class=java> + * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null); + * + * MyValue val = cache.get(new MyKey()); + * + * // Normal java getter. + * String fieldVal = val.getMyFieldName(); + * </pre> + * <h1 class="header">Working With Maps and Collections</h1> + * All maps and collections in the portable objects are serialized automatically. When working + * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most + * adequate collection or map in either language. For example, {@link ArrayList} in Java will become + * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} + * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} + * in C#, etc. + * <h1 class="header">Dynamic Structure Changes</h1> + * Since objects are always cached in the portable binary format, server does not need to + * be aware of the class definitions. Moreover, if class definitions are not present or not + * used on the server, then clients can continuously change the structure of the portable + * objects without having to restart the cluster. For example, if one client stores a + * certain class with fields A and B, and another client stores the same class with + * fields B and C, then the server-side portable object will have the fields A, B, and C. + * As the structure of a portable object changes, the new fields become available for SQL queries + * automatically. + * <h1 class="header">Building Portable Objects</h1> + * Ignite comes with {@link BinaryObjectBuilder} which allows to build portable objects dynamically: + * <pre name=code class=java> + * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject"); + * + * builder.setField("fieldA", "A"); + * builder.setField("fieldB", "B"); + * + * PortableObject portableObj = builder.build(); + * </pre> + * For the cases when class definition is present + * in the class path, it is also possible to populate a standard POJO and then + * convert it to portable format, like so: + * <pre name=code class=java> + * MyObject obj = new MyObject(); + * + * obj.setFieldA("A"); + * obj.setFieldB(123); + * + * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj); + * </pre> + * <h1 class="header">Portable Metadata</h1> + * Even though Ignite portable protocol only works with hash codes for type and field names + * to achieve better performance, Ignite provides metadata for all portable types which + * can be queried ar runtime via any of the {@link org.apache.ignite.IgniteObjects#metadata(Class)} + * methods. Having metadata also allows for proper formatting of {@code PortableObject.toString()} method, + * even when portable objects are kept in binary format only, which may be necessary for audit reasons. + */ +public interface BinaryObject extends Serializable, Cloneable { + /** + * Gets portable object type ID. + * + * @return Type ID. + */ + public int typeId(); + + /** + * Gets meta data for this portable object. + * + * @return Meta data. + * @throws BinaryObjectException In case of error. + */ + @Nullable public BinaryTypeMetadata metaData() throws BinaryObjectException; + + /** + * Gets field value. + * + * @param fieldName Field name. + * @return Field value. + * @throws BinaryObjectException In case of any other error. + */ + @Nullable public <F> F field(String fieldName) throws BinaryObjectException; + + /** + * Checks whether field is set. + * + * @param fieldName Field name. + * @return {@code true} if field is set. + */ + public boolean hasField(String fieldName); + + /** + * Gets field descriptor. + * + * @param fieldName Field name. + * @return Field descriptor. + * @throws BinaryObjectException If failed. + */ + public BinaryField fieldDescriptor(String fieldName) throws BinaryObjectException; + + /** + * Gets fully deserialized instance of portable object. + * + * @return Fully deserialized instance of portable object. + * @throws BinaryInvalidTypeException If class doesn't exist. + * @throws BinaryObjectException In case of any other error. + */ + @Nullable public <T> T deserialize() throws BinaryObjectException; + + /** + * Copies this portable object. + * + * @return Copy of this portable object. + */ + public BinaryObject clone() throws CloneNotSupportedException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java new file mode 100644 index 0000000..014f256 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java @@ -0,0 +1,136 @@ +/* + * 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.binary; + +import org.jetbrains.annotations.Nullable; + +/** + * Portable object builder. Provides ability to build portable objects dynamically without having class definitions. + * <p> + * Here is an example of how a portable object can be built dynamically: + * <pre name=code class=java> + * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject"); + * + * builder.setField("fieldA", "A"); + * builder.setField("fieldB", "B"); + * + * PortableObject portableObj = builder.build(); + * </pre> + * + * <p> + * Also builder can be initialized by existing portable object. This allows changing some fields without affecting + * other fields. + * <pre name=code class=java> + * PortableBuilder builder = Ignition.ignite().portables().builder(person); + * + * builder.setField("name", "John"); + * + * person = builder.build(); + * </pre> + * </p> + * + * If you need to modify nested portable object you can get builder for nested object using + * {@link #getField(String)}, changes made on nested builder will affect parent object, + * for example: + * + * <pre name=code class=java> + * PortableBuilder personBuilder = grid.portables().createBuilder(personPortableObj); + * PortableBuilder addressBuilder = personBuilder.setField("address"); + * + * addressBuilder.setField("city", "New York"); + * + * personPortableObj = personBuilder.build(); + * + * // Should be "New York". + * String city = personPortableObj.getField("address").getField("city"); + * </pre> + * + * @see org.apache.ignite.IgniteObjects#builder(int) + * @see org.apache.ignite.IgniteObjects#builder(String) + * @see org.apache.ignite.IgniteObjects#builder(BinaryObject) + */ +public interface BinaryObjectBuilder { + /** + * Returns value assigned to the specified field. + * If the value is a portable object instance of {@code GridPortableBuilder} will be returned, + * which can be modified. + * <p> + * Collections and maps returned from this method are modifiable. + * + * @param name Field name. + * @return Filed value. + */ + public <T> T getField(String name); + + /** + * Sets field value. + * + * @param name Field name. + * @param val Field value (cannot be {@code null}). + * @see BinaryObject#metaData() + */ + public BinaryObjectBuilder setField(String name, Object val); + + /** + * Sets field value with value type specification. + * <p> + * Field type is needed for proper metadata update. + * + * @param name Field name. + * @param val Field value. + * @param type Field type. + * @see BinaryObject#metaData() + */ + public <T> BinaryObjectBuilder setField(String name, @Nullable T val, Class<? super T> type); + + /** + * Sets field value. + * <p> + * This method should be used if field is portable object. + * + * @param name Field name. + * @param builder Builder for object field. + */ + public BinaryObjectBuilder setField(String name, @Nullable BinaryObjectBuilder builder); + + /** + * Removes field from this builder. + * + * @param fieldName Field name. + * @return {@code this} instance for chaining. + */ + public BinaryObjectBuilder removeField(String fieldName); + + /** + * Sets hash code for resulting portable object returned by {@link #build()} method. + * <p> + * If not set {@code 0} is used. + * + * @param hashCode Hash code. + * @return {@code this} instance for chaining. + */ + public BinaryObjectBuilder hashCode(int hashCode); + + /** + * Builds portable object. + * + * @return Portable object. + * @throws BinaryObjectException In case of error. + */ + public BinaryObject build() throws BinaryObjectException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectException.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectException.java new file mode 100644 index 0000000..124f267 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectException.java @@ -0,0 +1,57 @@ +/* + * 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.binary; + +import org.apache.ignite.IgniteException; +import org.jetbrains.annotations.Nullable; + +/** + * Exception indicating portable object serialization error. + */ +public class BinaryObjectException extends IgniteException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Creates portable exception with error message. + * + * @param msg Error message. + */ + public BinaryObjectException(String msg) { + super(msg); + } + + /** + * Creates portable exception with {@link Throwable} as a cause. + * + * @param cause Cause. + */ + public BinaryObjectException(Throwable cause) { + super(cause); + } + + /** + * Creates portable exception with error message and {@link Throwable} as a cause. + * + * @param msg Error message. + * @param cause Cause. + */ + public BinaryObjectException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java new file mode 100644 index 0000000..665b5ea --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java @@ -0,0 +1,240 @@ +/* + * 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.binary; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Raw reader for portable objects. Raw reader does not use field name hash codes, therefore, + * making the format even more compact. However, if the raw reader is used, + * dynamic structure changes to the portable objects are not supported. + */ +public interface BinaryRawReader { + /** + * @return Byte value. + * @throws BinaryObjectException In case of error. + */ + public byte readByte() throws BinaryObjectException; + + /** + * @return Short value. + * @throws BinaryObjectException In case of error. + */ + public short readShort() throws BinaryObjectException; + + /** + * @return Integer value. + * @throws BinaryObjectException In case of error. + */ + public int readInt() throws BinaryObjectException; + + /** + * @return Long value. + * @throws BinaryObjectException In case of error. + */ + public long readLong() throws BinaryObjectException; + + /** + * @return Float value. + * @throws BinaryObjectException In case of error. + */ + public float readFloat() throws BinaryObjectException; + + /** + * @return Double value. + * @throws BinaryObjectException In case of error. + */ + public double readDouble() throws BinaryObjectException; + + /** + * @return Char value. + * @throws BinaryObjectException In case of error. + */ + public char readChar() throws BinaryObjectException; + + /** + * @return Boolean value. + * @throws BinaryObjectException In case of error. + */ + public boolean readBoolean() throws BinaryObjectException; + + /** + * @return Decimal value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public BigDecimal readDecimal() throws BinaryObjectException; + + /** + * @return String value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public String readString() throws BinaryObjectException; + + /** + * @return UUID. + * @throws BinaryObjectException In case of error. + */ + @Nullable public UUID readUuid() throws BinaryObjectException; + + /** + * @return Date. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Date readDate() throws BinaryObjectException; + + /** + * @return Timestamp. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Timestamp readTimestamp() throws BinaryObjectException; + + /** + * @return Object. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> T readObject() throws BinaryObjectException; + + /** + * @return Byte array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public byte[] readByteArray() throws BinaryObjectException; + + /** + * @return Short array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public short[] readShortArray() throws BinaryObjectException; + + /** + * @return Integer array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public int[] readIntArray() throws BinaryObjectException; + + /** + * @return Long array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public long[] readLongArray() throws BinaryObjectException; + + /** + * @return Float array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public float[] readFloatArray() throws BinaryObjectException; + + /** + * @return Byte array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public double[] readDoubleArray() throws BinaryObjectException; + + /** + * @return Char array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public char[] readCharArray() throws BinaryObjectException; + + /** + * @return Boolean array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public boolean[] readBooleanArray() throws BinaryObjectException; + + /** + * @return Decimal array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public BigDecimal[] readDecimalArray() throws BinaryObjectException; + + /** + * @return String array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public String[] readStringArray() throws BinaryObjectException; + + /** + * @return UUID array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public UUID[] readUuidArray() throws BinaryObjectException; + + /** + * @return Date array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Date[] readDateArray() throws BinaryObjectException; + + /** + * @return Timestamp array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Timestamp[] readTimestampArray() throws BinaryObjectException; + + /** + * @return Object array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Object[] readObjectArray() throws BinaryObjectException; + + /** + * @return Collection. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> Collection<T> readCollection() throws BinaryObjectException; + + /** + * @param colCls Collection class. + * @return Collection. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> Collection<T> readCollection(Class<? extends Collection<T>> colCls) + throws BinaryObjectException; + + /** + * @return Map. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <K, V> Map<K, V> readMap() throws BinaryObjectException; + + /** + * @param mapCls Map class. + * @return Map. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls) throws BinaryObjectException; + + /** + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T extends Enum<?>> T readEnum() throws BinaryObjectException; + + /** + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T extends Enum<?>> T[] readEnumArray() throws BinaryObjectException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawWriter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawWriter.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawWriter.java new file mode 100644 index 0000000..2081774 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawWriter.java @@ -0,0 +1,225 @@ +/* + * 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.binary; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Raw writer for portable object. Raw writer does not write field name hash codes, therefore, + * making the format even more compact. However, if the raw writer is used, + * dynamic structure changes to the portable objects are not supported. + */ +public interface BinaryRawWriter { + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeByte(byte val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeShort(short val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeInt(int val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeLong(long val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeFloat(float val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDouble(double val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeChar(char val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeBoolean(boolean val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDecimal(@Nullable BigDecimal val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeString(@Nullable String val) throws BinaryObjectException; + + /** + * @param val UUID to write. + * @throws BinaryObjectException In case of error. + */ + public void writeUuid(@Nullable UUID val) throws BinaryObjectException; + + /** + * @param val Date to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDate(@Nullable Date val) throws BinaryObjectException; + + /** + * @param val Timestamp to write. + * @throws BinaryObjectException In case of error. + */ + public void writeTimestamp(@Nullable Timestamp val) throws BinaryObjectException; + + /** + * @param obj Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeObject(@Nullable Object obj) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeByteArray(@Nullable byte[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeShortArray(@Nullable short[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeIntArray(@Nullable int[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeLongArray(@Nullable long[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeFloatArray(@Nullable float[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDoubleArray(@Nullable double[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeCharArray(@Nullable char[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeBooleanArray(@Nullable boolean[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDecimalArray(@Nullable BigDecimal[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeStringArray(@Nullable String[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeUuidArray(@Nullable UUID[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeDateArray(@Nullable Date[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeTimestampArray(@Nullable Timestamp[] val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public void writeObjectArray(@Nullable Object[] val) throws BinaryObjectException; + + /** + * @param col Collection to write. + * @throws BinaryObjectException In case of error. + */ + public <T> void writeCollection(@Nullable Collection<T> col) throws BinaryObjectException; + + /** + * @param map Map to write. + * @throws BinaryObjectException In case of error. + */ + public <K, V> void writeMap(@Nullable Map<K, V> map) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public <T extends Enum<?>> void writeEnum(T val) throws BinaryObjectException; + + /** + * @param val Value to write. + * @throws BinaryObjectException In case of error. + */ + public <T extends Enum<?>> void writeEnumArray(T[] val) throws BinaryObjectException; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java new file mode 100644 index 0000000..3881b49 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java @@ -0,0 +1,291 @@ +/* + * 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.binary; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Reader for portable objects used in {@link Binarylizable} implementations. + * Useful for the cases when user wants a fine-grained control over serialization. + * <p> + * Note that Ignite never writes full strings for field or type names. Instead, + * for performance reasons, Ignite writes integer hash codes for type and field names. + * It has been tested that hash code conflicts for the type names or the field names + * within the same type are virtually non-existent and, to gain performance, it is safe + * to work with hash codes. For the cases when hash codes for different types or fields + * actually do collide, Ignite provides {@link BinaryTypeIdMapper} which + * allows to override the automatically generated hash code IDs for the type and field names. + */ +public interface BinaryReader { + /** + * @param fieldName Field name. + * @return Byte value. + * @throws BinaryObjectException In case of error. + */ + public byte readByte(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Short value. + * @throws BinaryObjectException In case of error. + */ + public short readShort(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Integer value. + * @throws BinaryObjectException In case of error. + */ + public int readInt(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Long value. + * @throws BinaryObjectException In case of error. + */ + public long readLong(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @throws BinaryObjectException In case of error. + * @return Float value. + */ + public float readFloat(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Double value. + * @throws BinaryObjectException In case of error. + */ + public double readDouble(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Char value. + * @throws BinaryObjectException In case of error. + */ + public char readChar(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Boolean value. + * @throws BinaryObjectException In case of error. + */ + public boolean readBoolean(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Decimal value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public BigDecimal readDecimal(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return String value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public String readString(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return UUID. + * @throws BinaryObjectException In case of error. + */ + @Nullable public UUID readUuid(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Date. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Date readDate(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Timestamp. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Timestamp readTimestamp(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Object. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> T readObject(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Byte array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public byte[] readByteArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Short array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public short[] readShortArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Integer array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public int[] readIntArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Long array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public long[] readLongArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Float array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public float[] readFloatArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Byte array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public double[] readDoubleArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Char array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public char[] readCharArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Boolean array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public boolean[] readBooleanArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Decimal array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return String array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public String[] readStringArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return UUID array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public UUID[] readUuidArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Date array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Date[] readDateArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Timestamp array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Timestamp[] readTimestampArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Object array. + * @throws BinaryObjectException In case of error. + */ + @Nullable public Object[] readObjectArray(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Collection. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> Collection<T> readCollection(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @param colCls Collection class. + * @return Collection. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T> Collection<T> readCollection(String fieldName, Class<? extends Collection<T>> colCls) + throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Map. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <K, V> Map<K, V> readMap(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @param mapCls Map class. + * @return Map. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls) + throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T extends Enum<?>> T readEnum(String fieldName) throws BinaryObjectException; + + /** + * @param fieldName Field name. + * @return Value. + * @throws BinaryObjectException In case of error. + */ + @Nullable public <T extends Enum<?>> T[] readEnumArray(String fieldName) throws BinaryObjectException; + + /** + * Gets raw reader. Raw reader does not use field name hash codes, therefore, + * making the format even more compact. However, if the raw reader is used, + * dynamic structure changes to the portable objects are not supported. + * + * @return Raw reader. + */ + public BinaryRawReader rawReader(); +} \ No newline at end of file
