This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for xt db basis #56
Open
naomijub
wants to merge
5
commits into
main
Choose a base branch
from
add-support-for-xt-db-basis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
syntax = "proto3"; | ||
|
||
package com.xtdb.protos; | ||
import "common.proto"; | ||
|
||
message DbBasisRequest { | ||
OptionInt64 tx_id = 1; | ||
OptionDatetime valid_time = 2; | ||
OptionDatetime tx_time = 3; | ||
} | ||
|
||
message DbBasisResponse { | ||
string xt_id = 1; | ||
string valid_time = 2; | ||
string xt_tx = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
(ns gxtdb.adapters.db | ||
(:require [gxtdb.adapters.tx-time :refer [->clj-time]] | ||
[gxtdb.utils :refer [not-nil?]] | ||
[xtdb.api :as xt])) | ||
|
||
(defn ->db-basis [params] | ||
(let [valid-time (some-> params :valid-time ->clj-time) | ||
tx-time (some-> params :tx-time ->clj-time) | ||
tx-id (some-> params :tx-id :value :some)] | ||
(case [(not-nil? valid-time) (not-nil? tx-time) (not-nil? tx-id)] | ||
[true true true] {::xt/valid-time valid-time} | ||
[true false false] {::xt/valid-time valid-time} | ||
[true true false] {::xt/valid-time valid-time ::xt/tx-time tx-time} | ||
[true false true] {::xt/valid-time valid-time ::xt/tx tx-id} | ||
[false true false] {::xt/tx-time tx-time} | ||
[false false true] {::xt/tx tx-id} | ||
nil))) | ||
(:require [gxtdb.utils :as utils])) | ||
|
||
(defn db-basis->proto [db-basis-response] | ||
{:xt-id (-> db-basis-response :xt/id str) | ||
:valid-time (-> db-basis-response :xtdb.api/valid-time utils/->inst-str) | ||
:tx-time (-> db-basis-response :xtdb.api/tx-time utils/->inst-str)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(ns gxtdb.controllers | ||
(:require [clojure.pprint :as pprint] | ||
[gxtdb.adapters.db :refer [->db-basis]] | ||
[gxtdb.adapters.db :as adapters.db] | ||
[gxtdb.adapters.entity :as adapters.entity] | ||
[gxtdb.adapters.tx-log :as tx-log-adapter] | ||
[gxtdb.logic.time :refer [assoc-some-time]] | ||
|
@@ -19,12 +19,12 @@ | |
|
||
(defn entity-tx [xtdb-node params] | ||
(let [id (->id (:id-type params) (:entity-id params)) | ||
db-basis (->db-basis params) | ||
db-basis (adapters.db/db-basis->proto params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it breaks here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the old one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would checkout There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! I reverted |
||
db (open-db xtdb-node (:open-snapshot params) db-basis)] | ||
(->> id (xt/entity-tx db) adapters.entity/entity-tx->proto))) | ||
|
||
(defn entity [xtdb-node params] | ||
(let [id (->id (:id-type params) (:entity-id params)) | ||
db-basis (->db-basis params) | ||
db-basis (adapters.db/db-basis->proto params) | ||
db (open-db xtdb-node (:open-snapshot params) db-basis)] | ||
(->> id (xt/entity db) adapters.entity/entity->proto))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change broke stuff, I would probably test it with duplication for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also,
db-basis->proto
and->db-basis
are different things and had different usages