How can I avoid duplicates in ScriptDb? - database

I have some objects to save in the database, but they must be unique every time the script is executed. These objects are just going to change values every instance of the application. The problem is that when I create the first object, more copies are also created every time the script is executed after that. I try to use the same object again, but when I do the query, I get objects from previous executions giving me the wrong values. I just want to be able to reset the same objects to their default values and not have many unnecessary copies in the ScriptDb.
Here is some code:
// Get a database instance
var database = getDb();
// Create a new employee instance
var myEmployee = {
element: "currentEmployee",
firstName: "",
lastName: "",
ID: 0,
manager: "",
managerEmail: "",
department: "1 - University Store",
startDate: "",
endDate: "",
regularHours: 0,
vacationHours: 0,
sickHours: 0,
personalHours: 0,
H2Hours: 0,
overtimeHours: 0,
totalHours: 0,
rowLocation: 0,
salaryType: "H",
};
var week1 = {
// Identify the week and for query purposes
element: "Week1",
// User entries
HW: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
VH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
SH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
PH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
TH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
// Calculated totals
TotalHW:0, TotalVH: 0, TotalSH: 0, TotalPH: 0, TotalHours: 0,
// Week totals
Vacation: 0, Sick: 0, Personal: 0, H2: 0, OT: 0, Regular: 0,
}
var week2 = {
// Identify the week and for query purposes
element: "Week2",
// User entries
HW: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
VH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
SH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
PH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
TH: {THUR: 0, FRI: 0, SAT: 0, SUN: 0, MON: 0, TUES: 0, WED: 0},
// Calculated totals
TotalHW:0, TotalVH: 0, TotalSH: 0, TotalPH: 0, TotalHours: 0,
// Week totals
Vacation: 0, Sick: 0, Personal: 0, H2: 0, OT: 0, Regular: 0,
}
// Save these to the database
database.save(myEmployee);
database.save(week1);
database.save(week2);
Then, I would use the statement ScriptDb.getMyDb.query({element: element}).next() to retrieve the object. The string element containing "currentEmployee", "Week1", or "Week2".

To avoid re-creating uniquely-keyed objects in ScriptDb, you must first check whether the object you're thinking of saving is already there. If it is, then you need to get the handle of the stored object to use for updates. If it's not there, you will save() your new object, and the return value will be the handle of the copy in the database.
The general pattern is this:
// Get a database instance
var db = getDb();
var result = db.query( {key:keyval, ...} );
if (result.hasNext()) {
// The object already exists in ScriptDb
var obj = result.next()
}
else {
// The object doesn't exist in ScriptDb, so create it
// This example would start by creating only the key values,
// expanding the object during the update stage below.
// Alternatively, you could create the entire object with all
// its properties.
obj = db.save({key:keyval, ...})
}
// Can now update the obj that is in ScriptDb
obj.prop1 = value1;
obj.prop2 = value2;
...
// Save updated object
db.save(obj);
Here's an example of how that pattern could apply to your code. You'll see here that the alternative approach to creating new objects is being used, in which the new object is created in ScriptDb with all its properties at once.
// Get a database instance
var database = getDb();
// Find or create employee instance
var result = database.query({element: "currentEmployee"});
if (result.hasNext()) {
var myEmployee = result.next();
} else {
myEmployee = database.save({
element: "currentEmployee",
firstName: "",
lastName: "",
ID: 0,
manager: "",
managerEmail: "",
department: "1 - University Store",
startDate: "",
endDate: "",
regularHours: 0,
vacationHours: 0,
sickHours: 0,
personalHours: 0,
H2Hours: 0,
overtimeHours: 0,
totalHours: 0,
rowLocation: 0,
salaryType: "H"
});
};
// Find or create Week1 instance
result = database.query({element: "Week1"});
if (result.hasNext()) {
var week1 = result.next();
} else {
week1 = database.save({
// Identify the week and for query purposes
element: "Week1",
// User entries
HW: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
VH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
SH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
PH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
TH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
// Calculated totals
TotalHW: 0, TotalVH: 0, TotalSH: 0, TotalPH: 0, TotalHours: 0,
// Week totals
Vacation: 0, Sick: 0, Personal: 0, H2: 0, OT: 0, Regular: 0,
});
}
// Find or create Week2 instance
result = database.query({element: "Week2"});
if (result.hasNext()) {
var week2 = result.next();
} else {
week2 = database.save({
// Identify the week and for query purposes
element: "Week2",
// User entries
HW: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
VH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
SH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
PH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
TH: {THUR: 0,FRI: 0,SAT: 0,SUN: 0,MON: 0,TUES: 0,WED: 0},
// Calculated totals
TotalHW: 0, TotalVH: 0, TotalSH: 0, TotalPH: 0, TotalHours: 0,
// Week totals
Vacation: 0, Sick: 0, Personal: 0, H2: 0, OT: 0, Regular: 0,
});
}
// At this point, myEmployee, week1 and week2 refer to the ScriptDb objects.
// While we can use them as any javascript object, they also contain information
// relevant to their state as ScriptDb objects.
...

