in ytdb/src/main/java/com/youtrackdb/ldbc/ytdb/loader/SchemaCreator.java [51:107]
private List<String> loadSchemaStatements() throws IOException {
List<String> statements = new ArrayList<>();
StringBuilder currentStatement = new StringBuilder();
try (InputStream is = getClass().getResourceAsStream(SCHEMA_FILE)) {
if (is == null) {
throw new IOException("Schema file not found: " + SCHEMA_FILE);
}
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(is, StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
// Skip empty lines and comments
if (line.isEmpty() || line.startsWith("--")) {
continue;
}
// Skip SET commands (they're not executable in this context)
if (line.toUpperCase().startsWith("SET ")) {
continue;
}
// Accumulate statement until semicolon
currentStatement.append(line);
if (line.endsWith(";")) {
// Remove trailing semicolon and add complete statement
String statement = currentStatement.toString();
statement = statement.substring(0, statement.length() - 1).trim();
if (!statement.isEmpty()) {
statements.add(statement);
}
currentStatement.setLength(0); // Reset for next statement
} else {
// Multi-line statement - add space between lines
currentStatement.append(" ");
}
}
// Handle any remaining statement without semicolon
if (currentStatement.length() > 0) {
String statement = currentStatement.toString().trim();
if (!statement.isEmpty()) {
statements.add(statement);
}
}
}
}
return statements;
}