當前位置: 首頁>>代碼示例>>Java>>正文


Java BinaryObjectBuilder.build方法代碼示例

本文整理匯總了Java中org.apache.ignite.binary.BinaryObjectBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java BinaryObjectBuilder.build方法的具體用法?Java BinaryObjectBuilder.build怎麽用?Java BinaryObjectBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ignite.binary.BinaryObjectBuilder的用法示例。


在下文中一共展示了BinaryObjectBuilder.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createKeyObject

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * Converting entity key to cache key
 *
 * @param key entity key
 * @return string key
 */
public Object createKeyObject(EntityKey key) {
	Object result = null;
	if ( key.getColumnValues().length == 1 ) {
		IgniteCache<Object, BinaryObject> entityCache = getEntityCache( key.getMetadata() );
		CacheConfiguration cacheConfig = entityCache.getConfiguration( CacheConfiguration.class );
		result = toValidKeyObject( key.getColumnValues()[0], cacheConfig.getKeyType() );
	}
	else {
		BinaryObjectBuilder builder = createBinaryObjectBuilder( findKeyType( key.getMetadata() ) );
		for ( int i = 0; i < key.getColumnNames().length; i++ ) {
			builder.setField( StringHelper.stringAfterPoint( key.getColumnNames()[i] ), key.getColumnValues()[i] );
		}
		result = builder.build();
	}
	return result;
}
 
開發者ID:hibernate,項目名稱:hibernate-ogm-ignite,代碼行數:23,代碼來源:IgniteDatastoreProvider.java

示例2: createAssociationKeyObject

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
public Object createAssociationKeyObject( RowKey rowKey, AssociationKeyMetadata keyMetadata ) {
	Object result = null;
	if ( IgniteAssociationSnapshot.isThirdTableAssociation( keyMetadata ) ) {
		result = UUID.randomUUID().toString();
	}
	else {
		String associationKeyColumns[] = keyMetadata.getAssociatedEntityKeyMetadata().getAssociationKeyColumns();
		if ( associationKeyColumns.length == 1 ) {
			result = rowKey.getColumnValue( associationKeyColumns[0] );
		}
		else {
			BinaryObjectBuilder builder = createBinaryObjectBuilder( findKeyType( keyMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata() ) );
			for ( int i = 0; i < associationKeyColumns.length; i++ ) {
				builder.setField( StringHelper.stringAfterPoint( associationKeyColumns[i] ), rowKey.getColumnValue( associationKeyColumns[i] ) );
			}
			result = builder.build();
		}
	}
	return result;
}
 
開發者ID:hibernate,項目名稱:hibernate-ogm-ignite,代碼行數:21,代碼來源:IgniteDatastoreProvider.java

示例3: createPerson

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 *
 */
