维特比后向算法标注

@param table
176433
public void tag(Table table)
    {
        int size = table.size();
        if (size == 0) return;
        int tagSize = id2tag.length;
        double[][] net = new double[size][tagSize];
        for (int i = 0; i < size; ++i)
        {
            LinkedList<double[]> scoreList = computeScoreList(table, i);
            for (int tag = 0; tag < tagSize; ++tag)
            {
                net[i][tag] = computeScore(scoreList, tag);
            }
        }

        if (size == 1)
        {
            double maxScore = -1e10;
            int bestTag = 0;
            for (int tag = 0; tag < net[0].length; ++tag)
            {
                if (net[0][tag] > maxScore)
                {
                    maxScore = net[0][tag];
                    bestTag = tag;
                }
            }
            table.setLast(0, id2tag[bestTag]);
            return;
        }

        int[][] from = new int[size][tagSize];
        double[][] maxScoreAt = new double[2][tagSize]; // 滚动数组
        System.arraycopy(net[0], 0, maxScoreAt[0], 0, tagSize); // 初始preI=0,  maxScoreAt[preI][pre] = net[0][pre]
        int curI = 0;
        for (int i = 1; i < size; ++i)
        {
            curI = i & 1;
            int preI = 1 - curI;
            for (int now = 0; now < tagSize; ++now)
            {
                double maxScore = -1e10;
                for (int pre = 0; pre < tagSize; ++pre)
                {
                    double score = maxScoreAt[preI][pre] + matrix[pre][now] + net[i][now];
                    if (score > maxScore)
                    {
                        maxScore = score;
                        from[i][now] = pre;
                        maxScoreAt[curI][now] = maxScore;
                    }
                }
                net[i][now] = maxScore;
            }
        }
        // 反向回溯最佳路径
        double maxScore = -1e10;
        int maxTag = 0;
        for (int tag = 0; tag < tagSize; ++tag)
        {
            if (maxScoreAt[curI][tag] > maxScore)
            {
                maxScore = maxScoreAt[curI][tag];
                maxTag = tag;
            }
        }

        table.setLast(size - 1, id2tag[maxTag]);
        maxTag = from[size - 1][maxTag];
        for (int i = size - 2; i > 0; --i)
        {
            table.setLast(i, id2tag[maxTag]);
            maxTag = from[i][maxTag];
        }
        table.setLast(0, id2tag[maxTag]);
    }
569063
private void validateTable(TableDefinition tableDef) {
        for (String optName : tableDef.getOptionNames()) {
            String optValue = tableDef.getOption(optName);
            switch (optName) {
            case CommonDefs.OPT_AGING_FIELD:
                validateTableOptionAgingField(tableDef, optValue);
                break;
            case CommonDefs.OPT_RETENTION_AGE:
                validateTableOptionRetentionAge(tableDef, optValue);
                break;
            case CommonDefs.OPT_SHARDING_FIELD:
                validateTableOptionShardingField(tableDef, optValue);
                break;
            case CommonDefs.OPT_SHARDING_GRANULARITY:
                validateTableOptionShardingGranularity(tableDef, optValue);
                break;
            case CommonDefs.OPT_SHARDING_START:
                validateTableOptionShardingStart(tableDef, optValue);
                break;
            case CommonDefs.OPT_AGING_CHECK_FREQ:
                validateTableOptionAgingCheckFrequency(tableDef, optValue);
                break;
            default:
                Utils.require(false, "Unknown option for SpiderService table: " + optName);
            }
        }
        
        for (FieldDefinition fieldDef : tableDef.getFieldDefinitions()) {
            validateField(fieldDef);
        }
        
        if (tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null &&
            tableDef.getOption(CommonDefs.OPT_AGING_CHECK_FREQ) == null) {
            String agingCheckFreq = tableDef.getAppDef().getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
            if (Utils.isEmpty(agingCheckFreq)) {
                agingCheckFreq = "1 DAY";
            }
            tableDef.setOption(CommonDefs.OPT_AGING_CHECK_FREQ, agingCheckFreq);
        }
    }
800343
function (table) {
			var isArr = shine.lib.table.getn (table) > 0,
				result = shine.gc['create' + (isArr? 'Array' : 'Object')](),
				numValues = table.__shine.numValues,
				i,
				l = numValues.length;

			for (i = 1; i < l; i++) {
				result[i - 1] = ((numValues[i] || shine.EMPTY_OBJ) instanceof shine.Table)? shine.utils.toObject(numValues[i]) : numValues[i];
			}

			for (i in table) {
				if (table.hasOwnProperty(i) && !(i in shine.Table.prototype) && i !== '__shine') {
					result[i] = ((table[i] || shine.EMPTY_OBJ) instanceof shine.Table)? shine.utils.toObject(table[i]) : table[i];
				}
			}
			
			return result;
		}
