Skip to content

Commit

Permalink
Update schema.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
ostafen committed May 18, 2024
1 parent 75a4610 commit 30f3439
Show file tree
Hide file tree
Showing 9 changed files with 3,261 additions and 1,462 deletions.
14 changes: 2 additions & 12 deletions immudb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ def sqlExec(self, stmt, params={}, noWait=False):

return sqlexec.call(self._stub, self._rs, stmt, params, noWait)

def sqlQuery(self, query, params={}, columnNameMode=constants.COLUMN_NAME_MODE_NONE):
def sqlQuery(self, query, params={}, columnNameMode=constants.COLUMN_NAME_MODE_NONE, acceptStream=False):
"""Queries the database using SQL
Args:
query: a query in immudb SQL dialect.
Expand All @@ -1624,17 +1624,7 @@ def sqlQuery(self, query, params={}, columnNameMode=constants.COLUMN_NAME_MODE_N
['table1', 'table2']
"""
ret = sqlquery.call(self._stub, self._rs, query,
params, columnNameMode)
if columnNameMode in [constants.COLUMN_NAME_MODE_DATABASE, constants.COLUMN_NAME_MODE_FULL]:
# newer DB version don't insert database name anymore, we need to
# process it manually
for i, t in enumerate(ret):
newkeys = [
x.replace("[@DB]", self._currentdb.decode("utf-8")) for x in t.keys()]
k = dict(zip(newkeys, list(t.values())))
ret[i] = k
return ret
return sqlquery.call(self._stub, self._rs, query, params, columnNameMode, self._currentdb, acceptStream)

