Package net.yacy.kelondro.util

Examples of net.yacy.kelondro.util.kelondroException


        this.entry.setCol(col_laudio, Integer.parseInt(prop.getProperty("laudio", "0")));
        this.entry.setCol(col_lvideo, Integer.parseInt(prop.getProperty("lvideo", "0")));
        this.entry.setCol(col_lapp, Integer.parseInt(prop.getProperty("lapp", "0")));
        this.snippet = crypt.simpleDecode(prop.getProperty("snippet", ""), null);
        this.word = null;
        if (prop.containsKey("word")) throw new kelondroException("old database structure is not supported");
        if (prop.containsKey("wi")) {
            this.word = new WordReferenceVars(new WordReferenceRow(Base64Order.enhancedCoder.decodeString(prop.getProperty("wi", ""))));
        }
        this.ranking = 0;
        this.comp = null;
View Full Code Here


                this.cellwidth = -1; // yet undefined
            } else if (typename.equals("Bitfield")) {
                this.celltype = celltype_bitfield;
                this.cellwidth = -1; // yet undefined
            } else {
                throw new kelondroException("kelondroColumn - undefined type def '" + typename + "'");
            }          
        }
       
        // parse length
        p = celldef.indexOf('-');
        if (p < 0) {
            // if the cell was defined with a type, we dont need to give an explicit with definition
            if (this.cellwidth < 0) throw new kelondroException("kelondroColumn - no cell width definition given");
            final int q = celldef.indexOf(' ');
            if (q < 0) {
                this.nickname = celldef;
                celldef = "";
            } else {
                this.nickname = celldef.substring(0, p);
                celldef = celldef.substring(q + 1);
            }
        } else {
            this.nickname = celldef.substring(0, p);
            final int q = celldef.indexOf(' ');
            if (q < 0) {
                try {
                    this.cellwidth = Integer.parseInt(celldef.substring(p + 1));
                } catch (final NumberFormatException e) {
                    throw new kelondroException("kelondroColumn - cellwidth description wrong:" + celldef.substring(p + 1));
                }
                celldef = "";
            } else {
                try {
                    this.cellwidth = Integer.parseInt(celldef.substring(p + 1, q));
                } catch (final NumberFormatException e) {
                    throw new kelondroException("kelondroColumn - cellwidth description wrong:" + celldef.substring(p + 1, q));
                }
                celldef = celldef.substring(q + 1);
            }
        }
       
        // check length constraints
        if (this.cellwidth < 0) throw new kelondroException("kelondroColumn - no cell width given for " + this.nickname);
        if (((typename.equals("boolean")) && (this.cellwidth > 1)) ||
            ((typename.equals("byte")) && (this.cellwidth > 1)) ||
            ((typename.equals("short")) && (this.cellwidth > 2)) ||
            ((typename.equals("int")) && (this.cellwidth > 4)) ||
            ((typename.equals("long")) && (this.cellwidth > 8)) ||
            ((typename.equals("char")) && (this.cellwidth > 1))
           ) throw new kelondroException("kelondroColumn - cell width " + this.cellwidth + " too wide for type " + typename);
        /*
        if (((typename.equals("short")) && (this.cellwidth <= 1)) ||
            ((typename.equals("int")) && (this.cellwidth <= 2)) ||
            ((typename.equals("long")) && (this.cellwidth <= 4))
           ) throw new kelondroException("kelondroColumn - cell width " + this.cellwidth + " not appropriate for type " + typename);
        */
        // parse/check encoder type
        if (celldef.length() > 0 && celldef.charAt(0) == '{') {
            p = celldef.indexOf('}');
            final String expf = celldef.substring(1, p);
            celldef = celldef.substring(p + 1).trim();
                 if (expf.equals("b64e")) this.encoder = encoder_b64e;
            else if (expf.equals("b256")) this.encoder = encoder_b256;
            else if (expf.equals("bytes")) this.encoder = encoder_bytes;
            else {
                if (this.celltype == celltype_undefined)      this.encoder = encoder_bytes;
                else if (this.celltype == celltype_boolean)   this.encoder = encoder_bytes;
                else if (this.celltype == celltype_binary)    this.encoder = encoder_bytes;
                else if (this.celltype == celltype_string)    this.encoder = encoder_bytes;
                else throw new kelondroException("kelondroColumn - encoder missing for cell '" + this.nickname + "'");
            }
        } else {
            if (this.celltype == celltype_cardinal) throw new kelondroException("kelondroColumn - encoder missing for cell " + this.nickname);
            this.encoder = encoder_bytes;
        }
       
        assert (this.celltype != celltype_cardinal) || (this.encoder == encoder_b64e) || (this.encoder == encoder_b256);
       
