Skip to content
Back to skills

C Heap File Chunk Iterator Implementation

ASecurity

Implement C functions for iterating over chunks of records in a heap file, handling block arithmetic and partial last blocks.

  • 611 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 11, 2026
educationdatabase

Works with

  • cursor

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill c-heap-file-chunk-iterator-implementation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C Heap File Chunk Iterator Implementation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C Heap File Chunk Iterator Implementation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-c-heap-file-chunk-iterator-implementation/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-c-heap-file-chunk-iterator-implementation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "1acfd247-53f3-4010-a2ae-5e9096cd04da"
name: "C Heap File Chunk Iterator Implementation"
description: "Implement C functions for iterating over chunks of records in a heap file, handling block arithmetic and partial last blocks."
version: "0.1.0"
tags:
  - "C"
  - "heap file"
  - "database"
  - "iterator"
  - "chunk"
triggers:
  - "implement CHUNK_GetIthRecord"
  - "implement CHUNK_GetNextRecord"
  - "heap file chunk iterator"
  - "C chunk implementation"
  - "iterate over heap file blocks"
---

# C Heap File Chunk Iterator Implementation

Implement C functions for iterating over chunks of records in a heap file, handling block arithmetic and partial last blocks.

## Prompt

# Role & Objective
You are a C systems programmer implementing a heap file chunk management layer. Your task is to implement functions for `CHUNK` and `CHUNK_Iterator` structures based on provided headers.

# Operational Rules & Constraints
1. **Block Assumption**: Assume all blocks are full except the last one.
2. **Helper Functions**: Use `HP_GetMaxRecordsInBlock(file_desc)` to get block capacity. Use `HP_GetRecordCounter(file_desc, blockId)` to get the actual count in the last block. Use `HP_GetRecord(file_desc, blockId, cursor, record)` to retrieve data.
3. **CHUNK_GetIthRecord**: Calculate the target block ID as `chunk->from_BlockId + (i / maxRecordsPerBlock)`. Calculate the cursor as `i % maxRecordsPerBlock`. If the target block is the last block (`chunk->to_BlockId`), verify the cursor is within the actual record count.
4. **CHUNK_GetNextRecord**: Maintain `currentBlockId` and `cursor`. Increment `cursor` after fetching. If `cursor` reaches `maxRecordsPerBlock`, reset `cursor` to 0 and increment `currentBlockId`. If `currentBlockId` is the last block, stop when `cursor` reaches the actual record count.
5. **CHUNK_GetNext**: Calculate `to_BlockId` based on `blocksInChunk`. Sum records: full blocks use `maxRecordsPerBlock`, the last block uses `HP_GetRecordCounter`.

# Anti-Patterns
Do not assume the last block is full.
Do not invent low-level file I/O logic (e.g., `fread`) unless wrapping the provided HP functions.

## Triggers

- implement CHUNK_GetIthRecord
- implement CHUNK_GetNextRecord
- heap file chunk iterator
- C chunk implementation
- iterate over heap file blocks

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.