Skip to content

Commit c689e95

Browse files
committed
HPCC-35694 DFUQuery sort by compressed size
Signed-off-by: Gordon Smith<GordonJSmith@gmail.com>
1 parent 39e3dc5 commit c689e95

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

.github/instructions/esp-service-interface.instructions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ applyTo: '**/*.ecm'
1010
- Increment the `version` and `default_client_version` attributes of the `ESPservice` element.
1111
- Include the `exceptions_inline` attribute in any new `ESPresponse` and `ESPmethod` element.
1212

13+
## Version Bumping
14+
- Always bump the `ESPservice` `version` and `default_client_version` when changing request/response schemas or behavior.
15+
- Use the next sequential version string (for example, if current is 1.67, bump to 1.68).
16+
- Keep changes backward compatible; do not remove or change existing fields without a version gate.
17+
1318
## Naming Conventions
1419
- Use `PascalCase` for element names.
1520
- Use lower case for native types such as `string`, `integer`, `boolean`, etc.

dali/base/dadfs.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14146,6 +14146,14 @@ static IPropertyTreeIterator *deserializeFileAttrIterator(MemoryBuffer& mb, unsi
1414614146
setIsCompressed(attr);
1414714147
}
1414814148

14149+
if (options.includeField(DFUQResultField::compressedsize))
14150+
{
14151+
// Falls back to origsize if not compressed for more sensible sorting
14152+
// Really should distinguish between size, compressed size and disk size (where disk size === compressed size or orig size when uncompressed)
14153+
const char *compressedSizeProp = getDFUQResultFieldName(DFUQResultField::compressedsize);
14154+
attr->setPropInt64(compressedSizeProp, isCompressed(*attr) ? attr->getPropInt64(compressedSizeProp, -1) : attr->getPropInt64(getDFUQResultFieldName(DFUQResultField::origsize), -1));
14155+
}
14156+
1414914157
if (options.includeField(DFUQResultField::cost))
1415014158
{
1415114159
// JCSMORE - cost could be computed in Dali instead - would simplify filtering/projecting code

esp/services/ws_dfu/ws_dfuService.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,38 @@ __int64 CWsDfuEx::findPositionBySize(const __int64 size, bool descend, IArrayOf<
29202920
return addToPos;
29212921
}
29222922

2923+
__int64 CWsDfuEx::findPositionByCompressedSize(const __int64 size, bool descend, IArrayOf<IEspDFULogicalFile>& LogicalFiles)
2924+
{
2925+
__int64 addToPos = -1;
2926+
2927+
ForEachItemIn(i, LogicalFiles)
2928+
{
2929+
IEspDFULogicalFile& File = LogicalFiles.item(i);
2930+
__int64 nSize;
2931+
if (File.getIsCompressed())
2932+
{
2933+
nSize = File.getCompressedFileSize();
2934+
}
2935+
else
2936+
{
2937+
const char* sSize = File.getLongSize();
2938+
nSize = atoi64_l(sSize,strlen(sSize));
2939+
}
2940+
if (descend && size > nSize)
2941+
{
2942+
addToPos = i;
2943+
break;
2944+
}
2945+
if (!descend && size < nSize)
2946+
{
2947+
addToPos = i;
2948+
break;
2949+
}
2950+
}
2951+
2952+
return addToPos;
2953+
}
2954+
29232955
__int64 CWsDfuEx::findPositionByParts(const __int64 parts, bool descend, IArrayOf<IEspDFULogicalFile>& LogicalFiles)
29242956
{
29252957
__int64 addToPos = -1;
@@ -3333,6 +3365,7 @@ void CWsDfuEx::getAPageOfSortedLogicalFile(IEspContext &context, IUserDescriptor
33333365
}
33343366

33353367
__int64 recordSize=attr.getPropInt64("@recordSize",0), size=attr.getPropInt64("@size",-1);
3368+
__int64 compressedSize = attr.getPropInt64("@compressedSize", size);
33363369

33373370
if (nFileSizeFrom > 0 && size < nFileSizeFrom)
33383371
continue;
@@ -3368,6 +3401,10 @@ void CWsDfuEx::getAPageOfSortedLogicalFile(IEspContext &context, IUserDescriptor
33683401
{
33693402
addToPos = findPositionBySize(size, descending, LogicalFileList);
33703403
}
3404+
else if (stricmp(sortBy, "CompressedFileSize")==0)
3405+
{
3406+
addToPos = findPositionByCompressedSize(compressedSize, descending, LogicalFileList);
3407+
}
33713408
else if (stricmp(sortBy, "Parts")==0)
33723409
{
33733410
addToPos = findPositionByParts(parts, descending, LogicalFileList);
@@ -3769,6 +3806,7 @@ void CWsDfuEx::setDFUQuerySortOrder(IEspDFUQueryRequest& req, StringBuffer& sort
37693806
static const std::unordered_map<std::string_view, std::string_view> legacyMappings =
37703807
{
37713808
{"FileSize", "@DFUSFsize"},
3809+
{"CompressedFileSize", "@compressedSize"},
37723810
{"ContentType", "@kind"},
37733811
{"IsCompressed", "@compressed"},
37743812
{"Records", "@recordcount"},

esp/services/ws_dfu/ws_dfuService.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class CWsDfuEx : public CWsDfu
215215
IArrayOf<IEspDFULogicalFile>& LogicalFiles, int& addToPos, bool& reachLimit);
216216
__int64 findPositionByParts(const __int64 parts, bool decsend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);
217217
__int64 findPositionBySize(const __int64 size, bool decsend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);
218+
__int64 findPositionByCompressedSize(const __int64 size, bool decsend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);
218219
__int64 findPositionByRecords(const __int64 records, bool decsend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);
219220
__int64 findPositionByName(const char *name, bool descend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);
220221
__int64 findPositionByOwner(const char *owner, bool descend, IArrayOf<IEspDFULogicalFile>& LogicalFiles);

esp/src/src-react/components/Files.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from "react";
22
import { CommandBar, ContextualMenuItemType, ICommandBarItemProps, Icon, Link } from "@fluentui/react";
3+
import { makeStyles, tokens } from "@fluentui/react-components";
34
import { scopedLogger } from "@hpcc-js/util";
45
import * as WsDfu from "src/WsDfu";
56
import { CreateDFUQueryStore, Get } from "src/ESPLogicalFile";
@@ -24,6 +25,13 @@ import { SizeMe } from "../layouts/SizeMe";
2425

2526
const logger = scopedLogger("src-react/components/Files.tsx");
2627

28+
const useStyles = makeStyles({
29+
dimmed: {
30+
opacity: "0.666",
31+
color: tokens.colorNeutralForeground3
32+
}
33+
});
34+
2735
const FilterFields: Fields = {
2836
"LogicalName": { type: "string", label: nlsHPCC.Name, placeholder: nlsHPCC.somefile },
2937
"Description": { type: "string", label: nlsHPCC.Description, placeholder: nlsHPCC.SomeDescription },
@@ -103,6 +111,7 @@ export const Files: React.FunctionComponent<FilesProps> = ({
103111
store
104112
}) => {
105113

114+
const styles = useStyles();
106115
const hasFilter = React.useMemo(() => Object.keys(filter).length > 0, [filter]);
107116

108117
const [showFilter, setShowFilter] = React.useState(false);
@@ -216,10 +225,23 @@ export const Files: React.FunctionComponent<FilesProps> = ({
216225
},
217226
csvFormatter: (value, row) => row.IntSize,
218227
},
219-
CompressedFileSizeString: {
228+
CompressedFileSize: {
220229
label: nlsHPCC.CompressedSize,
221230
formatter: (value, row) => {
222-
return Utility.convertedSize(row.CompressedFileSize);
231+
if (row.IsCompressed) {
232+
return Utility.convertedSize(row.CompressedFileSize);
233+
}
234+
const fileSize = Utility.convertedSize(row.IntSize);
235+
if (fileSize) {
236+
return `[${fileSize}]`;
237+
}
238+
return "";
239+
},
240+
className: (value: any, row: any) => {
241+
if (!row.IsCompressed) {
242+
return styles.dimmed;
243+
}
244+
return "";
223245
},
224246
csvFormatter: (value, row) => row.CompressedFileSize,
225247
},

0 commit comments

Comments
 (0)