Related

How to change datatype of column in FeatureCollection in GEE

I have FeatureCollection with 4 columns with different datatypes. One of them is "long" which I neet to converte to "Int". The FeatureCollection was imported as shapefiles. I need this column as "Int" to do classification.
type: FeatureCollection
id: users/aleksandramonika/pola_beskidy_trening
version: 1667257388739078
columns: Object (4 properties)
id: Long
class: Long
name: String
system:index: String
I don't know how to access and change type of a column.
I tried to change the value with remap, but the datatype was changed to "any".
FeatureCollection (30 elements, 4 columns)
type: FeatureCollection
columns: Object (4 properties)
id: Long
class:
name: String
system:index: String
var agriculture = ee.FeatureCollection(agriculture).remap(
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
'class');

Changing the values of a dictionary Python

In the code below I create a dictionary 3 times and then attempt to change the value of Ontrade from True to False on Strategy 2 with the alteration function. However it does not work as expected and turns all the Ontrade values into True. How would i be able to fix that?
import numpy as np
import pprint
listrange = 5
data = {}
dict_integrity = {"Array": np.array([]), "last_timestamp": 0, "last_Trades": 0, "Order_id_list": 0, "Ontrade": False, "TakeProfits": 0, "StopLoss": 0}
for x in range(listrange):
data["Strategy " + str(x)] = dict_integrity
alteration = data["Strategy " + str(2)]["Ontrade"] = True
Output:
{'Strategy 0': {'Array': array([], dtype=float64),
'Ontrade': True,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0},
'Strategy 1': {'Array': array([], dtype=float64),
'Ontrade': True,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0},
'Strategy 2': {'Array': array([], dtype=float64),
'Ontrade': True,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0}}
Expected Output:
{'Strategy 0': {'Array': array([], dtype=float64),
'Ontrade': False,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0},
'Strategy 1': {'Array': array([], dtype=float64),
'Ontrade': False,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0},
'Strategy 2': {'Array': array([], dtype=float64),
'Ontrade': True,
'Order_id_list': 0,
'StopLoss': 0,
'TakeProfits': 0,
'last_Trades': 0,
'last_timestamp': 0}}

how to sort the json array by keys in descending order using angular

var arr = {
'2021-07-20-21:10': {
sends: 1,
recvs: 1,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 0,
appErrors: 0,
responseTimeAvg: 172,
responseTimeMax: 172,
when: '21:10',
hostCount: 1,
},
'2021-07-20-21:22': {
sends: 1,
recvs: 0,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 0,
responseTimeMax: 0,
when: '21:22',
hostCount: 1,
},
'2021-07-20-21:13': {
sends: 2,
recvs: 1,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 89,
responseTimeMax: 177,
when: '21:13',
hostCount: 2,
},
'2021-07-20-21:14': {
sends: 1,
recvs: 0,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 0,
responseTimeMax: 0,
when: '21:14',
hostCount: 1,
}}
and it has to be sorted based on keys in desc order
var arr = {
'2021-07-20-21:22': {
sends: 1,
recvs: 1,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 0,
appErrors: 0,
responseTimeAvg: 172,
responseTimeMax: 172,
when: '21:22',
hostCount: 1,
},
'2021-07-20-21:14': {
sends: 1,
recvs: 0,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 0,
responseTimeMax: 0,
when: '21:14',
hostCount: 1,
},
'2021-07-20-21:13': {
sends: 2,
recvs: 1,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 89,
responseTimeMax: 177,
when: '21:13',
hostCount: 2,
},
'2021-07-20-21:10': {
sends: 1,
recvs: 0,
notSents: 0,
rejects: 0,
xptSkips: 0,
timeouts: 1,
appErrors: 0,
responseTimeAvg: 0,
responseTimeMax: 0,
when: '21:10',
hostCount: 1,
}}
You can extract the "keys" of your array using the Object.keys() function, then use the sort function to sort that array of keys, and generate a new object iterating over each keys there... Code would be (keeping arr as the name of your array):
// Get the keys of your "array"
let arrayOfKeys = Object.keys(arr)
// We sort it out...
let sortedArray = arrayOfKeys.sort()
// We will create the "final" array
let resultingArray = {}
// Now we iterate over each element, in order:
sortedArray.forEach((element) => {
resultingArray[element] = arr[element]
})
...of course this can be shortened wildly, for example:
var resultingArr = {}
Object.keys(arr).sort().forEach(e -> { resultingArr[e] = arr[e] })
EDIT: I see that you need to sort the array in descending order. This can be done using a custom sort function, or using the function reverse(). Just correct the sorting step:
// We sort it out...
let sortedArray = arrayOfKeys.sort().reverse()

