Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6668 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Feb 15, 2010
1 parent 047f871 commit 6538043
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
8 changes: 5 additions & 3 deletions htroot/Table_API_p.java
Expand Up @@ -72,9 +72,11 @@ public static serverObjects respond(final RequestHeader header, final serverObje
for (String pk: pks) {
try {
Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes());
String url = "http://localhost:" + sb.getConfig("port", "8080") + new String(row.from(WorkTables.TABLE_API_COL_URL));
result = client.GET(url);
l.put(url, result.getStatusCode());
if (row != null) {
String url = "http://localhost:" + sb.getConfig("port", "8080") + new String(row.from(WorkTables.TABLE_API_COL_URL));
result = client.GET(url);
l.put(url, result.getStatusCode());
}
} catch (IOException e) {
Log.logException(e);
}
Expand Down
1 change: 1 addition & 0 deletions htroot/Tables_p.java
Expand Up @@ -178,6 +178,7 @@ private static void setEdit(final Switchboard sb, final serverObjects prop, fina
prop.put("showedit_table", table);
prop.put("showedit_pk", pk);
Tables.Row row = sb.tables.select(table, pk.getBytes());
if (row == null) return;
int count = 0;
byte[] cell;
for (String col: columns) {
Expand Down
2 changes: 0 additions & 2 deletions source/de/anomic/data/WorkTables.java
Expand Up @@ -64,8 +64,6 @@ public void recordAPICall(final serverObjects post, final String servletName, St
);
} catch (IOException e) {
Log.logException(e);
} catch (NullPointerException e) {
Log.logException(e);
}
Log.logInfo("APICALL", apiurl);
}
Expand Down
25 changes: 23 additions & 2 deletions source/net/yacy/kelondro/blob/Tables.java
Expand Up @@ -130,7 +130,13 @@ public int size(String table) 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;
if (pk == null) {
pki = size(tablename);
Expand Down Expand Up @@ -305,7 +311,8 @@ public byte[] createRow(String table) throws IOException {

public Row select(final String table, byte[] pk) throws IOException {
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 {
Expand Down Expand Up @@ -403,11 +410,25 @@ public class Row {
final Map<String, byte[]> map;

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.map = entry.getValue();
}

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.map = map;
}
Expand Down

0 comments on commit 6538043

Please sign in to comment.