Skip to content

Commit

Permalink
PIVOT-9351 Fix some measure definitions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
GBQT authored May 15, 2024
1 parent d37af50 commit b75f5b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,20 @@ public class ManagerDescriptionConfig implements IActivePivotManagerDescriptionC
/** Measure of the chunk size. */
public static final String CHUNK_SIZE_SUM = "ChunkSize.SUM";
/** Measure of the the non-written rows in Chunks. */
public static final String NON_WRITTEN_ROWS_COUNT = "NonWrittenRows.COUNT";
public static final String NON_WRITTEN_ROWS_COUNT = "Unused rows";
/**
* Measure of the the non-written rows in Chunks, relative to the total non-written rows in the
* application.
*/
public static final String NON_WRITTEN_ROWS_RATIO = "NonWrittenRows.Ratio";
public static final String NON_WRITTEN_ROWS_RATIO = "Unused rows ratio";
/** Measure of the deleted rows in Chunks. */
public static final String DELETED_ROWS_COUNT = "DeletedRows.COUNT";
public static final String DELETED_ROWS_COUNT = "Deleted rows";
/**
* Measure of the deleted rows in Chunks, relative to the total deleted rows in the application.
*/
public static final String DELETED_ROWS_RATIO = "DeletedRows.Ratio";
public static final String DELETED_ROWS_RATIO = "Deleted rows ratio";
/** The number of committed rows within chunks. */
public static final String COMMITTED_ROWS_COUNT = "CommittedRows.COUNT";
public static final String COMMITTED_ROWS_COUNT = "Used rows";
/** The size in bytes of chunk memory used to store effective data. */
public static final String COMMITTED_CHUNK_MEMORY = "CommittedChunkMemory.SUM";
/** The ratio of committed rows within chunks. */
Expand Down Expand Up @@ -638,8 +638,16 @@ private void chunkMeasures(final ICopperContext context) {
.withDescription("the ratio of freed rows within the chunks")
.publish(context);

final CopperMeasure totalRows =
Copper.sum(DatastoreConstants.CHUNK__SIZE)
.withDescription("the total number of rows in chunks")
.as("Physical row count")
.withFormatter(NUMBER_FORMATTER)
.withinFolder(CHUNK_FOLDER)
.publish(context);

nonWrittenRowsCount
.divide(chunkSize)
.divide(totalRows)
.withType(Types.TYPE_DOUBLE)
.withFormatter(PERCENT_FORMATTER)
.as(NON_WRITTEN_ROWS_RATIO)
Expand Down Expand Up @@ -739,64 +747,18 @@ private void dictionaryMeasures(ICopperContext context) {
.withDescription("the number of entries in the corresponding dictionary, when relevant")
.publish(context);

Copper.measure(COMMITTED_ROWS_COUNT)
.per(
Copper.hierarchy(OWNER_HIERARCHY).level(OWNER_HIERARCHY),
Copper.hierarchy(FIELD_HIERARCHY).level(FIELD_HIERARCHY),
Copper.hierarchy(PARTITION_HIERARCHY).level(PARTITION_HIERARCHY))
.avg()
.as("Used rows")
.withFormatter(NUMBER_FORMATTER)
.withinFolder(STORE_CHUNK_FOLDER)
.withDescription("the number of rows actually containing data in a chunk in the store")
.publish(context);

Copper.measure(DELETED_ROWS_COUNT)
perChunkAggregation(DatastoreConstants.CHUNK__SIZE)
.max()
.per(
Copper.hierarchy(OWNER_HIERARCHY).level(OWNER_HIERARCHY),
Copper.hierarchy(FIELD_HIERARCHY).level(FIELD_HIERARCHY),
Copper.hierarchy(PARTITION_HIERARCHY).level(PARTITION_HIERARCHY))
.avg()
.as("Deleted rows")
Copper.hierarchy(PARTITION_HIERARCHY).level(PARTITION_HIERARCHY),
Copper.hierarchy(CHUNK_CLASS_LEVEL).level(CHUNK_CLASS_LEVEL))
.min()
.as("Chunk size")
.withFormatter(NUMBER_FORMATTER)
.withinFolder(STORE_CHUNK_FOLDER)
.withDescription("the number of deleted rows from the store")
.publish(context);

final CopperMeasure storeUnusedRows =
Copper.measure(NON_WRITTEN_ROWS_COUNT)
.per(
Copper.hierarchy(OWNER_HIERARCHY).level(OWNER_HIERARCHY),
Copper.hierarchy(FIELD_HIERARCHY).level(FIELD_HIERARCHY),
Copper.hierarchy(PARTITION_HIERARCHY).level(PARTITION_HIERARCHY))
.avg()
.as("Unused rows")
.withFormatter(NUMBER_FORMATTER)
.withinFolder(STORE_CHUNK_FOLDER)
.withDescription("the number of empty rows in the store")
.publish(context);

final CopperMeasure storeChunkSize =
perChunkAggregation(DatastoreConstants.CHUNK__SIZE)
.max()
.per(
Copper.hierarchy(OWNER_HIERARCHY).level(OWNER_HIERARCHY),
Copper.hierarchy(FIELD_HIERARCHY).level(FIELD_HIERARCHY),
Copper.hierarchy(PARTITION_HIERARCHY).level(PARTITION_HIERARCHY),
Copper.hierarchy(CHUNK_CLASS_LEVEL).level(CHUNK_CLASS_LEVEL))
.min()
.as("Chunk size")
.withFormatter(NUMBER_FORMATTER)
.withinFolder(STORE_CHUNK_FOLDER)
.withDescription("the size of each chunk for the store")
.publish(context);

Copper.combine(storeChunkSize, storeUnusedRows)
.mapToDouble(a -> a.readDouble(1) / a.readDouble(0))
.as("Unused rows ratio")
.withFormatter(PERCENT_FORMATTER)
.withinFolder(STORE_CHUNK_FOLDER)
.withDescription("the ratio of unused rows inside the chunks")
.withDescription("the size of each chunk for the store")
.publish(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void testNonWrittenCount() throws QueryException {
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " NON EMPTY [Measures].[NonWrittenRows.COUNT] ON COLUMNS"
+ " NON EMPTY [Measures].[Unused rows] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res = pivot.execute(query);

Expand Down Expand Up @@ -366,7 +366,7 @@ public void testFreedCount() throws QueryException {
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " [Measures].[DeletedRows.COUNT] ON COLUMNS"
+ " [Measures].[Deleted rows] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res = pivot.execute(query);

Expand Down Expand Up @@ -394,15 +394,15 @@ public void testNonWrittenRatio() throws QueryException {
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " NON EMPTY [Measures].[NonWrittenRows.COUNT] ON COLUMNS"
+ " NON EMPTY [Measures].[Unused rows] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res2 = pivot.execute(query2);

final MDXQuery query3 =
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " NON EMPTY [Measures].[NonWrittenRows.Ratio] ON COLUMNS"
+ " NON EMPTY [Measures].[Unused rows ratio] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res3 = pivot.execute(query3);

Expand Down Expand Up @@ -435,15 +435,15 @@ public void testDeletedRatio() throws QueryException {
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " NON EMPTY [Measures].[DeletedRows.COUNT] ON COLUMNS"
+ " NON EMPTY [Measures].[Deleted rows] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res2 = pivot.execute(query2);

final MDXQuery query3 =
new MDXQuery(
"SELECT"
+ " NON EMPTY [Chunks].[ChunkId].[ChunkId].Members ON ROWS,"
+ " NON EMPTY [Measures].[DeletedRows.Ratio] ON COLUMNS"
+ " NON EMPTY [Measures].[Deleted rows ratio] ON COLUMNS"
+ " FROM [MemoryCube]");
CellSetDTO res3 = pivot.execute(query3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void testCommittedRowsRatio() throws QueryException {

final MDXQuery storeAcommittedRows =
new MDXQuery(
"SELECT NON EMPTY [Measures].[CommittedRows.COUNT] ON COLUMNS "
"SELECT NON EMPTY [Measures].[Used rows] ON COLUMNS "
+ "FROM [MemoryCube]"
+ "WHERE [Owners].[Owner].[ALL].[AllMember].[Store A]");

Expand Down

0 comments on commit b75f5b0

Please sign in to comment.