Skip to content

Commit

Permalink
fixed horizontal temperature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Nov 3, 2023
1 parent f45dba0 commit b4bdba1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.polypheny.db.rex.RexNode;
import org.polypheny.db.rex.RexShuttle;
import org.polypheny.db.transaction.Statement;
import org.polypheny.db.type.entity.PolyValue;


/**
Expand All @@ -36,7 +37,7 @@ public class WhereClauseVisitor extends RexShuttle {

private final Statement statement;
@Getter
private final List<Object> values = new ArrayList<>();
private final List<PolyValue> values = new ArrayList<>();
private final long partitionColumnIndex;
@Getter
protected boolean valueIdentified = false;
Expand All @@ -57,11 +58,11 @@ public RexNode visitCall( final RexCall call ) {

if ( call.operands.size() == 2 ) {
if ( call.op.getKind() == Kind.EQUALS ) {
Object value;
PolyValue value;
if ( call.operands.get( 0 ) instanceof RexIndexRef ) {
if ( ((RexIndexRef) call.operands.get( 0 )).getIndex() == partitionColumnIndex ) {
if ( call.operands.get( 1 ) instanceof RexLiteral ) {
value = ((RexLiteral) call.operands.get( 1 )).getValueForQueryParameterizer();
value = ((RexLiteral) call.operands.get( 1 )).value;
values.add( value );
valueIdentified = true;
} else if ( call.operands.get( 1 ) instanceof RexDynamicParam ) {
Expand Down
5 changes: 3 additions & 2 deletions dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ private Pair<List<AllocationPartition>, PartitionProperty> addGroupsAndPartition

int j = 0;
for ( AllocationPartitionGroup group : partitionGroups.keySet() ) {
List<String> qualifiers = group.isUnbound ? null : (j < partitionInfo.qualifiers.size() + 1 ? null : partitionInfo.qualifiers.get( j++ ));
List<String> qualifiers = group.isUnbound ? null : (j < partitionInfo.qualifiers.size() ? partitionInfo.qualifiers.get( j++ ) : null);
partitionGroups.put( group, List.of( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition(
partitionInfo.table.id,
partitionInfo.table.namespaceId,
Expand All @@ -2577,7 +2577,8 @@ private Pair<List<AllocationPartition>, PartitionProperty> addGroupsAndPartition
group.isUnbound,
PlacementType.AUTOMATIC,
DataPlacementRole.REFRESHABLE,
qualifiers, PartitionType.NONE ) ) );
qualifiers,
PartitionType.NONE ) ) );
}

//get All PartitionGroups and then get all partitionIds for each PG and add them to completeList of partitionIds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public long getTargetPartitionId( LogicalTable table, PartitionProperty property

// Process all accumulated CatalogPartitions
for ( AllocationPartition partition : Catalog.snapshot().alloc().getPartitionsFromLogical( table.id ) ) {
if ( unboundPartitionId == -1 && partition.isUnbound ) {
if ( partition.isUnbound ) {
unboundPartitionId = partition.id;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,12 @@ public void copyAllocationData( Transaction transaction, LogicalAdapter store, L
i++;
}
}*/
int columIndex = 0; // todo dl //snapshot.alloc().getC sourcePlacement.indexOf( targetProperty.partitionColumnId );
int columIndex = 0;
if ( partitionColumn.tableId == table.id ) {
columIndex = source.sourceAlg.alg.getRowType().getField( partitionColumn.name, true, false ).getIndex();
}



//int partitionColumnIndex = -1;
String parsedValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public AlgNode visit( LogicalFilter filter ) {
if ( !whereClauseVisitor.getValues().isEmpty() ) {

whereClauseValues = whereClauseVisitor.getValues().stream()
.map( Object::toString )
.map( PolyValue::toJson )
.collect( Collectors.toList() );
if ( log.isDebugEnabled() ) {
log.debug( "Found Where Clause Values: {}", whereClauseValues );
Expand Down Expand Up @@ -293,7 +293,7 @@ public AlgNode visit( LogicalFilter filter ) {
if ( !operationWasRewritten ) {
for ( long partitionId : accessedPartitions ) {

if ( catalog.getSnapshot().alloc().getPartitionsFromLogical( table.id ).stream().noneMatch( p -> p.id == partitionId ) ) {
if ( catalog.getSnapshot().alloc().getAlloc( pkPlacement.id, partitionId ).isEmpty() ) {
continue;
}

Expand Down Expand Up @@ -367,7 +367,7 @@ private Triple<Long, String, Boolean> handleDmlInsert( List<String> updateColumn
if ( partitionColumnIndex == -1 || currentTuple.get( partitionColumnIndex ).getValue() == null ) {
partitionValue = PartitionManager.NULL_STRING;
} else {
partitionValue = currentTuple.get( partitionColumnIndex ).toString().replace( "'", "" );
partitionValue = currentTuple.get( partitionColumnIndex ).value.toJson().replace( "'", "" );
}
identPart = (int) partitionManager.getTargetPartitionId( table, property, partitionValue );
accessedPartitionList.add( identPart );
Expand Down Expand Up @@ -453,8 +453,7 @@ private Triple<Long, String, Boolean> handleDmlInsert( List<String> updateColumn

tempPartitionId = partitionManager.getTargetPartitionId( table, property, currentRow.get( partitionValueIndex ).toString() );

long finalTempPartitionId = tempPartitionId;
if ( catalog.getSnapshot().alloc().getPartitionsFromLogical( table.id ).stream().noneMatch( p -> p.id == finalTempPartitionId ) ) {
if ( catalog.getSnapshot().alloc().getAlloc( pkPlacement.id, tempPartitionId ).isEmpty() ) {
continue;
}

Expand Down Expand Up @@ -541,7 +540,7 @@ private Pair<Set<Long>, String> handleDmlUpdate( List<String> updateColumns, Log
log.debug( " UPDATE: Found PartitionColumnID Match: '{}' at index: {}", property.partitionColumnId, index );
}
// Routing/Locking can now be executed on certain partitions
partitionValue = sourceExpressionList.get( index ).toString().replace( "'", "" );
partitionValue = ((RexLiteral) sourceExpressionList.get( index )).value.toJson().replace( "'", "" );
if ( log.isDebugEnabled() ) {
log.debug(
"UPDATE: partitionColumn-value: '{}' should be put on partition: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ public void temperaturePartitionTest() throws SQLException {
long targetId = partitionManager.getTargetPartitionId( table, partitionProperty, partitionValue );

List<AllocationPartition> hotPartitionsAfterChange = Catalog.snapshot().alloc().getPartitionsFromGroup( ((TemperaturePartitionProperty) updatedProperty).getHotPartitionGroupId() );
Assert.assertTrue( hotPartitionsAfterChange.stream().map( p -> p.id ).collect( Collectors.toList() ).contains( Catalog.snapshot().alloc().getEntity( targetId ).orElseThrow().partitionId ) );
Assert.assertTrue( hotPartitionsAfterChange.stream().map( p -> p.id ).collect( Collectors.toList() ).contains( targetId ) );

//Todo @Hennlo check number of access
} finally {
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public void hybridPartitioningTest() throws SQLException {
new Object[]{ 407, "BarFoo", 67 } ) );

// Remove data
statement.executeUpdate( "DELETE FROM \"hybridpartitioningtest\" where tvarchar = 'Foo' " );
statement.executeUpdate( "DELETE FROM \"hybridpartitioningtest\" where tvarchar = 'Foo'" );

// Assert and Check if Table has the desired entries
TestHelper.checkResultSet(
Expand Down

0 comments on commit b4bdba1

Please sign in to comment.