I'm trying to mutate bytes coming from a stream because decoding, but it's not working

I'm trying to wrap an io.ReaderCloser, which in production would come from a request handler, with a custom reader that can be passed into a JSON decoder.
I created the below
import (
"io"
)
// RemoveNull is a stream wrapper that should remove null bytes from the byte stream
type RemoveNull struct {
Reader io.ReadCloser
}
// NewRemoveNullStream creates a new RemoveNull reader which passes the stream through a null check first
func NewRemoveNullStream(reader io.ReadCloser) RemoveNull {
return RemoveNull{
Reader: reader,
}
}
// Read wraps a Reader to remove null bytes in the stream
func (null RemoveNull) Read(p []byte) (n int, err error) {
n, err = null.Reader.Read(p)
if err != nil {
return n, err
}
nn := 0
for i := range p {
if p[i] != 0 {
p[nn] = p[i]
nn++
}
}
p = p[:nn]
// fmt.Println(p) i can see the value of p changing and all the null bytes are removed
return n, nil
}
// Close closes the internal reader
func (null RemoveNull) Close() error {
return null.Close()
}
When I run the following I can see from the print statement that indeed all the null bytes are removed and the len(p) == the size of all the expected good bytes. I wrote the test below to see if the code if working as I intended, and that's where I realized it's not.
Here is the full test
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"testing"
"github.com/francoispqt/gojay" // can be replaced with the std json lib, code still doesn't work
)
func TestRemoveNull_Read(t *testing.T) {
type fields struct {
Reader io.ReadCloser
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "should remove null bytes",
fields: fields{
Reader: ioutil.NopCloser(bytes.NewReader([]byte{123, 34, 98, 111, 100, 121, 34, 58, 34, 102, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 108, 101, 34, 125})),
},
want: "female",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
reader := tt.fields.Reader
reader = NewRemoveNullStream(tt.fields.Reader) // wrapper the reader above in the nullByte reader
// passed the reader into this JSON unmarshaller
decoder := gojay.BorrowDecoder(reader)
defer decoder.Release()
var v _testStruct
err := decoder.DecodeObject(&v)
if err != nil {
t.Fatalf("ReadAll failed %v", err)
}
bb, _ := json.Marshal(v)
fmt.Println(string(bb)) // all the null bytes are still present
fmt.Println(len(v.Body), len(tt.want))
if v.Body != tt.want {
t.Fatalf("DecodeObject() unexpected value, got %s want %s", v.Body, tt.want)
}
})
}
}
type _testStruct struct {
Body string `json:"body"`
}
func (v *_testStruct) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
switch k {
case "body":
err := dec.String(&v.Body)
return err
}
return nil
}
// NKeys returns the number of keys to unmarshal
func (v *_testStruct) NKeys() int { return 0 }
From the test I can see that all the null bytes are still present when decoding, yet in the RemoveNull reader I can see that all the null bytes have been removed from the underline array. Any thoughts on whats wrong and how i can achieve the goal of removing the bytes from the stream to avoid having the decoder decode the null bytes?
There are errors in your Read implementation. It terminates prematurely in case of io.EOF, where there is both error and data. It returns the wrong number of bytes read. The last part where you assign the slice is also meaningless as it doesn't update the slice passed into the function.
Try this:
func (null RemoveNull) Read(p []byte) (n int, err error) {
n, err = null.Reader.Read(p)
nn := 0
for i:=0;i<n;i++ {
if p[i] != 0 {
p[nn] = p[i]
nn++
}
}
return nn, err
}

TCC Error: index too large

I have been playing around with ray-casting and decided to use 3D arrays to make levels, However TCC spits out this:
M_MAIN.C:19: error: index too large
Is there a limit to how large an array can be?
Code:
#define MAP_01_WIDTH 8
#define MAP_01_HEIGHT 8
#define MAP_01_DEPTH 8
#define MAP_01_PLAYER_START_X 2
#define MAP_01_PLAYER_START_Y 2
#define MAP_01_PLAYER_START_Z 2
char MAP_01[MAP_01_WIDTH][MAP_01_DEPTH][MAP_01_HEIGHT] =
{
{ {1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {2, 0, 3, 0, 0, 4, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 0, 0, 0, 0, 0, 0, 1}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {2, 0, 0, 0, 0, 0, 0, 2}, {1, 0, 0, 0, 0, 0, 0, 1} },
{ {1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1} }
};
You define the array with size 8x8x8 but initializing it with 9x8x8 elements. Fix the size with:
#define MAP_01_WIDTH 9
Or better yet, let the compiler calculate that:
char MAP_01[][MAP_01_DEPTH][MAP_01_HEIGHT] = {...};

Resources