Object createPerson(int id, String name) {
    if (!isBinaryMarshaller()) {
        Person p = new Person(id);
        p.name = name;

        return p;
    }
    else {
        BinaryObjectBuilder o = grid(0).binary().builder("Person");
        o.setField("id", id);
        o.setField("name", name);

        return o.build();
    }
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:19,代碼來源:IgniteCacheAbstractInsertSqlQuerySelfTest.java

示例4: createPerson2

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 *
 */
Object createPerson2(int id, String name, int valFld) {
    if (!isBinaryMarshaller()) {
        Person2 p = new Person2(id);
        p.name = name;
        p.IntVal = valFld;

        return p;
    }
    else {
        BinaryObjectBuilder o = grid(0).binary().builder("Person2");
        o.setField("id", id);
        o.setField("name", name);
        o.setField("IntVal", valFld);

        return o.build();
    }
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:21,代碼來源:IgniteCacheAbstractInsertSqlQuerySelfTest.java

示例5: buildBinaryObject

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * Construct binary object from query result.
 *
 * @param typeName Type name.
 * @param fields Fields descriptors.
 * @param loadColIdxs Select query columns index.
 * @param rs ResultSet.
 * @return Constructed binary object.
 * @throws CacheLoaderException If failed to construct binary object.
 */
protected Object buildBinaryObject(String typeName, JdbcTypeField[] fields, Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException {
    try {
        BinaryObjectBuilder builder = ignite.binary().builder(typeName);

        for (JdbcTypeField field : fields) {
            Integer colIdx = columnIndex(loadColIdxs, field.getDatabaseFieldName());

            Object colVal = transformer.getColumnValue(rs, colIdx, field.getJavaFieldType());

            builder.setField(field.getJavaFieldName(), colVal, (Class<Object>)field.getJavaFieldType());
        }

        return builder.build();
    }
    catch (SQLException e) {
        throw new CacheException("Failed to read binary object: " + typeName, e);
    }
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:29,代碼來源:CacheJdbcPojoStore.java

示例6: newBinaryObject

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * @param builder Builder.
 * @param desc Descriptor with parameters of BinaryObject to build.
 * @return BinaryObject built by provided description
 */
private static BinaryObject newBinaryObject(BinaryObjectBuilder builder, BinaryUpdateDescription desc) {
    builder.setField(SEQ_NUM_FLD, desc.itemId + 1);

    switch (desc.fieldType) {
        case NUMBER:
            builder.setField(desc.fieldName, getNumberFieldVal());
            break;
        case STRING:
            builder.setField(desc.fieldName, getStringFieldVal());
            break;
        case ARRAY:
            builder.setField(desc.fieldName, getArrayFieldVal());
            break;
        case OBJECT:
            builder.setField(desc.fieldName, new Object());
    }

    return builder.build();
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:25,代碼來源:BinaryMetadataUpdatesFlowTest.java

示例7: testCrossFormatObjectsIdentity

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 *
 */
@SuppressWarnings("unchecked")
public void testCrossFormatObjectsIdentity() {
    IgniteCache c = binKeysCache();

    c.put(new ComplexBinaryFieldsListHashedKey(), "zzz");

    // Now let's build an identical key for get
    BinaryObjectBuilder bldr = grid(0).binary().builder(ComplexBinaryFieldsListHashedKey.class.getName());

    bldr.setField("firstField", 1);
    bldr.setField("secondField", "value");
    bldr.setField("thirdField", 0x1020304050607080L);

    BinaryObject binKey = bldr.build();

    assertEquals("zzz", c.get(binKey));
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:21,代碼來源:GridCacheBinaryObjectsAbstractSelfTest.java

示例8: testSameBinaryKey

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * @throws Exception If failed.
 */
public void testSameBinaryKey() throws Exception {
    IgniteCache<BinaryObject, BinaryObject> replicatedCache =
        jcache(0).withKeepBinary();

    IgniteCache<BinaryObject, BinaryObject> partitionedCache =
        jcache(0, "partitioned").withKeepBinary();

    BinaryObjectBuilder keyBuilder = ignite(0).binary().builder("keyType")
        .setField("F1", "V1");

    BinaryObjectBuilder valBuilder = ignite(0).binary().builder("valueType")
        .setField("F2", "V2")
        .setField("F3", "V3");

    BinaryObject key = keyBuilder.build();
    BinaryObject val = valBuilder.build();

    replicatedCache.put(key, val);
    partitionedCache.put(key, val);

    assertNotNull(replicatedCache.get(key));
    assertNotNull(partitionedCache.get(key));
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:27,代碼來源:BinaryObjectBuilderAdditionalSelfTest.java

示例9: insertOrUpdateTuple

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
@Override
public void insertOrUpdateTuple(EntityKey key, TuplePointer tuplePointer, TupleContext tupleContext) throws TupleAlreadyExistsException {
	IgniteCache<Object, BinaryObject> entityCache = provider.getEntityCache( key.getMetadata() );
	Tuple tuple = tuplePointer.getTuple();

	Object keyObject = null;
	BinaryObjectBuilder builder = null;
	IgniteTupleSnapshot tupleSnapshot = (IgniteTupleSnapshot) tuple.getSnapshot();
	keyObject = tupleSnapshot.getCacheKey();
	if ( tuple.getSnapshotType() == SnapshotType.UPDATE ) {
		builder = provider.createBinaryObjectBuilder( tupleSnapshot.getCacheValue() );
	}
	else {
		builder = provider.createBinaryObjectBuilder( provider.getEntityTypeName( key.getMetadata().getTable() ) );
	}
	for ( String columnName : tuple.getColumnNames() ) {
		Object value = tuple.get( columnName );
		if ( value != null ) {
			builder.setField( StringHelper.realColumnName( columnName ), value );
		}
		else {
			builder.removeField( StringHelper.realColumnName( columnName ) );
		}
	}
	BinaryObject valueObject = builder.build();
	entityCache.put( keyObject, valueObject );
	tuplePointer.setTuple( new Tuple( new IgniteTupleSnapshot( keyObject, valueObject, key.getMetadata() ), SnapshotType.UPDATE ) );
}
 
開發者ID:hibernate,項目名稱:hibernate-ogm-ignite,代碼行數:29,代碼來源:IgniteDialect.java

示例10: createBinPerson

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * Create binary person.
 *
 * @param id ID.
 * @param name Name.
 * @param secondName Second name.
 * @return Person.
 */
private Object createBinPerson(int id, String name, String secondName) {
    BinaryObjectBuilder bldr = ignite(0).binary().builder("Person");

    bldr.setField("id", id);
    bldr.setField("firstName", name);
    bldr.setField("secondName", secondName);

    return bldr.build();
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:18,代碼來源:IgniteCacheAbstractSqlDmlQuerySelfTest.java

示例11: copy

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * @param po Binary object.
 * @param fields Fields.
 * @return Copy.
 */
private BinaryObject copy(BinaryObject po, Map<String, Object> fields) {
    BinaryObjectBuilder builder = BinaryObjectBuilderImpl.wrap(po);

    if (fields != null) {
        for (Map.Entry<String, Object> e : fields.entrySet())
            builder.setField(e.getKey(), e.getValue());
    }

    return builder.build();
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:16,代碼來源:BinaryMarshallerSelfTest.java

示例12: build

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * Build object.
 *
 * @param parts Parts.
 * @return Result.
 */
private BinaryObjectImpl build(Object... parts) {
    String typeName = "Type" + TYPE_CTR.get();

    BinaryObjectBuilder builder = grid().binary().builder(typeName);

    if (!F.isEmpty(parts)) {
        for (int i = 0; i < parts.length; )
            builder.setField((String)parts[i++], parts[i++]);
    }

    return (BinaryObjectImpl) builder.build();
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:19,代碼來源:BinarySerialiedFieldComparatorSelfTest.java

示例13: beforeTestsStarted

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
    Ignite ignite = startGrid(0);

    BinaryObjectBuilder builder = ignite.binary().builder(TEST_OBJECT);
    BinaryObjectBuilder builder2 = ignite.binary().builder(TEST_OBJECT_2);

    builder2.setField("id", 1);
    builder2.setField("boolVal", true);

    BinaryObject testObject = builder2.build();

    builder.setField("id", 1);
    builder.setField("testObject", testObject);

    BinaryObject binObj = builder.build();

    IgniteCache<String, BinaryObject> cache = grid(0).cache(DEFAULT_CACHE_NAME);

    cache.put("0", binObj);
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:22,代碼來源:AbstractJdbcPojoQuerySelfTest.java

示例14: streamBinaryData

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 * Create and add binary data via Streamer API.
 *
 * @param grid to get streamer.
 * @return test object (it is key and val).
 */
private BinaryObject streamBinaryData(final Ignite grid) {
    final IgniteDataStreamer<BinaryObject, BinaryObject> streamer = grid.dataStreamer(CACHE_NAME);

    streamer.keepBinary(true);

    final BinaryObjectBuilder builder = grid.binary().builder("custom_type");

    BinaryObject entity = null;

    for (int i = 0; i < 1; i++) {
        builder.setField("id", i);

        entity = builder.build();

        streamer.addData(entity, entity);
    }

    streamer.flush();
    streamer.close();
    streamer.future().get();

    return entity;
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:30,代碼來源:GridCacheStoreManagerDeserializationTest.java

示例15: testCorrectMetadataNullField

import org.apache.ignite.binary.BinaryObjectBuilder; //導入方法依賴的package包/類
/**
 *
 */
public void testCorrectMetadataNullField() {
    BinaryObjectBuilder builder = binaries().builder("SomeType2");

    builder.setField("dateField", null, Date.class);

    builder.setField("objectField", null, GridBinaryTestClasses.Company.class);

    builder.build();

    builder = binaries().builder("SomeType2");

    builder.setField("dateField", new Date());

    builder.setField("objectField", new GridBinaryTestClasses.Company());

    builder.build();

}
 
開發者ID:apache,項目名稱:ignite,代碼行數:22,代碼來源:BinaryObjectBuilderAdditionalSelfTest.java


注:本文中的org.apache.ignite.binary.BinaryObjectBuilder.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。