Skip to content

Commit

Permalink
Adjust python module for meson build and fix bug with >16 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
JCoym committed Dec 21, 2020
1 parent c8b5d8f commit 44e13b4
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 71 deletions.
2 changes: 1 addition & 1 deletion python/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions python/julea/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,7 +18,7 @@
import pathlib

juleadir = pathlib.Path(__file__).parent.parent.parent
libdir = juleadir.joinpath('build', 'lib')
libdir = juleadir.joinpath('bld')

JULEA = ctypes.CDLL(libdir.joinpath('libjulea.so'))
JULEA_ITEM = ctypes.CDLL(libdir.joinpath('libjulea-item.so'))
Expand Down
2 changes: 1 addition & 1 deletion python/julea/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
10 changes: 5 additions & 5 deletions python/julea/benchmark/bench_distributed_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2017-2019 Michael Kuhn
# Copyright (C) 2019-2020 Johannes Coym
# Copyright (C) 2017-2020 Michael Kuhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -80,7 +80,7 @@ def bench_delete(use_batch):
def bench_status(use_batch):
n = 1000
distribution = JDistribution(J_DISTRIBUTION_ROUND_ROBIN)
dummy = bytearray(1)
dummy = bytes(1)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JDistributedObject("python", "benchmark", distribution)
Expand Down Expand Up @@ -110,7 +110,7 @@ def bench_status(use_batch):
def bench_read(use_batch, block_size):
n = 25000
distribution = JDistribution(J_DISTRIBUTION_ROUND_ROBIN)
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JDistributedObject("python", "benchmark", distribution)
Expand Down Expand Up @@ -144,7 +144,7 @@ def bench_read(use_batch, block_size):
def bench_write(use_batch, block_size):
n = 25000
distribution = JDistribution(J_DISTRIBUTION_ROUND_ROBIN)
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JDistributedObject("python", "benchmark", distribution)
Expand Down
10 changes: 5 additions & 5 deletions python/julea/benchmark/bench_item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2010-2019 Michael Kuhn
# Copyright (C) 2019-2020 Johannes Coym
# Copyright (C) 2010-2020 Michael Kuhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -112,7 +112,7 @@ def bench_delete_batch_without_get():

def bench_status(use_batch):
n = 1000
dummy = bytearray(1)
dummy = bytes(1)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
collection = JCollection("benchmark", batch, False)
Expand Down Expand Up @@ -142,7 +142,7 @@ def bench_status(use_batch):

def bench_read(use_batch, block_size):
n = 25000
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
collection = JCollection("benchmark", batch, False)
Expand Down Expand Up @@ -177,7 +177,7 @@ def bench_read(use_batch, block_size):

def bench_write(use_batch, block_size):
n = 25000
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
collection = JCollection("benchmark", batch, False)
Expand Down
4 changes: 2 additions & 2 deletions python/julea/benchmark/bench_kv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2017-2019 Michael Kuhn
# Copyright (C) 2019-2020 Johannes Coym
# Copyright (C) 2017-2020 Michael Kuhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
10 changes: 5 additions & 5 deletions python/julea/benchmark/bench_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2017-2019 Michael Kuhn
# Copyright (C) 2019-2020 Johannes Coym
# Copyright (C) 2017-2020 Michael Kuhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -72,7 +72,7 @@ def bench_delete(use_batch):

def bench_status(use_batch):
n = 200000
dummy = bytearray(1)
dummy = bytes(1)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JObject("python", "benchmark")
Expand Down Expand Up @@ -101,7 +101,7 @@ def bench_status(use_batch):

def bench_read(use_batch, block_size):
n = 200000
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JObject("python", "benchmark")
Expand Down Expand Up @@ -132,7 +132,7 @@ def bench_read(use_batch, block_size):

def bench_write(use_batch, block_size):
n = 200000
dummy = bytearray(block_size)
dummy = bytes(block_size)

with JBatch(J_SEMANTICS_TEMPLATE_DEFAULT) as batch:
o = JObject("python", "benchmark")
Expand Down
2 changes: 1 addition & 1 deletion python/julea/item/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/julea/item/collection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
15 changes: 7 additions & 8 deletions python/julea/item/item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -98,19 +98,18 @@ def write(self, value, offset, batch):
"""Writes an item
Args:
value: A bytearray holding the data to write
value: bytes holding the data to write
offset: The offset where the data is written
batch: A batch
Returns:
bytes_written: A c_ulonglong with the bytes written
(Access with bytes_written.value)
"""
length = ctypes.c_ulonglong(len(value))
value2 = ctypes.create_string_buffer(length.value)
value2.raw = value
value2 = ctypes.c_char_p(value)
bytes_written = ctypes.c_ulonglong(0)
JULEA_ITEM.j_item_write(
self.item, ctypes.byref(value2), length, offset,
self.item, value2, length, offset,
ctypes.byref(bytes_written), batch.get_pointer())
return bytes_written

