Skip to content

Commit

Permalink
More refactoring on pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoLR10 committed Mar 9, 2024
1 parent 827371b commit 836fedb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ast.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,21 @@
[(procedure? entity)
(error "Don't write procedures yet")])))

(define (table-column-value table column-name)
(define (table-column-value table table-name column-name)
(define (column-name-message column-name)
(error (format "Could not find column \"~s\" in table fields" column-name)))
(error (format "Could not find column ~s in table fields of table ~s" column-name table-name)))

(let* [(column-field (hash-ref (table-fields table) column-name (lambda () (column-name-message column-name))))
(field-type (field-type column-field))
(name (type-name field-type))]
(case name
[[INTEGER] integer32-value]
[[VARCHAR] stringl-value]
[[VARCHAR] (error "TODO: We only support integers for now and you asked for a string bud xD")]
[else (error (format "Could not find type ~a in table's fields: ~a" name (table-fields table)))])))

(define (extract-value schema table-name column-name)
(~> (lookup-table-in-schema schema table-name)
(table-column-value _ column-name)))
(table-column-value _ table-name column-name)))

(define-serializable table
[identifier row-id fields local-constraints] #:transparent
Expand Down
4 changes: 2 additions & 2 deletions main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
(define row1
`(("NAME" . ,(stringl "Nathan"))
("EDITOR" . ,(stringl "Visual Studio Code"))
("AGE" . ,(integer32 123))))
("AGE" . ,(integer32 100))))

(define row2
`(("NAME" . ,(stringl "Lemos"))
Expand Down Expand Up @@ -126,7 +126,7 @@
(set! schema (write-rows-to-disk schema "PROGRAMMER" (list row1 row2)))
;; (println (read-table-values-from-disk schema "PROGRAMMER"))
;; (define-values (pages amount-already-read) (build-pages 0 1 1 (+ 7 10 4) 0 "AGE" schema "PROGRAMMER"))
(println (search schema (query "CAR" "YEAR" 1996)))
(println (search schema (query "PROGRAMMER" "AGE" 100)))
;; (check-local-constraints programmer-table (list row1 row2))
;; (hash-set! schema "TEST" procedure-test)
;; (write-schema-to-disk schema)
Expand Down
Binary file modified ndf/data/PROGRAMMER.ndf
Binary file not shown.

0 comments on commit 836fedb

Please sign in to comment.