def listTables(self):
"""List all tables in the current database
Expand Down
142 changes: 103 additions & 39 deletions immudb/datatypesv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,30 +737,67 @@ class DatabaseNullableSettings(GRPCTransformable):
syncFrequency: NullableMilliseconds = None
writeBufferSize: NullableUint32 = None
ahtSettings: AHTNullableSettings = None
maxActiveTransactions: NullableUint32 = None
mvccReadSetLimit: NullableUint32 = None
vLogCacheSize: NullableUint32 = None
truncationSettings: TruncationNullableSettings = None
embeddedValues: NullableBool = None
preallocFiles: NullableBool = None

def _getHumanDataClass(self):
return grpcHumanizator(self, DatabaseSettingsV2)

@dataclass
class TruncationNullableSettings(GRPCTransformable):
retentionPeriod: NullableMilliseconds = None
truncationFrequency: NullableMilliseconds = None

def _getHumanDataClass(self):
return grpcHumanizator(self, TruncationSettings)

@dataclass
class ReplicationSettings(GRPCTransformable):
replica: Optional[bool] = None
masterDatabase: Optional[str] = None
masterAddress: Optional[str] = None
masterPort: Optional[int] = None
followerUsername: Optional[str] = None
followerPassword: Optional[str] = None
primaryDatabase: Optional[str] = None
primaryHost: Optional[str] = None
primaryPort: Optional[int] = None
primaryUsername: Optional[str] = None
primaryPassword: Optional[str] = None
syncReplication: Optional[bool] = None
syncAcks: Optional[int] = None
prefetchTxBufferSize: Optional[int] = None
replicationCommitConcurrency: Optional[int] = None
allowTxDiscarding: Optional[bool] = None
skipIntegrityCheck: Optional[bool] = None
waitForIndexing: Optional[bool] = None

def _getGRPC(self):
return schema.ReplicationNullableSettings(
replica=NullableBool(self.replica)._getGRPC(),
masterDatabase=NullableString(self.masterDatabase)._getGRPC(),
masterAddress=NullableString(self.masterAddress)._getGRPC(),
masterPort=NullableUint32(self.masterPort)._getGRPC(),
followerUsername=NullableString(self.followerUsername)._getGRPC(),
followerPassword=NullableString(self.followerPassword)._getGRPC()
primaryDatabase=NullableString(self.primaryDatabase)._getGRPC(),
primaryHost=NullableString(self.primaryHost)._getGRPC(),
primaryPort=NullableUint32(self.primaryPort)._getGRPC(),
primaryUsername=NullableString(self.primaryUsername)._getGRPC(),
primaryPassword=NullableString(self.primaryUsername)._getGRPC(),
syncReplication=NullableBool(self.syncReplication)._getGRPC(),
syncAcks=NullableUint32(self.syncAcks)._getGRPC(),
prefetchTxBufferSize=NullableUint32(self.prefetchTxBufferSize)._getGRPC(),
replicationCommitConcurrency=NullableUint32(self.replicationCommitConcurrency)._getGRPC(),
allowTxDiscarding=NullableBool(self.allowTxDiscarding)._getGRPC(),
skipIntegrityCheck=NullableBool(self.skipIntegrityCheck)._getGRPC(),
waitForIndexing=NullableBool(self.waitForIndexing)._getGRPC(),
)

@dataclass
class TruncationSettings(GRPCTransformable):
retentionPeriod: Optional[int]
truncationFrequency: Optional[int]

def _getGRPC(self):
return schema.TruncationNullableSettings(
retentionPeriod=NullableMilliseconds(self.retentionPeriod)._getGRPC(),
truncationFrequency=NullableMilliseconds(self.truncationFrequency)._getGRPC(),
)

@dataclass
class IndexSettings(GRPCTransformable):
Expand All @@ -777,6 +814,8 @@ class IndexSettings(GRPCTransformable):
commitLogMaxOpenedFiles: Optional[int] = None
flushBufferSize: Optional[int] = None
cleanupPercentage: Optional[float] = None
maxBulkSize: Optional[int] = None
bulkPreparationTimeout: Optional[int] = None

def _getGRPC(self):
return schema.IndexNullableSettings(
Expand All @@ -798,7 +837,9 @@ def _getGRPC(self):
commitLogMaxOpenedFiles=NullableUint32(
self.commitLogMaxOpenedFiles)._getGRPC(),
flushBufferSize=NullableUint32(self.flushBufferSize)._getGRPC(),
cleanupPercentage=NullableFloat(self.cleanupPercentage)._getGRPC()
cleanupPercentage=NullableFloat(self.cleanupPercentage)._getGRPC(),
maxBulkSize=NullableUint32(self.maxBulkSize)._getGRPC(),
bulkPreparationTimeout=NullableMilliseconds(self.bulkPreparationTimeout)._getGRPC(),
)


Expand All @@ -817,36 +858,48 @@ def _getGRPC(self):
@dataclass
class DatabaseSettingsV2(GRPCTransformable):
replicationSettings: ReplicationSettings = None
fileSize: Optional[int] = None
maxKeyLen: Optional[int] = None
maxValueLen: Optional[int] = None
maxTxEntries: Optional[int] = None
excludeCommitTime: Optional[bool] = None
fileSize: Optional[int] = None
maxKeyLen: Optional[int] = None
maxValueLen: Optional[int] = None
maxTxEntries: Optional[int] = None
excludeCommitTime: Optional[bool] = None
maxConcurrency: Optional[int] = None
maxIOConcurrency: Optional[int] = None
txLogCacheSize: Optional[int] = None
vLogMaxOpenedFiles: Optional[int] = None
txLogMaxOpenedFiles: Optional[int] = None
commitLogMaxOpenedFiles: Optional[int] = None
indexSettings: IndexSettings = None
vLogMaxOpenedFiles: Optional[int] = None
txLogMaxOpenedFiles: Optional[int] = None
commitLogMaxOpenedFiles: Optional[int] = None
indexSettings: IndexSettings = None
writeTxHeaderVersion: Optional[int] = None
autoload: Optional[bool] = None
readTxPoolSize: Optional[int] = None
autoload: Optional[bool] = None
readTxPoolSize: Optional[int] = None
syncFrequency: NullableMilliseconds = None
writeBufferSize: Optional[int] = None
ahtSettings: AHTSettings = None
maxActiveTransactions: Optional[int] = None
mvccReadSetLimit: Optional[int] = None
vLogCacheSize: Optional[int] = None
truncationSettings: TruncationSettings = None
embeddedValues: Optional[bool] = None
preallocFiles: Optional[bool] = None

def _getGRPC(self):
indexSettings = None
if self.indexSettings != None:
indexSettings = self.indexSettings._getGRPC()

replicationSettings = None
if self.replicationSettings != None:
replicationSettings = self.replicationSettings._getGRPC()

ahtSettings = None
if self.ahtSettings != None:
ahtSettings = self.ahtSettings._getGRPC()

truncSettings = None
if self.truncationSettings != None:
truncSettings = self.truncationSettings._getGRPC()

return schema.DatabaseNullableSettings(
replicationSettings=replicationSettings,
fileSize=NullableUint32(self.fileSize)._getGRPC(),
Expand All @@ -857,31 +910,40 @@ def _getGRPC(self):
maxConcurrency=NullableUint32(self.maxConcurrency)._getGRPC(),
maxIOConcurrency=NullableUint32(self.maxIOConcurrency)._getGRPC(),
txLogCacheSize=NullableUint32(self.txLogCacheSize)._getGRPC(),
vLogMaxOpenedFiles=NullableUint32(
self.vLogMaxOpenedFiles)._getGRPC(),
txLogMaxOpenedFiles=NullableUint32(
self.txLogMaxOpenedFiles)._getGRPC(),
commitLogMaxOpenedFiles=NullableUint32(
self.commitLogMaxOpenedFiles)._getGRPC(),
vLogMaxOpenedFiles=NullableUint32(self.vLogMaxOpenedFiles)._getGRPC(),
txLogMaxOpenedFiles=NullableUint32(self.txLogMaxOpenedFiles)._getGRPC(),
commitLogMaxOpenedFiles=NullableUint32(self.commitLogMaxOpenedFiles)._getGRPC(),
indexSettings=indexSettings,
writeTxHeaderVersion=NullableUint32(
self.writeTxHeaderVersion)._getGRPC(),
writeTxHeaderVersion=NullableUint32(self.writeTxHeaderVersion)._getGRPC(),
autoload=NullableBool(self.autoload)._getGRPC(),
readTxPoolSize=NullableUint32(self.readTxPoolSize)._getGRPC(),
syncFrequency=NullableMilliseconds(self.syncFrequency)._getGRPC(),
writeBufferSize=NullableUint32(self.writeBufferSize)._getGRPC(),
ahtSettings=ahtSettings
ahtSettings=ahtSettings,
maxActiveTransactions=NullableUint32(self.maxActiveTransactions)._getGRPC(),
mvccReadSetLimit=NullableUint32(self.mvccReadSetLimit)._getGRPC(),
vLogCacheSize=NullableUint32(self.vLogCacheSize)._getGRPC(),
truncationSettings=truncSettings,
embeddedValues=NullableBool(self.embeddedValues)._getGRPC(),
preallocFiles=NullableBool(self.preallocFiles)._getGRPC(),
)


@dataclass
class ReplicationNullableSettings(GRPCTransformable):
replica: NullableBool = None
masterDatabase: NullableString = None
masterAddress: NullableString = None
masterPort: NullableUint32 = None
followerUsername: NullableString = None
followerPassword: NullableString = None
primaryDatabase: NullableString = None
primaryHost: NullableString = None
primaryPort: NullableUint32 = None
primaryUsername: NullableString = None
primaryPassword: NullableString = None
syncReplication: NullableBool = None
syncAcks: NullableUint32 = None
prefetchTxBufferSize: NullableUint32 = None,
replicationCommitConcurrency: NullableUint32 = None,
allowTxDiscarding: NullableBool = None,
skipIntegrityCheck: NullableBool = None,
waitForIndexing: NullableBool = None,

def _getHumanDataClass(self):
return grpcHumanizator(self, ReplicationSettings)
Expand All @@ -902,6 +964,8 @@ class IndexNullableSettings(GRPCTransformable):
commitLogMaxOpenedFiles: NullableUint32 = None
flushBufferSize: NullableUint32 = None
cleanupPercentage: NullableFloat = None
maxBulkSize: NullableUint32 = None
bulkPreparationTimeout: NullableMilliseconds = None

def _getHumanDataClass(self):
return grpcHumanizator(self, IndexSettings)
Expand Down Expand Up @@ -1035,7 +1099,7 @@ class DatabaseListRequestV2(GRPCTransformable):

@dataclass
class DatabaseListResponseV2(GRPCTransformable):
databases: List[Union[DatabaseWithSettings, DatabaseWithSettingsV2]] = None
databases: List[Union[DatabaseWithSettings, DatabaseInfo]] = None

def _getHumanDataClass(self):
return DatabaseListResponseV2(databases=[toConvert._getHumanDataClass() for toConvert in self.databases])
Expand All @@ -1048,11 +1112,11 @@ class DatabaseWithSettings(GRPCTransformable):
loaded: bool = None

def _getHumanDataClass(self):
return grpcHumanizator(self, DatabaseWithSettingsV2)
return grpcHumanizator(self, DatabaseInfo)


@dataclass
class DatabaseWithSettingsV2(GRPCTransformable):
class DatabaseInfo(GRPCTransformable):
name: str = None
settings: DatabaseSettingsV2 = None
loaded: bool = None
Expand Down
Loading

0 comments on commit 30f3439

Please sign in to comment.