Expand All @@ -123,13 +122,13 @@ def read(self, length, offset, batch):
batch: A batch
Returns:
value: The ctype with the data that was read
(Access data with value.raw)
(Access data with value.value)
bytes_read: A c_ulonglong with the bytes read
(Access with bytes_read.value)
"""
value = ctypes.create_string_buffer(length)
value = ctypes.c_char_p(bytes(length))
bytes_read = ctypes.c_ulonglong(0)
JULEA_ITEM.j_item_read(
self.item, ctypes.byref(value), length, offset,
self.item, value, length, offset,
ctypes.byref(bytes_read), batch.get_pointer())
return value, bytes_read
2 changes: 1 addition & 1 deletion python/julea/kv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
9 changes: 4 additions & 5 deletions python/julea/kv/kv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -51,13 +51,12 @@ def put(self, value, batch):
"""Writes a Key-Value pair
Args:
value: A bytearray of data to be written in the KV pair
value: bytes of data to be written in the KV pair
batch: A batch
"""
length = ctypes.c_ulong(len(value))
value2 = ctypes.create_string_buffer(length.value)
value2.raw = value
JULEA_KV.j_kv_put(self.kv, ctypes.byref(value2),
value2 = ctypes.c_char_p(value)
JULEA_KV.j_kv_put(self.kv, value2,
length, None, batch.get_pointer())

def get(self, batch):
Expand Down
2 changes: 1 addition & 1 deletion python/julea/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/julea/lib/batch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/julea/lib/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/julea/lib/distribution.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion python/julea/object/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
15 changes: 7 additions & 8 deletions python/julea/object/distributed_object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -79,19 +79,18 @@ def write(self, value, offset, batch):
"""Writes an object
Args:
value: A bytearray holding the data to write
value: bytes holding the data to write
offset: The offset where the data is written
batch: A batch
Returns:
bytes_written: A c_ulonglong with the bytes written
(Access with bytes_written.value)
"""
length = ctypes.c_ulonglong(len(value))
value2 = ctypes.create_string_buffer(length.value)
value2.raw = value
value2 = ctypes.c_char_p(value)
bytes_written = ctypes.c_ulonglong(0)
JULEA_OBJECT.j_distributed_object_write(
self.object, ctypes.byref(value2), length, offset,
self.object, value2, length, offset,
ctypes.byref(bytes_written), batch.get_pointer())
return bytes_written

Expand All @@ -104,13 +103,13 @@ def read(self, length, offset, batch):
batch: A batch
Returns:
value: The ctype with the data that was read
(Access data with value.raw)
(Access data with value.value)
bytes_read: A c_ulonglong with the bytes read
(Access with bytes_read.value)
"""
value = ctypes.create_string_buffer(length)
value = ctypes.c_char_p(bytes(length))
bytes_read = ctypes.c_ulonglong(0)
JULEA_OBJECT.j_distributed_object_read(
self.object, ctypes.byref(value), length, offset,
self.object, value, length, offset,
ctypes.byref(bytes_read), batch.get_pointer())
return value, bytes_read
15 changes: 7 additions & 8 deletions python/julea/object/object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -75,19 +75,18 @@ def write(self, value, offset, batch):
"""Writes an object
Args:
value: A bytearray holding the data to write
value: bytes holding the data to write
offset: The offset where the data is written
batch: A batch
Returns:
bytes_written: A c_ulonglong with the bytes written
(Access with bytes_written.value)
"""
length = ctypes.c_ulonglong(len(value))
value2 = ctypes.create_string_buffer(length.value)
value2.raw = value
value2 = ctypes.c_char_p(value)
bytes_written = ctypes.c_ulonglong(0)
JULEA_OBJECT.j_object_write(
self.object, ctypes.byref(value2), length, offset,
self.object, value2, length, offset,
ctypes.byref(bytes_written), batch.get_pointer())
return bytes_written

Expand All @@ -100,13 +99,13 @@ def read(self, length, offset, batch):
batch: A batch
Returns:
value: The ctype with the data that was read
(Access data with value.raw)
(Access data with value.value)
bytes_read: A c_ulonglong with the bytes read
(Access with bytes_read.value)
"""
value = ctypes.create_string_buffer(length)
value = ctypes.c_char_p(bytes(length))
bytes_read = ctypes.c_ulonglong(0)
JULEA_OBJECT.j_object_read(
self.object, ctypes.byref(value), length, offset,
self.object, value, length, offset,
ctypes.byref(bytes_read), batch.get_pointer())
return value, bytes_read
2 changes: 1 addition & 1 deletion python/julea/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JULEA - Flexible storage framework
# Copyright (C) 2019 Johannes Coym
# Copyright (C) 2019-2020 Johannes Coym
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down
Loading

0 comments on commit 44e13b4

Please sign in to comment.