1075528
public String tileTable(String table) {

		StringBuilder output = new StringBuilder();
		TileDao tileDao = geoPackage.getTileDao(table);
		output.append("Table Name: " + tileDao.getTableName());
		long minZoom = tileDao.getMinZoom();
		long maxZoom = tileDao.getMaxZoom();
		output.append("\nMin Zoom: " + minZoom);
		output.append("\nMax Zoom: " + maxZoom);
		output.append("\nTiles: " + tileDao.count());

		TileMatrixSet tileMatrixSet = tileDao.getTileMatrixSet();

		output.append("\n\nContents\n\n").append(
				textOutput(tileMatrixSet.getContents()));

		output.append("\n\nTile Matrix Set\n\n").append(
				textOutput(tileMatrixSet));

		output.append("\n\n Tile Matrices");

		for (long zoom = minZoom; zoom <= maxZoom; zoom++) {
			TileMatrix tileMatrix = tileDao.getTileMatrix(zoom);
			if (tileMatrix != null) {
				output.append("\n\n").append(textOutput(tileMatrix));
				output.append("\n\tTiles: " + tileDao.count(zoom));
				BoundingBox boundingBox = tileDao.getBoundingBox(zoom);
				output.append("\n\tTile Bounds: \n").append(
						textOutput(boundingBox));
			}
		}

		return output.toString();
	}
134828
public void addTable(Object objKey, BaseTable table)
    {
        if (m_mapTable == null)
            m_mapTable = new Hashtable<Object,BaseTable>();
        if (objKey == null)
            objKey = new Integer(m_mapTable.size());
        m_mapTable.put(objKey, table);
    }
747222
public Crud<T, K> table(String table) {
        return new LazyCrud<T, K>(this, table);
    }
145042
public void addTable(final Table table) {
        final List<Column> columns = table.getColumns();
        for (final Column column : columns) {
            if (!_analysisJobBuilder.containsSourceColumn(column)) {
                _analysisJobBuilder.addSourceColumn(column);
            }
        }
    }
