public SerializableRowKey(RowKey key) { columnNames = key.getColumnNames(); columnValues = key.getColumnValues(); }
@Override public RowKey readObject(ObjectInput input) throws IOException, ClassNotFoundException { VersionChecker.readAndCheckVersion( input, VERSION, RowKey.class ); String[] columnNames = (String[]) input.readObject(); Object[] values = (Object[]) input.readObject(); return new RowKey( columnNames, values ); }
private int findIndexByRowKey(List<BinaryObject> objects, RowKey rowKey, String indexColumnName) { int result = -1; if ( !objects.isEmpty() ) { String columnNames[] = indexColumnName == null ? rowKey.getColumnNames() : new String[] { indexColumnName }; String fieldNames[] = new String[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { fieldNames[i] = StringHelper.stringAfterPoint( columnNames[i] ); } for ( int i = 0; i < objects.size() && result < 0; i++ ) { BinaryObject bo = objects.get( i ); boolean thisIsIt = true; for ( int j = 0; j < columnNames.length; j++ ) { if ( !Objects.equals( rowKey.getColumnValue( columnNames[j] ), bo.field( fieldNames[j] ) ) ) { thisIsIt = false; break; } } if ( thisIsIt ) { result = i; } } } return result; }
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; }
for ( String columnName : inverseRowKey.getColumnNames() ) { inverseAssociationRow.put( columnName, associationRow.get( columnName ) );
public RowKey(String[] columnNames, Object[] columnValues) { this.columnNames = columnNames; this.columnValues = columnValues; this.hashCode = generateHashCode(); }
/** * Returns the entity key on the other side of association row represented by the given row key. * <p> * <b>Note:</b> May only be invoked if the row key actually contains all the columns making up that entity key. * Specifically, it may <b>not</b> be invoked if the association has index columns (maps, ordered collections), as * the entity key columns will not be part of the row key in this case. */ private EntityKey getEntityKey(AssociationKey associationKey, RowKey rowKey) { String[] associationKeyColumns = associationKey.getMetadata().getAssociatedEntityKeyMetadata().getAssociationKeyColumns(); Object[] columnValues = new Object[associationKeyColumns.length]; int i = 0; for ( String associationKeyColumn : associationKeyColumns ) { columnValues[i] = rowKey.getColumnValue( associationKeyColumn ); i++; } EntityKeyMetadata entityKeyMetadata = associationKey.getMetadata().getAssociatedEntityKeyMetadata().getEntityKeyMetadata(); return new EntityKey( entityKeyMetadata, columnValues ); }
public static boolean matches(RowKey actual, RowKey expected) { if ( actual.getColumnNames().length != expected.getColumnNames().length ) { return false; } for ( int i = 0; i < expected.getColumnNames().length; i++ ) { Object expectedValue = expected.getColumnValues()[i]; Object actualValue = actual.getColumnValues()[i]; if ( !sameValue( expectedValue, actualValue ) ) { return false; } } return true; }
private String toShortString(RowKey rowKey) { final StringBuilder sb = new StringBuilder(); sb.append( "(" ); int i = 0; for ( String column : rowKey.getColumnNames() ) { sb.append( column ).append( "=" ).append( rowKey.getColumnValue( column ) ); i++; if ( i < rowKey.getColumnNames().length ) { sb.append( ", " ); } } sb.append( ")" ); return sb.toString(); }
public RowKey build() { final String[] columnNamesArray = columnNames.toArray( new String[columnNames.size()] ); final int length = columnNamesArray.length; Object[] columnValuesArray = new Object[length]; for ( int index = 0; index < length; index++ ) { columnValuesArray[index] = tuple.get( columnNamesArray[index] ); } return new RowKey( columnNamesArray, columnValuesArray ); }
/** * Returns the entity key on the other side of association row represented by the given row key. * <p> * <b>Note:</b> May only be invoked if the row key actually contains all the columns making up that entity key. * Specifically, it may <b>not</b> be invoked if the association has index columns (maps, ordered collections), as * the entity key columns will not be part of the row key in this case. */ private EntityKey getEntityKey(AssociationKey associationKey, RowKey rowKey) { String[] associationKeyColumns = associationKey.getMetadata().getAssociatedEntityKeyMetadata().getAssociationKeyColumns(); Object[] columnValues = new Object[associationKeyColumns.length]; int i = 0; for ( String associationKeyColumn : associationKeyColumns ) { columnValues[i] = rowKey.getColumnValue( associationKeyColumn ); i++; } EntityKeyMetadata entityKeyMetadata = associationKey.getMetadata().getAssociatedEntityKeyMetadata().getEntityKeyMetadata(); return new EntityKey( entityKeyMetadata, columnValues ); }
@Override public void writeObject(ObjectOutput output, RowKey key) throws IOException { output.writeInt( VERSION ); output.writeObject( key.getColumnNames() ); output.writeObject( key.getColumnValues() ); }
private void addNavigationalInformationForInverseSide(int propertyIndex, AssociationKeyMetadata associationKeyMetadata, Object[] newColumnValue) { RowKey rowKey = getInverseRowKey( associationKeyMetadata, newColumnValue ); Tuple associationRow = new Tuple(); for ( String column : rowKey.getColumnNames() ) { associationRow.put( column, rowKey.getColumnValue( column ) ); } AssociationPersister associationPersister = createInverseAssociationPersister( propertyIndex, associationKeyMetadata, newColumnValue ); associationPersister.getAssociation().put( rowKey, associationRow ); if ( associationPersister.getAssociationContext().getEntityTuplePointer().getTuple() == null ) { throw log.entityTupleNotFound( associationKeyMetadata.getCollectionRole(), associationPersister.getAssociationKey().getEntityKey() ); } associationPersister.flushToDatastore(); }
@Override public RowKey readObject(ObjectInput input) throws IOException, ClassNotFoundException { VersionChecker.readAndCheckVersion( input, VERSION, RowKey.class ); String[] columnNames = (String[]) input.readObject(); Object[] values = (Object[]) input.readObject(); return new RowKey( columnNames, values ); }
@Override public void writeObject(ObjectOutput output, RowKey key) throws IOException { output.writeInt( VERSION ); output.writeObject( key.getColumnNames() ); output.writeObject( key.getColumnValues() ); }
for ( String columnName : op.getKey().getColumnNames() ) { if ( !keyColumnNames.contains( columnName ) ) { deleteSelection.column( quote( columnName ) ); for ( String columnName : value.getColumnNames() ) { if ( keyColumnNames.contains( columnName ) ) { delete.where( eq( quote( columnName ), QueryBuilder.bindMarker( columnName ) ) ); columnValues.add( value.getColumnValue( columnName ) );
@Override public Set<RowKey> getRowKeys() { Set<RowKey> rowKeys = new HashSet<RowKey>( associationMap.size() ); for ( SerializableRowKey key : associationMap.keySet() ) { rowKeys.add( new RowKey( key.getColumnNames(), key.getColumnValues() ) ); } return rowKeys; }
private static void removeAssociationFromBridgeTable(InfinispanRemoteDatastoreProvider provider, AssociationKey key) { final String bridgeTable = cacheName( key ); final ProtoStreamMappingAdapter mapper = provider.getDataMapperForCache( bridgeTable ); Map<RowKey, Map<String, Object>> rowsMap = loadRowKeysByQuery( provider, key ); for ( RowKey rowKey : rowsMap.keySet() ) { String[] columnNames = rowKey.getColumnNames(); Object[] columnValues = rowKey.getColumnValues(); ProtostreamId idBuffer = mapper.createIdPayload( columnNames, columnValues ); mapper.withinCacheEncodingContext( c -> c.remove( idBuffer ) ); } }
provider.getEntityTypeName( itemMetadata.getTable() ) ); for ( String columnName : op.getKey().getColumnNames() ) { Object value = op.getKey().getColumnValue( columnName ); if ( value != null ) { putBoBuilder.setField( StringHelper.stringAfterPoint( columnName ), value );
public IgniteAssociationSnapshot(AssociationKey associationKey, Map<Object, BinaryObject> associationMap) { this.rows = CollectionHelper.newHashMap( associationMap.size() ); for ( Map.Entry<Object, BinaryObject> entry : associationMap.entrySet() ) { IgniteAssociationRowSnapshot snapshot = new IgniteAssociationRowSnapshot( entry.getKey(), entry.getValue(), associationKey.getMetadata() ); String rowKeyColumnNames[] = associationKey.getMetadata().getRowKeyColumnNames(); Object rowKeyColumnValues[] = new Object[rowKeyColumnNames.length]; for ( int i = 0; i < rowKeyColumnNames.length; i++ ) { String columnName = rowKeyColumnNames[i]; rowKeyColumnValues[i] = snapshot.get( columnName ); } RowKey rowKey = new RowKey( rowKeyColumnNames, rowKeyColumnValues ); this.rows.put( rowKey, snapshot ); } }