View Full Code Here

            return row[column].cellwidth;
        }
       
        public final int compareTo(final Entry o) {
            // compares only the content of the primary key
            if (objectOrder == null) throw new kelondroException("objects cannot be compared, no order given");
            assert primaryKeyLength == o.getPrimaryKeyLength();
            return objectOrder.compare(this.bytes(), 0, o.bytes(), 0, primaryKeyLength);
        }
View Full Code Here

        }
       
        private final void setCol(final int encoder, final int offset, final int length, final long cell) {
            switch (encoder) {
            case Column.encoder_none:
                throw new kelondroException("ROW", "setColLong has celltype none, no encoder given");
            case Column.encoder_b64e:
                Base64Order.enhancedCoder.encodeLong(cell, rowinstance, offset, length);
                break;
            case Column.encoder_b256:
                NaturalOrder.encodeLong(cell, rowinstance, offset, length);
                break;
            case Column.encoder_bytes:
                throw new kelondroException("ROW", "setColLong of celltype bytes not applicable");
            }
        }
View Full Code Here

            case Column.encoder_b256:
                l = c + NaturalOrder.decodeLong(rowinstance, offset + colstrt, cellwidth);
                NaturalOrder.encodeLong(l, rowinstance, offset + colstrt, cellwidth);
                return l;
            }
            throw new kelondroException("ROW", "addCol did not find appropriate encoding");
        }
View Full Code Here

        }
       
        protected final long getColLong(final int encoder, final int clstrt, final int length) {
            switch (encoder) {
            case Column.encoder_none:
                throw new kelondroException("ROW", "getColLong has celltype none, no encoder given");
            case Column.encoder_b64e:
                // start - fix for badly stored parameters
                if ((length >= 3) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B') && (rowinstance[offset + clstrt + 2] == '@')) return 0;
                if ((length == 2) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B')) return 0;
                if ((length == 1) && (rowinstance[offset + clstrt] == '[')) return 0;
                boolean maxvalue = true;
                for (int i = 0; i < length; i++) if (rowinstance[offset + clstrt + i] != '_') {maxvalue = false; break;}
                if (maxvalue) return 0;
                // stop - fix for badly stored parameters
                return Base64Order.enhancedCoder.decodeLong(rowinstance, offset + clstrt, length);
            case Column.encoder_b256:
                return NaturalOrder.decodeLong(rowinstance, offset + clstrt, length);
            case Column.encoder_bytes:
                throw new kelondroException("ROW", "getColLong of celltype bytes not applicable");
            }
            throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
        }
View Full Code Here

                return null;
            }
            nextKey = normalizeKey(nextKey); // the key must be normalized because the keyIterator may iterate over not-normalized keys
            try {
                final Map<String, String> obj = get(nextKey, false);
                if (obj == null) throw new kelondroException("no more elements available");
                return obj;
            } catch (final IOException e) {
                finish = true;
                return null;
            } catch (final RowSpaceExceededException e) {
View Full Code Here

                }
            }
        } catch (final FileNotFoundException e) {
            // should never happen
            Log.logSevere("Table", "", e);
            throw new kelondroException(e.getMessage());
        } catch (final IOException e) {
            Log.logSevere("Table", "", e);
            throw new kelondroException(e.getMessage());
        }

        // track this table
        tableTracker.put(tablefile.toString(), this);
    }
View Full Code Here

        try {
            return Records.tableSize(tablefile, recordsize);
        } catch (final IOException e) {
            if (!fixIfCorrupted) {
                Log.logSevere("Table", "table size broken for file " + tablefile.toString(), e);
                throw new kelondroException(e.getMessage());
            }
            Log.logSevere("Table", "table size broken, try to fix " + tablefile.toString());
            try {
                Records.fixTableSize(tablefile, recordsize);
                Log.logInfo("Table", "successfully fixed table file " + tablefile.toString());
                return Records.tableSize(tablefile, recordsize);
            } catch (final IOException ee) {
                Log.logSevere("Table", "table size fix did not work", ee);
                throw new kelondroException(e.getMessage());
            }
        }
    }
View Full Code Here

        } else {
            oldOrder = NaturalOrder.bySignature(sortOrderKey);
            if (oldOrder == null) oldOrder = Base64Order.bySignature(sortOrderKey);
        }
        if ((rowdef.objectOrder != null) && (oldOrder != null) && (!(rowdef.objectOrder.signature().equals(oldOrder.signature()))))
            throw new kelondroException("old collection order does not match with new order; objectOrder.signature = " + rowdef.objectOrder.signature() + ", oldOrder.signature = " + oldOrder.signature());
        this.sortBound = (int) exportedCollection.getColLong(exp_order_bound);
        if (sortBound > chunkcount) {
            Log.logWarning("RowCollection", "corrected wrong sortBound; sortBound = " + sortBound + ", chunkcount = " + chunkcount);
            this.sortBound = chunkcount;
        }
View Full Code Here

TOP

Related Classes of net.yacy.kelondro.util.kelondroException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.