orbiter 15 years ago
parent 047f8718a7
commit 6538043d89

@ -72,9 +72,11 @@ public class Table_API_p {
for (String pk: pks) { for (String pk: pks) {
try { try {
Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes()); Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes());
if (row != null) {
String url = "http://localhost:" + sb.getConfig("port", "8080") + new String(row.from(WorkTables.TABLE_API_COL_URL)); String url = "http://localhost:" + sb.getConfig("port", "8080") + new String(row.from(WorkTables.TABLE_API_COL_URL));
result = client.GET(url); result = client.GET(url);
l.put(url, result.getStatusCode()); l.put(url, result.getStatusCode());
}
} catch (IOException e) { } catch (IOException e) {
Log.logException(e); Log.logException(e);
} }

@ -178,6 +178,7 @@ public class Tables_p {
prop.put("showedit_table", table); prop.put("showedit_table", table);
prop.put("showedit_pk", pk); prop.put("showedit_pk", pk);
Tables.Row row = sb.tables.select(table, pk.getBytes()); Tables.Row row = sb.tables.select(table, pk.getBytes());
if (row == null) return;
int count = 0; int count = 0;
byte[] cell; byte[] cell;
for (String col: columns) { for (String col: columns) {

@ -64,8 +64,6 @@ public class WorkTables extends Tables {
); );
} catch (IOException e) { } catch (IOException e) {
Log.logException(e); Log.logException(e);
} catch (NullPointerException e) {
Log.logException(e);
} }
Log.logInfo("APICALL", apiurl); Log.logInfo("APICALL", apiurl);
} }

@ -130,7 +130,13 @@ public class Tables {
} }
private byte[] ukey(String tablename) throws IOException { private byte[] ukey(String tablename) throws IOException {
byte[] pk = select(system_table_pkcounter, tablename.getBytes()).from(system_table_pkcounter_counterName); Row row = select(system_table_pkcounter, tablename.getBytes());
if (row == null) {
// table counter entry in pkcounter table does not exist: make a new table entry
row = new Row(tablename.getBytes(), system_table_pkcounter_counterName, int2key(0).getBytes());
insert(system_table_pkcounter, row);
}
byte[] pk = row.from(system_table_pkcounter_counterName);
int pki; int pki;
if (pk == null) { if (pk == null) {
pki = size(tablename); pki = size(tablename);
@ -305,7 +311,8 @@ public class Tables {
public Row select(final String table, byte[] pk) throws IOException { public Row select(final String table, byte[] pk) throws IOException {
BEncodedHeap heap = getHeap(table); BEncodedHeap heap = getHeap(table);
return new Row(pk, heap.get(pk)); if (heap.has(pk)) return new Row(pk, heap.get(pk));
return null;
} }
public void delete(final String table, byte[] pk) throws IOException { public void delete(final String table, byte[] pk) throws IOException {
@ -403,11 +410,25 @@ public class Tables {
final Map<String, byte[]> map; final Map<String, byte[]> map;
public Row(final Map.Entry<byte[], Map<String, byte[]>> entry) { public Row(final Map.Entry<byte[], Map<String, byte[]>> entry) {
assert entry != null;
assert entry.getKey() != null;
assert entry.getValue() != null;
this.pk = entry.getKey(); this.pk = entry.getKey();
this.map = entry.getValue(); this.map = entry.getValue();
} }
public Row(final byte[] pk, final Map<String, byte[]> map) { public Row(final byte[] pk, final Map<String, byte[]> map) {
assert pk != null;
assert map != null;
this.pk = pk;
this.map = map;
}
public Row(final byte[] pk, String k0, byte[] v0) {
assert k0 != null;
assert v0 != null;
HashMap<String, byte[]> map = new HashMap<String, byte[]>();
map.put(k0, v0);
this.pk = pk; this.pk = pk;
this.map = map; this.map = map;
} }

Loading…
Cancel
Save