1325211
public boolean hasTableOrColumnCaseSensitive(String table, String column) {

        boolean result = false;
        ResultSet set = null;

        try {
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(column)) {
                // Check if the column is given
                set = m_con.getMetaData().getColumns(null, null, table, column);
                if (set.next()) {
                    String colname = set.getString("COLUMN_NAME");
                    if (colname.equalsIgnoreCase(column)) {
                        result = true; // The column is available
                    }
                }
            } else if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(table)) {
                // Check the table
                set = m_con.getMetaData().getTables(null, null, table, null);
                if (set.next()) {
                    String tablename = set.getString("TABLE_NAME");
                    if (tablename.equalsIgnoreCase(table)) {
                        result = true;
                    }
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            result = false;
        } finally {
            try {
                if (set != null) {
                    set.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return result;
    }
1241937
@SuppressWarnings("unchecked")
    private void validateTable(int targetRow) {
        // TODO pooling of the arrays?
        if (null == this.values) {
            // nothing has been created yet
            int size = (targetRow + 1);
            if (SIZE_TABLE > size) {
                size = SIZE_TABLE;
            }
            this.values = (V[][]) new Object[size][];
        } else if (targetRow >= this.values.length) {
            // this row puts us beyond the current storage
            final int size = (targetRow + 1);
            Object[][] newTable = new Object[size][];
            System.arraycopy(this.values, 0, newTable, 0, this.values.length);
            this.values = (V[][]) newTable;
        } else if (null != this.values[targetRow]) {
            // we already have this row created and are set
            return;
        }
        // need to create the new row in the table
        this.values[targetRow] = (V[]) new Object[SIZE_ROW];
        for (int i = 0; i < SIZE_ROW; i++) {
            this.values[targetRow][i] = (V) NO_VALUE;
        }
    }
455942
private void readTable(InputStream is, SynchroTable table) throws IOException
   {
      int skip = table.getOffset() - m_offset;
      if (skip != 0)
      {
         StreamHelper.skip(is, skip);
         m_offset += skip;
      }

      String tableName = DatatypeConverter.getString(is);
      int tableNameLength = 2 + tableName.length();
      m_offset += tableNameLength;

      int dataLength;
      if (table.getLength() == -1)
      {
         dataLength = is.available();
      }
      else
      {
         dataLength = table.getLength() - tableNameLength;
      }

      SynchroLogger.log("READ", tableName);

      byte[] compressedTableData = new byte[dataLength];
      is.read(compressedTableData);
      m_offset += dataLength;

      Inflater inflater = new Inflater();
      inflater.setInput(compressedTableData);
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressedTableData.length);
      byte[] buffer = new byte[1024];
      while (!inflater.finished())
      {
         int count;

         try
         {
            count = inflater.inflate(buffer);
         }
         catch (DataFormatException ex)
         {
            throw new IOException(ex);
         }
         outputStream.write(buffer, 0, count);
      }
      outputStream.close();
      byte[] uncompressedTableData = outputStream.toByteArray();

      SynchroLogger.log(uncompressedTableData);

      m_tableData.put(table.getName(), uncompressedTableData);
   }
5824
public int compare(Object objA, Object objB)
    {
        String idAStr = _table.getColumn((String)objA).getProperty("id");
        String idBStr = _table.getColumn((String)objB).getProperty("id");
        int idA;
        int idB;

        try {
            idA = Integer.parseInt(idAStr);
        }
        catch (Exception ex) {
            return 1;
        }
        try {
            idB = Integer.parseInt(idBStr);
        }
        catch (Exception ex) {
            return -1;
        }
        return idA < idB ? -1 : (idA > idB ? 1 : 0);
    }
729141
public void addMouseListenerToHeaderInTable(JTable table)
    { 
        table.setColumnSelectionAllowed(false); 
        MouseListener mouseListener = new MouseAdapter()
        {
            public void mouseClicked(MouseEvent e)
            {
                if (e.getSource() instanceof JTableHeader)
                {   // Always
                    JTableHeader tableHeader = (JTableHeader)e.getSource();
                    TableColumnModel columnModel = tableHeader.getColumnModel();
                    int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
                    int column = tableHeader.getTable().convertColumnIndexToModel(viewColumn); 
                    if(e.getClickCount() == 1 && column != -1)
                    {
                        boolean order = Constants.ASCENDING;
                        if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0)
                            order = !order;
                        if (!(tableHeader.getDefaultRenderer() instanceof SortableHeaderRenderer))
                            tableHeader.setDefaultRenderer(new SortableHeaderRenderer(tableHeader.getDefaultRenderer()));   // Set up header renderer the first time
                        if ((((SortableHeaderRenderer)tableHeader.getDefaultRenderer()).getSortedByColumn() == viewColumn)
                                && (((SortableHeaderRenderer)tableHeader.getDefaultRenderer()).getSortedOrder() == order))
                                    order = !order;
                        column = columnToFieldColumn(column);
                        boolean bSuccess = sortByColumn(column, order);
                        if (bSuccess)
                            setSortedByColumn(tableHeader, viewColumn, order);
                    }
                }
             }
         };
        table.getTableHeader().addMouseListener(mouseListener);
    }
425951
public static void deleteTableExtensions(GeoPackageCore geoPackage,
			String table) {

		deleteGeometryIndex(geoPackage, table);
		deleteFeatureTileLink(geoPackage, table);
		deleteTileScaling(geoPackage, table);
		deleteProperties(geoPackage, table);
		deleteFeatureStyle(geoPackage, table);
		deleteContentsId(geoPackage, table);

		// Delete future extensions for the table here
	}
538164
public static void deleteProperties(GeoPackageCore geoPackage, String table) {

		if (table.equalsIgnoreCase(PropertiesCoreExtension.TABLE_NAME)) {
			deletePropertiesExtension(geoPackage);
		}

	}
946738
@NonNull
  public static UpdateStart update(@NonNull String table) {
    return update(CqlIdentifier.fromCql(table));
  }
697815
protected function makeTable($table): ?Table
    {
        // 如果是字符串,那么应该是表名,创建表对象
        if (is_string($table)) {
            return table($table);
        }

        // 如果已经是表对象,返回
        if ($table instanceof Table) {
            return $table;
        }

        return null;
    }
142613
public static void deleteGriddedCoverage(GeoPackageCore geoPackage,
			String table) {

		if (geoPackage.isTableType(ContentsDataType.GRIDDED_COVERAGE, table)) {

			GriddedTileDao griddedTileDao = geoPackage.getGriddedTileDao();
			GriddedCoverageDao griddedCoverageDao = geoPackage
					.getGriddedCoverageDao();
			ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();

			try {
				if (griddedTileDao.isTableExists()) {
					griddedTileDao.delete(table);
				}
				if (griddedCoverageDao.isTableExists()) {
					griddedCoverageDao.delete(table);
				}
				if (extensionsDao.isTableExists()) {
					extensionsDao.deleteByExtension(
							CoverageDataCore.EXTENSION_NAME, table);
				}
			} catch (SQLException e) {
				throw new GeoPackageException(
						"Failed to delete Table Index. GeoPackage: "
								+ geoPackage.getName() + ", Table: " + table, e);
			}
		}

	}